469412 Commits

Author SHA1 Message Date
Nikita Popov
309d55140c [AArch64][GlobalISel] Fix incorrect ABI when tail call not supported (#70215)
The check for whether a tail call is supported calls
determineAssignments(), which may modify argument flags. As such, even
though the check fails and a non-tail call will be emitted, it will not
have a different (incorrect) ABI.

Fix this by operating on a separate copy of the arguments.

Fixes https://github.com/llvm/llvm-project/issues/70207.

(cherry picked from commit 292f34b0d3cb2a04be5ebb85aaeb838b29f71323)
llvmorg-17.0.4
2023-10-31 09:00:30 +01:00
Nikita Popov
9477268e42 [AArch64] Add test for #70207 (NFC)
(cherry picked from commit d9cfb82207035fc7382ad02ec827c0dbed96565c)
2023-10-31 09:00:30 +01:00
Nikita Popov
c2eab59e62 [GVN] Fix use-after-free in load PRE with select available value (#69314)
replaceValuesPerBlockEntry() only handled simple and coerced load
values, however the load may also be referenced by a select value.

Additionally, I suspect that the previous code might have been incorrect
if a load had an offset, as it always constructed the AvailableValue
from scratch.

Fixes https://github.com/llvm/llvm-project/issues/69301.

(cherry picked from commit 7f1733a252cbbad74445bd54dc95aeec52bb3199)
2023-10-31 09:00:10 +01:00
Piotr Zegar
586481468a [clang-tidy] Fix crash in modernize-use-trailing-return-type (#70709)
Resolved the crash that occurred during the use of a user-defined
C-style string literal. The fix entails checking whether the identifier
is non-empty before attempting to read its name.

(cherry picked from commit a396fb247e0719f56a830a9e4aab0449be7f843a)
2023-10-31 08:59:21 +01:00
Brad Smith
9d0ca259ee [OpenMP] Fix building for 32-bit DragonFly, NetBSD, OpenBSD (#70527)
Fixing ```#error "Unknown or unsupported OS"```

(cherry picked from commit 223852aecf3f01cea21c40ea128a26f6a194345d)
2023-10-31 08:59:13 +01:00
Konstantinos Parasyris
a8046f72bf [OpenMP] record-replay use static-cast (#70516)
[OpenMP] Fixes #69905

(cherry picked from commit 01828c4323172db5901ac3e959d52553b2bd74e5)
2023-10-31 08:59:04 +01:00
David Truby
12bbcd627f [flang] Add comdats to functions with linkonce linkage (#66516)
This fixes a bug where functions generated by the MLIR Math dialect, for
example ipowi, would fail to link with link.exe on Windows due to having
linkonce linkage but no associated comdat. Adding the comdat on ELF also
allows linkers to perform better garbage collection in the binary.

Simply adding comdats to all functions with this linkage type should
also cover future cases where linkonce or linkonce_odr functions might
be necessary.

(cherry picked from commit 5f476b80e3d472f672f5f6a719eebe2c0aadf52c)
2023-10-31 08:58:56 +01:00
David Truby
bdb1553c76 [mlir] Add pass to add comdat to all linkonce functions (#65270)
This adds a new pass to add an Any comdat to each linkonce
and linkonce_odr function in the LLVM dialect. These comdats are
necessary on Windows
to allow the default system linker to link binaries containing these
functions.

(cherry picked from commit a6857156df9a73720fbd9633067d1a61c32dd74e)
2023-10-31 08:58:56 +01:00
Takuya Shimizu
3347c84415 Update release note for the fix 2023-10-30 12:59:55 +01:00
Takuya Shimizu
f6fb6a996c [clang][ExprConst] Fix crash on uninitialized array subobject (#67817)
https://reviews.llvm.org/D146358 was assuming that all subobjects have
their own name (`SubobjectDecl`), but it was not true for array
elements.

Fixes https://github.com/llvm/llvm-project/issues/67317
2023-10-30 12:59:49 +01:00
Craig Topper
8c8abe6b93 [RISCV] Correct copyPhysReg for GPRPF64. (#70419)
GPRF64 represents a pair of registers. We were only copying the even
part. We need to copy the odd part too.
2023-10-30 12:56:23 +01:00
Paul Walker
615beaec04 [SVE] Fix incorrect offset calculation when rewriting an instruction's frame index. (#70315)
When partially packing an offset into an SVE load/store instruction we
are incorrectly calculating the remainder.

(cherry picked from commit 7c90be2857fc4c6a2e67f203ca289ed7773fae03)
2023-10-30 12:56:05 +01:00
DianQK
bb29e1ead2 [MemCpyOpt] Combine alias metadatas when replacing byval arguments (#70580)
Fixes #70578.

(cherry picked from commit 0c4f326d8bc97a2fdb0533a68dbe1a7164da3911)
2023-10-30 10:21:23 +01:00
Brad Smith
2b82ec7947 [OpenMP] Use the more appropriate function to retrieve the thread id on OpenBSD (#65553)
Use the getthrid() function instead of a syscall.

(cherry picked from commit 7e31b45d6a2571ff17426930dcbb784473a965b4)
2023-10-30 10:18:17 +01:00
Louis Dionne
8909a24d0a [libc++] Encode additional ODR-affecting properties in the ABI tag (#69669)
As explained in `__config`, we have an ABI tag that we use to ensure
that we don't run into ODR issues when mixing different versions of
libc++ in multiple TUs. However, the reasoning behind that extends not
only to different versions of libc++, but also to different
configurations of the same version of libc++. In fact, we've been aware
of this for a while but never really bothered to make the change because
ODR issues are often thought to be benign.

Well, it turns out that I just spent over an hour banging my head
against an issue that boils down to our lack of encoding of some ODR
properties in the ABI tag, so here's the patch we should have done a
long time ago.

For now, the ODR properties we encode in the ABI tag are:
- library version
- exceptions vs no-exceptions
- hardening mode

Those are all things that we support different values for on a per-TU
basis and they definitely affect ODR in a meaningful way. We can add
more properties later as we see fit.

(cherry picked from commit bc792a284362696c91599f9ab01f74eda4b9108f)
2023-10-30 10:17:40 +01:00
KAWASHIMA Takahiro
e9dcc15f51 [AArch64] Prevent argument promotion of vector with size > 128 bits (#70034)
This patch prevents argument promotion from promoting pointers to
fixed-length vector types larger than 128 bits like `<8 x float>` into
the values of the pointees.

Such vector types are used for SVE VLS but there is no ABI for SVE VLS
arguments and the backend cannot lower such value arguments.

Fixes #69147

(cherry picked from commit 926173c614784149889b2c975adccf52bcece75b)
2023-10-27 14:59:14 +02:00
wanglei
4b7f4152a8 [LoongArch] Implement COPY instruction between CFRs (#69300)
With this patch, all CFRs can be used for register allocation.

(cherry picked from commit 271087e3a0875672b26c185a28b3552d5600d2fb)
2023-10-27 14:48:09 +02:00
Owen Pan
fb62a201a1 Revert "[clang-format] Fix align consecutive declarations over function pointers"
This reverts commit a84e0b4bdc9999872adbdaafbade8164b197784b.

Fixes #68079.

(cherry picked from commit 7bc1031c474ebb2216a5432273dafe4d1490fbce)
2023-10-27 14:47:59 +02:00
Aaron Ballman
1f6d35b366 Fix tests for c23 <-> c2x 2023-10-27 14:47:29 +02:00
Aaron Ballman
030d68ef2c Fix a c23 -> c2x think-o 2023-10-27 14:47:29 +02:00
Aaron Ballman
2a41d978b4 [C23] Use thread_local semantics (#70107)
When implementing thread_local as a keyword in C23, we accidentally
started using C++11 thread_local semantics when using that keyword
instead of using C11 _Thread_local semantics.

This oversight is fixed by pretending the user wrote _Thread_local
instead. This doesn't have the best behavior in terms of diagnostics,
but it does correct the semantic behavior.

Fixes https://github.com/llvm/llvm-project/issues/70068
Fixes https://github.com/llvm/llvm-project/issues/69167
2023-10-27 14:47:29 +02:00
kadir çetinkaya
afbe3549af [clangd] Disable crashy unchecked-optional-access tidy check (#69427)
Fixes https://github.com/llvm/llvm-project/issues/69369.
Fixes https://github.com/clangd/clangd/issues/1700.

(cherry picked from commit e63ab13c82e78f65baca48d5b5e4f6ea8d55dbc7)
2023-10-25 14:02:20 +02:00
Nikita Popov
7f790f9a39 [ConstraintElim] Don't decompose values wider than 64 bits (#68803)
Our coefficients are 64-bits, so adding/multiplying them can wrap in
64-bits even if there would be no wrapping the full bit width.

The alternative would be to check for overflows during all adds/muls in
decomposition. I assume that we don't particularly care about handling
wide integers here, so I've opted to bail out.

Fixes https://github.com/llvm/llvm-project/issues/68751.

(cherry picked from commit 1d43096e16ff7288c7feac1ae81fd4f745ce10bb)
2023-10-24 08:29:57 +02:00
Nikita Popov
a1c67ffd0a [ConstraintElim] Add test for #68751 (NFC)
(cherry picked from commit 2b74db6c9bff757ce016d62a7086617e2b9e43b3)
2023-10-24 08:29:57 +02:00
Brad Smith
ef50a367e3 [mlir] Avoid including <alloca.h> on DragonFly
(cherry picked from commit a157a82b1e7a8d4be34cc862db4b42fa9db363d0)
2023-10-24 08:25:58 +02:00
DianQK
a7101379d7 [LVI][CVP] Treat undef like a full range on abs(x, false) (#68711)
Fixes #68682.

(cherry picked from commit 2ad9a658005e6a4204d7ee617c3949632a707aa5)
2023-10-24 08:24:50 +02:00
Martin Storsjö
aa03fba83b [libcxx] [test] Add a test parameter for disabling memory intensive tests (#68214)
Specifically, the test std/input.output/string.streams/stringstream/stringstream.members/gcount.pass.cpp
allocates a std::string with INT_MAX-1 elements, and then writes this to
a std::stringstream. On Linux, running this test consumes around 5.0 GB
of memory; on Windows, it ends up using up to 6.8 GB of memory.

This limits whether such tests can run on e.g. GitHub Actions runners,
where the free runners are limited to 8 GB of memory.

This is somewhat similar to, but still notably different, from the
existing test parameter long_tests.

(cherry picked from commit 122064a6303eb9c06e0af231f5a4ce145d9a2e67)
2023-10-24 08:24:01 +02:00
Tom Stellard
71f408bc36 workflows/release-tasks: Fix release note artifact upload (#69522)
(cherry picked from commit afdad4fd402d1e8917375960df7104bc16f4cba9)
2023-10-23 09:40:21 +02:00
Tobias Hieta
9ab3ce1d7a Bump version to 17.0.4 2023-10-23 09:39:40 +02:00
Tom Stellard
880a282a40 workflows/release-lit: Pass correct build directory to pypa/gh-action-pypi-publish (#69438)
(cherry picked from commit 1db8abf21a7c025d850624b487b5b792c562094e)
2023-10-23 09:37:35 +02:00
Tom Stellard
8719ee0cb3 workflows/release-lit: Fix dev suffix removal (#69397)
This was broken by b71edfaa4ec3c998aadb35255ce2f60bba2940b0.

(cherry picked from commit 6a7f0b9d9fb533abeb14a7b5af03205688b3786a)
2023-10-23 09:37:35 +02:00
Fangrui Song
888437e1b6 [asan] Ensure __asan_register_elf_globals is called in COMDAT asan.module_ctor (#67745)
On ELF platforms, when there is no global variable and the unique module ID is
non-empty, COMDAT asan.module_ctor is created with no
`__asan_register_elf_globals` calls. If this COMDAT is the prevailing copy
selected by the linker, the linkage unit will have no
`__asan_register_elf_globals` call: the redzone will not be poisoned and ODR
violation checker will not work (#67677).

This behavior is benign for -fno-sanitize-address-globals-dead-stripping because
asan.module_ctor functions that call `__asan_register_globals`
(`InstrumentGlobalsWithMetadataArray`) do not use COMDAT.

To fix #67677:

* Use COMDAT for -fsanitize-address-globals-dead-stripping on ELF platforms.
* Call `__asan_register_elf_globals` even if there is no global variable.
* If the unique module ID is empty, don't call SetComdatForGlobalMetadata:
  placing `@.str` in a COMDAT would incorrectly discard internal COMDAT `@.str`
  in other compile units.

Alternatively, when there is no global variable, asan.module_ctor is not COMDAT
and does not call `__asan_register_elf_globals`. However, the asan.module_ctor
function cannot be eliminated by the linker.

Tested the following script. Only ELF -fsanitize-address-globals-dead-stripping has changed behaviors.
```
echo > a.cc  # no global variable, empty uniqueModuleId
echo 'void f() {}' > b.cc  # with global variable, with uniqueModuleId
echo 'int g;' > c.cc  # with global variable
for t in x86_64-linux-gnu arm64-apple-macosx x86_64-windows-msvc; do
  for gc in -f{,no-}sanitize-address-globals-dead-stripping; do
    for f in a.cc b.cc c.cc; do
      echo /tmp/Rel/bin/clang -S --target=$t -fsanitize=address $gc $f -o -
      /tmp/Rel/bin/clang -S --target=$t -fsanitize=address $gc $f -o - | sed -n '/asan.module_ctor/,/ret/p'
    done
  done
done
```

---

Identical to commit 16eed8c906875e748c3cb610f3dc4b875f3882aa.
6420d3301cd4f0793adcf11f59e8398db73737d8 is an incorrect revert for genuine
purely internal issues.
llvmorg-17.0.3
2023-10-17 08:20:52 +02:00
Owen Pan
2e00f4ca4e [clang-format][doc] Update the Linux kernel coding style URL
(cherry picked from commit 8902f12e61aa2d3053ad4d536e36569fc8bc9512)
2023-10-17 08:19:10 +02:00
Owen Pan
aeb83c3783 [clang-format] Fix a serious bug in git-clang-format (#65723)
When applying format changes to staged files, git-clang-format
erroneously checks out all files in the index and thus may overwrite
unstaged changes.

Fixes #65643.

(cherry picked from commit 743659be87daff4cc8861c525d4a6229d787ef14)
2023-10-17 08:18:23 +02:00
Artem Dergachev
268faa377a [LSan] Mark create_thread_leak.cpp as UNSUPPORTED: darwin.
It started to fail in a flaky manner a few days ago on GreenDragon buildbots
(i.e. x86_64-darwin). I didn't track down the root cause but LSan isn't
actually supported on darwin anyway, so UNSUPPORTED seems appropriate.

Prior art: 3ff080b5.

(cherry picked from commit 0a3519d5a27b9400250b5f6656b50148021e7496)
2023-10-17 08:17:30 +02:00
Nikita Popov
491a91e8ee [PowerPC] Use zext instead of anyext in custom and combine (#68784)
This custom combine currently converts `and(anyext(x),c)` into
`anyext(and(x,c))`. This is not correct, because the original expression
guaranteed that the high bits are zero, while the new one sets them to
undef.

Emit `zext(and(x,c))` instead.

Fixes https://github.com/llvm/llvm-project/issues/68783.

(cherry picked from commit 127ed9ae266ead58aa525f74f4c86841f6674793)
2023-10-17 08:12:03 +02:00
Nikita Popov
8ce6b65c89 [PowerPC] Add test for #68783 (NFC)
(cherry picked from commit 0ead1faef0bfaea499c3b2d13ab417f6bf3f67e1)
2023-10-17 08:12:03 +02:00
Owen Pan
7a23a5d43c [clang-format] Fix a bug in RemoveParentheses: ReturnStatement (#67911)
Don't remove the outermost parentheses surrounding a return statement
expression when inside a function/lambda that has the decltype(auto)
return type.

Fixed #67892.

(cherry picked from commit 75441a684273268ce91036aa2c770e669d39f501)
2023-10-16 10:17:20 +02:00
Noah Goldstein
be4016e527 [X86] Fix logic for optimizing movmsk(bitcast(shuffle(x))); PR67287
Prior logic would remove the shuffle iff all of the elements in `x`
where used. This is incorrect.

The issue is `movmsk` only cares about the highbits, so if the width
of the elements in `x` is smaller than the width of the elements
for the `movmsk`, then the shuffle, even if it preserves all the elements,
may change which ones are used by the highbits.

For example:
`movmsk64(bitcast(shuffle32(x, (1,0,3,2))))`

Even though the shuffle mask `(1,0,3,2)` preserves all the elements, it
flips which will be relevant to the `movmsk64` (x[1] and x[3]
before and x[0] and x[2] after).

The fix here, is to ensure that the shuffle mask can be scaled to the
element width of the `movmsk` instruction. This ensure that the
"high" elements stay "high". This is overly conservative as it
misses cases like `(1,1,3,3)` where the "high" elements stay
intact despite not be scalable, but for an relatively edge-case
optimization that should generally be handled during
simplifyDemandedBits, it seems okay.

(cherry picked from commit 1684c65bc997a8ce0ecf96a493784fe39def75de)
2023-10-16 10:15:06 +02:00
Noah Goldstein
496b174053 [X86] Add tests for incorrectly optimizing out shuffle used in movmsk; PR67287
(cherry picked from commit 65a576e27be814bd23f39b31a8074e9850b0fe26)
2023-10-16 10:15:06 +02:00
Martin Storsjö
f50c6382c7 [clang] [MinGW] Explicitly always pass the -fno-use-init-array (#68571)
On MinGW targets, the .ctors section is always used for constructors.

When using the .ctors section, the constructors need to be emitted in
reverse order to get them execute in the right order. (Constructors with
a specific priority are sorted separately by the linker later.) In LLVM,
in CodeGen/AsmPrinter/AsmPrinter.cpp, there's code that reverses them
before writing them out, executed when using the .ctors section. This
logic is done whenever TM.Options.UseInitArray is set to false. Thus,
make sure to set UseInitArray to false for this target.

This fixes https://github.com/llvm/llvm-project/issues/55938.

(cherry picked from commit a2b8c49c1839076b540c542c024fcfe2361a3e47)
2023-10-16 10:14:56 +02:00
DianQK
d10b731adc [LVI][CVP] Treat undef like a full range (#68190)
When converting to ConstantRange, we should treat undef like a full range.
Fixes #68381.

(cherry picked from commit 81857940f278e21f7957a2833d4b6ec72819e79f)
2023-10-16 10:14:49 +02:00
Simon Pilgrim
37b79e779f [X86] combineConcatVectorOps - only concatenate single-use subops
We could maybe extend this by allowing the lowest subop to have multiple uses and extract the lowest subvector result of the concatenated op, but let's just get the fix in first.

Fixes #67333
2023-10-10 08:49:11 +02:00
Tobias Hieta
5a13ce2d60 Bump version to 17.0.3 2023-10-10 08:47:40 +02:00
Arvind Mukund
e7b3b94cf5 [clang] Correct behavior of LLVM_UNREACHABLE_OPTIMIZE=OFF for Release builds (#68284)
```c++
AArch64SVEPcsAttr *AArch64SVEPcsAttr::CreateImplicit(ASTContext &Ctx, SourceRange Range, Spelling S) {
  AttributeCommonInfo I(Range, NoSemaHandlerAttribute, (
    S == GNU_aarch64_sve_pcs ? AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, GNU_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/} :
    S == CXX11_clang_aarch64_sve_pcs ? AttributeCommonInfo::Form{AttributeCommonInfo::AS_CXX11, CXX11_clang_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/} :
    S == C23_clang_aarch64_sve_pcs ? AttributeCommonInfo::Form{AttributeCommonInfo::AS_C23, C23_clang_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/} :
    (llvm_unreachable("Unknown attribute spelling!"),  AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/})));
  return CreateImplicit(Ctx, I);
}
```

```c++
AArch64SVEPcsAttr *AArch64SVEPcsAttr::CreateImplicit(ASTContext &Ctx, SourceRange Range, Spelling S) {
  AttributeCommonInfo I(Range, NoSemaHandlerAttribute, [&]() {
    switch (S) {
    case GNU_aarch64_sve_pcs:
      return AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, GNU_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/};
    case CXX11_clang_aarch64_sve_pcs:
      return AttributeCommonInfo::Form{AttributeCommonInfo::AS_CXX11, CXX11_clang_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/};
    case C23_clang_aarch64_sve_pcs:
      return AttributeCommonInfo::Form{AttributeCommonInfo::AS_C23, C23_clang_aarch64_sve_pcs, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/};
    default:
      llvm_unreachable("Unknown attribute spelling!");
      return AttributeCommonInfo::Form{AttributeCommonInfo::AS_GNU, 0, false /*IsAlignas*/, false /*IsRegularKeywordAttribute*/};
    }
  }());
  return CreateImplicit(Ctx, I);
}
```

Fixes https://github.com/llvm/llvm-project/issues/68237
Conflicts:
	clang/docs/ReleaseNotes.rst
2023-10-10 08:43:34 +02:00
Martin Storsjö
f0a687d821 [LLD] [COFF] Fix handling of comdat .drectve sections (#68116)
This can happen when manually emitting strings into .drectve sections
with `__attribute__((section(".drectve")))`, which is a way to emulate
`#pragma comment(linker, "...")` for mingw compilers, without requiring
building with -fms-extensions.

Normally, this doesn't generate any comdat, but if compiled with
-fsanitize=address, this section does get turned into a comdat section.

This fixes #67261. This issue can be seen as a regression; a change in
the "lli" tool in 17.x triggers this case, if compiled with ASAN
enabled, triggering this unsupported corner case in LLD. With this
change, LLD can handle it.

(cherry picked from commit 503bc5f66111f7e4fc79972bb9bfec8bb5606bab)
2023-10-10 08:43:27 +02:00
Tom Stellard
8a8ade49ff workflows/release-binaries: Use more cores to avoid the 6 hour timeout (#67874)
(cherry picked from commit 95b2c6b3d6dc5f8b6ee5eb4f8dbc96dea0f50cac)
2023-10-10 08:43:18 +02:00
Martin Storsjö
1090b91a28 [AArch64] Disable loop alignment for Windows targets (#67894)
This should fix #66912. When emitting SEH unwind info, we need to be
able to calculate the exact length of functions before alignments are
fixed. Until that limitation is overcome, just disable all loop
alignment on Windows targets.

(cherry picked from commit 6ae36c012728a274a78a771e4506681732f85a6d)
2023-10-10 08:43:06 +02:00
Shoaib Meenai
69c8c96691 [Sema] Use underlying type of scoped enum for -Wformat diagnostics (#67378)
Right now, `-Wformat` for a scoped enum will suggest a cast based on the
format specifier being used. This can lead to incorrect results, e.g.
attempting to format a scoped enum with `%s` would suggest casting to
`char *` instead of fixing the specifier. Change the logic to treat the
scoped enum's underlying type as the intended type to be printed, and
suggest format specifier changes and casts based on that.

(cherry picked from commit 0b07b06effe5fdf779b75bb5ac6cf15e477cb0be)
2023-10-10 08:42:54 +02:00
René Rebe
b2417f51db Fix release/export.sh to export runtimes tarball, too (#67404)
This addresses missing cmake files needed to build some sub-projects
like libstdcxx.

Co-authored-by: René Rebe <rene@exactcode.de>
llvmorg-17.0.2
2023-10-03 08:37:35 +02:00