465329 Commits

Author SHA1 Message Date
Kazu Hirata
0fd1e93bd7 [LegacyPM] Remove unused declaration initializeAnnotation2MetadataLegacyPass
The corresponding function definition was removed by:

  commit 773d663e4729f55d23cb04f78a9d003643f2cb37
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Mon Feb 27 19:00:37 2023 -0800
2023-06-23 01:32:36 -07:00
Tamás Danyluk
248b85344b [SCCPSolver] Speed up SCCPSolver by avoiding repeated work list elements
If a value is already the last element of the worklist, then I think that we don't have to add it again, it is not needed to process it repeatedly.

For some long Triton-generated LLVM IR, this can cause a ~100x speedup.

Differential Revision: https://reviews.llvm.org/D153561
2023-06-23 10:23:53 +02:00
Alex Zinenko
135e5bf894 [mlir][transform] don't wrap a warning into silenceable failure
Wrapping a warning into a silenceable failure will result in the warning
being interpreted as an error, which it is not.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D153546
2023-06-23 08:20:53 +00:00
Alex Zinenko
c580bd261c [mlir][transform] fix handle invalidation check for reentrant regions
When exiting the scope of a region attached to a transform op, clean up
the handle invalidation checks assocaited with handles defined in this
region. Otherwise, these checks may trigger on the next entry to the
region while there is no incorrect usage.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D153545
2023-06-23 08:20:49 +00:00
Balázs Kéri
dd639eb15a [clang][ASTImporter] Add import of CXXRewrittenBinaryOperator.
Fix for issue #62770.

Reviewed By: donat.nagy

Differential Revision: https://reviews.llvm.org/D153424
2023-06-23 10:04:01 +02:00
Dhruv Chawla
3f77724de7
[TargetLowering] Better code generation for ISD::SADDSAT/SSUBSAT when operand sign is known
When the sign of either of the operands is known, it is possible to
determine what the saturating value will be without having to compute it
using the sign bits.

Differential Revision: https://reviews.llvm.org/D153575
2023-06-23 13:20:36 +05:30
Dhruv Chawla
911df1e8dd
[AArch64] Pre-commit test for D153575 2023-06-23 13:08:26 +05:30
Kazu Hirata
4eb06e57f1 [LegacyPM] Remove LoopAccessLegacyAnalysis
Differential Revision: https://reviews.llvm.org/D153610
2023-06-23 00:36:39 -07:00
Ulrich Weigand
bb0bbed610 Fix bytecode reader/writer on big-endian platforms
This makes the bytecode reader/writer work on big-endian platforms.
The only problem was related to encoding of multi-byte integers,
where both reader and writer code make implicit assumptions about
endianness of the host platform.

This fixes the current test failures on s390x, and in addition allows
to remove the UNSUPPORTED markers from all other bytecode-related
test cases - they now also all pass on s390x.

Also adding a GFAIL_SKIP to the MultiModuleWithResource unit test,
as this still fails due to an unrelated endian bug regarding
decoding of external resources.

Differential Revision: https://reviews.llvm.org/D153567

Reviewed By: mehdi_amini, jpienaar, rriddle
2023-06-23 09:22:55 +02:00
Haojian Wu
7298bcf7f0 [clangd] Store offsets in MacroOccurrence
Remove the existing `Rng` field.

From the review comment: https://reviews.llvm.org/D147034

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D153259
2023-06-23 09:21:08 +02:00
Jean Perier
1fb0707da6 [flang][hlfir] Simplify hlfir::convertToValue
Use hlfir::loadTrivialScalars to dereference pointer, allocatables, and
load numerical and logical scalars.

This has a small fallout on tests:

- load is done on the HLFIR entity (#0 of hlfir.declare) and not the FIR one (#1). This makes no difference at the FIR level (#1 and #0 only differs to account for assumed and explicit shape lower bounds).

- loadTrivialScalars get rids of allocatable fir.box for monomoprhic scalars
  (it is not needed). This exposed a bug in lowering of MERGE with
  a polymorphic and a monomorphic argument: when the monomorphic is not
  a fir.box, the polymorphic fir.class should not be reboxed but its
  address should be read.

Reviewed By: tblah

Differential Revision: https://reviews.llvm.org/D153252
2023-06-23 09:04:25 +02:00
Martin Braenne
efbb4aaace [clang][dataflow] Dump useful debugging information when we crash.
- The AST of the function we're currently analyzing
- The CFG
- The CFG element we're currently processing

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D153549
2023-06-23 06:49:28 +00:00
Kazu Hirata
2ef2c644b6 [mlir] Remove unused forward declaration QuantizedIntegerType
The declaration was added without a corresponding class definition by:

  commit 13bb8f491a1cb429226768cfd4ca6bcea3b938dd
  Author: Stella Laurenzo <laurenzo@google.com>
  Date:   Wed Apr 3 11:16:32 2019 -0700
2023-06-22 23:45:53 -07:00
Kazu Hirata
3f8ed16c67 [Transforms] Remove unused forward declaration PredicateScalarEvolution
The declaration was added without a corresponding class definition by:

  commit a84064bcda1a737658d33e96ca58516d01af70a6
  Author: Florian Hahn <flo@fhahn.com>
  Date:   Wed Dec 21 22:02:31 2022 +0000

It is most likely a misspelling of PredicatedScalarEvolution.
2023-06-22 23:45:52 -07:00
Kazu Hirata
fdd5f695fc [llvm] Use llvm::is_contained (NFC) 2023-06-22 23:45:50 -07:00
Jacques Pienaar
fbb5f73371 [mlir][docgen] Change nested check
Allows for single op nested regions.
2023-06-22 22:05:55 -07:00
Kazu Hirata
7175d6a596 [CodeGen] Remove unused declaration createVLIWSched
The declaration was added without a corresponding function by:

  commit cc3bb85580189d4a004cfd9bd2d6286cd1c1169f
  Author: James Nagurne <j-nagurne@ti.com>
  Date:   Fri Oct 22 17:08:16 2021 -0500
2023-06-22 21:21:29 -07:00
Jon Chesterfield
d4d8cd8446 [libc] Factor specifics of packet type out of process
NFC. Simplifies process slightly, gives more options for testing it.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D153604
2023-06-23 03:45:23 +01:00
Jon Chesterfield
7e799342e1 [libc] Simplify access permissions, change to composition over inheritance
Private member variable minimises scope of access to Process

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D153603
2023-06-23 02:54:22 +01:00
Oleksii Lozovskyi
be1b2ac948 [compiler-rt][CMake] Multiarch build of XRay libraries
Instead of dumping all sources into RTXray object library with a weird
special case for x86, handle multiarch builds better. Build a separate
object library for each arch with its arch-specific sources, then link
in all those libraries.

This fixes the build on platforms that produce fat binaries, such as new
macOS which expects both x86_64 and aarch64 objects in the same library
since Apple Silicon is a thing.

This only enables building XRay support for Apple Silicon. It does not
actually work yet on macOS, neither on Intel nor on Apple Silicon CPUs.
Thus the tests are still disabled.

Reviewed By: MaskRay, phosek

Differential Revision: https://reviews.llvm.org/D153221
2023-06-22 18:41:07 -07:00
Jon Chesterfield
85c66f5d18 [libc] Instantiate and sanity check rpc class
CMake plumbing cargo culted from other tests.
Minor changes to Process to allow statically allocating a buffer.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D153594
2023-06-23 02:11:18 +01:00
Amaury Séchet
34d8c5b9ce [DAG] Peek through trunc when combining select into shifts.
This fixes a regression in D127115

Depends on D127115

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D151916
2023-06-23 00:35:39 +00:00
Sheng
65b710efc1 [m68k] Fix incorrect handling of TLS when matching addressing mode.
`TargetGlobalTLSAddress` is not considered and handled correctly when matching addressing mode, which leads to an incorrect result of instruction selection.

fixes #63162.

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D153103
2023-06-23 08:30:53 +08:00
Vitaly Buka
fe6de0be2f [nfc][msan] Clang-format includes 2023-06-22 17:13:50 -07:00
Vitaly Buka
dc4d9d615f [msan] Release origin pages with shadow 2023-06-22 17:07:02 -07:00
Vitaly Buka
243ef9efea [test][hwasan] Reformat comments 2023-06-22 17:07:02 -07:00
Vitaly Buka
f0b97270af [test][hwasan] Describe why HWASAN does not work 2023-06-22 17:07:02 -07:00
Alex Langford
28fb39f16a [lldb] Adjust for changes in objc runtime
The Objective-C runtime and the shared cache has changed slightly.
Given a class_ro_t, the baseMethods ivar is now a pointer union and may
either be a method_list_t pointer or a pointer to a relative list of
lists. The entries of this relative list of lists are indexes that refer
to a specific image in the shared cache in addition to a pointer offset
to find the accompanying method_list_t. We have to go over each of these
entries, parse it, and then if the relevant image is loaded in the
process, we add those methods to the relevant clang Decl.

In order to determine if an image is loaded, the Objective-C runtime
exposes a symbol that lets us determine if a particular image is loaded.
We maintain a data structure SharedCacheImageHeaders to keep track of
that information.

There is a known issue where if an image is loaded after we create a
Decl for a class, the Decl will not have the relevant methods from that
image (i.e. for Categories).

rdar://107957209

Differential Revision: https://reviews.llvm.org/D153597
2023-06-22 16:42:22 -07:00
Matt Arsenault
71ba28eaac Revert "AMDGPU: Use generic helper for skipping over allocas"
This reverts commit aa7e09ebd38c5f23f6d7d6d8394a2aea04715ba9.
2023-06-22 18:15:19 -04:00
Matt Arsenault
aa7e09ebd3 AMDGPU: Use generic helper for skipping over allocas 2023-06-22 18:02:49 -04:00
Daniel Hoekwater
d8cef4f8fa [MC] Detect out of range jumps further than 2^32 bytes
On AArch64, object files may be greater than 2^32 bytes. If an
offset is greater than the max value of a 32-bit unsigned integer,
LLVM silently truncates the offset. Instead, make it return an
error.

Differential Revision: https://reviews.llvm.org/D153494
2023-06-22 21:56:22 +00:00
Fangrui Song
16e1b8d6c0 [MC] Suppress -Wunused-but-set-variable in -DLLVM_ENABLE_ASSERTIONS=off builds after D153096 2023-06-22 14:51:08 -07:00
Philip Reames
691618a7a9 [RISCV] Document overview of vector pseudos [nfc]
I tried to give a rough overview of our current pseudo structure. I'm mostly focused on the policy handling bits - since that's what I'm in the process of changing - but touched on the other dimensions in the process of framing it.

Differential Revision: https://reviews.llvm.org/D152937
2023-06-22 14:49:13 -07:00
Shatian Wang
a89c9b35be [BOLT] Fixing relative ordering of cold sections under multi-way function splitting
Order code sections with names in the form of ".text.cold.i" based on the value of i

[Context] SplitFunctions.cpp implements splitting strategies that can potentially split each function into maximum N>2 fragments.
When such N-way splitting happens, new code sections with names ".text.cold.1", ..., ".text.cold.i", ... "text.cold.N-2" will be created
A section with name ".text.cold.i" contains the the (i+2)th fragment of each function.
As an example, if each function is splitted into N=3 fragments: hot, warm, cold, then code sections will now include
- a section with name ".text" containing hot fragments
- a section with name ".text.cold" containing warm fragments
- a section with name ".text.cold.1" containing cold fragments

The order of these new sections in the output binary currently depends on the order in which they are encountered by the emitter.
For example, under N=3-way splitting, if the first function is 2-way splitted into hot and cold and the second function is 3-way splitted into hot, warm, and cold
then the cold fragment is encountered first, resulting in the final section to be in the following order
.text (hot), .text.cold.1 (cold), .text.cold (warm)

The above is suboptimal because the distance of jumps/calls between the hot and the warm sections will be much bigger than when ordering the sections as follows
.text (hot), .text.cold (warm), .text.cold.1 (cold)

This diff orders the sections with names in the form of ".text.cold" or ".text.cold.i" based on the value of i (assuming the i-value of ".text.cold" is 0).

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D152941
2023-06-22 14:26:48 -07:00
Maksim Panchenko
deb53102a7 [BOLT] Remove unnecessary diagnostics
When optimizations passes do not change anything, skip their diagnostics
output. NFC otherwise.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D153386
2023-06-22 14:07:00 -07:00
Jonas Devlieghere
f9f279dc64
[lldb] Fix variable name mismatch between signature and docs (NFC)
The variable is named `bundle_dir` but the documentation referenced
`directory` which generated a warning.
2023-06-22 13:50:54 -07:00
Tomasz Kuchta
9875273ad2 [DFSAN] Add support for _tolower
I noticed that in some cases _tolower shows as uninstrumented - I've added it as "functional" in the done_abilist.txt file

Reviewed by: browneee

Differential Revision: https://reviews.llvm.org/D153410
2023-06-22 20:48:14 +00:00
Fangrui Song
a699921baa [MC,x86-32] Remove a gold<2.34 workaround
This workaround appears to apply with gold<2.34 -O2/-O3 (linker -O2, not
compiler driver -O2). This used to be more visible as we used -Wl,-O3 in
CMake, but the option is generally not recommended and has been removed
by d63016a86548e8231002a760bbe9eb817cd1eb00 (Dec 2021).

This finishes a workaround removal work started by D64327 (2019).

Link: https://github.com/llvm/llvm-project/issues/45269
2023-06-22 13:44:15 -07:00
Manna, Soumi
213709e7be [CLANG] Fix Static Code Analyzer Concerns with bad bit right shift operation in getNVPTXLaneID()
In getNVPTXLaneID(CodeGenFunction &), the value of LaneIDBits is 4294967295 since function call llvm::Log2_32(CGF->getTarget()->getGridValue().GV_Warp_Size) might return 4294967295.

  unsigned LaneIDBits =
       llvm::Log2_32(CGF.getTarget().getGridValue().GV_Warp_Size);
  unsigned LaneIDMask = ~0u >> (32u - LaneIDBits);

The shift amount (32U - LaneIDBits) might be 33, So it has undefined behavior for right shifting by more than 31 bits.

This patch adds an assert to guard the LaneIDBits overflow issue with LaneIDMask value.

Reviewed By: tahonermann

Differential Revision: https://reviews.llvm.org/D151606
2023-06-22 13:29:28 -07:00
Peter Klausler
77a57f6b25
[flang] Avoid crash in statement function error case
The predicate IsPureProcedure() crashes with infinite
recursion when presented with mutually recursive statement
functions -- an error case that should be recoverable.
Fix by adding a visited set.

Fixes bug https://github.com/llvm/llvm-project/issues/63231

Differential Revision: https://reviews.llvm.org/D153569
2023-06-22 13:25:41 -07:00
Jon Chesterfield
65a4ce09f8 [libc] Can build amdgpu libc even if rocm is missing
Clang defaults to failing to build if it can't find rocm device libs

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D153581
2023-06-22 21:18:44 +01:00
Valentin Clement
d5a50ed9bd
[flang][openacc] Add lowering support for multi-dimensional arrays reduction
Lower multi-dimensional arrays reduction for add and mul operator.

Depends on D153448

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D153455
2023-06-22 13:11:29 -07:00
Valentin Clement
ff86ce65f6
[flang][openacc] Add lowering support for 1d array reduction for add/mul operator
Lower 1d array reduction for add and mul operator. Multi-dimensional arrays and
other operator will follow.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D153448
2023-06-22 13:09:48 -07:00
Manna, Soumi
982a87ab74 [CLANG] Fix potential null pointer dereference bugs
This patch uses castAs instead of getAs which will assert if the type doesn't match and adds nullptr check if needed.

Also this patch improves the codes and passes I.getData() instead of doing a lookup in dumpVarDefinitionName()
since we're iterating over the same map in LocalVariableMap::dumpContex().

Reviewed By: aaron.ballman, aaronpuchert

Differential Revision: https://reviews.llvm.org/D153033
2023-06-22 12:58:38 -07:00
Vitaly Buka
30ac031dd5 [NFC][asan] Add FIXME for a posible optimization 2023-06-22 12:41:41 -07:00
Manna, Soumi
11528fceac [Clang] Fix Static Code Analysis Concerns with copy without assign
This patch adds missing assignment operator to the class which has user-defined copy constructor.

Reviewed By: tahonermann, aaronpuchert

Differential Revision: https://reviews.llvm.org/D150931
2023-06-22 12:36:26 -07:00
Vitaly Buka
82a6152344 [asan] Don't double poison secondary allocations
Sanitizers allocate shadow and memory as MAP_NORESERVE.

User memory can stay this way and do not increase RSS as long as we
don't store there.

The shadow unpoisoning also can avoid RSS increase for zeroed pages.
However as soon we poison the shadow, we need the page in RSS.

To avoid unnececary RSS increase we should not poison memory just before
unpoisoning them.

Depends on D153497.

Reviewed By: thurston

Differential Revision: https://reviews.llvm.org/D153500
2023-06-22 12:35:21 -07:00
Fangrui Song
fb294c0612 [MC] Fold A-B when A's fragment precedes B's fragment
When the MCAssembler is non-null and the MCAsmLayout is null, we can fold A-B
when

* A and B are in the same fragment, or
* A's fragment suceeds B's fragment, and they are not separated by non-data fragments (D69411)

This patch allows folding when A's fragment precedes B's fragment so
that `9997b - . == 0` below can be evaluated as true:

```
nop
.arch_extension sec
9997:nop
// old behavior: error: expected absolute expression
.if 9997b - . == 0
.endif
```

Add a case to llvm/test/MC/ARM/directive-if-subtraction.s.
Note: for MCAsmStreamer, we cannot evaluate `.if . - 9997b == 0` at parse
time due to MCAsmStreamer::getAssemblerPtr returning nullptr (D45164).

Some Darwin tests check that this folding does not work. Add `.p2align 2` to
block some label difference folding or adjust the tests.

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D153096
2023-06-22 12:24:19 -07:00
Florian Hahn
dc9f69e483
[LV] Add test with reduction start values that are/may be poison/undef.
Test cases for #62565.
2023-06-22 20:15:23 +01:00
Joseph Huber
767852b1a8 [Clang] Disable libc headers for offloading languages
These headers are currently broken when included from the offloading
languages like OpenMP, OpenCL, CUDA, and HIP. Turn this logic off so we
can compile these languages when the GPU libc is installed. I am
currently trying to remedy this and have made an RFC for it in libc,
see https://discourse.llvm.org/t/rfc-implementing-gpu-headers-in-the-llvm-c-library/71523.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D153578
2023-06-22 14:12:32 -05:00