532325 Commits

Author SHA1 Message Date
Joseph Huber
4abe47c6fc
[libc] Enable 'mktime' for the GPU (#133437)
Summary:
This is a dependency on `strftime` which we provide, so we should have
this.
2025-03-28 11:14:51 -05:00
John Harrison
6526cda5d8
[lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (#133007)
This adds new types and helpers to support the 'initialize' request with
the new typed RequestHandler. While working on this I found there were a
few cases where we incorrectly treated initialize arguments as
capabilities. The new `lldb_dap::protocol::InitializeRequestArguments`
and `lldb_dap::protocol::Capabilities` uncovered the inconsistencies.

---------

Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-03-28 09:13:10 -07:00
Matt Arsenault
a33d789bb7
llvm-reduce: Avoid invalid reductions on x86_intrcc (#133396)
If there are arguments, the first one must be byval.
2025-03-28 23:11:28 +07:00
Craig Topper
f7f479b2a3
[RISCV] Use templates to reduce duplicated code for assembler operand predicates. (#133351)
We already had a template isUImm function. This patch adds isSImm,
isShiftedUImm, and 2 helpers that take a predicate function to validate
the immediate with. I'm using a template for the predicate function.
2025-03-28 09:03:31 -07:00
Jay Foad
a983c3b209
[TableGen] Make more use of CodeGenRegisterClass::EnumValue. NFC. (#132749) 2025-03-28 15:54:53 +00:00
Alex Bradbury
71a977d0d6
[RISCV] Add shift-add (SH1ADD, ...) to isCopyInstrImpl (#133443)
As with #132002, these do show up in a compilation of llvm-test-suite
(including SPEC 2017). We remove 30-40 static instances so this isn't
anything earth shattering.

rs2 is always added to the other shifted (and potentially extended)
operand unmodified, so rs1==zero is equivalent to a copy.
2025-03-28 15:46:50 +00:00
Michael Buch
8ea3f818de [lldb][test] TestCCallingConventions.py: skip on older AArch64 compilers
With our Clang-15 arm64 CI this test-case crashes when compiling the test program:
```
user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/lang/c/calling-conventions/ms_abi.c
Unexpected callee-save save/restore opcode!
UNREACHABLE executed at /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/clang_1501/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp:1129!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/clang_1501_build/bin/clang -g -O0 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -arch arm64 -I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../..//include -I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/lldb-build/tools/lldb/include -I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/lang/c/calling-conventions -I/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/make -include /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h -fno-limit-debug-info -Werror=ignored-attributes -MT ms_abi.o -MD -MP -MF ms_abi.d -c -o ms_abi.o /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/lang/c/calling-conventions/ms_abi.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/lang/c/calling-conventions/ms_abi.c'.
4.	Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@func'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clang-15                 0x0000000105d512b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  clang-15                 0x0000000105d500e4 llvm::sys::RunSignalHandlers() + 112
2  clang-15                 0x0000000105d507c4 llvm::sys::CleanupOnSignal(unsigned long) + 232
3  clang-15                 0x0000000105c79d78 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 128
4  clang-15                 0x0000000105c79f94 CrashRecoverySignalHandler(int) + 124
5  libsystem_platform.dylib 0x0000000185ecba24 _sigtramp + 56
6  libsystem_pthread.dylib  0x0000000185e9ccc0 pthread_kill + 288
7  libsystem_c.dylib        0x0000000185daca40 abort + 180
8  clang-15                 0x0000000105c88508 llvm::install_out_of_memory_new_handler() + 0
9  clang-15                 0x0000000104af7404 fixupCalleeSaveRestoreStackOffset(llvm::MachineInstr&, unsigned long long, bool, bool*) + 0
10 clang-15                 0x0000000104af53e0 llvm::AArch64FrameLowering::emitPrologue(llvm::MachineFunction&, llvm::MachineBasicBlock&) const + 3564
```
2025-03-28 15:32:18 +00:00
Matt Arsenault
2213872002
llvm-reduce: Use isCallee helper (#133419) 2025-03-28 22:24:42 +07:00
swatheesh-mcw
fe30cf18ab
Revert "Revert "[flang][openmp] Adds Parser and Semantic Support for Interop Construct, and Init and Use Clauses."" (#132343)
Reverts llvm/llvm-project#132005
2025-03-28 15:21:52 +00:00
YunQiang Su
2218587b5b
MIPS: Support isLegalICmpImmediate and isLegalAddImmediate (#133400)
Set it to true only if isInt<16>.
By default implemention defines them to true always. For most cases,
MIPS uses 16bit IMM, and for microMIPS, ICMP and ADDiu have 16bit IMM
flavors.
2025-03-28 23:03:52 +08:00
Antonio Frighetto
460d628d90 [GVN] Clean up unused argument, unify style, modernize syntax (NFC)
Finalize code style overhaul in GVN, following up to
2a0946bc0dffca89d16cd9d5208ec9416ed8100e and 9deed7d2ef3a147c4e8410910967fde601359039.
2025-03-28 15:59:28 +01:00
Kazu Hirata
0ae9c65d4a
[tools] Use *Set::insert_range (NFC) (#133384)
We can use *Set::insert_range to replace "for" loop-based insertions.
In some cases, we can further fold insert_range into the set
declaration.
2025-03-28 07:53:09 -07:00
Kazu Hirata
43829039c9
[Format] Use a range constructor of DenseSet (NFC) (#133382) 2025-03-28 07:52:43 -07:00
Cassandra Beckley
9ce77255b9
[HLSL] Add __spirv__ macro (#132848)
This macro can be used by HLSL code to detect that it is being compiled
for the SPIR-V target.
2025-03-28 10:49:19 -04:00
Hari Limaye
bf5627c85e
[LV] Optimize VPWidenIntOrFpInductionRecipe for known TC (#118828)
Optimize the IR generated for a VPWidenIntOrFpInductionRecipe to use the
narrowest type necessary, when the trip-count of a loop is known to be
constant and the only use of the recipe is the condition used by the
vector loop's backedge branch.
2025-03-28 14:47:40 +00:00
Haojian Wu
db04c3e4b3
[clang] Implement some missing interfaces for DelegatingDeserializationListener (#133424)
Split from the https://github.com/llvm/llvm-project/pull/133395 per the
review comment.

This patch also moves the `DelegatingDeserializationListener` close to
`ASTDeserializationListener`.
2025-03-28 15:31:21 +01:00
David Spickett
1f90a88b80
[libcxx] Remove clang-18 workaround in picolib build (#133254)
clang-19 changed how Arm triples were normalised and so while we
supported 18 and 19, we could not hard code the path here.

Now that Linaro's bots are running clang-19, and libcxx is going to drop
clang-18 support (https://github.com/llvm/llvm-project/pull/130142) I
have simplified it by hard coding the path again.

I also looked into why this exists in the first place. It was added in
https://reviews.llvm.org/D154246 but not questioned at the time.

It is due to the way we build compiler-rt, which is due to the final
layout we need in the install:
1. The builtins library must be called libclang_rt.builtins.a for clang
to find it. There must not be an architecture name in the filename.
2. That builtins library must be directly in lib/, next to picolib's
installed files.

To achieve number 1 we must set LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON.
However, that causes the file to be installed in a per-target dir which
breaks number 2. So to fix that, we move the builtins library up one
level into lib/.

The alternative is to turn off per-target dirs, which results in a
builtin file with an arch in the name, then rename and move that file
(since it gets installed into lib/generic/).

So in the end, it's the same amount of hacks. I think it's best to keep
the one that uses LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON, as this is the
recommended way to built these days.
2025-03-28 14:30:38 +00:00
Nick Sarnie
48b7530273
[clang][flang][Triple][llvm] Add isOffload function to LangOpts and isGPU function to Triple (#126956)
I'm adding support for SPIR-V, so let's consolidate these checks.

---------

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2025-03-28 14:19:20 +00:00
Paschalis Mpeis
427725508b
[BOLT] Add getter for optional relocations (#133085)
Minor refactoring on comments.
2025-03-28 14:07:51 +00:00
Philip Reames
b6569cce40
[RISCV] Refine location size for segment spill and fill (#133268)
This is a follow up to #133171. I realized we could assume the structure
of the previous MMO, and thus the split is much simpler than I'd
initially pictured.
2025-03-28 07:06:17 -07:00
Andras Gemes
579379cf7f
[Nomination] Add HighTec representatives to the Security Group (#124142)
I would like to nominate Mario Cupelli (@mariocup) and myself to join
the LLVM Security Group as representatives (vendor contacts) of [HighTec
EDV Systeme](https://github.com/hightec-rt).

Mario is the CTO of HighTec and has a strong background in compiler
safety qualification. I am a SW engineer with a focus on cybersecurity
and a goal to contribute to the LLVM Security Group.

HighTec collaborates with major silicon vendors and offers
safety-qualified C/C++ and Rust compilers based on LLVM. Our active
contributions to LLVM include work on the linker and various patches and
we are committed to further improving LLVM’s security.

Our motivation for joining the LLVM Security Group is to collaborate
with LLVM security experts, stay informed about the latest CVEs in LLVM
and meet the cybersecurity requirements of the automotive industry.
2025-03-28 14:02:57 +00:00
Jay Foad
53b48301eb
[AMDGPU] Tweak address space definitions. NFC. (#133442)
Define address spaces in numerical order. Fix comments to refer to
"local" instead of "group" address space.
2025-03-28 13:43:31 +00:00
Baranov Victor
d6dcd985c0
[clang-tidy] Fix thread_local false positives in misc-use-internal-linkage check (#132573)
Based on C++ standard (see issue
https://github.com/llvm/llvm-project/issues/131679) and
[StackOverflow](https://stackoverflow.com/questions/22794382/are-c11-thread-local-variables-automatically-static)
`thread_local` variables are implicitly `static` so we should not
suggest adding `static` on a `thread_local` variables. I'd appreciate if
someone else will confirm this too because reading standard is tricky.

However, many people still use `static` and `thread_local` together:
[github
code-search](https://github.com/search?type=code&q=%22static+thread_local%22+language%3AC%2B%2B).
Maybe disabling warnings on `thread_local` should be made as a flag?
WDYT?

Closes https://github.com/llvm/llvm-project/issues/131679.
2025-03-28 21:33:58 +08:00
Baranov Victor
ecdbd26ba4
[clang-tidy][NFC] improve documentation for bugprone-argument-comment check (#133436)
Improve docs for `bugprone-argument-comment` check by writing explicitly
default values for options.
Before this change, it was unclear what values are default.
2025-03-28 14:33:53 +01:00
Daniel Chen
316bb89c94
[Driver] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON on AIX. (#132821)
In the wake of discussion in PR #131200 and internal discussion after,
we will add support for `LLVM_ENABLE_PER_TARGET_RUNTIME=ON` for AIX
instead of disable it. I already reverted the change in PR #131200.

The default value of the option is still OFF on AIX.
2025-03-28 09:22:02 -04:00
Matthias Springer
4abff4d7b2
[mlir][Transforms] Improve replaceOpWithMultiple API (#132608)
This commit adds an additional overload to `replaceOpWithMultiple` that
accepts additional container types. This has been brought up by users of
the new `replaceOpWithMultiple` API.

In particular, one missing container type was
`SmallVector<SmallVector<Value>>`. The "default" `ArrayRef<ValueRange>`
container type can lead to use-after-scope errors in cases such as:
```c++
// Compute the replacement value ranges. Some replacements are single
// values, some are value ranges.
SmallVector<ValueRange> repl;
repl.push_back(someValueRange);  // OK
for (...) {
  // push_back(Value) triggers an implicit conversion to ValueRange,
  // which does not own the range.
  repl.push_back(someValue);  // triggers use-after-scope later
}
rewriter.replaceOpWithMultiple(op, repl);
```

In this example, users should use `SmallVector<SmallVector<Value>>
repl;`.
2025-03-28 14:18:54 +01:00
Krzysztof Parzyszek
33cd00f8c8
[flang] Use more generic overload for Operation in Traverse (#133305)
Currently there are two specific overloads: for unary operations, i.e.
`Operation<D, R, O>`, and binary ones `Operation<D, R, LO, RO>`.

This makes it impossible for a derived class to use a single overload to
handle all types of operations: `Operation<D, R, O...>`. Since the base
overloads need to be included in the derived class's scope, via `using
Base::operator()` either one of the specific overloads will always be a
better candidate than the more generic derived one.

```
class MyVisitor : public Traverse<...> {
  using Traverse<...>::operator();

  template <typename D, typename R, typename... O>
  Result operator()(const Operation<D, R, O...> &op) const {
    // Will never be used.
  }
};
```
This patch replaces the two specific overloads for Operation in Traverse
with a single generic overload, while preserving the existing
functionality, and allowing derived classes to use a single overload as
well.
2025-03-28 08:17:31 -05:00
Alex Bradbury
a481452cd8
[RISCV] Add OR/XOR/SUB to RISCVInstrInfo::isCopyInstrImpl (#132002)
This adds coverage for additional instructions in isCopyInstrImpl, for
now picking just those where I can observe that there is a codegen
difference for SPEC.

This allows MachineCopyPropagation to successfully eliminate no-op moves in this form.
2025-03-28 12:59:18 +00:00
Simon Pilgrim
212a48b4da [X86] combine-bitselect.ll - regenerate VPTERNLOG comments 2025-03-28 12:47:02 +00:00
Joseph Huber
772173f548
[Clang][AMDGPU] Remove special handling for COV4 libraries (#132870)
Summary:
When we were first porting to COV5, this lead to some ABI issues due to
a change in how we looked up the work group size. Bitcode libraries
relied on the builtins to emit code, but this was changed between
versions. This prevented the bitcode libraries, like OpenMP or libc,
from being used for both COV4 and COV5. The solution was to have this
'none' functionality which effectively emitted code that branched off of
a global to resolve to either version.

This isn't a great solution because it forced every TU to have this
variable in it. The patch in
https://github.com/llvm/llvm-project/pull/131033 removed support for
COV4 from OpenMP, which was the only consumer of this functionality.
Other users like HIP and OpenCL did not use this because they linked the
ROCm Device Library directly which has its own handling (The name was
borrowed from it after all).

So, now that we don't need to worry about backward compatibility with
COV4, we can remove this special handling. Users can still emit COV4
code, this simply removes the special handling used to make the OpenMP
device runtime bitcode version agnostic.
2025-03-28 07:35:16 -05:00
Nico Weber
c4bc1b1d81
[clang] Update Mach-O ptrauth driver defaults (#132834)
Xcode clang default-enables a bunch of ptrauth flags when targeting
arm64e. Let's match that.
2025-03-28 08:34:25 -04:00
Veera
4cdcf3b193
[InstCombine] Fold (trunc nuw A to i1) == (trunc nuw B to i1) to A == B (#133368)
Fixes #133344

Proof: https://alive2.llvm.org/ce/z/X3Uh23 

InstCombine couldn't optimize `i1` because `canonicalizeICmpBool()` was
transforming the comparison into bitwise operations before
`foldICmpTruncWithTruncOrExt()` was called.

This PR solves the ordering issue by placing
`foldICmpTruncWithTruncOrExt()` before `canonicalizeICmpBool()`.

I believe this will not cause any regressions since all tests are
passing.
2025-03-28 08:32:45 -04:00
Jesse D
f76254d9b2
[libc] Fix implicit conversion error in DyadicFloat::as_mantissa_type(). (#133383)
This is the same fix that was recently applied to
as_mantissa_type_rounded(), but for as_mantissa_type().
2025-03-28 08:31:17 -04:00
Dmitry Sidorov
7f103ad537
[SPIR-V] Add llvm.loop.unroll metadata lowering (#132062)
.enable lowers to Unroll LoopControl
.disable lowers to DontUnroll LoopControl
.count lowers to PartialCount LoopControl
.full lowers to Unroll LoopControl

TODO in future patches: enable structurizer for non-vulkan targets.

---------

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
2025-03-28 13:27:08 +01:00
Simon Pilgrim
45c3fe8ff3
[X86] Add test coverage for the concatable sources vpermv3 -> vpermv fold for non-constant shuffle masks (#133415)
Test both forward/reverse concat cases
2025-03-28 11:58:21 +00:00
Vyacheslav Levytskyy
b009c5af71
[SPIR-V] Mark XFAIL the test case that fails with LLVM_ENABLE_EXPENSIVE_CHECKS enabled (#133142)
After https://github.com/llvm/llvm-project/pull/130605
structurizer/cf.switch.ifstmt.simple2.ll test case starts failing with
the "PHI operand is not live-out from predecessor" diagnostic message.
This test case didn't include usual "-verify-machineinstrs" argument and
the fail was missed before
https://github.com/llvm/llvm-project/pull/130605 merging.

The problem looks not blocking, because the test case successfully
passes its CHECK's. This PR is to fix the build process by mark the test
case as XFAIL when LLVM_ENABLE_EXPENSIVE_CHECKS is enabled.

Investigation of the Machine Verifier complaint is to do. The issue is
created: https://github.com/llvm/llvm-project/issues/133141
2025-03-28 12:55:31 +01:00
Weaver
af150272cf Revert "MIPS: Set EnableLoopTermFold (#133378)"
This reverts commit 71f43a7c42a37d18be98b0885d62ef76e658f242.

Caused build bot failures:
https://lab.llvm.org/buildbot/#/builders/190/builds/17267
https://lab.llvm.org/buildbot/#/builders/144/builds/21445
https://lab.llvm.org/buildbot/#/builders/46/builds/14343

please consider fixing the test failure in long-array-initialize.ll before
recommitting.
2025-03-28 11:31:56 +00:00
Paul Schwabauer
8a3fe30a0a
[PATCH] [clang][frontend] Fix serialization for CXXConstructorDecl (refs llvm#132794) (#133077)
When retrieving the ExplicitSpecifier from a CXXConstructorDecl, one of
its canonical declarations is returned. To correctly write the
declaration record the ExplicitSpecifier of the current declaration must
be used.

Failing to do so results in a crash during deserialization.
2025-03-28 11:34:24 +01:00
Stanislav Mekhanoshin
7d869045e0
[AMDGPU] Hoist some constant stuff out of the loop in AMDGPUAsmParser.cpp. NFC. (#133398) 2025-03-28 03:27:16 -07:00
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