532236 Commits

Author SHA1 Message Date
Balázs Benics
319045d8c4
[analyzer] Add metrics tracking time spent in Z3 solver (#133236)
These metrics would turn out to be useful for verifying an upgrade of Z3.
2025-03-28 11:26:28 +01:00
Ana Mihajlovic
f7a034d400
[AMDGPU] (x or y) xor -1 -> x nor y (#130264)
Added pattern so s_nor is selected for ((i1 x or i1 y) xor -1) instead
of s_or and s_xor . This patch is for i1 divergent. The ballot in the
test is added for the retrieval of lanemask. The control flow is needed
because the combiner can't pass through phi instructions.
2025-03-28 11:20:17 +01:00
Qinkun Bao
0d64f5adba
[NFC] Fix a typo in StdLibraryFunctionsChecker.cpp comments (#133375) 2025-03-28 10:19:58 +00:00
macurtis-amd
21a8c63cdc
[offload] Remove bad assert in StaticLoopChunker::Distribute (#132705)
When building with asserts enabled, this can actually cause strange
miscompilations because an incorrect llvm.assume is generated at the
point of the assertion.
2025-03-28 04:53:00 -05:00
Pavel Labath
b82fd71109
[lldb] Adjust skips on reverse continue tests (#133240)
The x86-specific issue has been fixed with #132122. Watchpoint tests
fail on aarch64 with macos<15.0 due to a kernel bug.
2025-03-28 09:41:56 +00:00
Nikolas Klauser
c13c04fdfe
[libc++] Simplify the implementation of the pointer aliases in allocator_traits (#127079) 2025-03-28 10:27:00 +01:00
Donát Nagy
50d4ae4a62
[analyzer] Fix format attribute handling in GenericTaintChecker (#132765)
Previously `optin.taint.GenericTaint` misinterpreted the parameter
indices and produced false positives in situations when a [format
attribute](https://clang.llvm.org/docs/AttributeReference.html#format)
is applied on a non-static method. This commit fixes this bug
2025-03-28 10:20:26 +01:00
YunQiang Su
71f43a7c42
MIPS: Set EnableLoopTermFold (#133378)
Setting `EnableLoopTermFold` enables `loop-term-fold` pass.
2025-03-28 16:49:45 +08:00
Mallikarjuna Gouda
1318a7bb09
Reland [MIPS] Define SubTargetFeature for i6500 cpu (#132907) (#133366)
Relands #132907 with a fix in the testcase:
clang/test/CodeGen/Mips/subtarget-feature-test.c
enable this test for only mips64 target

PR #130587 defined same SubTargetFeature for CPUs i6400 and i6500 which
resulted into following warning when -mcpu=i6500 was used:

+i6500' is not a recognized feature for this target (ignoring feature)

This PR fixes above issue by defining separate SubTargetFeature for
i6500.
2025-03-28 09:49:38 +01:00
Florian Hahn
7b75db5755
[VPlan] Add new VPIRPhi overlay for VPIRInsts wrapping phi nodes (NFC). (#129387)
Add a new VPIRPhi subclass of VPIRInstruction, that purely serves as an
overlay, to provide more convenient checking (via directly doing
isa/dyn_cast/cast) and specialied execute/print implementations.

Both VPIRInstruction and VPIRPhi share the same VPDefID, and are
differentiated by the backing IR instruction.

This pattern could alos be used to provide more specialized interfaces
for some VPInstructions ocpodes, without introducing new, completely
spearate recipes. An example would be modeling VPWidenPHIRecipe &
VPScalarPHIRecip using VPInstructions opcodes and providing an interface
to retrieve incoming blocks and values through a VPInstruction subclass
similar to VPIRPhi.

PR: https://github.com/llvm/llvm-project/pull/129387
2025-03-28 08:43:46 +00:00
Pengcheng Wang
883612859b
[TableGen] Add !instances operator to get defined records (#129680)
The format is: `!instances<T>([regex])`.
    
This operator produces a list of records whose type is `T`. If
`regex` is provided, only records whose name matches the regular
expression `regex` will be included. The format of `regex` is ERE
(Extended POSIX Regular Expressions).
2025-03-28 16:31:00 +08:00
Fraser Cormack
b52977b868
[libclc] Move pow, powr & pown to the CLC library (#133294)
These functions were already nominally in the CLC library.

Similar to others, these builtins are now vectorized and are not broken
down into scalar types.
2025-03-28 08:23:24 +00:00
Fraser Cormack
0a74cbfac4
[libclc] Pass -fapprox-func when compiling 'native' builtins (#133119)
The libclc build system isn't well set up to pass arbitrary options to
arbitrary source files in a non-intrusive way. There isn't currently any
other motivating example to warrant rewriting the build system just to
satisfy this requirement. So this commit uses a filename-based approach
to inserting this option into the list of compile flags.
2025-03-28 08:22:19 +00:00
Pengcheng Wang
f5f4da6db6
[RISCV] Don't vectorize for loops with small trip count (#132176)
Inspired by https://reviews.llvm.org/D130755.

I don't know the logic behind the value 5, it is copied from AArch64.

For some tests, I have to change the trip count so that we don't
break what they are testing.
2025-03-28 15:51:29 +08:00
Letu Ren
29cb00331f
[mlir][llvmir] add llvm.experimental.constrained.uitofp intrinsics (#133300)
https://llvm.org/docs/LangRef.html#llvm-experimental-constrained-uitofp-intrinsic

Signed-off-by: Letu Ren <fantasquex@gmail.com>
2025-03-28 08:47:36 +01:00
Letu Ren
68f71aae3b
[mlir][llvmir] add llvm.sincos intrinsics (#133311)
https://llvm.org/docs/LangRef.html#llvm-frexp-intrinsic

Signed-off-by: Letu Ren <fantasquex@gmail.com>
2025-03-28 08:45:46 +01:00
Daniil Kovalev
e3f1c464f7
[PAC][lld] Support -z nopac-plt flag (#132973)
Support `-z nopac-plt` so it's possible to cancel previous `-z pac-plt`.
2025-03-28 10:32:56 +03:00
Jean-Didier PAILLEUX
5b36835df0
[flang] Expose -m64 option (#132409)
Exposes `-m64` option for Flang. 
These options can be used to build libraries or tools (e.g. OpenBlas).
2025-03-28 08:15:01 +01:00
Sudharsan Veeravalli
a6e61ce239
[RISCV] Remove duplicate check in SelectAddrRegImmLsb00000. NFC (#133372) 2025-03-28 12:39:59 +05:30
YunQiang Su
7eccafc3c8
MIPS: Implement isAsCheapAsAMove for addiu (#133273)
Set `addiu` as `isAsCheapAsAMove` only when the src register or imm is
zero only.

If other cases are set `isAsCheapAsAMove`, MachineLICM will reject to
hoist it.
2025-03-28 13:34:07 +08:00
Matt Arsenault
0ed8b27890
llvm-reduce: Avoid removing convergent with convergence tokens (#132946)
Check if the intrinsics are declared in the module as an overly
conservative fix.

Fixes #132695
2025-03-28 12:30:35 +07:00
Qinkun Bao
bed2bdf17b
[NFCI] Change compiler_rt_Test_runtime to lowercase (#133362) 2025-03-27 22:20:14 -07:00
Mircea Trofin
68571f9151 Revert "[compiler-rt][nfc] DenseMap needs placement new (#133329)"
This reverts commit 4485e25dd2a57be1ee504b4dd863a1e140f5084c.
Buildbot failures, e.g. https://lab.llvm.org/buildbot/#/builders/66/builds/11827
2025-03-27 22:15:13 -07:00
Mircea Trofin
4485e25dd2
[compiler-rt][nfc] DenseMap needs placement new (#133329) 2025-03-27 21:39:12 -07:00
Maksim Panchenko
96e5ee23a7
[BOLT][AArch64] Add partial support for lite mode (#133014)
In lite mode, we only emit code for a subset of functions while
preserving the original code in .bolt.org.text. This requires updating
code references in non-emitted functions to ensure that:

* Non-optimized versions of the optimized code never execute.
* Function pointer comparison semantics is preserved.

On x86-64, we can update code references in-place using "pending
relocations" added in scanExternalRefs(). However, on AArch64, this is
not always possible due to address range limitations and linker address
"relaxation".

There are two types of code-to-code references: control transfer (e.g.,
calls and branches) and function pointer materialization.
AArch64-specific control transfer instructions are covered by #116964.

For function pointer materialization, simply changing the immediate
field of an instruction is not always sufficient. In some cases, we need
to modify a pair of instructions, such as undoing linker relaxation and
converting NOP+ADR into ADRP+ADD sequence.

To achieve this, we use the instruction patch mechanism instead of
pending relocations. Instruction patches are emitted via the regular MC
layer, just like regular functions. However, they have a fixed address
and do not have an associated symbol table entry. This allows us to make
more complex changes to the code, ensuring that function pointers are
correctly updated. Such mechanism should also be portable to RISC-V and
other architectures.

To summarize, for AArch64, we extend the scanExternalRefs() process to
undo linker relaxation and use instruction patches to partially
overwrite unoptimized code.
2025-03-27 21:33:25 -07:00
Fangrui Song
0ed4bdfe70 PPCAsmParser: Detect multiple specifiers
In addition, simplify extractSpecifier and switch to the `Specifier`
naming convention.
2025-03-27 20:57:13 -07:00
Stanislav Mekhanoshin
81c6ce3b33
[AMDGPU] Simplify VOP3_CVT_PK_F8_F32_Profile. NFC. (#133328) 2025-03-27 20:50:15 -07:00
Kazu Hirata
673f4705a8
[llvm] Use *Set::insert_range (NFC) (#133353)
We can use *Set::insert_range to collapse:

  for (auto Elem : Range)
    Set.insert(E.first);

down to:

  Set.insert_range(llvm::make_first_range(Range));

In some cases, we can further fold that into the set declaration.
2025-03-27 20:44:20 -07:00
Kazu Hirata
c9197b27b4
[AMDGPU] Use MapVector instead of DenseMap (NFC) (#133356)
This patch combines:

  DenseMap<MachineBasicBlock *, bool> ReachableMap;
  SmallVector<MachineBasicBlock *, 4> ReachableOrdered;

into:

  MapVector<MachineBasicBlock *, bool> ReachableMap;

because we add elements to the two data structures in lockstep, and we
care about preserving the insertion order.

As a side benefit, we get to avoid hash lookups at:

  ReachableMap[MBB] = true;
2025-03-27 20:34:23 -07:00
wanglei
d055e58334
[LoongArch][MC] Add relocation support for fld fst [x]vld [x]vst
This also fixes errors when using Clang with step-by-step compilation.
Because the optimization will pass relocation information to memory
access instructions. For example:
t.c:
```
float f = 0.1;
float foo() { return f;}
```
```
clang --target=loongarch64 -O2 -c t.c --save-temps
```

Reviewed By: tangaac, SixWeining

Pull Request: https://github.com/llvm/llvm-project/pull/133225
2025-03-28 11:20:17 +08:00
Kazu Hirata
cb80b26e37
[clang] Use *Set::insert_range (NFC) (#133357)
We can use *Set::insert_range to collapse:

  for (auto Elem : Range)
    Set.insert(E);

down to:

  Set.insert_range(Range);

In some cases, we can further fold that into the set declaration.
2025-03-27 20:14:25 -07:00
Kazu Hirata
a1bb750745
[mlir] Use a range constructor of DenseSet (NFC) (#133355) 2025-03-27 20:13:30 -07:00
Jinjie Huang
c8b69c9076
[NFC][SampleFDO] Clean the unneeded field and the related loop (#132376)
Clean the unneeded field 'TotalCollectedSamples' and the unnecessary
loop.
The field seems introduced in:https://reviews.llvm.org/D31952, and its
uses were removed in: https://reviews.llvm.org/D19287, but this field
and unnecessary calculation were not cleaned up.
This patch will remove these unneeded codes.
2025-03-28 11:06:00 +08:00
Florian Mayer
52d7f14a89
Revert "[sanitizer] intercept getservent_r, getservbyname_r, getservbyport_r" (#133358)
Reverts llvm/llvm-project#133339
2025-03-27 22:51:04 -04:00
Jakub Kuderski
f359c0bde5
[mlir][arith] Trim trailing spaces in wide int emulation tests. NFC. (#133349)
Followup cleanup after https://github.com/llvm/llvm-project/pull/132375
and https://github.com/llvm/llvm-project/pull/133248
2025-03-27 22:36:05 -04:00
Lang Hames
14c36db16f [ORC] Generalize GetDylibInterface to support MachO Universal Binaries.
Also adds a testcase for dylib handling in llvm-jitlink`s -weak-lx and
-weak_library options.
2025-03-28 13:28:04 +11:00
wanglei
725a7b664b
[LoongArch] Pre-commit test for #133225
Reviewed By: SixWeining

Pull Request: https://github.com/llvm/llvm-project/pull/133224
2025-03-28 10:21:23 +08:00
Craig Topper
d131b78e06
[RISCV] Disable i1 fixed vectors with more than 1024 elements. (#133267)
v2048i1 is an MVT, but v2048i8 is not so we don't support i8 vectors
with more than 1024 elements. Lowering a v2048i1 shufflevector would
requires promoting to v2048i8. Since v2048i8 isn't legal and isn't an
MVT this leads to a crash.

To fix the crash, this patch makes v2048i1 an illegal type.
2025-03-27 19:12:21 -07:00
Longsheng Mou
a6cb5cc0f0
[mlir] Add nullptr checks in SparseElementsAttr parser (#133222)
This PR adds nullptr checks in the SparseElementsAttr parser to improve
robustness and prevent crashes. Fixes #132891.
2025-03-28 10:11:14 +08:00
Craig Topper
ebe1ece4bb
[TableGen][RISCV] Support sub-operands in CompressInstEmitter.cpp. (#133039)
I'm looking into using sub-operands for memory operands. This would use
MIOperandInfo to create a single operand that contains a register and
immediate as sub-operands. We can treat this as a single operand for
parsing and matching in the assembler. I believe this will provide some
simplifications like removing the InstAliases we need to support "(rs1)"
without an immediate.

Doing this requires making CompressInstEmitter aware of sub-operands.

I've chosen to use a flat list of operands in the CompressPats so each
sub-operand is represented individually.
2025-03-27 19:10:40 -07:00
Matheus Izvekov
89cfeeb062
[clang] fix structural comparison for dependent class member pointer (#133343)
Fixes a regression introduced in
https://github.com/llvm/llvm-project/pull/130537 and reported here
https://github.com/llvm/llvm-project/issues/133144

This fixes a crash in ASTStructuralEquivalence where the non-null
precondition for IsStructurallyEquivalent would be violated, when
comparing member pointers with a dependent class.

This also drive-by fixes the ast node traverser for member pointers so
it doesn't traverse into the qualifier in case it's not a type, or the
class declaration in case it would be equivalent to what the qualifier
refers.

This avoids printing of `<<<NULL>>>` on the text node dumper, which is
redundant.

No release notes since the regression was never released.

Fixes https://github.com/llvm/llvm-project/issues/133144
2025-03-27 22:09:36 -03:00
Hank Chang
d443cd62d2
[ASan] Move early exit checks outside "instrumentFunction()" to avoid… (#133285)
… unnecessary FunctionSanitizer construction (NFC)

This patch moves several early-exit checks (e.g., empty function, etc.)
out of `AddressSanitizer::instrumentFunction` and into the caller. This
change avoids unnecessary construction of FunctionSanitizer when
instrumentation is not needed.
2025-03-28 09:00:30 +08:00
egebeysel
3a3732c252
[mlir][arith] wide integer emulation support for fpto*i ops (#132375)
Adding wide integer emulation support for `arith.fpto*i` operations. As
the other emulated operations, the upper and lower `N` bits of the `i2N`
integer result are emitted separately.

For the unsigned case we use the following emulation

```c
// example is 64 -> 32 bit emulation, but the implementation is generalized to any 2N -> N case
const double TWO_POW_N = (uint_64_t(1) << N); // 2^N, N is the bitwidth of the widest int supported

// f is a floating-point value representing the input of the fptoui op.
uint32_t hi = (uint32_t)(f / TWO_POW_N);         // Truncates the division result
uint32_t lo = (uint32_t)(f - hi * TWO_POW_N);       // Subtracts to get the lower bits.
```

For the signed case, we defer the emulation of the absolute value to
`fptoui` and handle the sign:

```
fptosi(fp) = sign(fp) * fptoui(abs(fp))
```

The edge cases of `NaNs, +-inf` and overflows/underflows are undefined
behaviour and the resulting numbers are the combination of the lower
bitwidth UB values. These operations also propagate poison values.

Signed-off-by: Ege Beysel <beysel@roofline.ai>
2025-03-27 20:58:56 -04:00
Eli Friedman
cd6e959102
Revert "[MC] Explicitly mark MCSymbol for MO_ExternalSymbol" (#133291)
Reverts llvm/llvm-project#108880 .

The patch has no regression test, no description of why the fix is
necessary, and the code is modifying MC datastructures in a way that's
forbidden in the AsmPrinter.

Fixes #132055.
2025-03-27 17:46:42 -07:00
Sam Elliott
75ca080dab
[RISCV][Xqccmp] Correctly Parse/Disassemble pushfp (#133188)
In the `qc.cm.pushfp` instruction, it is like `cm.pushfp` except in one
important way - `qc.cm.pushfp {ra}, -N*16` is not a valid encoding,
because this would update `s0`/`fp`/`x8` without saving it.

This change now correctly rejects this variant of the instruction, both
during parsing and during disassembly. I also implemented validation for
immediates that represent register lists (both kinds), which may help to
catch bugs in the future.
2025-03-27 17:43:26 -07:00
Krzysztof Drewniak
d7c53a91c2
[mlir] Decouple enum generation from attributes, adding EnumInfo and EnumCase (#132148)
This commit pulls apart the inherent attribute dependence of classes
like EnumAttrInfo and EnumAttrCase, factoring them out into simpler
EnumCase and EnumInfo variants. This allows specifying the cases of an
enum without needing to make the cases, or the EnumInfo itself, a
subclass of SignlessIntegerAttrBase.

The existing classes are retained as subclasses of the new ones, both
for backwards compatibility and to allow attribute-specific information.

In addition, the new BitEnum class changes its default printer/parser
behavior: cases when multiple keywords appear, like having both nuw and
nsw in overflow flags, will no longer be quoted by the operator<<, and
the FieldParser instance will now expect multiple keywords. All
instances of BitEnumAttr retain the old behavior.
2025-03-27 19:40:06 -05:00
Craig Topper
f4e14e7cf3 [RISCV] Const correct reference argument to isElementRotate. NFC 2025-03-27 17:23:00 -07:00
Florian Mayer
aa3149d204
[sanitizer] intercept getservent_r, getservbyname_r, getservbyport_r (#133339) 2025-03-27 17:05:37 -07:00
AdityaK
d18faf6460
[MLIR] NFC: Remove unused includes (#133327) 2025-03-27 16:50:47 -07:00
Craig Topper
9cd88847b5 [RISCV] Remove unused MCOperandPredicate from simm12_lsb00000. NFC
I don't think the use of isBareSymbolRef() was correct since we
don't have any relocations associated with this instruction type.
2025-03-27 16:45:58 -07:00