Martin Storsjö [Sun, 1 Oct 2023 20:42:16 +0000 (23:42 +0300)]
[clang] [MinGW] Tolerate mingw specific linker options during compilation (#67891)
Prior to
591c4b64b3650884c2c68eb47d755ebb62981b99, the mingw specific
linker options -mthreads, -mconsole, -mwindows and -mdll would be
tolerated also at compile time, but generating a warning about being
unused.
After that commit, they were marked as target specific, which means that
it's an error if they're unused (which would consider them used for the
wrong target). These specific options are only relevant when linking,
but we want to tolerate them at compile time too, like before.
This was fixed for -mthreads in
a79995ca6004082774a87f7a58ab6be5343364b7, while the other options didn't
seem to be commonly used during compilation.
After the 17.x release, we've got more reports about this actually being
an issue, in #64464. Therefore, apply the same fix for them; marking
them as tolerated for mingw targets during compilation, even if they're
unused. Also add a testcase for -mthreads which was already handled.
Thus, this fixes #64464.
(cherry picked from commit
e39de2b8862ae43459324da84279366997265078)
Adapted from the original commit; the test in the original commit
depended on
f39c399d9d15efe8309d8aa3d0ecf62205e6c474. Instead of
using -###, when we're not actually using the printed output of
-###, instead use -fdriver-only.
Martin Storsjö [Mon, 2 Oct 2023 10:47:30 +0000 (13:47 +0300)]
[LLD] [COFF] Restore the current dir as the first entry in the search path (#67857)
Before
af744f0b84e2b6410be65277068b9033124c73b2, the first entry
among the search paths was the empty string, indicating searching
in (or starting from) the current directory. After
af744f0b84e2b6410be65277068b9033124c73b2, the toolchain/clang
specific lib directories were added at the head of the search path.
This would cause lookups of literal file names or relative paths
to match paths in the toolchain, if there are coincidental files
with similar names there, even if they would be find in the current
directory as well.
Change addClangLibSearchPaths to append to the list like all other
operations on searchPaths - but move the invocation of the
function to the right place in the sequence.
This fixes #67779.
(cherry picked from commit
f906fd53b5ce12f07aec394ddf900c7f9f583405)
Martin Storsjö [Mon, 2 Oct 2023 10:43:56 +0000 (13:43 +0300)]
[LLD] [COFF] Clarify -print-search-path for the empty string element (#67856)
Also switch the test case to use -NEXT to strictly match all lines.
(cherry picked from commit
7d7d9e462a8983d71e01786c9ad61a976ff10e8a)
Matheus Izvekov [Thu, 21 Sep 2023 11:16:11 +0000 (13:16 +0200)]
[NFC] clang-format lld/COFF/Driver.cpp and lld/Common/Filesystem.cpp
In order to reduce noise for a MR.
(cherry picked from commit
a5e280bc6bda10607e0e7c864e4d23fac02d00aa)
Martin Storsjö [Mon, 2 Oct 2023 10:22:23 +0000 (13:22 +0300)]
[compiler-rt] Reinstate removal of CRT choice flags from CMAKE_*_FLAGS* (#67935)
This reverts one part of commit
9f4dfcb795bb0ecf9944553f49371164801cd83f, with a modified comment added
about the code.
Ideally, this would only be reinstated temporarily - but given the
situation in vcpkg, it looks likely that they would keep passing the
duplicate options for quite some time. The conflicting CRT choice
usually are benign but only would cause warnings about one option
overriding the other, if passing e.g. "/MDd /MT".
However when vcpkg currently sets these options in CMAKE_*_FLAGS_DEBUG,
it passes the redundant option /D_DEBUG; thus the compiler finally ends
up with e.g. "/D_DEBUG /MDd /MT", which has the effect of defining
_DEBUG while using a release mode CRT, which allegedly breaks the build.
There's a PR up for removing this redundant /D_DEBUG option in vcpkg in
https://github.com/microsoft/vcpkg/pull/34123. With that in place, this
change wouldn't be strictly needed.
(cherry picked from commit
7bc09a471fbc274d8632d1379d4134bec63fecc4)
DianQK [Thu, 28 Sep 2023 08:13:21 +0000 (16:13 +0800)]
[MemCpyOpt] Merge alias metadatas when replacing arguments (#67539)
Alias metadata may no longer be valid after replacing the call argument.
Fix this by merging it with the memcpy alias metadata.
This fixes a miscompilation encountered in
https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Failing.20tests.20when.20rustc.20is.20compiled.20with.201.20CGU.
(cherry picked from commit
4e6e476329a8359cb381517864ed6f88a152e37b)
Nikita Popov [Thu, 28 Sep 2023 07:43:22 +0000 (09:43 +0200)]
[MemCpyOpt] Add test for #67539 (NFC)
(cherry picked from commit
d5c8b23b1ee1dcb6922e8226143410840edabe50)
Argyrios Kyrtzidis [Wed, 20 Sep 2023 01:18:23 +0000 (18:18 -0700)]
[DependencyScanningFilesystem] Make sure the local/shared cache filename lookups use only absolute paths (#66122)
Previously a relative path would be used as a key for cache lookup and
if the same relative path was used from another compiler invocation with
a different working directory then the first cache entry was erroneously
returned.
(cherry picked from commit
36b37c775c285bbff9b57630e7ea9d00b918cc91)
Shoaib Meenai [Thu, 21 Sep 2023 00:32:35 +0000 (17:32 -0700)]
[Sema] Fix fixit cast printing inside macros (#66853)
`Lexer::getLocForEndOfToken` is documented as returning an invalid
source location when the end of the token is inside a macro expansion.
We don't want that for this particular application, so just calculate
the end location directly instead.
Before this, format fix-its would omit the closing parenthesis (thus
producing invalid code) for macros, e.g.:
```
$ cat format.cpp
extern "C" int printf(const char *, ...);
enum class Foo { Bar };
#define LOG(...) printf(__VA_ARGS__)
void f(Foo foo) { LOG("%d\n", foo); }
$ clang -fsyntax-only format.cpp
format.cpp:4:29: warning: format specifies type 'int' but the argument has type 'Foo' [-Wformat]
4 | void f(Foo f) { LOG("%d\n", f); }
| ~~ ^
| static_cast<int>(
format.cpp:3:25: note: expanded from macro 'LOG'
3 | #define LOG(...) printf(__VA_ARGS__)
| ^~~~~~~~~~~
1 warning generated.
```
We now emit a valid fix-it:
```
$ clang -fsyntax-only format.cpp
format.cpp:4:31: warning: format specifies type 'int' but the argument has type 'Foo' [-Wformat]
4 | void f(Foo foo) { LOG("%d\n", foo); }
| ~~ ^~~
| static_cast<int>( )
format.cpp:3:25: note: expanded from macro 'LOG'
3 | #define LOG(...) printf(__VA_ARGS__)
| ^~~~~~~~~~~
1 warning generated.
```
Fixes https://github.com/llvm/llvm-project/issues/63462
(cherry picked from commit
61c5ad8857a71510e4393680a1e42740da4ba6fa)
Artem Belevich [Tue, 12 Sep 2023 20:35:07 +0000 (13:35 -0700)]
Work around two more instances of __noinline__ conflicts. (#66138)
Fixes https://github.com/llvm/llvm-project/issues/57544
(cherry picked from commit
588023ddafb4b0cd11914ab068c6d07187374d69)
Alex Langford [Mon, 31 Jul 2023 23:30:17 +0000 (16:30 -0700)]
[lldb] Fix building LLDB standlone without framework
In
a809720102fae8d1b5a7073f99f9dae9395c5f41 I refactored some logic to
deal with the clang resource directory in standalone LLDB builds.
However, this logic escaped me because it only runs when you do not
build LLDB.framework.
Differential Revision: https://reviews.llvm.org/D156763
(cherry picked from commit
6888de118707e6392b46073fc35738804f9f1d80)
Alex Langford [Tue, 25 Jul 2023 22:38:04 +0000 (15:38 -0700)]
[lldb][NFCI] Change logic to find clang resource dir in standalone builds
As of
0beffb854209a41f31beb18f9631258349a99299 there is a CMake
function to actually calculate the relative path to the clang resource
directory. Currently we have some bespoke logic that looks in a few
places, but with this new function we should be able to eliminate some
complexity here.
Also, I moved the functionality from LLDBConfig to LLDBStandalone since
it is only used in standalone builds.
Differential Revision: https://reviews.llvm.org/D156270
(cherry picked from commit
a809720102fae8d1b5a7073f99f9dae9395c5f41)
Wael Yehia [Thu, 28 Sep 2023 05:33:41 +0000 (01:33 -0400)]
[XCOFF] Do not generate the special .ref for zero-length sections (#66805)
Co-authored-by: Wael Yehia <wyehia@ca.ibm.com>
(cherry picked from commit
da55b1b52fbce80093eee8dd4185df4861a44ba5)
duk [Thu, 10 Aug 2023 20:33:43 +0000 (16:33 -0400)]
Fix buildbot failure caused by D157623
GCC doesn't like the implicit conversion here.
(cherry picked from commit
f11f90d5f4ebfab2b44bf3c98b2d2162acf81e2c)
namazso [Thu, 10 Aug 2023 20:00:58 +0000 (16:00 -0400)]
[lld][COFF] Remove incorrect flag from EHcont table
Fixes EHCont implementation in LLD. Closes #64570
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D157623
(cherry picked from commit
e335c78ec2848e24b10e32e015a84347c69c8130)
Tulio Magno Quites Machado Filho [Mon, 25 Sep 2023 17:03:34 +0000 (14:03 -0300)]
workflows/release-tasks: Setup FileCheck and not for release-lit (#66799)
lit tests require commands FileCheck and not. They must be available in
the PATH.
This also guarantees that python3-psutil is installed in order to enable
more tests.
Fixes #64892.
(cherry picked from commit
b2247f85dc4b187dd0ebc93059a0aa42f35dd64a)
Nikita Popov [Fri, 22 Sep 2023 10:25:56 +0000 (12:25 +0200)]
[StackColoring] Handle fixed object index
This is a followup to #66988. The implementation there did not
account for the possibility of the catch object frame index
referrring to a fixed object, which is the case on win64.
(cherry picked from commit
aa70f4d8cf8f09a2997773156289b16d6a16ec01)
Nikita Popov [Thu, 21 Sep 2023 07:13:27 +0000 (09:13 +0200)]
[StackColoring] Handle SEH catch object stack slots conservatively
The write to the SEH catch object happens before cleanuppads are
executed, while the first reference to the object will typically
be in a catchpad.
If we make use of first-use analysis, we may end up allocating
an alloca used inside the cleanuppad and the catch object at the
same stack offset, which would be incorrect.
https://reviews.llvm.org/D86673 was a previous attempt to fix it.
It used the heuristic "a slot loaded in a WinEH pad and never
written" to detect catch objects. However, because it checks
for more than one load (while probably more than zero was
intended), the fix does not actually work.
The general approach also seems dubious to me, so this patch
reverts that change entirely, and instead marks all catch object
slots as conservative (i.e. excluded from first-use analysis)
based on the WinEHFuncInfo. As far as I can tell we don't need
any heuristics here, we know exactly which slots are affected.
Fixes https://github.com/llvm/llvm-project/issues/66984.
(cherry picked from commit
b3cb4f069c2cb99bdae68d6906156af20e76314f)
Nikita Popov [Thu, 21 Sep 2023 07:13:27 +0000 (09:13 +0200)]
[X86] Add test for #66984 (NFC)
(cherry picked from commit
8b4e29b35d21b079e8b30244cbbfc4d4bc4a29d4)
Nikita Popov [Wed, 20 Sep 2023 09:41:42 +0000 (11:41 +0200)]
[SimpleLoopUnswitch] Fix exponential unswitch
When unswitching via invariant condition injection, we currently
mark the condition in the old loop, so that it does not get
unswitched again. However, if there are multiple branches for
which conditions can be injected, then we can do that for both
the old and new loop. This means that the number of unswitches
increases exponentially.
Change the handling to be more similar to partial unswitching,
where we instead mark the whole loop, rather than a single
condition. This means that we will only generate a linear number
of loops.
TBH I think even that is still highly undesirable, and we should
probably be unswitching all candidates at the same time, so that
we end up with only two loops. But at least this mitigates the
worst case.
The test case is a reduced variant that generates 1700 lines of IR
without this patch and 290 with it.
Fixes https://github.com/llvm/llvm-project/issues/66868.
(cherry picked from commit
8362cae71b80bc43c8c680cdfb13c495705a622f)
Nikita Popov [Wed, 20 Sep 2023 08:46:25 +0000 (10:46 +0200)]
[SimpleLoopUnswitch] Fix reversed branch during condition injection
The in-loop successor is only on the left after a potential condition
inversion. As we re-use the old condition as-is, we should also
reuse the old successors as-is.
Fixes https://github.com/llvm/llvm-project/issues/63962.
(cherry picked from commit
afd7db48c55cb87566758e961f1ebac8af16b8bc)
Antonio Frighetto [Thu, 14 Sep 2023 07:16:01 +0000 (09:16 +0200)]
[clang] Include `expected-no-diagnostics` in newly-added test (NFC)
(cherry picked from commit
c990d9444350ef583c6d53e84d9c10cebbf65532)
Antonio Frighetto [Wed, 13 Sep 2023 16:44:19 +0000 (18:44 +0200)]
[clang] Bail out when handling union access with virtual inheritance
An assertion issue that arose when handling union member access with
virtual base class has been addressed. As pointed out by @zygoloid,
there is no need for further derived-to-base analysis in this instance,
so we can bail out upon encountering a virtual base class. Minor
refinement on the function name as we might not be handling a union.
Reported-By: ormris
Fixes: https://github.com/llvm/llvm-project/issues/65982
(cherry picked from commit
660876a4019b81b5a7427a3dcec5ce8c39cd1ee0)
Takuya Shimizu [Tue, 5 Sep 2023 03:12:42 +0000 (12:12 +0900)]
[clang][Diagnostics] Fix wrong line number display (#65238)
When the caret location is lower than the lowest source range, clang is
printing wrong line numbers. The first line number should consider caret
location line even when there are source ranges provided.
Current wrong line example: https://godbolt.org/z/aj4qEjzs4
(cherry picked from commit
ef5217b3c0dcbb58927fe43400b6d1faa677bf98)
Kazu Hirata [Thu, 21 Sep 2023 17:29:46 +0000 (10:29 -0700)]
Revert "[InlineCost] Check for conflicting target attributes early"
This reverts commit
d6f994acb3d545b80161e24ab742c9c69d4bbf33.
Several people have reported breakage resulting from this patch:
- https://github.com/llvm/llvm-project/issues/65152
- https://github.com/llvm/llvm-project/issues/65205
(cherry picked from commit
b4301df61fc77a9d54ac236bc88742a731285f1c)
Nikita Popov [Fri, 15 Sep 2023 09:42:59 +0000 (11:42 +0200)]
[GVN] Also remove phi nodes from VN table (PR65447)
Followup to D158849: We also need to remove the phi node from the
VN table, which is not handled by removeInstruction().
Fixes https://github.com/llvm/llvm-project/issues/65447.
(cherry picked from commit
18e77760ce5e42d9057f69c3e64a8300d01a48ac)
Nikita Popov [Thu, 17 Aug 2023 14:37:32 +0000 (16:37 +0200)]
[GVN] Invalidate MDA when deduplicating phi nodes
Duplicate phi nodes were being directly removed, without
invalidating MDA. This could result in a new phi node being
allocated at the same address, incorrectly reusing a cache entry.
Fix this by optionally allowing EliminateDuplicatePHINodes() to
collect phi nodes to remove into a vector, which allows GVN to
handle removal itself.
Fixes https://github.com/llvm/llvm-project/issues/64598.
Differential Revision: https://reviews.llvm.org/D158849
(cherry picked from commit
7c229f6e85478bb0626a5e598f47b7be94bb50b0)
Tobias Hieta [Mon, 25 Sep 2023 11:03:29 +0000 (13:03 +0200)]
Bump version to 17.0.2
paulwalker-arm [Thu, 14 Sep 2023 11:58:58 +0000 (12:58 +0100)]
[SVE] Ensure SVE call operands passed via memory are correctly initialised. (#66070)
The stores created when passing operands via memory don't typically
maintain the chain, because they can be done in any order. Instead,
a new chain is created based on all collated stores. SVE parameters
passed via memory don't follow this idiom and try to maintain the
chain, which unfortunately can result in them being incorrectly
deadcoded when the chain is recreated.
This patch brings the SVE side in line with the non-SVE side to
ensure no stores become lost whilst also allowing greater flexibility
when ordering the stores.
Paul Walker [Fri, 8 Sep 2023 16:14:58 +0000 (16:14 +0000)]
[SVE] Precommit test to show missing initialisation of call operand.
When calling func_f8_and_v0_passed_via_memory the memory used to
hold the first vector operand is allocated but not initialised.
Tobias Hieta [Tue, 19 Sep 2023 09:05:13 +0000 (11:05 +0200)]
Bump version to 17.0.1
Tobias Hieta [Tue, 19 Sep 2023 07:44:33 +0000 (09:44 +0200)]
Remove RC suffix
Chuanqi Xu [Mon, 28 Aug 2023 05:32:27 +0000 (13:32 +0800)]
Revert "[C++20] [Coroutines] Mark await_suspend as noinline if the awaiter is not empty"
This reverts commit
f05226d7e38c36efe029a0eb4201b0843f81b5e8.
Chuanqi Xu [Mon, 28 Aug 2023 05:32:23 +0000 (13:32 +0800)]
Revert "[NFC] [C++20] [Coroutines] Mention the side effect of a fix may bring regressions"
This reverts commit
6998ecd330f2b028bf4678edd4f53b5489c5e6df.
Kohei Asano [Thu, 14 Sep 2023 12:26:11 +0000 (21:26 +0900)]
[SimplifyCFG] handle monotonic wrapped case for D150943 (#65882)
(cherry picked from commit
fef82492209b24fd0b36a199657f3ed822e601a6)
Martin Storsjö [Tue, 29 Aug 2023 08:31:53 +0000 (11:31 +0300)]
[lli] Make sure the exported __chkstk functions are included when exporting them
The trick we use (since
cbc2a0623a39461b56bd9eeb308ca535f03793f8)
for exporting the __chkstk function (with various per-arch names)
that is defined in a different object file, relies on the function
already being linked in (by some function referencing it).
This function does end up referenced if there's a function that
allocates more than 4 KB on the stack. In most cases, it's referenced
somewhere, but in the case of builds with LLVM_LINK_LLVM_DYLIB
enabled (so most of the code resides in a separate libLLVM-<ver>.dll)
the only code in lli.exe is the lli tool specific code and the
mingw-w64 crt startup code. In the case of GCC based MinGW i386
builds with LLVM_LINK_LLVM_DYLIB, nothing else references it though.
Manually add a reference to the function to make sure it is linked
in (from libgcc or compiler-rt builtins) so that it can be exported.
This fixes one build issue encountered in
https://github.com/msys2/MINGW-packages/pull/18002.
Differential Revision: https://reviews.llvm.org/D159085
(cherry picked from commit
4bba12f7226228221d1fa4bad7732e25647ecb87)
David Green [Fri, 8 Sep 2023 08:02:15 +0000 (09:02 +0100)]
[ARM] Change CRC predicate to just HasCRC
This removes the backend requirement for crc instructions on HasV8, relying on
just HasCRC instead. This should allow them to be selected with ArmV7 + crc,
making them more usable whilst hopefully not making them incorrectly generated
(they only come from intrinsics, and HasCRC usually requires HasV8). This is
how most other instructions are specified.
(cherry picked from commit
a82c106e571c6991a95c38a936a466895122d713)
Peter Klausler [Thu, 6 Jul 2023 22:03:05 +0000 (15:03 -0700)]
[flang] Allow runtime build with AVOID_NATIVE_INT128_T=1
This patch enables the Fortran runtime support library to be
built without native 128-bit integer support in the C++ compiler.
Experimental: do not merge yet.
Differential Revision: https://reviews.llvm.org/D154660
(cherry picked from commit
1c35c1a73907a95ce54b5a0edca513591e2bc069)
Sam James [Tue, 5 Sep 2023 15:02:04 +0000 (16:02 +0100)]
[Clang] Fix JIT test on 32-bit systems
As reported by mgorny at https://reviews.llvm.org/D159115#4638037, the
unsigned long long cast fails on 32-bit systems at least with GCC.
It looks like a pointer provenance/aliasing issue rather than a bug in GCC.
Acked by Vassil Vassilev on the original revision.
(cherry picked from commit
3403686b72507e3fdbcd69f21fb9235ffa0ca169)
Jessica Clarke [Mon, 4 Sep 2023 00:46:00 +0000 (01:46 +0100)]
[builtins][AArch64] Implement _sync out-of-line atomics
Whilst Clang does not use these, recent GCC does, and so on systems such
as FreeBSD that wish to use compiler-rt as the system runtime library
but also wish to support building programs with GCC these interfaces are
needed.
This is a light adaptation of the code committed to GCC by Sebastian Pop
<spop@amazon.com>, relicensed with permission for use in compiler-rt.
Fixes https://github.com/llvm/llvm-project/issues/63483
Reviewed By: sebpop, MaskRay
Differential Revision: https://reviews.llvm.org/D158536
(cherry picked from commit
4bb2416d42eb593c44bbeb765e1b8641a58f853c)
Wael Yehia [Wed, 6 Sep 2023 14:17:45 +0000 (14:17 +0000)]
Fix AIX OS requirements for ThinLTO to 7.2.5 SP7
Tejas Joshi [Mon, 4 Sep 2023 09:46:52 +0000 (10:46 +0100)]
[SCEV] Fix potentially empty set for unsigned ranges
The following commit enabled the analysis of ranges for heap allocations:
22ca38da25e19a7c5fcfeb3f22159aba92ec381e
The range turns out to be empty in cases such as the one in test (which
is [1,1)), leading to an assertion failure. This patch fixes for the
same case.
Fixes https://github.com/llvm/llvm-project/issues/63856
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D159160
(cherry picked from commit
0609b65aaf03b083d282a4ffe8bf660351dac461)
Igor Kirillov [Wed, 30 Aug 2023 14:52:28 +0000 (14:52 +0000)]
[CodeGen] Fix incorrect insertion point selection for reduction nodes in ComplexDeinterleavingPass
When replacing ComplexDeinterleavingPass::ReductionOperation, we can do it
either from the Real or Imaginary part. The correct way is to take whichever
is later in the BasicBlock, but before the patch, we just always took the
Real part.
Fixes https://github.com/llvm/llvm-project/issues/65044
Differential Revision: https://reviews.llvm.org/D159209
(cherry picked from commit
e2cb07c322e85604dc48f9caec52b3570db0e1d8)
Danila Malyutin [Tue, 29 Aug 2023 15:05:01 +0000 (18:05 +0300)]
[CodeGen][AArch64] Commit test for #65044
(cherry picked from commit
2fce8f74b3c04bbf7e941cfed7604edae2b573b6)
Konstantin Varlamov [Wed, 30 Aug 2023 06:29:33 +0000 (23:29 -0700)]
[libc++][hardening] Remove hardening from release notes, undeprecate safe mode
This patch effectively maintains the status quo, making sure that the
safe mode keeps working the same way as before. Hardening will target
the next major release, allowing it to go through RFC and for the
implementation to stabilize and mature.
Differential Revision: https://reviews.llvm.org/D159171
Igor Kirillov [Thu, 10 Aug 2023 15:38:27 +0000 (15:38 +0000)]
[LoopVectorize] Fix incorrect order of invariant stores when there are multiple reductions.
When a loop has multiple reductions, each with an intermediate invariant
store, the order in which those reductions are processed is not considered.
This can result in the invariant stores outside the loop not preserving the
original order.
This patch sorts VPReductionPHIRecipes by the order in which they have
stores in the original loop before running
`InnerLoopVectorizer::fixReduction` function, and it helps to maintain
the correct order of stores.
Fixes https://github.com/llvm/llvm-project/issues/64047
Differential Revision: https://reviews.llvm.org/D157631
(cherry picked from commit
ac65fb869977185b44757b94dc5130bd08c6f7e2)
Igor Kirillov [Thu, 10 Aug 2023 15:35:39 +0000 (15:35 +0000)]
[LoopVectorize] Pre-commit tests for D157631
Differential Revision: https://reviews.llvm.org/D157630
(cherry picked from commit
2df9ed11c51ebf6d19f7cb22c3794d1bd460ddf8)
Arthur Eubanks [Wed, 6 Sep 2023 18:28:38 +0000 (11:28 -0700)]
[RelNotes] Add more details on the removal of the legacy optimization pipeline
Christian Sigg [Wed, 30 Aug 2023 10:23:25 +0000 (12:23 +0200)]
[mlir][nfc] Allow ops to have operands/attributes named `context`.
This is probably a bad idea, but it's only become a problem with properties and is easy to fix.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D159185
DianQK [Sun, 3 Sep 2023 04:23:33 +0000 (12:23 +0800)]
[JumpThreading] Invalidate LVI after `combineMetadataForCSE`.
(cherry picked from commit
7ded71b1e43fff0be3acb74038bfea87f38d5cfa)
DianQK [Sun, 3 Sep 2023 04:18:57 +0000 (12:18 +0800)]
[JumpThreading][NFC] Pre-commit for invalid LVI.
(cherry picked from commit
5855a4be9cbc3c4584d8a1632886c347044dfbef)
Takuya Shimizu [Mon, 4 Sep 2023 02:19:46 +0000 (11:19 +0900)]
Revert "[clang][Docs] Added release note for D142609"
The associated commit was reverted and backported in a93ca35, so this
release note line should also be removed.
This reverts commit
061e855767dbe0821d81a8d47158f468dd00ae5f.
Younan Zhang [Mon, 28 Aug 2023 06:51:59 +0000 (14:51 +0800)]
[clang][clangd] Ensure the stack bottom before building AST
`clang::runWithSufficientStackSpace` requires the address of the
initial stack bottom to prevent potential stack overflows.
In addition, add a fallback to ASTFrontendAction in case any client
forgets to call it when not through CompilerInstance::ExecuteAction,
which is rare.
Fixes https://github.com/clangd/clangd/issues/1745.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D158967
(cherry picked from commit
e257c0a9190637e44e292271103a13d70bec4b03)
Younan Zhang [Wed, 16 Aug 2023 07:33:58 +0000 (15:33 +0800)]
[clang] Construct ExprRequirement with SubstitutionDiagnostic on SubstFailure
We're expecting a SubstitutionDiagnostic in diagnoseUnsatisfiedRequirement
if the status of ExprRequirement is SubstFailure. Previously, the Requirement
was created with Expr on SubstFailure by mistake, which could lead to the
assertion failure in the subsequent diagnosis.
Fixes https://github.com/clangd/clangd/issues/1726
Fixes https://github.com/llvm/llvm-project/issues/64723
Fixes https://github.com/llvm/llvm-project/issues/64172
In addition, this patch also fixes an invalid test from D129499.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D158061
Elizabeth Andrews [Mon, 14 Aug 2023 19:01:14 +0000 (12:01 -0700)]
[NFC][Clang] Fix static analyzer concern about null value dereference
Differential Revision: https://reviews.llvm.org/D157554
Fangrui Song [Mon, 28 Aug 2023 05:19:31 +0000 (22:19 -0700)]
[sanitizer] scanf interceptor: fix write size for %mc/%mC/%mS
When the optional assignment-allocation character 'm' (Extension to the
ISO C standard) is present, we currently use internal_strlen(buf)+1 for
all of cCsS[ (D85350). Fix cCS to use the correct size.
Fix https://github.com/llvm/llvm-project/issues/61768
Reviewed By: #sanitizers, vitalybuka
Differential Revision: https://reviews.llvm.org/D158485
(cherry picked from commit
beeb37a8f3275281be305d2d1afe35ca053e21c0)
Vassil Vassilev [Fri, 1 Sep 2023 19:50:54 +0000 (19:50 +0000)]
[CodeGen] First check the kind and then the llvm::Function properties.
This patch fixes valgrind reports from downstream consumers about conditional
jump over uninitialised memory.
The original report:
```[ RUN ] ScopeReflectionTest.IsComplete
==987150== Conditional jump or move depends on uninitialised value(s)
==987150== at 0x1E1128F: clang::CodeGen::CodeGenModule::SetLLVMFunctionAttributesForDefinition(clang::Decl const*, llvm::Function*) (CodeGenModule.cpp:2391)
==987150== by 0x1E4F181: clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (CodeGenModule.cpp:5669)
==987150== by 0x1E4A194: clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (CodeGenModule.cpp:3909)
==987150== by 0x1E4A752: clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (CodeGenModule.cpp:3649)
==987150== by 0x1E532F5: clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) [clone .part.0] (CodeGenModule.cpp:6563)
==987150== by 0x1B0BEDD: (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) (ModuleBuilder.cpp:190)
==987150== by 0x1AEA47B: clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (CodeGenAction.cpp:235)
==987150== by 0x101B02F: clang::IncrementalASTConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (IncrementalParser.cpp:52)
==987150== by 0x101ED93: clang::IncrementalParser::ParseOrWrapTopLevelDecl() (IncrementalParser.cpp:276)
==987150== by 0x101FBBC: clang::IncrementalParser::Parse(llvm::StringRef) (IncrementalParser.cpp:342)
==987150== by 0x100E104: clang::Interpreter::Parse(llvm::StringRef) (Interpreter.cpp:360)
==987150== by 0xE734C0: Cpp::Interpreter::Parse(llvm::StringRef) (CppInterOpInterpreter.h:172)
==987150== Uninitialised value was created by a heap allocation
==987150== at 0x844BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==987150== by 0x1B0C882: StartModule (ModuleBuilder.cpp:139)
==987150== by 0x1B0C882: clang::CodeGenerator::StartModule(llvm::StringRef, llvm::LLVMContext&) (ModuleBuilder.cpp:360)
==987150== by 0x101C4AF: clang::IncrementalParser::GenModule() (IncrementalParser.cpp:372)
==987150== by 0x101FC0E: clang::IncrementalParser::Parse(llvm::StringRef) (IncrementalParser.cpp:362)
==987150== by 0x100E104: clang::Interpreter::Parse(llvm::StringRef) (Interpreter.cpp:360)
==987150== by 0x100E243: clang::Interpreter::create(std::unique_ptr<clang::CompilerInstance, std::default_delete<clang::CompilerInstance> >) (Interpreter.cpp:279)
==987150== by 0xF2131A: compat::createClangInterpreter(std::vector<char const*, std::allocator<char const*> >&) (Compatibility.h:123)
==987150== by 0xF22AB9: Cpp::Interpreter::Interpreter(int, char const* const*, char const*, std::vector<std::shared_ptr<clang::ModuleFileExtension>, std::allocator<std::shared_ptr<clang::ModuleFileExtension> > > const&, void*, bool) (CppInterOpInterpreter.h:146)
==987150== by 0xF1827A: CreateInterpreter (CppInterOp.cpp:2494)
==987150== by 0xECFA0E: TestUtils::GetAllTopLevelDecls(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<clang::Decl*, std::allocator<clang::Decl*> >&, bool) (Utils.cpp:23)
==987150== by 0xE9CB85: ScopeReflectionTest_IsComplete_Test::TestBody() (ScopeReflectionTest.cpp:71)
==987150== by 0xF0ED0C: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /home/vvassilev/workspace/builds/scratch/cppyy/InterOp/build-with-clang-repl-release/unittests/CppInterOp/CppInterOpTests)
==987150==
```
Differential revision: https://reviews.llvm.org/D159339
(cherry picked from commit
92246a9be0ba47788ada9621bef58ce7819be526)
Fangrui Song [Fri, 1 Sep 2023 06:26:46 +0000 (23:26 -0700)]
[Driver] Report warnings for unclaimed TargetSpecific options for assembler input
This patch amends D151590 to not error for unlaimed TargetSpecific
options for `-x assembler` input files. This input type causes Driver to
construct tools::ClangAs (-fintegrated-as) or other assemblers (e.g.
tools::gnutools::Assembler) Their ConstructJobs methods, unlike
Clang::ConstructJobs, claim very few options. If an option is unclaimed,
it either leads to a -Wunused-command-line-argument warning or an error
(if `TargetSpecific` is set):
```
% clang '-###' --target=aarch64 -mbranch-protection=bti -c a.s
clang: error: unsupported option '-mbranch-protection=' for target 'aarch64'
```
It seems that downgrading the diagnostic to warning is most useful as
many users use CFLAGS even for `.s` files:
```
clang --target=aarch64 -mbranch-protection=bti -S a.c
clang --target=aarch64 -mbranch-protection=bti -c a.s
```
I decide not to suppress the warning so that
-Wunused-command-line-argument lovers still get a warning, and help
projects use proper ASFLAGS/CFLAGS/etc.
Note: `-mbranch-protection=bti a.S` currently has no warning as `-x assembler-with-cpp`
instructs clangDriver to select tools::Clang and claim most options.
Revert D159010 to demonstrate that we emit a warning for -mfpmath= for
`-x assembler` input.
Modify my AIX cleanup
cd18efb61d759405956dbd30e4b5f2720d8e1783 to
add an err_drv_unsupported_opt_for_target.
Reviewed By: thesamesam
Differential Revision: https://reviews.llvm.org/D159173
(cherry picked from commit
e9d454d1c195958645fb0948f8b97262e7f8b33a)
hstk30 [Thu, 31 Aug 2023 16:54:57 +0000 (17:54 +0100)]
[AArch64] Fix arm neon vstx lane memVT size
StN lane memory size set too big lead to alias analysis goes wrong.
Fixes https://github.com/llvm/llvm-project/issues/64696
Differential Revision: https://reviews.llvm.org/D158611
(cherry picked from commit
db8f6c009e5a17d304be7404e50eb20b2dd0c75b)
Martin Storsjö [Wed, 30 Aug 2023 20:29:15 +0000 (23:29 +0300)]
[llvm-windres] Implement the windres flag --use-temp-file
Whether a temp file or a pipe is used for preprocessing is an
internal detail, this flag has a notable effect on the preprocessing
in GNU windres. Without this flag, GNU windres passes command
arguments as-is to popen(), which means they get evaluated by a
shell without being re-escaped for this case. To mimic this,
llvm-windres has manually tried to unescape arguments.
When GNU windres is given the --use-temp-file flag, it uses a
different API for invoking the preprocessor, and this API takes care
of preserving special characters in the command line arguments.
For users of GNU windres, this means that by using --use-temp-file,
they don't need to do the (quite terrible) double escaping of
quotes/spaces etc.
The xz project uses the --use-temp-file flag when invoking
GNU windres, see
https://github.com/tukaani-project/xz/commit/
6b117d3b1fe91eb26d533ab16a2e552f84148d47.
However as llvm-windres didn't implement this flag and just
assumed the GNU windres popen() behaviour, they had to use a
different codepath for llvm-windres.
That separate codepath for llvm-windres broke later when llvm-windres
got slightly more accurate unescaping of lone quotes in
0f4c6b120f21d582ab7c5c4f2b2a475086c34938 /
https://reviews.llvm.org/D146848 (fixing a discrepancy to GNU
windres as found in https://github.com/llvm/llvm-project/issues/57334),
and this was reported in
https://github.com/mstorsjo/llvm-mingw/issues/363.
Not touching the implementation of the --preprocessor option
with respect to the --use-temp-file flag; that option is doubly
tricky as GNU windres changed its behaviour in a backwards incompatible
way recently (and llvm-windres currently matches the old behaviour).
(See
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=
21c33bcbe36377abf01614fb1b9be439a3b6de20,
https://sourceware.org/bugzilla/show_bug.cgi?id=27594 and
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=
5edb8e3f5ad8d74a83fc0df7f6e4514eed0aa77f;hp=
3abbafc2aacc6706fea3e3e326e2f08d107c3672
for the behaviour change.)
Differential Revision: https://reviews.llvm.org/D159223
(cherry picked from commit
2bcc0fdc58a220cb9921b47ec8a32c85f2511a47)
Haojian Wu [Fri, 28 Jul 2023 15:58:15 +0000 (17:58 +0200)]
[Tooling/Inclusion] Add std::range symbols in the mapping.
Fixes https://github.com/llvm/llvm-project/issues/64191
Differential Revision: https://reviews.llvm.org/D156648
(cherry picked from commit
171868dc2cd60c6e3eaeb3861b18ba0e22461291)
Fangrui Song [Thu, 31 Aug 2023 16:31:25 +0000 (09:31 -0700)]
[sanitizer][test] -std=c2x instead of -std=c23
Adjust tests from
dd230efe703f34678ce52280e50238abf908aaa1 to use
-std=c2x instead, as Clang in release/17.x doesn't support -std=c23.
Fangrui Song [Wed, 30 Aug 2023 19:29:50 +0000 (19:29 +0000)]
[Driver] Adjust -fsanitize=function & -mexecute-only interop after D158614
clangDriver depends on clangBasic, so clangBasic should not depend on
clangDriver, even just its header. Also remove clangBasic's dependency
on LLVMOption.
The issue can be seen through the bazel commit
d26dd681f9726ed7d43d7c0bdd8ee3cb2db69a2b which is reverted now.
Add hasFlagNoClaim and use it as we don't want to suppress
-Wunused-command-line-argument for -mexecute-only just because
-fsanitize= is specified.
Ying Yi [Tue, 29 Aug 2023 19:02:13 +0000 (20:02 +0100)]
[UBSan] Disable the function and kcfi sanitizers on an execute-only target.
An execute-only target disallows data access to code sections.
-fsanitize=function and -fsanitize=kcfi instrument indirect function
calls to load a type hash before the function label. This results in a
non-execute access to the code section and a runtime error.
To solve the issue, -fsanitize=function should not be included in any
check group (e.g. undefined) on an execute-only target. If a user passes
-fsanitize=undefined, there is no error and no warning. However, if the
user explicitly passes -fsanitize=function or -fsanitize=kcfi on an
execute-only target, an error will be emitted.
Fixes: https://github.com/llvm/llvm-project/issues/64931.
Reviewed By: MaskRay, probinson, simon_tatham
Differential Revision: https://reviews.llvm.org/D158614
Phoebe Wang [Tue, 29 Aug 2023 01:31:00 +0000 (09:31 +0800)]
[X86][BF16] Lower FP_ROUND for vector types under AVX512BF16
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D158952
(cherry picked from commit
b667e9c23d6d2f1c7371eb4a03b30de4a6f8b7b6)
Phoebe Wang [Tue, 29 Aug 2023 00:59:24 +0000 (08:59 +0800)]
[X86][BF16] Add test coverage for AVX-NE-CONVERT
Split from D158952.
(cherry picked from commit
30ec9473c6685d64d5caa17e2a6e8f4ccf275159)
Haojian Wu [Mon, 31 Jul 2023 07:20:55 +0000 (09:20 +0200)]
[clangd] Respect IWYU keep pragma for standard headers.
see the issue https://github.com/llvm/llvm-project/issues/64191
Differential Revision: https://reviews.llvm.org/D156650
(cherry picked from commit
dcb28244faa88cb566a852533790bcac75daaa0f)
Craig Topper [Mon, 28 Aug 2023 17:11:12 +0000 (10:11 -0700)]
[RISCV] Prevent tryToFoldBNEOnCmpXchgResult from deleting AND if it has others users.
This disables the transform if the branch does not have the kill
flag set for the AND we want to delete.
Ideally we'd be able to share the AND with the AND we create in
the expansion, but that's a more complex transform. So this starts
with the simple approach to fix miscompile.
This should be backported to LLVM 17.
Fixes PR65025.ll
Reviewed By: asb
Differential Revision: https://reviews.llvm.org/D158962
(cherry picked from commit
ff6d33382faf3709fa270ae0abb8d165142df9ae)
Amy Kwan [Wed, 30 Aug 2023 16:54:12 +0000 (11:54 -0500)]
[PowerPC][lld] Account for additional X-Forms -> D-Form/DS-Forms load/stores when relaxing initial-exec to local-exec
D153645 added additional X-Form load/stores that can be generated for TLS accesses.
However, these added instructions have not been accounted for in lld. As a result,
lld does not know how to handle them and cannot relax initial-exec to local-exec
when the initial-exec sequence contains these additional load/stores.
This patch aims to resolve https://github.com/llvm/llvm-project/issues/64424.
Differential Revision: https://reviews.llvm.org/D158197
(cherry picked from commit
698b45aa902de4d30c798e8d6bd080c8e31bade8)
Simon Tatham [Mon, 21 Aug 2023 07:43:21 +0000 (08:43 +0100)]
[AArch64] Add Defs=[NZCV] to MTE loop pseudos.
The `STGloop` family of pseudo-instructions all expand to a loop which
iterates over a region of memory setting all its MTE tags to a given
value. The loop writes to the flags in order to check termination. But
the unexpanded pseudo-instructions were not marked as modifying the
flags. Therefore it was possible for one to end up in a location where
the flags were live, and then the loop would corrupt them.
We spotted the effect of this in a libc++ test involving a lot of
complicated inlining, and haven't been able to construct a smaller
test case that demonstrates actual incorrect output code. So my test
here is just checking that `implicit-def $nzcv` shows up on the
pseudo-instructions as they're output from isel.
Reviewed By: DavidSpickett
Differential Revision: https://reviews.llvm.org/D158262
(cherry picked from commit
b09c575975b691e988a0f2e31d632c5f1038ab1d)
Mark de Wever [Sat, 26 Aug 2023 17:25:45 +0000 (19:25 +0200)]
[libc++][format] Fixes out of bounds access.
Fixes https://llvm.org/PR65011
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D158940
(cherry picked from commit
8930d04d5580c6a2cf04545c87387cd150cd7b46)
Yuxuan Shui [Wed, 30 Aug 2023 12:40:56 +0000 (15:40 +0300)]
[lldb][windows] _wsopen_s does not accept bits other than `_S_IREAD | _S_IWRITE`
When sending file from a Linux host to a Windows remote, Linux host will try to copy the source file's permission bits, which will contain `_S_I?GRP` and `_S_I?OTH` bits. Those bits are rejected by `_wsopen_s`, causing it to return EINVAL.
This patch masks out the rejected bits.
GitHub issue: #64313
Reviewed By: jasonmolenda, DavidSpickett
Differential Revision: https://reviews.llvm.org/D156817
(cherry picked from commit
9a4b3fdb82327e808213070fd157be3c557b8b9d)
Garvit Gupta [Wed, 30 Aug 2023 05:05:44 +0000 (22:05 -0700)]
[RISCV] Fix assertion failure when zcmp extension is enabled.
Before accessing "getOpcode" thorugh machine instruction, check if the iterator
has reached the end of Machine basic block otherwise we will crash at the
assertion `!NodePtr->isKnownSentinel()`.
The above assertion is hit in "Prologue/Epilogue Insertion & Frame Finalization
pass".
Reviewed By: craig.topper, wangpc
Differential Revision: https://reviews.llvm.org/D158256
(cherry picked from commit
fdef7952cbc26fd31d0d92a4f14dde58bc461fe9)
Markus Böck [Sat, 26 Aug 2023 14:10:52 +0000 (16:10 +0200)]
[mlir] Fix infinite recursion in alias initializer
The alias initializer keeps a list of child indices around. When an alias is then marked as non-deferrable, all children are also marked non-deferrable.
This is currently done naively which leads to an infinite recursion if using mutable types or attributes containing a cycle.
This patch fixes this by adding an early return if the alias is already marked non-deferrable. Since this function is the only way to mark an alias as non-deferrable, it is guaranteed that if it is marked non-deferrable, all its children are as well, and it is not required to walk all the children.
This incidentally makes the non-deferrable marking also `O(n)` instead of `O(n^2)` (although not performance sensitive obviously).
Differential Revision: https://reviews.llvm.org/D158932
Matthias Springer [Sat, 26 Aug 2023 07:57:43 +0000 (09:57 +0200)]
[mlir] Fix crash when adding nested dialect extensions
A dialect extension can add additional dialect extensions in its `apply` function. This used to crash when the vector of `extensions` was internally reallocated while it is being iterated over.
Differential Revision: https://reviews.llvm.org/D158838
Balaji V. Iyer [Fri, 25 Aug 2023 22:15:28 +0000 (15:15 -0700)]
[mlir][math] Modify math.powf to handle negative bases.
Powf expansion currently returns NaN when the base is negative.
This is because taking natural log of a negative number gives
NaN. This patch will square the base and half the exponent, thereby
getting around the negative base problem.
Reviewed By: rsuderman
Differential Revision: https://reviews.llvm.org/D158797
Matthias Springer [Fri, 25 Aug 2023 13:53:39 +0000 (15:53 +0200)]
[mlir][memref] Fix crash in SubViewReturnTypeCanonicalizer
`SubViewReturnTypeCanonicalizer` is used by `OpWithOffsetSizesAndStridesConstantArgumentFolder`, which folds constant SSA value (dynamic) sizes into static sizes. The previous implementation crashed when a dynamic size was folded into a static `1` dimension, which was then mistaken as a rank reduction.
Differential Revision: https://reviews.llvm.org/D158721
Lei Huang [Fri, 25 Aug 2023 16:29:41 +0000 (11:29 -0500)]
[PowerPC] Update V17.0.0 release notes
Serge Pavlov [Wed, 30 Aug 2023 05:32:35 +0000 (12:32 +0700)]
[clang][test] Make check pattern shorter
A check pattern in clang/test/SemaCXX/template-64605.cpp contains template
specialization kind (the text "implicit_instantiation"). It does not need to
be checked and can be safely removed.
Presence of this text in the check pattern prevents from backporting some
commits to the release branch: https://github.com/llvm/llvm-project/issues/64605.
It has only recently been printed and the relevant commit is not present in
the release/17.x branch.
(cherry picked from commit
8859c644ede4898f90f77dcad2286de08a9ba62e)
Serge Pavlov [Mon, 21 Aug 2023 06:20:22 +0000 (13:20 +0700)]
[clang] Run test for concrete target
The test clang/test/SemaCXX/template-64605.cpp uses pragma FENV_ACCESS,
which is not supported on all targets. Restrict it to x86_64 only.
(cherry picked from commit
73e5a70e676850b79f196e01e2194a2485041584)
Serge Pavlov [Mon, 21 Aug 2023 05:20:37 +0000 (12:20 +0700)]
[clang] Set FP options in Sema when instantiating CompoundStmt
When an expression is instantiated, TreeTransform skips ImplicitCastExpr
nodes, assuming they are recreated when the instantiated expression is
built. It breaks functions that use non-default floating-point options,
because they are kept in these ImplicitCastExprs. In this case the
recreated ImplicitCastExpr takes FP options from the current Sema state
and not from AST node.
To fix this issue the FP options in Sema object are set when a compound
statement is cloned in TreeTransform.
This change fixes https://github.com/llvm/llvm-project/issues/64605
([Regression 16 -> 17] Template instantiation ignores FENV_ACCESS being
ON for both definition and instantiation).
Differential Revision: https://reviews.llvm.org/D158158
(cherry picked from commit
0baf85c331090fbe2d2b42214ed0664d55feb0b5)
Tom Stellard [Mon, 28 Aug 2023 16:38:27 +0000 (09:38 -0700)]
workflows: Fix libclang-abi test after update to use download-artifac… (#64877)
workflows: Fix libclang-abi test after update to use download-artifact v3
Aaron Ballman [Thu, 10 Aug 2023 11:22:45 +0000 (07:22 -0400)]
Silently accept -Wgnu-empty-initializer
https://github.com/llvm/llvm-project/commit/
5d8aaad4452f60ba8902e921d9bed606713a8f26
removed the warning group as the functionality is no longer a GNU
extension. However, users have asked for the warning group to be
supported so that code transitioning from Clang 16 to Clang 17 has an
easier migration path when compiling with -Werror. This patch restores
the warning group, but as an ignored warning group because the
functionality is now always considered to be a C extension rather than
a GNU extension. This allows users to do:
-Werror -pedantic -Wno-gnu-empty-intializer -Wno-c2x-extensions
to silence the diagnostics in both Clang 16 and Clang 17.
Fixes https://github.com/llvm/llvm-project/issues/64357
Differential Revision: https://reviews.llvm.org/D157503
(cherry picked from commit
151214b40d869455666ca76548a9e3ad639f79de)
Jon Roelofs [Tue, 15 Aug 2023 23:55:32 +0000 (16:55 -0700)]
[CMake] Add a few more missing dependencies on ClangDriverOptions
This often breaks modules-enabled bootstrap builds.
(cherry picked from commit
1e4d6122cda6529781ecf467c2ae84e5dd41acdf)
Owen Pan [Thu, 17 Aug 2023 08:00:02 +0000 (01:00 -0700)]
[clang-format] Exclude kw_decltype in RemoveParentheses
From https://en.cppreference.com/w/cpp/language/decltype:
Note that if the name of an object is parenthesized, it is treated as an
ordinary lvalue expression, thus decltype(x) and decltype((x)) are often
different types.
Fixes #64786.
Differential Revision: https://reviews.llvm.org/D158155
(cherry picked from commit
e3a79503a30f8c9d8fba79f3e5427bb895f320cf)
Luke Lau [Thu, 17 Aug 2023 09:49:49 +0000 (10:49 +0100)]
[RISCV] Don't relax policy to ta when vmerge's VL shrinks during folding
When folding a vmerge into its operands, if the resulting VL is smaller than
what the vmerge had originally then what was previously in its body then gets
moved to the tail. In that case, we can't relax the tail policy to agnostic
when the merge operand is undefined, since we need to preserve these elements
past the new VL.
Fixes https://github.com/llvm/llvm-project/issues/64754
Reviewed By: craig.topper, reames
Differential Revision: https://reviews.llvm.org/D158161
(cherry picked from commit
007b41b3939832b6938bb1ba91e9febebf93d3b8)
Luke Lau [Thu, 17 Aug 2023 09:36:12 +0000 (10:36 +0100)]
[RISCV] Add test case showing vmerge fold miscompile with tail policy
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D158160
(cherry picked from commit
6e532f94eb0e2c9c93a3d75b4cf53bf12ab9f518)
Fangrui Song [Mon, 14 Aug 2023 15:59:59 +0000 (08:59 -0700)]
Function multi-versioning: disable ifunc for ELF targets other than glibc/Android/FreeBSD
Generalize D127933 (Fuchsia special case) to other ELF targets. Ensure
that musl, NetBSD, OpenBSD, etc do not get ifunc codegen which is
unsupported in their rtld.
Link: https://discourse.llvm.org/t/does-ifunc-use-from-llvm-require-os-support/67628
Close: https://github.com/llvm/llvm-project/issues/64631
(cherry picked from commit
0c3a02b8c09bb408a74a638a263e51d67c92ca74)
Brooks Davis [Tue, 29 Aug 2023 04:22:29 +0000 (21:22 -0700)]
[msan] Fix compilation on non-glibc
SANITIZER_GLIBC is always defined so should be tested with an if not an
ifdef.
Fixes:
ad7e2501000d
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D159041
(cherry picked from commit
692344d87357ded619d216b265a9375f4326d8fb)
Martin Storsjö [Mon, 28 Aug 2023 20:31:08 +0000 (20:31 +0000)]
[compiler-rt] [test] Adjust an XFAIL for strtoll_strict.c for MinGW targets
8033231240f223dc7c718d1d27ece2dbcc8057c6 made this test pass
in MinGW environments, even if it still is failing in MSVC
environments.
(cherry picked from commit
277fc9475fb89c0b80d4237dbc8d698a55203c0d)
Fangrui Song [Mon, 28 Aug 2023 07:49:49 +0000 (00:49 -0700)]
[sanitizer] Intercept glibc 2.38 __isoc23_* functions
`strtol("0b1", 0, 0)` can be (pre-C23) 0 or (C23) 1.
`sscanf("0b10", "%i", &x)` is similar. glibc 2.38 introduced
`__isoc23_strtol` and `__isoc23_scanf` family functions for binary
compatibility.
When `_ISOC2X_SOURCE` is defined (implied by `_GNU_SOURCE`) or
`__STDC_VERSION__ > 201710L`, `__GLIBC_USE_ISOC2X` is defined to 1 and
these `__isoc23_*` symbols are used.
Add `__isoc23_` versions for the following interceptors:
* sanitizer_common_interceptors.inc implements strtoimax/strtoumax.
Remove incorrect FIXME about https://github.com/google/sanitizers/issues/321
* asan_interceptors.cpp implements just strtol and strtoll. The default
`replace_str` mode checks `nptr` is readable and `endptr` is writable.
atoi reuses the existing strtol interceptor.
* msan_interceptors.cpp implements strtol family functions and their
`_l` versions. Tested by lib/msan/tests/msan_test.cpp
* sanitizer_common_interceptors.inc implements scanf family functions.
The strtol family functions are spreaded, which is not great, but the
patch (intended for release/17.x) does not attempt to address the issue.
Add symbols to lib/sanitizer_common/symbolizer/scripts/global_symbols.txt to
support both glibc pre-2.38 and 2.38.
When build bots migrate to glibc 2.38+, we will lose test coverage for
non-isoc23 versions since the existing C++ unittests imply `_GNU_SOURCE`.
Add test/sanitizer_common/TestCases/{strtol.c,scanf.c}.
They catch msan false positive in the absence of the interceptors.
Fix https://github.com/llvm/llvm-project/issues/64388
Fix https://github.com/llvm/llvm-project/issues/64946
Link: https://lists.gnu.org/archive/html/info-gnu/2023-07/msg00010.html
("The GNU C Library version 2.38 is now available")
Reviewed By: #sanitizers, vitalybuka, mgorny
Differential Revision: https://reviews.llvm.org/D158943
(cherry picked from commit
ad7e2501000da2494860f06a306dfe8c08cc07c3)
Fangrui Song [Sun, 27 Aug 2023 17:36:30 +0000 (10:36 -0700)]
[asan] Intercept atoll and strtoll on Windows
`_MSC_VER>=1800` (Visual Studio 2013) supports atoll/strtoll.
Remove the obsoleted workaround ASAN_INTERCEPT_ATOLL_AND_STRTOLL.
test/asan/TestCases/atoll_strict.c passes but
test/asan/TestCases/strtoll_strict.c doesn't.
(cherry picked from commit
8033231240f223dc7c718d1d27ece2dbcc8057c6)
dingfei [Thu, 17 Aug 2023 05:44:05 +0000 (13:44 +0800)]
[clang] Update NumFunctionDeclBits for FunctionDeclBitfields
NumFunctionDeclBits is not updated when DeductionCandidateKind is
incremented.
Fixes https://github.com/llvm/llvm-project/issues/64171
Reviewed By: cor3ntin, balazske, aaron.ballman
Differential Revision: https://reviews.llvm.org/D158145
(cherry picked from commit
91c4b5550ecfbb7afe7275c341b73a6d3a1bbd78)
Galen Elias [Tue, 1 Aug 2023 20:42:04 +0000 (13:42 -0700)]
[clang-format] Fix braced initializer with templated base class
Fixes #64134.
Differential Revision: https://reviews.llvm.org/D156705
(cherry picked from commit
400da115c58ae19445cfdc871a3f559f160fc5c6)
Takuya Shimizu [Tue, 8 Aug 2023 12:10:25 +0000 (21:10 +0900)]
[clang][ExprConstant] Fix crash on uninitialized base class subobject
This patch fixes the reported regression caused by D146358 through adding notes about an uninitialized base class when we diagnose uninitialized constructor.
This also changes the wording from the old one in order to make it clear that the uninitialized subobject is a base class and its constructor is not called.
Wording changes:
BEFORE: `subobject of type 'Base' is not initialized`
AFTER: `constructor of base class 'Base' is not called`
Fixes https://github.com/llvm/llvm-project/issues/63496
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D153969
Vassil Vassilev [Tue, 29 Aug 2023 19:38:34 +0000 (19:38 +0000)]
Reland "[clang-repl] Adapt to the recent dylib-related changes in ORC."
Original commit message:"
ORC splits into separate dylibs symbols coming from the process and symbols
materialized in the Jit. This patch adapts intent of the existing interface and
adds a regression test to make sure both Jit'd and compiled symbols can be found.
Differential revision: https://reviews.llvm.org/D159115
"
This patch disables the test statement on windows as it seems we might have a
bug in the way we model dllimports.
(cherry picked from commit
452cb7f20bc7b976eb6fec4ac9f2d902f4175c08)
Phoebe Wang [Mon, 28 Aug 2023 01:46:35 +0000 (09:46 +0800)]
[X86][BF16] Lower FP_EXTEND for vector types under AVX512BF16
Fixes #64460
Reviewed By: RKSimon, skan
Differential Revision: https://reviews.llvm.org/D158950
(cherry picked from commit
6688701497ea8e562b769bdb154a40f4a1099abb)
Erik Desjardins [Fri, 25 Aug 2023 19:37:05 +0000 (15:37 -0400)]
[Tests][ConstraintElim] autogen newly-added case in large-constant-ints.ll (NFC)
I forgot to do this in
66ec5df3a7f33366455d50769e4e878544becea6 / https://reviews.llvm.org/D158810.
Since this is testing for an assertion failure, the test checks don't matter, but we might as well avoid unnecessary churn the next time someone modifies this test.
(cherry picked from commit
df112cba034eefb86d0e92e18518f5e944d58c37)
Erik Desjardins [Fri, 25 Aug 2023 03:46:16 +0000 (23:46 -0400)]
[ConstraintElim] fix crash with large constants in mul nsw
Another case of https://github.com/llvm/llvm-project/issues/55085.
The added test would trip an assertion due to calling `getSExtValue()` on a value that doesn't fit in int64_t.
Differential Revision: https://reviews.llvm.org/D158810
(cherry picked from commit
66ec5df3a7f33366455d50769e4e878544becea6)
Khem Raj [Fri, 25 Aug 2023 17:43:00 +0000 (10:43 -0700)]
[llvm-exegesis] Use mmap2 when mmap is unavailable to fix riscv32 build
Some 32-bit architectures don't have mmap and define mmap2 instead.
E.g. on riscv32 we may get
```
| /mnt/b/yoe/master/build/tmp/work-shared/llvm-project-source-17.0.0-r0/git/llvm/tools/llvm-exegesis/lib/X86/Target.cpp:1116:19: error: use of undeclared identifier 'SYS_mmap'
| 1116 | generateSyscall(SYS_mmap, MmapCode);
| | ^
| /mnt/b/yoe/master/build/tmp/work-shared/llvm-project-source-17.0.0-r0/git/llvm/tools/llvm-exegesis/lib/X86/Target.cpp:1134:19: error: use of undeclared identifier 'SYS_mmap'
| 1134 | generateSyscall(SYS_mmap, GeneratedCode); | | ^
| 1 warning and 2 errors generated.
```
Co-Authored-By: Fangrui Song <i@maskray.me>
Differential Revision: https://reviews.llvm.org/D158375
(cherry picked from commit
01a92f06f23585f15b3e83b7c378d0df2d91e06b)