Commit Graph

498792 Commits

Author SHA1 Message Date
Aaron Ballman
3f954f5751 Correct mismatched allocation/deallocation calls
This amends dceaa0f449 because ASAN
caught an issue where the allocation and deallocation were not properly
paired: https://lab.llvm.org/buildbot/#/builders/239/builds/7001

Use malloc and free throughout this file to ensure that all kinds of
memory buffers use the proper pairing.
2024-05-15 12:36:19 -04:00
Benjamin Kramer
29c2475f21 [mlir] Fix the build after 03c53c69a3 2024-05-15 18:34:59 +02:00
Craig Topper
f0e79db215 [RISCV] Fix 80 columns in RISCVMatInt.cpp. NFC 2024-05-15 09:28:11 -07:00
Nuri Amari
141391ad2f [lld] Fix -ObjC load behavior with LTO (#92162)
When -ObjC is passed, the linker must force load any object files that
contain special sections that store Objective-C / Swift information that
is used at runtime.

This should work regadless if input files are bitcode or native, but it
was not working with bitcode. This is because the sections that identify
an object file that should be loaded were inconsistent when dealing with
a native file vs bitcode file. In particular, bitcode files were not
searched for `__TEXT,__swift` prefixed sections, while native files
were.

This means LLD wasn't loading certain bitcode files and forcing the user
to introduce --force-load to their linker invocation for that archive.

Co-authored-by: Nuri Amari <nuriamari@fb.com>
2024-05-15 09:21:02 -07:00
Fangrui Song
03c53c69a3 [MC] Remove UseAssemblerInfoForParsing
Commit 6c0665e221
(https://reviews.llvm.org/D45164) enabled certain constant expression
evaluation for `MCObjectStreamer` at parse time (e.g. `.if` directives,
see llvm/test/MC/AsmParser/assembler-expressions.s).

`getUseAssemblerInfoForParsing` was added to make `clang -c` handling
inline assembly similar to `MCAsmStreamer` (e.g. `llvm-mc -filetype=asm`),
where such expression folding (related to
`AttemptToFoldSymbolOffsetDifference`) is unavailable.

I believe this is overly conservative. We can make some parse-time
expression folding work for `clang -c` even if `clang -S` would still
report an error, a MCAsmStreamer issue (we cannot print `.if`
directives) that should not restrict the functionality of
MCObjectStreamer.

```
% cat b.cc
asm(R"(
.pushsection .text,"ax"
.globl _start; _start: ret
.if . -_start == 1
  ret
.endif
.popsection
)");
% gcc -S b.cc && gcc -c b.cc
% clang -S -fno-integrated-as b.cc     # succeeded

% clang -c b.cc     # succeeded with this patch
% clang -S b.cc     # still failed
<inline asm>:4:5: error: expected absolute expression
    4 | .if . -_start == 1
      |     ^
1 error generated.
```

Close #62520
Link: https://discourse.llvm.org/t/rfc-clang-assembly-object-equivalence-for-files-with-inline-assembly/78841

Pull Request: https://github.com/llvm/llvm-project/pull/91082
2024-05-15 09:18:39 -07:00
Serge Pavlov
9bbefb7f60 [clang] Store FPOptions earlier when parsing function (#92146)
After https://github.com/llvm/llvm-project/pull/85605 ([clang] Set
correct FPOptions if attribute 'optnone' presents) the current FP
options in Sema are saved during parsing function because Sema can
modify them if optnone is present. However they were saved too late, it
caused fails in some cases when precompiled headers are used. This patch
moves the storing earlier.
2024-05-15 23:12:57 +07:00
Piotr Zegar
54c6ee922a [clang-tidy] Add AllowImplicitlyDeletedCopyOrMove option to cppcoreguidelines-special-member-functions (#71683)
Improved cppcoreguidelines-special-member-functions check with a new
option AllowImplicitlyDeletedCopyOrMove, which removes the requirement
for explicit copy or move special member functions when they are already
implicitly deleted.

Closes #62392
2024-05-15 17:53:03 +02:00
Piotr Zegar
ba3447601c [clang-tidy] Fix crash in modernize-use-constraints (#92019)
Improved modernize-use-constraints check by fixing a crash that occurred
in some scenarios and excluded system headers from analysis.

Problem were with DependentNameTypeLoc having null type location as
getQualifierLoc().getTypeLoc().

Fixes #91872
2024-05-15 17:52:46 +02:00
Jay Foad
3a8d176af5 [utils][filecheck-lint] Add shebang (#92243) 2024-05-15 17:50:52 +02:00
Timm Bäder
74218a9c8f [clang][Interp] Implement __builtin_convertvector 2024-05-15 17:40:48 +02:00
Luke Lau
ff313ee70a [RISCV] Remove hasSideEffects=1 for vsetvli pseudos (#91319)
In a similar vein to #90049, we currently model all of the effects of a
vsetvli pseudo:

* VL and VTYPE are marked as defs
* VL preserving x0,x0 vsetvlis doesn't get emitted until
RISCVInsertVSETVLI, and when they are they have implicit uses on VL
* Regular vector pseudos are fully modelled too: Before
RISCVInsertVSETVLI they can be moved between vsetvli pseudos because we
will eventually insert vsetvlis to correct VL and VTYPE. Afterwards,
they will have implicit uses on VL and VTYPE.

Since we model everything we can remove hasSideEffects=1. This gives us
some improvements like sinking in vsetvli-insert-crossbb.ll.

We need to update RISCVDeadRegisterDefinitions to keep handling vsetvli
pseudos since it only operates on instructions with unmodelled side
effects.
2024-05-15 23:37:31 +08:00
jyu2-git
8e00703be9 [Clang][OpenMP] Fix runtime problem when explicit map both pointer and pointee (#92210)
ponter int *p for following map, test currently crash.

  map(p, p[:100]) or map(p, p[1])

Currly IR looks like
// &p, &p, sizeof(int), TARGET_PARAM | TO | FROM
// &p, p[0], 100sizeof(float) TO | FROM

Worrking IR is
// map(p, p[0:100]) to map(p[0:100])
// &p, &p[0], 100*sizeof(float), TARGET_PARAM | TO | FROM | PTR_AND_OBJ

The change is add new argument AreBothBasePtrAndPteeMapped in
generateInfoForComponentList

Use that to skip map for map(p), when processing map(p[:100]) generate
map with right flag.
2024-05-15 08:20:25 -07:00
Elvina Yakubova
dcf3102be8 [BOLT][NFC] Add documentation on BOLT options (#92117)
Add .md file documentation with all BOLT options to display it more
conveniently.
2024-05-15 16:16:39 +01:00
Rajveer Singh Bharadwaj
bed5546bb5 [DebugInfo] Get rid of redundant conditional checks in /DebugInfo (#92111)
Resolves #90326
2024-05-15 11:16:15 -04:00
Phoebe Wang
b576a6b045 [X86][AMX] Fix a bug after #83628 (#91207)
We need to check if `GR64Cand` a valid register before using it.

Test is not needed since it's covered in llvm-test-suite.

Fixes #90954
2024-05-15 23:15:48 +08:00
Daniel Kuts
4527adc500 Fix null pointer dereference in logging in mlir TransformOps (#92237)
A variable `typeConverterOp` may be nullptr after dynamic cast. There is
a security guard for this, but during logging error message the variable
getting dereferenced.
Found with static analysis.
2024-05-15 08:15:13 -07:00
Timm Bäder
28d5f7907e [clang][Interp][NFC] Use a smaller default size for IntegralAP
Since we later possibly initialize the value by using operator-new,
we need the default value to _not_ allocate memory.
2024-05-15 17:12:42 +02:00
Timm Bäder
413aaf11cd [clang][Interp][NFC] Support IntAP(S) in emitPrimCast 2024-05-15 17:12:41 +02:00
Krzysztof Parzyszek
8ab753c121 [flang][OpenMP] Add REQUIRES: asserts to test that relies on it
This should fix failures in release builds.
2024-05-15 10:10:49 -05:00
Aaron Ballman
dceaa0f449 [Support] Use malloc instead of non-throwing new (#92157)
When allocating a memory buffer, we use a non-throwing new so that we
can explicitly handle memory buffers that are too large to fit into
memory. However, when exceptions are disabled, LLVM installs a custom
new handler

(90109d4448/llvm/lib/Support/InitLLVM.cpp (L61))
that explicitly crashes when we run out of memory

(de14b749fe/llvm/lib/Support/ErrorHandling.cpp (L188))
and that means this particular out-of-memory situation cannot be
gracefully handled.

This was discovered while working on #embed
(https://github.com/llvm/llvm-project/pull/68620) on Windows and
resulted in a crash rather than the preprocessor issuing a diagnostic as
expected.

This patch switches away from the non-throwing new to a call to malloc
(and free), which will return a null pointer without calling a custom
new handler. It is the only instance in Clang or LLVM that I could find
which used a non-throwing new, so I did not think we would need anything
more involved than this change.

Testing this would be highly platform dependent and so it does not come
with test coverage. And because it doesn't change behavior that users
are likely to be able to observe, it does not come with a release note.
2024-05-15 10:55:34 -04:00
Florian Hahn
8a4cbeada9 [Clang] Unbreak build take 2 using uint64_t() explicitly. 2024-05-15 15:49:03 +01:00
AdityaK
b42d245b77 [GVNHoist] Replace combineKnownMetadata with combineMetadataForCSE (#92197)
There is no reason to call combineMetadata directly with a list of MD_
nodes. The combineMetadataForCSE function handles all the metadata
correctly

Partially fixes: #30866
2024-05-15 07:44:34 -07:00
Florian Hahn
da116bd82c [Clang] Use ULL for std::max constant argument to fix build failure.
getKnownMinValue returns uint64_t, use ULL to make sure the second arg
is also 64 bit.
2024-05-15 15:37:52 +01:00
Endre Fülöp
eda098aade [clang][analyzer] Fix a crash in alpha.unix.BlockInCriticalSection (#90030)
When analyzing C code with function pointers the checker crashes because
of how the implementation extracts `IdentifierInfo`. Without the fix, this
test crashes.
2024-05-15 16:26:17 +02:00
Abid Qadeer
61da6366d0 [flang] Initial debug info support for local variables. (#90905)
We need the information in the `DeclareOp` to generate debug information
for variables.  Currently, cg-rewrite removes the `DeclareOp`. As
`AddDebugInfo` runs after that, it cannot process the `DeclareOp`. My
initial plan was to make the `AddDebugInfo` pass run before the cg-rewrite
but that has few issues.
    
1. Initially I was thinking to use the memref op to carry the variable
attr. But as @tblah suggested in the #86939, it makes more sense to
carry that information on `DeclareOp`. It also makes it easy to handle
it in codegen and there is no special handling needed for arguments. For
this reason, we need to preserve the `DeclareOp` till the codegen.
    
2. Running earlier, we will miss the changes in passes that run between
cg-rewrite and codegen.
    
But not removing the DeclareOp in cg-rewrite has the issue that ShapeOp
remains and it causes errors during codegen. To solve this problem, I
convert DeclareOp to XDeclareOp in cg-rewrite instead of removing
it. This was mentioned as possible solution by @jeanPerier in
https://reviews.llvm.org/D136254
    
The conversion follows similar logic as used for other operators in that
file. The FortranAttr and CudaAttr are currently not converted but left
as TODO when the need arise.

Now `AddDebugInfo` pass can extracts information about local variables
from `XDeclareOp` and creates `DILocalVariableAttr`. These are attached
to `XDeclareOp` using `FusedLoc` approach. Codegen can use them to
create `DbgDeclareOp`.  I have added tests that checks the debug
information in mlir from and also in llvm ir.

Currently we only handle very limited types. Rest are given a place
holder type. The previous placeholder type was basic type with
`DW_ATE_address` encoding. When variables are added, it started
causing assertions in the llvm debug info generation logic for some
types. It has been changed to an interger type to prevent these issues
until we handle those types properly.
2024-05-15 15:20:27 +01:00
Jay Foad
466d266945 [AMDGPU] Fix GFX90x check prefixes in tests (#92254) 2024-05-15 15:13:53 +01:00
Jie Fu
7c8176ebd3 [Coroutines] Remove unused function (NFC)
llvm-project/llvm/lib/Transforms/Coroutines/CoroSplit.cpp:1223:1:
error: unused function 'scanPHIsAndUpdateValueMap' [-Werror,-Wunused-function]
scanPHIsAndUpdateValueMap(Instruction *Prev, BasicBlock *NewBlock,
^
1 error generated.
2024-05-15 22:08:17 +08:00
Krzysztof Parzyszek
8d386c63a8 [Frontend][OpenMP] Reduction modifier must be applied somewhere (#92160)
Detect the case when a reduction modifier ends up not being applied
after construct decomposition, treat it as an error.

This fixes a regression in the gfortran test suite after PR90098.
2024-05-15 09:05:02 -05:00
Krzysztof Parzyszek
4ec4a8e7fe [Frontend][OpenMP] Privatizing clauses in construct decomposition (#92176)
Add remaining clauses with the "privatizing" property to construct
decomposition, specifically to the part handling the `allocate` clause.

---------

Co-authored-by: Tom Eccles <t@freedommail.info>
2024-05-15 09:04:07 -05:00
Krzysztof Parzyszek
97a30448f9 [flang][OpenMP] Add private to allocate in parallel-sections.f90 (#92185)
Add a privatizing clause to the construct that uses `allocate` clause.
Amend the CHECK lines to reflect the expected output.
2024-05-15 08:57:45 -05:00
Koakuma
c2fba6df94 [clang][SPARC] Treat empty structs as if it's a one-bit type in the CC (#90338)
Make sure that empty structs are treated as if it has a size of one bit
in function parameters and return types so that it occupies a full
argument and/or return register slot.

This fixes crashes and miscompilations when passing and/or returning
empty structs.

Reviewed by: @s-barannikov
2024-05-15 20:49:28 +07:00
Krzysztof Parzyszek
95e307caeb Fix bolt build with -DBUILD_SHARED_LIBS=ON after 71fbbb69d
Commit 71fbbb69d6 moved getGUID out of
line in llvm/IR/GlobalValue, now users have to link LLVMCore to have
the definition of it.

/usr/bin/ld: CMakeFiles/LLVMBOLTRewrite.dir/PseudoProbeRewriter.cpp.o: in function `(anonymous namespace)::PseudoProbeRewriter::parsePseudoProbe()':
PseudoProbeRewriter.cpp:(.text._ZN12_GLOBAL__N_119PseudoProbeRewriter16parsePseudoProbeEv+0x3d0): undefined reference to `llvm::GlobalValue::getGUID(llvm::StringRef)'
/usr/bin/ld: CMakeFiles/LLVMBOLTRewrite.dir/PseudoProbeRewriter.cpp.o: in function `(anonymous namespace)::PseudoProbeRewriter::encodePseudoProbes()':
PseudoProbeRewriter.cpp:(.text._ZN12_GLOBAL__N_119PseudoProbeRewriter18encodePseudoProbesEv+0x11a1): undefined reference to `llvm::GlobalValue::getGUID(llvm::StringRef)'
collect2: error: ld returned 1 exit status
make[2]: *** [tools/bolt/lib/Rewrite/CMakeFiles/LLVMBOLTRewrite.dir/build.make:275: lib/libLLVMBOLTRewrite.so.19.0git] Error 1
2024-05-15 08:35:49 -05:00
Hans
3bb39690d7 [coro] Lower llvm.coro.await.suspend.handle to resume with tail call (#89751)
The C++ standard requires that symmetric transfer from one coroutine to
another is performed via a tail call. Failure to do so is a miscompile
and often breaks programs by quickly overflowing the stack.

Until now, the coro split pass tried to ensure this in the
`addMustTailToCoroResumes()` function by searching for
`llvm.coro.resume` calls to lower as tail calls if the conditions were
right: the right function arguments, attributes, calling convention
etc., and if a `ret void` was sure to be reached after traversal with
some ad-hoc constant folding following the call.

This was brittle, as the kind of implicit variants required for a tail
call to happen could easily be broken by other passes (e.g. if some
instruction got in between the `resume` and `ret`), see for example
9d1cb18d19 and
284da049f5.

Also the logic seemed backwards: instead of searching for possible tail
call candidates and doing them if the circumstances are right, it seems
better to start with the intention of making the tail calls we need, and
forcing the circumstances to be right.

Now that we have the `llvm.coro.await.suspend.handle` intrinsic (since
f786881340) which corresponds exactly to
symmetric transfer, change the lowering of that to also include the
`resume` part, always lowered as a tail call.
2024-05-15 15:29:08 +02:00
Kamlesh Kumar
b59760d83d Revert "[ExceptionDemo] Correct and update example ExceptionDemo" (#92257)
Reverts llvm/llvm-project#69485
2024-05-15 18:57:49 +05:30
Simon Pilgrim
f8395f8420 [X86] Cleanup check prefixes identified in #92248
Avoid using leading numbers in check prefixes - replace with actual triple config names.
2024-05-15 14:25:29 +01:00
Simon Pilgrim
3f07430c38 [X86] avoid-sfb-g-no-change.mir - cleanup check prefixes identified in #92248
Don't include "-LABEL" (or any other FileCheck modifier) in the core check prefix name
2024-05-15 14:23:46 +01:00
Simon Pilgrim
e26eacf771 [X86] prefetch.ll - cleanup check prefixes identified in #92248
Avoid using leading numbers in check prefixes - replace with actual triple config names (and makes it easier to add X64 test coverage in a future commit).
2024-05-15 14:11:24 +01:00
Simon Pilgrim
96ac2e3af7 [X86] cmpxchg-clobber-flags.ll - cleanup check prefixes identified in #92248
Avoid using numbers as check prefix - replace with actual triple config names
2024-05-15 14:11:24 +01:00
Simon Pilgrim
97418bb519 [X86] patchable functions - cleanup check prefixes identified in #92248
Avoid using numbers as check prefix - replace with actual triple config names
2024-05-15 14:11:23 +01:00
Tom Stellard
d06270ee00 [workflows] Fix libclang-abi-tests to work with new version scheme (#91865) 2024-05-15 06:08:29 -07:00
Pietro Ghiglio
83d9aa2768 [VPlan] Add scalar inferencing support for addrspace cast (#92107)
Fixes https://github.com/llvm/llvm-project/issues/91434

PR: https://github.com/llvm/llvm-project/pull/92107
2024-05-15 14:03:21 +01:00
Julian Schmidt
932f0de43a [clang-tidy] fix crash due to assumed callee in min-max-use-initializer-list (#91992)
Previously, the call to `findArgs` for a `CallExpr` inside of a `min` or
`max` call would call `findArgs` before checking if the argument is a
call to `min` or `max`, which is what `findArgs` is expecting.
The fix moves the name checking before the call to `findArgs`, such that
only a `min` or `max` function call is used as an argument.

Fixes #91982 
Fixes #92249
2024-05-15 14:52:32 +02:00
Simon Pilgrim
8987369465 [X86] sibcall - cleanup check prefixes identified in #92248
Avoid using numbers as check prefix - replace with actual triple config names
2024-05-15 13:49:39 +01:00
Simon Pilgrim
8a71284cb9 [MC][X86] Cleanup check prefixes identified in #92248
Avoid using numbers as check prefix - replace with actual triple config names where possible
2024-05-15 13:43:42 +01:00
Julian Schmidt
3b5a121a24 [clang-tidy][NFC] replace comparison of begin and end iterators with range empty (#91994)
Improves readability by changing comparisons of `*_begin` and `*_end`
iterators into `.empty()` on their range.
2024-05-15 14:35:07 +02:00
Joseph Huber
398162ddbc [libc] Fix typo in test message 2024-05-15 07:12:54 -05:00
Jay Foad
1650f1b3d7 Fix typo "indicies" (#92232) 2024-05-15 13:10:16 +01:00
Jan Patrick Lehr
ccbf908b08 [libc] Fix GPU test build error (#92235)
This fixes a build error on the AMDGPU buildbot introduced in PR
https://github.com/llvm/llvm-project/pull/92172
2024-05-15 07:06:40 -05:00
Krzysztof Parzyszek
e6ef836f23 [flang][OpenMP] Add -fopenmp-version=52 to teams.f90 (#92180)
One of the functions in the test has `teams if(...)`. The `if` clause
was only allowed on the `teams` directive in OpenMP 5.2.
2024-05-15 06:45:57 -05:00
Krzysztof Parzyszek
de18f5ecf8 [flang][OpenMP] Remove allocate from taskgroup in test (#92173)
Remove the `allocate`, because it needs to be used together with a
privatizing clause. The only such clause for `taskgroup` is
`task_reduction`, but it's not yet supported.
2024-05-15 06:23:34 -05:00