Commit Graph

481694 Commits

Author SHA1 Message Date
Youngsuk Kim
bc85284273 [clang-linker-wrapper] Re-use type returned from 'PointerType::getUnqual(C)' (NFC) (#73374)
Multiple calls to `PointerType::getUnqual(C)`, and calls to
`Type::getPointerTo(AddrSpace=0)` on them all result in the same type.

Clean them up to re-use the same `PtrTy` variable within function
`createRegisterGlobalsFunction()`.
2023-11-24 19:22:02 -05:00
Craig Topper
1a3b14d261 [RISCV] Add C intrinsics for scalar bitmanip and crypto
This adds riscv_bitmanip and riscv_crypto.h

This is based on the proposed spec here https://github.com/riscv-non-isa/riscv-c-api-doc/pull/44

Tests that previously used builtins directly now use the intrinsics.

Reviewed By: wangpc

Differential Revision: https://reviews.llvm.org/D155647
2023-11-24 16:17:22 -08:00
serge-sans-paille
afe8b93ffd [clang] Avoid memcopy for small structure with padding under -ftrivial-auto-var-init (#71677)
Recommit of 0d2860b795 with extra test
cases fixed.
2023-11-25 00:11:20 +01:00
philnik777
12563ea640 [libc++][NFC] Refactor _LIBCPP_AVAILABILITY_HAS_* macros to always be defined (#71002)
This makes the conditionals quite a bit simpler to understand, since it
avoids double negatives and makes sure we have <__availability>
included. For vendors which use availability macros, it also enforces
that they check when specific features are introduced and define the
macro for their platform appropriately.
2023-11-24 23:45:17 +01:00
Lixi Zhou
a3c0f705db [NFC] fix failed ompt tests on M1 device (#65696)
Fix the 2 failed ompt tests on M1 device found on #63194.

```
libomp :: ompt/synchronization/masked.c
libomp :: ompt/synchronization/master.c
```

For the details of this fix, please check the origin discussion in
https://github.com/llvm/llvm-project/issues/63194#issuecomment-1710494689

Thanks @jprotze for the fix.
2023-11-24 23:40:14 +01:00
Raymond Chang
85b2e9c022 [Clang][OpenMP] Emit unsupported directive error (#70233)
Hello!

This PR fixes #63871. Clang should no longer crash and instead emits an
error message.

Below is an example of the new error message:

```
~/dev/fork-llvm-project omp_dispatch_unimpl
❯ ./install/bin/clang -fopenmp  -c -emit-llvm -Xclang -disable-llvm-passes test.c
test.c:6:5: error: cannot compile this OpenMP dispatch directive yet
    6 |     #pragma omp dispatch
      |     ^~~~~~~~~~~~~~~~~~~~
1 error generated.
```
2023-11-24 16:28:32 -05:00
Stefan Gränitz
b86420c614 [JITLink][AArch32] Add dynamic lookup for relocation fixup infos (#71649)
Specifying relocation fixup constants with name and type facilitates
readability and compile-time checks. The `FixupInfo<EdgeKind>` facade
organizes the information into entries per relocation type and provides
uniform access across Arm and Thumb relocations. Since it uses template
specializations, it doesn't limit potential entries. We cannot access
the entries dynamically though, because `EdgeKind` must be given as a
compile-time constant.

With this patch we populate a static lookup table on-demand and use it
for dynamic access in opcode-checks.
2023-11-24 21:45:50 +01:00
Stefan Gränitz
95dcb8b49d [llvm-jitlink] Support plain AArch32 stubs in jitlink-check's stub_addr() expressions (#73268)
We want to use regular `stub_addr()` expressions in `jitlink-check` lines to test the generation of stubs in AArch32, but we don't want this to require a standardized GOT-based PLT implementation. In terms of performance and binary size it doesn't seem beneficial. And in terms of patching branch targets, we should be able to handle range-extension- and interworking-stubs without a lot of extra logic.

In order to allow such AArch32 stubs we add a separate path for `stub_addr()` expressions in `llvm-jitlink-elf`. The relocations in our stubs are not pointing to the GOT, but to the external symbol directly. Thus, we have to avoid access to the block of the edge target. Instead we only return the symbol name, which is enough to use `stub_addr()` expressions in tests.

The name of the AArch32 stubs section differs from the conventional `$__STUBS` on purpose. It allows to add a regular PLT/GOT implementation as an orthogonal feature in the future. In order to also allow decoding of stub target addresses in the future, we mention the stub flavor in the section name as well.
2023-11-24 21:41:00 +01:00
Florian Hahn
20f634f275 [Thumb] Add test case where the machine-outliner clobbers LR.
Add ad test case where `bl OUTLINED_FUNCTION_0` clobbers LR, which in
turn is used the later call to memcpy to return to the caller.
2023-11-24 20:27:43 +00:00
Jakub Kuderski
d625ea12c7 [mlir][spirv] Split codegen for float min/max reductions and others v2. [NFC] (#73363)
This is https://github.com/llvm/llvm-project/pull/69023 but with
cleanups.
Reduced complexity by avoiding CRTP and preprocessor defines in favor of
free functions

Original description by @unterumarmung:

---

This patch is part of a larger initiative aimed at fixing floating-point
`max` and `min` operations in MLIR:
https://discourse.llvm.org/t/rfc-fix-floating-point-max-and-min-operations-in-mlir/72671.

There are two types of min/max operations for floating-point numbers:
`minf`/`maxf` and `minimumf`/`maximumf`. The code generation for these
operations should differ from that of other vector reduction kinds. This
difference arises because CL and GL operations for floating-point min
and max do not have the same semantics when handling NaNs. Therefore, we
must enforce the desired semantics with additional ops.

~~However, since the code generation for floating-point min/max
operations shares the same functionality as extracting values for the
vector, we have decided to refactor the existing code using the CRTP
pattern.~~ This change does not alter the actual behavior of the code
and is necessary for future fixes to the codegen for floating-point
min/max operations.

---------

Co-authored-by: Daniil Dudkin <unterumarmung@yandex.ru>
2023-11-24 15:24:45 -05:00
Aiden Grossman
ddc6ef4641 Revert "[llvm-exegesis] Switch from MCJIT to LLJIT (#72838)"
This reverts commit 12b0ab2c9c.

Currently failing on certain configurations due to a missing
constructor. Pulling out so that I can reproduce the issue and make sure
I fix it before resubmitting.
2023-11-24 12:07:50 -08:00
Aiden Grossman
4233176f9b [SimpleLoopUnswitch] Remove callbacks (#73300)
After the removal of the legacyPM version of simple loop unswitch, there
is no longer a need for the callback mechanism to handle PM specific
tasks. This patch removes the callbacks to help simplify the code now
that they're no longer needed.
2023-11-24 11:36:52 -08:00
Aiden Grossman
12b0ab2c9c [llvm-exegesis] Switch from MCJIT to LLJIT (#72838)
This patch switches from using MCJIT to LLJIT as MCJIT is going to be
deprecated soon.

Fixes #41764.
2023-11-24 11:36:20 -08:00
Jakub Kuderski
6ba60390cc [mlir][spirv] Handle all zero-element memref types (#73351)
Bail out of type conversion instead of crashing.

Fixes: https://github.com/llvm/llvm-project/issues/73289
2023-11-24 14:13:34 -05:00
Stefan Pintilie
d896b1f5a6 [PowerPC] Do not string pool globals that are part of llvm used. (#66848)
The string pooling pass was incorrectly pooling global varables that
were part of llvm.used or llvm.compiler.used. This patch fixes the pass
to prevent that by checking each candidate to make sure that it is not
in either of those lists.
2023-11-24 12:21:28 -05:00
Antonio Frighetto
0ff5281c94 [GlobalISel] Treat shift amounts as unsigned in matchShiftImmedChain
A miscompilation issue in the GISel pre-legalization
phase has been addressed with improved routines.

Fixes: https://github.com/llvm/llvm-project/issues/71440.
2023-11-24 18:14:52 +01:00
Craig Topper
d9962c400f [IR] Add disjoint flag for Or instructions. (#72583)
This flag indicates that every bit is known to be zero in at least one
of the inputs. This allows the Or to be treated as an Add since there is
no possibility of a carry from any bit.

If the flag is present and this property does not hold, the result is
poison.

This makes it easier to reverse the InstCombine transform that turns Add
into Or.

This is inspired by a comment here
https://github.com/llvm/llvm-project/pull/71955#discussion_r1391614578

Discourse thread
https://discourse.llvm.org/t/rfc-add-or-disjoint-flag/75036
2023-11-24 08:49:19 -08:00
Craig Topper
5d501b1091 [GISel][RISCV] Fix several boundary cases in narrow G_SEXT_INREG. (#72719)
This fixes cases when SizeInBits is a multiple of the narrow size.

If SizeBits is equal to NarrowTy size, the first block would create an
illegal G_SEXT_INREG where the the extension size is equal to the type.
I tried to turn it into G_TRUNC+G_SEXT, but that just turned back into
G_SEXT_INREG causing an infinite loop. So punt to the splitting case.

In the for loop we should copy when the part ends on SizeInBits. In that
case there is no G_SEXT_INREG needed for partial. But we should note
that register in PartialExtensionReg for the first full part to use.

If the part starts on SizeInBits then we should do an AShr of
PartialExtensionReg.

We should only get to the G_SEXT_INREG case if the SizeInBits is in the
middle of the part.
2023-11-24 08:39:38 -08:00
Mark de Wever
233e7c5de2 [libc++] Removes codecvt. (#72496)
Implements:
- P2871R3 Remove Deprecated Unicode Conversion Facets from C++26
2023-11-24 17:34:30 +01:00
Mark de Wever
92d9f232dd [libc++] Implements Runtime format strings II. (#72543)
Implements
- P2918R2 Runtime format strings II
2023-11-24 17:30:33 +01:00
Kiran Chandramohan
76c4a6e310 [MLIR][OpenMP] NFC: Remove unused variable 2023-11-24 16:22:00 +00:00
Sebastian Poeplau
7091ca1ae3 [clang] Add missing LinkageSpec case to getCursorKindForDecl (#72401)
The LinkageSpec case was omitted, and there is a declared CXCursor_Kind
for it. Adapt the testsuite drivers to print mangled names for
declarations with extern linkage. Also update the test baseline for the
recursive-cxx-member-calls.cpp test.

Co-authored-by: Matthieu Eyraud <eyraud@adacore.com>
2023-11-24 21:41:17 +05:30
Alexey Bataev
e9fdb965f9 [SLP][NFC]Make collectValuesToDemote member of BoUpSLP to avoid using
Expr container, NFC.

Saves the memory and may improve compile time.
2023-11-24 08:05:19 -08:00
Akash Banerjee
c38dbfd3be [Flang] Add new Integration tests directory to Flang (#73141)
As per the RFC:
[https://discourse.llvm.org/t/rfc-flang-new-directory-for-adding-end-to-end-tests-for-lowering-to-llvm-ir-in-flang/74872/11](https://discourse.llvm.org/t/rfc-flang-new-directory-for-adding-end-to-end-tests-for-lowering-to-llvm-ir-in-flang/74872/11),
this patch adds a new Integration test directory for OpenMP-
`flang/test/Integration/OpenMP` and moves the existing OpenMP
integration tests from `flang/test/Driver/OpenMP` to this directory.

**This directory can be used to add Integration tests involving multiple
stages of the compiler (for eg. from Fortran to LLVM IR). It should not
contain executable tests. We should only add tests here sparingly and
only if there is no other way to test. Repeat this message in each test
that is added to this directory and sub-directories.**
2023-11-24 16:02:39 +00:00
Guillaume Chatelet
ee5749bf78 [libc] Provide compiler version properties (#73344)
This will be used to support conditional compilation based on compiler
version.
We adopt the same convention as
[libc++](https://github.com/llvm/llvm-project/blob/main/libcxx/include/__config)
- thx @legrosbuffle for the suggestion!
Usage:
```
#if defined(LIBC_COMPILER_CLANG_VER)
#  if LIBC_COMPILER_CLANG_VER < 1500
#    warning "Libc only supports Clang 15 and later"
#  endif
#elif defined(LIBC_COMPILER_GCC_VER)
#  if LIBC_COMPILER_GCC_VER < 1500
#    warning "Libc only supports GCC 15 and later"
#  endif
#elif defined(LIBC_COMPILER_MSC_VER)
#  if LIBC_COMPILER_MSC_VER < 1930
#    warning "Libc only supports Visual Studio 2022 RTW (17.0) and later"
#  endif
#endif
```
2023-11-24 17:02:11 +01:00
José Lira Junior
bd8f1068ca [lldb] correct inconsistent order of messages on process launch (#73173)
Fixes [#68035](https://github.com/llvm/llvm-project/issues/68035), where
an inconsistency in the order of "Process launched" and "Process
stopped" messages occurs during `process launch`.

The fix involves adjusting the message output sequence in
`CommandObjectProcessLaunch::DoExecute` within
`source/Commands/CommandObjectProcess.cpp`. This ensures "Process
launched" consistently precedes "Process stopped" when executing
commands with the '-o' flag, i.e., non-interactive mode.

Upon implementing this change, two tests failed:
`lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test` and
`lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test`. These failures
were expected as they relied on the previous, now-corrected message
order. Updating these tests to align with the new message sequence is
part of this PR's scope.
2023-11-24 15:48:16 +00:00
Egor Zhdan
18a5ca14d1 [Clang] Fix -Wdocumentation warning (NFC)
```
llvm-project/clang/include/clang/AST/OpenMPClause.h:7762:14: warning: parameter 'Modifier' not found in the function declaration [-Wdocumentation]
  /// \param Modifier The modifier applied to 'order' clause.
             ^~~~~~~~
llvm-project/clang/include/clang/AST/OpenMPClause.h:7762:14: note: did you mean 'M'?
  /// \param Modifier The modifier applied to 'order' clause.
```
2023-11-24 15:41:37 +00:00
Guillaume Chatelet
89a832435d [libc][cmake] Add missing dependencies for type_traits (#73339) 2023-11-24 16:29:29 +01:00
Jeremy Morse
59fab22642 [DebugInfo][RemoveDIs] Support cloning and remapping DPValues (#72546)
This patch adds support for CloneBasicBlock duplicating the DPValues
attached to instructions, and adds facilities to remap them into their new
context. The plumbing to achieve this is fairly straightforwards and
mechanical.

I've also added illustrative uses to LoopUnrollRuntime, SimpleLoopUnswitch
and SimplifyCFG. The former only updates for the epilogue right now so I've
added CHECK lines just for the end of an unrolled loop (further updates
coming later). SimpleLoopUnswitch had no debug-info tests so I've added a
new one. The two modified parts of SimplifyCFG are covered by the two
modified SimplifyCFG tests.

These are scenarios where we have to do extra cloning for copying of
DPValues because they're no longer instructions, and remap them too.
2023-11-24 15:17:32 +00:00
Jeremy Morse
2f7c050e19 [DebugInfo][RemoveDIs] Allow speculative-DPMarker creation
There's good justification for having a function specifying "I need there to be
a marker here, so return the marker there or create a new one". This was going
to come later in the series, but it's starting to become necessary much eariler
alas.

Make use of it in spliceDebugInfo, where we can occasionally splice DPValues
onto the end() iterator of a block while it's been edited.
2023-11-24 15:17:32 +00:00
Guillaume Chatelet
5e5a22caf8 [libc][NFC] Move float macro into its own header / add target os detection (#73311)
Floating point properties are a combination of target OS, target
architecture and compiler support.
 - Adding target OS detection,
 - Moving floating point type detection to its own file.

This is in preparation of adding support for `_Float16` which requires
testing compiler **version** and target architecture.
2023-11-24 16:11:05 +01:00
Nikita Popov
50c298fd17 [CVP] Regenerate test checks (NFC)
Avoid some spurious changes in a future patch.
2023-11-24 15:50:30 +01:00
Nikita Popov
88f7dc17eb [SCEV] Regenerate test checks (NFC)
There have been some minor but pervasive changes to the generated
CHECK lines, so regenerate all of them, to minimize future diffs.
2023-11-24 15:49:28 +01:00
Jinsong Ji
85ee351aa7 [CI] Skip libcxx in non-llvm repo (#73282)
The new libcxx workflow are run and failing in non llvm repo.
Skip it similar to other workflow.
2023-11-24 09:44:49 -05:00
Florian Hahn
820b3583c9 [AArch64] Add artificial clobbers to swift async context test.
Manually add clobbers for various register combinations to tests. This
highlights incorrectly performing shrink-wrapping, with
StoreSwiftAsyncContext expansion clobbering a live register.
2023-11-24 14:14:49 +00:00
Stefan Gränitz
962829bdb3 [JITLink] Fix typos: symobls -> symbols (NFC) 2023-11-24 15:04:00 +01:00
Stefan Gränitz
c8562e81bc [llvm-jitlink] Avoid assertion failure in make_error parameter
If GOTSym is not defined, we cannot call `GOTSym.getBlock()`. It failed with:
```
Assertion failed: (Base->isDefined() && "Not a defined symbol"), function getBlock, file JITLink.h, line 554.
```
2023-11-24 15:04:00 +01:00
Nikita Popov
7eeedc124f [CodeGen] Make some includes explicit (NFC)
Explicitly include some headers or forward-declare types, in
preparation for removing an include that pulls in many transitive
headers.
2023-11-24 14:43:18 +01:00
Timm Baeder
a79a5611bd [clang] Classify vector types in __builtin_classify_type (#73299) 2023-11-24 14:40:58 +01:00
Balázs Kéri
3d8a9105d7 [clang][ASTImporter] Fix import of SubstTemplateTypeParmType in return type of function. (#69724)
Import of a function with `auto` return type that is expanded to a
`SubstTemplateTypeParmType` could fail if the function itself is the
template specialization where the parameter was replaced.
2023-11-24 14:35:10 +01:00
Guillaume Chatelet
dc9787c872 [libc][NFC] Remove dead code (#73315) 2023-11-24 14:33:19 +01:00
Jeremy Morse
84f6e1d71c [DebugInfo] Clone dbg.values in SimplifyCFG like normal instructions (#72526)
The code in the CloneInstructionsIntoPredec... function modified by this
patch has a long history that dates back to 2011, see d715ec82b4.
There, when folding branches, all dbg.value intrinsics seen when folding
would be saved and then re-inserted at the end of whatever was folded. Over
the last 12 years this behaviour has been preserved.

However, IMO it's bad behaviour. If we have:

  inst1
  dbg.value1
  inst2
  dbg.value2

And we fold that sequence into a different block, then we would want the
instructions and variable assignments to appear in the same order. However
because of this old behaviour, the dbg.values are sunk, and we get:

  inst1
  inst2
  dbg.value1
  dbg.value2

This clustering of dbg.values can make assignments to the same variable
invisible, as well as reducing the coverage of other assignments.

This patch relaxes the CloneInstructions... function and allows it to clone
and update dbg.values in-place, causing them to appear in the original
order in the destination block. I've added some extra dbg.values to the
updated test: without the changes to the pass, the dbg.values sink into a
blob ahead of the select. The RemoveDIs code can't cope with this right now
so I've removed the "--try..." flag, restored in a commit to land in a
couple of hours.

(Metadata changes to make the LLVM-IR parser not drop the debug-info for it
being out of date. The RemoveDIs related RUN line has been removed because
it was spuriously passing due to the debug-info being dropped).
2023-11-24 13:30:34 +00:00
Utkarsh Saxena
e8cd401eae Remove extraneous ` in AttrDocs.td 2023-11-24 14:21:45 +01:00
pasmpe01
de6c9c84e2 [TLI][AArch64] Add TLI Mappings of @llvm.exp10 for ArmPL and SLEEF.
Update regex to _explicitly_ show which exp versions are added.
The previous regex used `exp[^e]` to avoid matching calls like:
`@llvm.experimental.stepvector`.

Note: ArmPL Mappings for scalable types are not yet utilized
(eg, `llvm.exp10.nxv2f64`, `llvm.exp10.nxv4f32`), as `replace-with-veclib`
pass needs improvements.
2023-11-24 12:24:33 +00:00
Tulio Magno Quites Machado Filho
cf1bde3342 [clang] Fix sorting module headers (#73146)
Struct Module::Header is not a POD type. As such, qsort() and
llvm::array_pod_sort() must not be used to sort it. This became an issue
with the new implementation of qsort() in glibc 2.39 that is not
guaranteed to be a stable sort, causing Headers to be re-ordered and
corrupted.

Replace the usage of llvm::array_pod_sort() with std::stable_sort() in
order to fix this issue. The signature of compareModuleHeaders() has to
be modified.

Fixes #73145.
2023-11-24 09:17:21 -03:00
Alexander Batashev
a4ee55fe6e [MLIR][NFC] Fix build on recent GCC with C++20 enabled (#73308)
The following pattern fails on recent GCC versions with -std=c++20 flag
passed and succeeds with -std=c++17. Such behavior is not observed on
Clang 16.0.

```
template <typename T>
struct Foo {
    Foo<T>(int a) {}
};
```

This patch removes template parameter from constructor in two occurences
to make the following command complete successfully:
bazel build -c fastbuild --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
@llvm-project//mlir/...

This patch is similar to https://reviews.llvm.org/D154782

Co-authored-by: Alexander Batashev <a.batashev@partner.samsung.com>
2023-11-24 15:13:39 +03:00
Akash Banerjee
6bdeb53ed9 [MLIR][OpenMP] Fix the assertion failure for VariableCaptureKind::ByCopy (#72424) 2023-11-24 11:33:55 +00:00
Akash Banerjee
f1d773863d [Flang][OpenMP] Remove use of non reference values from MapInfoOp (#72444)
This patch removes the val field from the `MapInfoOp`.

Previously when lowering `TargetOp`, the bounds information for the
`BoxValues` were also being mapped. Instead these ops are now cloned
inside the target region to prevent mapping of non reference typed
values.
2023-11-24 11:33:19 +00:00
Nikita Popov
c1e3a94105 [TargetLowering] Don't include ComplexDeinterleavingPass.h (NFC)
TargetLowering.h shouldn't include any passes and thus pull in
the entire pass infrastructure. Replace the include with forward
declarations.
2023-11-24 12:13:38 +01:00
Kadir Cetinkaya
076ec9f5f5 Fix build failure on certain bots 2023-11-24 11:39:16 +01:00