platform/upstream/llvm.git
19 months ago[clang-tools-extra] [clangd] Respect llvm_shlib_dir in tests
Michał Górny [Mon, 3 Oct 2022 07:59:34 +0000 (09:59 +0200)]
[clang-tools-extra] [clangd] Respect llvm_shlib_dir in tests

Add llvm_shlib_dir to variables used in clangd test suite, consistently
to how it is used in the test suites of clang, clang-tools-extra
and a few other components.  This is necessary to ensure that
the correct shared libraries are used when building clang standalone --
otherwise, use_clang() sets LD_LIBRARY_PATH to the directory containing
the earlier system installation of clang rather than the just-built
library.

Differential Revision: https://reviews.llvm.org/D135062

(cherry picked from commit 77945a344c3dee3f9735744c8d4151ef2cec6a8d)

19 months agouse LLVM_USE_STATIC_ZSTD
Cole [Fri, 2 Sep 2022 21:00:07 +0000 (21:00 +0000)]
use LLVM_USE_STATIC_ZSTD

removes LLVM_PREFER_STATIC_ZSTD in favor of using a LLVM_USE_STATIC_ZSTD

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D133222

(cherry picked from commit fc1da043f4f9198303abd6f643cf23439115ce73)

19 months agotweak zstd behavior in cmake and llvm config for better testing
Cole Kissane [Thu, 1 Sep 2022 14:49:42 +0000 (07:49 -0700)]
tweak zstd behavior in cmake and llvm config for better testing

add LLVM_PREFER_STATIC_ZSTD (default TRUE) cmake config flag
(compression test seems to fail for shared zstd on windows, note that zstd multithread is by default disabled in the static build so it may be a hidden variable)
propagate variable zstd_DIR in LLVMConfig.cmake.in
fix llvm-config CMakeLists.txt behavior for absolute libs windows
get zstd lib name

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D132870

(cherry picked from commit c0b4f248df79f184adba856f13a950a53c881f3f)

19 months ago[clang][DebugInfo] Emit debuginfo for non-constant case value
Yonghong Song [Mon, 26 Sep 2022 14:08:24 +0000 (07:08 -0700)]
[clang][DebugInfo] Emit debuginfo for non-constant case value

Currently, clang does not emit debuginfo for the switch stmt
case value if it is an enum value. For example,
  $ cat test.c
  enum { AA = 1, BB = 2 };
  int func1(int a) {
    switch(a) {
    case AA: return 10;
    case BB: return 11;
    default: break;
    }
    return 0;
  }
  $ llvm-dwarfdump test.o | grep AA
  $
Note that gcc does emit debuginfo for the same test case.

This patch added such a support with similar implementation
to CodeGenFunction::EmitDeclRefExprDbgValue(). With this patch,
  $ clang -g -c test.c
  $ llvm-dwarfdump test.o | grep AA
                  DW_AT_name    ("AA")
  $

Differential Revision: https://reviews.llvm.org/D134705

(cherry picked from commit 75be0482a2e2a78fae83f1ca604f4ee20d673796)

19 months ago[gn build] (manually) port 18b4a8bcf35 more
Nico Weber [Thu, 28 Jul 2022 11:14:43 +0000 (07:14 -0400)]
[gn build] (manually) port 18b4a8bcf35 more

(cherry picked from commit dd428a571c69621d5b6eb2e0e3ce5497c304fb2c)

19 months ago[LV] Update handling of scalable pointer inductions after b73d2c8.
Florian Hahn [Fri, 23 Sep 2022 17:23:01 +0000 (18:23 +0100)]
[LV] Update handling of scalable pointer inductions after b73d2c8.

The dependent code has been changed quite a lot since 151c144 which
b73d2c8 effectively reverts. Now we run into a case where lowering
didn't expect/support the behavior pre 151c144 any longer.

Update the code dealing with scalable pointer inductions to also check
for uniformity in combination with isScalarAfterVectorization. This
should ensure scalable pointer inductions are handled properly during
epilogue vectorization.

Fixes #57912.

(cherry picked from commit 2c692d891ed639779b1c4b504ca63037bbacc0e8)

19 months ago[LV] Add test for #57912.
Florian Hahn [Fri, 23 Sep 2022 10:44:13 +0000 (11:44 +0100)]
[LV] Add test for #57912.

Add test showing miscompilation during epilogue vectorization with SVE.

(cherry picked from commit 17167005d532dce35ade3a47a0403ffaa7fff6ff)

19 months ago[LV] Convert sve-epilog-vect.ll to use opaque pointers.
Florian Hahn [Fri, 23 Sep 2022 09:24:18 +0000 (10:24 +0100)]
[LV] Convert sve-epilog-vect.ll to use opaque pointers.

(cherry picked from commit 05b3493819fa8aba1eb7510afbcb80a64148beb6)

19 months ago[Clang] Fix variant crashes from GH58028, GH57370
Roy Jacobson [Thu, 29 Sep 2022 15:38:46 +0000 (18:38 +0300)]
[Clang] Fix variant crashes from GH58028, GH57370

Fixes a null dereference in some diagnostic issuing code.

Closes https://github.com/llvm/llvm-project/issues/57370
Closes https://github.com/llvm/llvm-project/issues/58028

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D134885

(cherry picked from commit 9415aad6a40fec74296008a25f34164a95c857f4)

20 months ago[ValueTracking] Fix CannotBeOrderedLessThanZero() for fdiv (PR58046)
Nikita Popov [Thu, 29 Sep 2022 13:51:05 +0000 (15:51 +0200)]
[ValueTracking] Fix CannotBeOrderedLessThanZero() for fdiv (PR58046)

When checking the RHS of fdiv, we should set the SignBitOnly flag,
because a negative zero can become -Inf, which is ordered less
than zero.

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

Differential Revision: https://reviews.llvm.org/D134876

20 months ago[InstSimplify] Add test for PR58046 (NFC)
Nikita Popov [Thu, 29 Sep 2022 13:21:57 +0000 (15:21 +0200)]
[InstSimplify] Add test for PR58046 (NFC)

20 months ago[libcxx] Make stdatomic.h work when included from a C source file
Gergely Nagy [Tue, 27 Sep 2022 11:59:55 +0000 (07:59 -0400)]
[libcxx] Make stdatomic.h work when included from a C source file

If a C source file includes the libc++ stdatomic.h, compilation will
break because (a) the C++ standard check will fail (which is expected),
and (b) `_LIBCPP_COMPILER_CLANG_BASED` won't be defined because the
logic defining it in `__config` is guarded by a `__cplusplus` check, so
we'll end up with a blank header. Move the detection logic outside of
the `__cplusplus` check to make the second check pass even in a C context
when you're using Clang. Note that `_LIBCPP_STD_VER` is not defined when
in C mode, hence stdatomic.h needs to check if in C++ mode before using
that macro to avoid a warning.

In an ideal world, a C source file wouldn't be including the libc++
header directory in its search path, so we'd never have this issue.
Unfortunately, certain build environments make this hard to guarantee,
and in this case it's easy to tweak this header to make it work in a C
context, so I'm hoping this is acceptable.

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

Differential Revision: https://reviews.llvm.org/D134591

(cherry picked from commit afec0f0ec38a72bcc6a697c1cefb1dac0bbd02fb)

20 months ago[docs] improve documentation for misc-const-correctness
Jonas Toth [Mon, 29 Aug 2022 09:19:16 +0000 (11:19 +0200)]
[docs] improve documentation for misc-const-correctness

Improve the documentation for 'misc-const-correctness' to:

- include better examples
- improve the english
- fix links to other checks that were broken due to the directory-layout changes
- mention the limitation that the check does not run on `C` code.

Addresses #56749, #56958

Reviewed By: njames93

Differential Revision: https://reviews.llvm.org/D132244

(cherry picked from commit b5b750346346bfe95c7c6b1cceacc6cfccc8f4f4)

20 months ago[clang-tidy] adjust treating of array-of-pointers when 'AnalyzePointers' is deactivated
Jonas Toth [Sun, 25 Sep 2022 17:26:32 +0000 (19:26 +0200)]
[clang-tidy] adjust treating of array-of-pointers when 'AnalyzePointers' is deactivated

'misc-const-correctness' previously considered arrays as 'Values' independent of the type of the elements.
This is inconsistent with the configuration of the check to disable treating pointers as values.
This patch rectifies this inconsistency.

Fixes #56749

Reviewed By: njames93

Differential Revision: https://reviews.llvm.org/D130793

(cherry picked from commit e66345d54d5f5e803f54c1ace487d57bb11ee884)

20 months agoFix build error in StmtPrinterTest.cpp
Nathan Ridge [Mon, 5 Sep 2022 07:48:17 +0000 (03:48 -0400)]
Fix build error in StmtPrinterTest.cpp

(cherry picked from commit c933453858307d060a1b79e257feb99c9ac828d7)

20 months ago[clangd] Avoid crash when printing call to string literal operator template
Nathan Ridge [Mon, 29 Aug 2022 08:19:19 +0000 (04:19 -0400)]
[clangd] Avoid crash when printing call to string literal operator template

Differential Revision: https://reviews.llvm.org/D132830

(cherry picked from commit 898c421975ed36b99ec2047589384539bd29a40b)

20 months ago[ELF] Rewrite R_RISCV_ALIGN nops when r.addend%4 != 0
Fangrui Song [Mon, 26 Sep 2022 21:20:27 +0000 (14:20 -0700)]
[ELF] Rewrite R_RISCV_ALIGN nops when r.addend%4 != 0

For RVC, GNU assembler and LLVM integrated assembler add c.nop followed by a
sequence of 4-byte nops. Even if remove % 4 == 0, we have to split one 4-byte
nop and therefore need to write the code sequence, otherwise we create an
incorrect c.unimp.

(cherry picked from commit 78084d9e77b9a2017e2215491b71b37c2671c292)

20 months agoBump version to 15.0.2
Tobias Hieta [Mon, 26 Sep 2022 06:22:40 +0000 (08:22 +0200)]
Bump version to 15.0.2

20 months agoExclude check-polly-unittests and check-polly-isl from check-all
Eli Friedman [Wed, 24 Aug 2022 19:52:17 +0000 (12:52 -0700)]
Exclude check-polly-unittests and check-polly-isl from check-all

The unittests are already included in check-polly, so check-all was
running them twice.  Running them twice causes a race on the output
files, which led to intermittent failures on the reverse-iteration
buildbot.

(cherry picked from commit 2c29268bfcc84c3b94bcb0aa34b7ef9c9bd9af01)

20 months ago[Hexagon] Add defaulted operator= to classes with defaulted copy ctor
Krzysztof Parzyszek [Thu, 18 Aug 2022 20:50:20 +0000 (13:50 -0700)]
[Hexagon] Add defaulted operator= to classes with defaulted copy ctor

This avoids deprecation warning:
```
warning: definition of implicit copy assignment operator for 'AddrInfo'
is deprecated because it has a user-declared copy constructor
[-Wdeprecated-copy]
```

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

(cherry picked from commit 252cea037bcad6e1e7236756bcbb4e4ed73e328d)

20 months ago[MachineCycle][NFC] add a cache for block and its top level cycle
Chen Zheng [Fri, 16 Sep 2022 05:48:44 +0000 (01:48 -0400)]
[MachineCycle][NFC] add a cache for block and its top level cycle

This solves https://github.com/llvm/llvm-project/issues/57664

Reviewed By: sameerds

Differential Revision: https://reviews.llvm.org/D134019

(cherry picked from commit c941d925b0e47ec166364178edac75cf1cb1ee1a)

20 months ago[libc++] Keep unary_function and binary_function in C++17 for one more release
Louis Dionne [Thu, 22 Sep 2022 20:17:31 +0000 (16:17 -0400)]
[libc++] Keep unary_function and binary_function in C++17 for one more release

In LLVM 15, we added the deprecation markup for unary_function and
binary_function for >= C++11, and we also removed it for >= C++17.
While this is in accordance with the Standard, it's also a bit quick
for our users, since there was no release in which the classes were
marked as deprecated before their removal.

We noticed widespread breakage due to this, and after months of trying
to fix downstream failures, I am coming to the conclusion that users
will be better served if we give them one release where unary_function
is deprecated but still provided even in >= C++17.

Differential Revision: https://reviews.llvm.org/D134473

20 months agoSPIRV: Fix compilation in NDEBUG.
James Y Knight [Thu, 11 Aug 2022 22:41:22 +0000 (22:41 +0000)]
SPIRV: Fix compilation in NDEBUG.

(cherry picked from commit 59351fe340f20a605bae53260ed30a8e0fd95cb6)

20 months ago[LV] Keep track of cost-based ScalarAfterVec in VPWidenPointerInd.
Florian Hahn [Mon, 19 Sep 2022 17:14:34 +0000 (18:14 +0100)]
[LV] Keep track of cost-based ScalarAfterVec in VPWidenPointerInd.

Epilogue vectorization uses isScalarAfterVectorization to check if
widened versions for inductions need to be generated and bails out in
those cases.

At the moment, there are scenarios where isScalarAfterVectorization
returns true but VPWidenPointerInduction::onlyScalarsGenerated would
return false, causing widening.

This can lead to widened phis with incorrect start values being created
in the epilogue vector body.

This patch addresses the issue by storing the cost-model decision in
VPWidenPointerInductionRecipe and restoring the behavior before 151c144.
This effectively reverts 151c144, but the long-term fix is to properly
support widened inductions during epilogue vectorization

Fixes #57712.

20 months ago[LV] Move new epilog-vectorization-widen-inductions.ll to AArch64 dir.
Florian Hahn [Mon, 19 Sep 2022 16:12:31 +0000 (17:12 +0100)]
[LV] Move new epilog-vectorization-widen-inductions.ll to AArch64 dir.

The test requires the AArch64 backend, so move it to the right subdir.

20 months ago[LV] Add tests for epilogue vectorization with widened inductions.
Florian Hahn [Mon, 19 Sep 2022 16:10:40 +0000 (17:10 +0100)]
[LV] Add tests for epilogue vectorization with widened inductions.

Includes a test for the miscompile in #57712.

20 months ago[libc++] Always query the compiler to find whether a type is always lockfree
Louis Dionne [Tue, 6 Sep 2022 21:07:18 +0000 (17:07 -0400)]
[libc++] Always query the compiler to find whether a type is always lockfree

In https://llvm.org/D56913, we added an emulation for the __atomic_always_lock_free
compiler builtin when compiling in Freestanding mode. However, the emulation
did (and could not) give exactly the same answer as the compiler builtin,
which led to a potential ABI break for e.g. enum classes.

After speaking to the original author of D56913, we agree that the correct
behavior is to instead always use the compiler builtin, since that provides
a more accurate answer, and __atomic_always_lock_free is a purely front-end
builtin which doesn't require any runtime support. Furthermore, it is
available regardless of the Standard mode (see https://godbolt.org/z/cazf3ssYY).

However, this patch does constitute an ABI break. As shown by https://godbolt.org/z/1eoex6zdK:
- In LLVM <= 11.0.1, an atomic<enum class with 1 byte> would not contain a lock byte.
- In LLVM >= 12.0.0, an atomic<enum class with 1 byte> would contain a lock byte.

This patch breaks the ABI again to bring it back to 1 byte, which seems
like the correct thing to do.

Fixes #57440

Differential Revision: https://reviews.llvm.org/D133377

(cherry picked from commit f1a601fe88f99d52ca80617266897b217bcd4d64)

20 months ago[docs] Fix build-docs.sh
Tobias Hieta [Mon, 19 Sep 2022 19:42:42 +0000 (21:42 +0200)]
[docs] Fix build-docs.sh

If libcxxabi is not included CMake will error out:

Cannot find target libcxxabi-SHARED

I ran into this doing the 15.0.0 release

Differential Revision: https://reviews.llvm.org/D133475

20 months ago[libcxx] Bump libc++ version to 15.0.1
Tobias Hieta [Mon, 19 Sep 2022 17:47:45 +0000 (19:47 +0200)]
[libcxx] Bump libc++ version to 15.0.1

20 months ago[CodeGen] Don't zero callee-save registers with zero-call-used-regs (PR57692)
Nikita Popov [Thu, 15 Sep 2022 15:00:55 +0000 (17:00 +0200)]
[CodeGen] Don't zero callee-save registers with zero-call-used-regs (PR57692)

Callee save registers must be preserved, so -fzero-call-used-regs
should not be zeroing them. The previous implementation only did
not zero callee save registers that were saved&restored inside the
function, but we need preserve all of them.

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

Differential Revision: https://reviews.llvm.org/D133946

(cherry picked from commit b4309800e9dc53a84222a6b57c8615d4a3084988)

20 months ago[lit] Set shlibpath_var on OpenBSD
Brad Smith [Fri, 16 Sep 2022 01:43:01 +0000 (21:43 -0400)]
[lit] Set shlibpath_var on OpenBSD

(cherry picked from commit 3eca0b395ff07d0428f4179e33a6ae295e608f47)

20 months ago[clang(d)] Include/Exclude CLDXC options properly
Kadir Cetinkaya [Thu, 15 Sep 2022 18:57:07 +0000 (20:57 +0200)]
[clang(d)] Include/Exclude CLDXC options properly

This handles the new CLDXC options that was introduced in
https://reviews.llvm.org/D128462 inside clang-tooling to make sure cl driver
mode is not broken.

Fixes https://github.com/clangd/clangd/issues/1292.

Differential Revision: https://reviews.llvm.org/D133962

(cherry picked from commit 23ace26e0d1aa2283d65d192c37592fb0eef1b1f)

20 months ago[Libomptarget] Revert changes to AMDGPU plugin destructors
Joseph Huber [Thu, 15 Sep 2022 23:28:52 +0000 (18:28 -0500)]
[Libomptarget] Revert changes to AMDGPU plugin destructors

These patches exposed a lot of problems in the AMD toolchain. Rather
than keep it broken we should revert it to its old semi-functional
state. This will prevent us from using device destructors but should
remove some new bugs. In the future this interface should be changed
once these problems are addressed more correctly.

This reverts commit ed0f21811544320f829124efbb6a38ee12eb9155.

This reverts commit 2b7203a35972e98b8521f92d2791043dc539ae88.

Fixes #57536

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D133997

20 months ago[llvm-objdump] Change printSymbolVersionDependency to use ELFFile API
Fangrui Song [Wed, 14 Sep 2022 19:30:34 +0000 (12:30 -0700)]
[llvm-objdump] Change printSymbolVersionDependency to use ELFFile API

When .gnu.version_r is empty (allowed by readelf but warned by objdump),
llvm-objdump -p may decode the next section as .gnu.version_r and may crash due
to out-of-bounds C string reference. ELFFile<ELFT>::getVersionDependencies
handles 0-entry .gnu.version_r gracefully. Just use it.

Fix https://github.com/llvm/llvm-project/issues/57707

Differential Revision: https://reviews.llvm.org/D133751

(cherry picked from commit 25394c9d10e73b666f4fa1dff2426824894cce58)

20 months ago[llvm-objdump][test] Add verneed-invalid.test
Fangrui Song [Wed, 14 Sep 2022 19:27:30 +0000 (12:27 -0700)]
[llvm-objdump][test] Add verneed-invalid.test

(cherry picked from commit 55a72dae1f996e4fb1528c1b6b1bff8550fec303)

20 months ago[compiler-rt] Handle non-canonical triples with new runtime lib layout
Rainer Orth [Sun, 11 Sep 2022 09:25:53 +0000 (11:25 +0200)]
[compiler-rt] Handle non-canonical triples with new runtime lib layout

As described in Issue #54196
<https://github.com/llvm/llvm-project/issues/54196>, the ideas of `clang`
and `compiler-rt` where runtime libs are located with
`-DLLVM_ENABLE_RUNTIMES` can differ.  This is the `compiler-rt` side of the
patch I've used to get them in sync for the `amd64-pc-solaris2.11` and
`sparc64-unknown-linux-gnu` release builds.

Tested on  `amd64-pc-solaris2.11` and `sparc64-unknown-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D133406

(cherry picked from commit cadc9cdedfef892b00b17658a823e4846a71e3ac)

20 months ago[NFC] Fix exception in version-check.py script
Tobias Hieta [Thu, 15 Sep 2022 11:32:32 +0000 (13:32 +0200)]
[NFC] Fix exception in version-check.py script

20 months agoBump version to 15.0.1
Tobias Hieta [Thu, 15 Sep 2022 08:16:56 +0000 (10:16 +0200)]
Bump version to 15.0.1

20 months agoDowngrade implicit int and implicit function declaration to warning only
Aaron Ballman [Wed, 14 Sep 2022 14:10:56 +0000 (10:10 -0400)]
Downgrade implicit int and implicit function declaration to warning only

The changes in Clang 15.0.0 which enabled these diagnostics as a
warning which defaulted to an error caused disruption for people
working on distributions such as Gentoo. There was an explicit request
to downgrade these to be warning-only in Clang 15.0.1 with the
expectation that Clang 16 will default the diagnostics to an error.

See
https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213
for more details on the discussion.

See https://reviews.llvm.org/D133800 for the public review of these
changes.

20 months ago[MachO] Don't fold compact unwind entries with LSDA
Shoaib Meenai [Sun, 28 Aug 2022 20:09:56 +0000 (01:09 +0500)]
[MachO] Don't fold compact unwind entries with LSDA

Folding them will cause the unwinder to compute the incorrect function
start address for the folded entries, which in turn will cause the
personality function to interpret the LSDA incorrectly and break
exception handling.

You can verify the end-to-end flow by creating a simple C++ file:
```
void h();
int main() { h(); }
```

and then linking this file against the liblsda.dylib produced by the
test case added here. Before this change, running the resulting program
would result in a program termination with an uncaught exception.
Afterwards, it works correctly.

Reviewed By: #lld-macho, thevinster

Differential Revision: https://reviews.llvm.org/D132845

(cherry picked from commit 56bd3185cdd8d79731acd6c75bf41869284a12ed)

20 months ago[MachO] Fix dead-stripping __eh_frame
Shoaib Meenai [Mon, 22 Aug 2022 19:55:41 +0000 (22:55 +0300)]
[MachO] Fix dead-stripping __eh_frame

This section is marked S_ATTR_LIVE_SUPPORT in input files, which meant
that on arm64, we were unnecessarily preserving FDEs if we e.g. had
multiple weak definitions for a function. Worse, we would actually
produce an invalid `__eh_frame` section in that case, because the CIE
associated with the unnecessary FDE would still get dead-stripped and
we'd end up with a dangling FDE. We set up associations from functions
to their FDEs, so dead-stripping will just work naturally, and we can
clear S_ATTR_LIVE_SUPPORT from our input `__eh_frame` sections to fix
dead-stripping.

Reviewed By: #lld-macho, int3

Differential Revision: https://reviews.llvm.org/D132489

(cherry picked from commit a745e47900dde15c180d5caea7a1d292ca809eb1)

20 months ago[libc++][format] Updates feature-test macros.
Mark de Wever [Sun, 4 Sep 2022 11:56:36 +0000 (13:56 +0200)]
[libc++][format] Updates feature-test macros.

During the discussion on the SG-10 mailinglist regarding the format
feature-test macros voted in during the last plenary it turns out libc++
can't mark the format feature-test macro as implemented.

According to
  https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_lib_format
the not yet implemented paper
  P1361R2 Integration of chrono with text formatting
affects the feature test macro.

Note that P1361R2 doesn't mention the feature-test macro nor is there an
LWG-issue to address the issue. The reporter of the issue didn't recall
where this requirement exactly has been decided.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D133271

20 months ago[LLD][COFF] Fix writing a map file when range extension thunks are inserted
Jan Ole Hüser [Wed, 7 Sep 2022 06:17:10 +0000 (09:17 +0300)]
[LLD][COFF] Fix writing a map file when range extension thunks are inserted

Bug: An assertion fails:

    Assertion failed: isa<To>(Val) && "cast<Ty>() argument of incompatible type!",
    file C:\Users\<user>\prog\llvm\llvm-git-lld-bug\llvm\include\llvm/Support/Casting.h, line 578

Bug is triggered, if

    - a map file is requested with /MAP, and
    - Architecture is ARMv7, Thumb, and
    - a relative jump (branch instruction) is greater than 16 MiB (2^24)

The reason for the Bug is:

    - a Thunk is created for the jump
    - a Symbol for the Thunk is created
        - of type `DefinedSynthetic`
        - in file `Writer.cpp`
        - in function `getThunk`
    - the Symbol has no name
    - when creating the map file, the name of the Symbol is queried
    - the function `Symbol::computeName` of the base class `Symbol`
      casts the `this` pointer to type `DefinedCOFF` (a derived type),
      but the acutal type is `DefinedSynthetic`
    - The in the llvm::cast an assertion fails

Changes:

- Modify regression test to trigger this bug
- Give the symbol pointing to the thunk a name, to fix the bug
- Add assertion, that only DefinedCOFF symbols are allowed to have an
  empty name, when the constructor of the base class Symbol is executed

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D133201

(cherry picked from commit 4e5a59a3839f54d928d37d49d4c4ddbb3f339b76)

20 months ago[mlir] Fix building CRunnerUtils on OpenBSD with 15.x
Brad Smith [Sat, 10 Sep 2022 00:33:30 +0000 (20:33 -0400)]
[mlir] Fix building CRunnerUtils on OpenBSD with 15.x

CRunnerUtils builds as C++11. 9c1d133c3a0256cce7f40e2e06966f84e8b99ffe broke
the build on OpenBSD. aligned_alloc() was only introduced in C++17.

20 months ago[DwarfEhPrepare] Assign dummy debug location for inserted _Unwind_Resume calls (PR57469)
Nikita Popov [Thu, 1 Sep 2022 08:13:35 +0000 (10:13 +0200)]
[DwarfEhPrepare] Assign dummy debug location for inserted _Unwind_Resume calls (PR57469)

DwarfEhPrepare inserts calls to _Unwind_Resume into landing pads.
If _Unwind_Resume happens to be defined in the same module and
debug info is used, then this leads to a verifier error:

  inlinable function call in a function with debug info must
    have a !dbg location
  call void @_Unwind_Resume(ptr %exn.obj) #0

Fix this by assigning a dummy location to the call. (As this
happens in the backend, inlining is not actually relevant here.)

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

Differential Revision: https://reviews.llvm.org/D133095

(cherry picked from commit 5134bd432f8c35c87f4c4dc3bb744d396adcab58)

20 months ago[Clang] Fix crash in coverage of if consteval.
Corentin Jabot [Fri, 26 Aug 2022 08:20:12 +0000 (10:20 +0200)]
[Clang] Fix crash in coverage of if consteval.

Clang crashes when encountering an `if consteval` statement.
This is the minimum fix not to crash.
The fix is consistent with the current behavior of if constexpr,
which does generate coverage data for the discarded branches.
This is of course not correct and a better solution is
needed for both if constexpr and if consteval.
See https://github.com/llvm/llvm-project/issues/54419.

Fixes #57377

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D132723

20 months ago[clang] Skip re-building lambda expressions in parameters to consteval fns.
Utkarsh Saxena [Tue, 30 Aug 2022 14:57:07 +0000 (16:57 +0200)]
[clang] Skip re-building lambda expressions in parameters to consteval fns.

As discussed in this [comment](https://github.com/llvm/llvm-project/issues/56183#issuecomment-1224331699),
we end up building the lambda twice: once while parsing the function calls and then again while handling the immediate invocation.

This happens specially during removing nested immediate invocation.
Eg: When we have another consteval function as the parameter along with this lambda expression. Eg: `foo(bar([]{}))`, `foo(bar(), []{})`

While removing such nested immediate invocations, we should not rebuild this lambda. (IIUC, rebuilding a lambda would always generate a new type which will never match the original type from parsing)

Fixes: https://github.com/llvm/llvm-project/issues/56183
Fixes: https://github.com/llvm/llvm-project/issues/51695
Fixes: https://github.com/llvm/llvm-project/issues/50455
Fixes: https://github.com/llvm/llvm-project/issues/54872
Fixes: https://github.com/llvm/llvm-project/issues/54587

Differential Revision: https://reviews.llvm.org/D132945

(cherry picked from commit e7eec38246560781e0a4020b19c7eb038a8c5655)

20 months ago[DAG] extractShiftForRotate - replace assertion for shift opcode with an early-out
Simon Pilgrim [Wed, 31 Aug 2022 13:39:32 +0000 (14:39 +0100)]
[DAG] extractShiftForRotate - replace assertion for shift opcode with an early-out

We feed the result from the first extractShiftForRotate call into the second, and that result might no longer be a shift op (usually due to constant folding).

NOTE: We REALLY need to stop creating nodes on the fly inside extractShiftForRotate!

Fixes Issue #57474

(cherry picked from commit eaede4b5b7cfc13ca0e484b4cb25b2f751d86fd9)

20 months ago[clang-format] Distinguish logical and after bracket from reference
jackh [Sat, 13 Aug 2022 03:12:10 +0000 (11:12 +0800)]
[clang-format] Distinguish logical and after bracket from reference

Fix commit `b646f0955574` and remove redundant code.

Differential Revision: https://reviews.llvm.org/D131750

(cherry picked from commit ef71383b0cfbacdbebf495015f6ead5294bf7759)

20 months ago[compiler-rt] [test] Handle missing ld.gold gracefully
Michał Górny [Tue, 6 Sep 2022 13:40:10 +0000 (15:40 +0200)]
[compiler-rt] [test] Handle missing ld.gold gracefully

Fix the is_binutils_lto_supported() function to handle missing
executables gracefully.  Currently, the function does not catch
exceptions from subprocess.Popen() and therefore causes lit to crash
if config.gold_executable does not specify a valid executable:

```
lit: /usr/lib/python3.11/site-packages/lit/TestingConfig.py:136: fatal: unable to parse config file '/tmp/portage/sys-libs/compiler-rt-
15.0.0/work/compiler-rt/test/lit.common.cfg.py', traceback: Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/lit/TestingConfig.py", line 125, in load_from_path
    exec(compile(data, path, 'exec'), cfg_globals, None)
  File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 561, in <module>
    if is_binutils_lto_supported():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 543, in is_binutils_lto_supported
    ld_cmd = subprocess.Popen([exe, '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1022, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1899, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'GOLD_EXECUTABLE-NOTFOUND'
```

Differential Revision: https://reviews.llvm.org/D133358

(cherry picked from commit ea953b9d9a65c202985a79f1f95da115829baef6)

20 months ago[Symbolizer] Handle {{{bt}}} symbolizer markup element.
Daniel Thornburgh [Fri, 5 Aug 2022 21:58:44 +0000 (14:58 -0700)]
[Symbolizer] Handle {{{bt}}} symbolizer markup element.

This adds support for backtrace generation to the llvm-symbolizer markup
filter, which is likely the largest use case.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D132706

(cherry picked from commit ea99225521cba6dec1ad4ca70a8665829e772fa9)

20 months ago[Symbolizer] Fix symbolizer-filter-markup-pc.test on Windows
Daniel Thornburgh [Mon, 8 Aug 2022 18:39:44 +0000 (11:39 -0700)]
[Symbolizer] Fix symbolizer-filter-markup-pc.test on Windows

(cherry picked from commit 0d6cf1e8b5fa8590f816d5330cb7c2dcc449ec24)

20 months ago[Symbolizer] Implement pc element in symbolizing filter.
Daniel Thornburgh [Mon, 1 Aug 2022 21:35:25 +0000 (14:35 -0700)]
[Symbolizer] Implement pc element in symbolizing filter.

Implements the pc element for the symbolizing filter, including it's
"ra" and "pc" modes. Return addresses ("ra") are adjusted by
decrementing one. By default, {{{pc}}} elements are assumed to point to
precise code ("pc") locations. Backtrace elements will adopt the
opposite convention.

Along the way, some minor refactors of value printing and colorization.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D131115

(cherry picked from commit bf48b128b02813e53e0c8f6585db837d14c9358f)

20 months ago[Symbolizer] Implement data symbolizer markup element.
Daniel Thornburgh [Tue, 19 Jul 2022 21:20:12 +0000 (14:20 -0700)]
[Symbolizer] Implement data symbolizer markup element.

This connects the Symbolizer to the markup filter and enables the first
working end-to-end flow using the filter.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D130187

(cherry picked from commit 22df238d4a642a4553ebf7b91325189be48b139d)

20 months agoAMDGPU: mbcnt allow for non-zero src1 for known-bits
David Stuttard [Tue, 9 Aug 2022 07:46:55 +0000 (08:46 +0100)]
AMDGPU: mbcnt allow for non-zero src1 for known-bits

Src1 for mbcnt can be a non-zero literal or register. Take this into account
when calculating known bits.

Differential Revision: https://reviews.llvm.org/D131478

(cherry picked from commit 1d1cc05539e275ae7666fc4b44bf725ec335078a)

20 months ago[RISCV][ReleaseNotes] Added LLVM and Clang release notes for RISC-V 15.0.0
Alex Bradbury [Mon, 5 Sep 2022 09:48:03 +0000 (10:48 +0100)]
[RISCV][ReleaseNotes] Added LLVM and Clang release notes for RISC-V 15.0.0

20 months ago[DOCS] Minor fixes and removals of WIP warnings
Tobias Hieta [Sun, 4 Sep 2022 14:48:01 +0000 (16:48 +0200)]
[DOCS] Minor fixes and removals of WIP warnings

20 months ago[RLEV] Pick a correct insert point when incoming instruction is itself a phi node
Philip Reames [Mon, 29 Aug 2022 18:37:42 +0000 (11:37 -0700)]
[RLEV] Pick a correct insert point when incoming instruction is itself a phi node

This fixes https://github.com/llvm/llvm-project/issues/57336. It was exposed by a recent SCEV change, but appears to have been a long standing issue.

Note that the whole insert into the loop instead of a split exit edge is slightly contrived to begin with; it's there solely because IndVarSimplify preserves the CFG.

Differential Revision: https://reviews.llvm.org/D132571

(cherry picked from commit c37b1a5f764380f83ba08ae0cebca2b162123eb6)

20 months ago[clang] Add __is_target_variant_{os,environment} builtins
Nico Weber [Fri, 26 Aug 2022 18:40:59 +0000 (14:40 -0400)]
[clang] Add __is_target_variant_{os,environment} builtins

Xcode 13's clang has them. For the included testcase, Xcode's clang
behaves like the implementation in this patch.

Availability.h in the macOS 12.0 SDK (part of Xcode 13, and the current
stable version of the macOS SDK) does something like:

   #if defined(__has_builtin)
     ...
     #if __has_builtin(__is_target_os)
      #if __has_builtin(__is_target_environment)
       #if __has_builtin(__is_target_variant_os)
        #if __has_builtin(__is_target_variant_environment)
         #if (... && ((__is_target_os(ios) && __is_target_environment(macabi)) || (__is_target_variant_os(ios) && __is_target_variant_environment(macabi))))
           #define __OSX_AVAILABLE_STARTING(_osx, _ios) ...
           #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) ...
           #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) ...

So if __has_builtin(__is_target_variant_os) or
__has_builtin(__is_target_variant_environment) are false, these defines are not
defined.

Most of the time, this doesn't matter. But open-source clang currently fails
to commpile a file containing only `#include <Security/cssmtype.h>` when
building for catalyst by adding a `-target arm64-apple-ios13.1-macabi` triple,
due to those __OSX_AVAILABLE macros not being set correctly.

If a potential future SDK version were to include cssmtype.h transitively
from a common header such as `<Foundation/Foundation.h>`, then it would become
close to impossible to build Catalyst binaries with open-source clang.

To fix this for normal catalyst builds, it's only necessary that
__has_builtin() evaluates to true for these two built-ins -- the implementation
of them doesn't matter. But as a courtesy, a correct (at least on the test
cases I tried) implementation is provided. (This should also help people who
try to build zippered code, where having the correct implementation does
matter.)

Differential Revision: https://reviews.llvm.org/D132754

21 months ago[SystemZ][z/OS] Account for renamed parameter name (libc++)
Muiez Ahmed [Tue, 30 Aug 2022 18:18:44 +0000 (14:18 -0400)]
[SystemZ][z/OS] Account for renamed parameter name (libc++)

The following patch (https://reviews.llvm.org/D129051) broke z/OS builds by renaming the parameter name. This patch accounts for that change.

Differential Revision: https://reviews.llvm.org/D132946

(cherry picked from commit e1e9961f7692cfb84c4b3bb213d515d4c80332a4)

21 months ago[Docs][OpenCL][SPIR-V] Release 15 notes for Clang.
Anastasia Stulova [Thu, 1 Sep 2022 09:04:50 +0000 (10:04 +0100)]
[Docs][OpenCL][SPIR-V] Release 15 notes for Clang.

21 months ago[Frontend] Restore Preprocessor::getPredefines()
Roy Jacobson [Wed, 31 Aug 2022 19:27:09 +0000 (22:27 +0300)]
[Frontend] Restore Preprocessor::getPredefines()

https://reviews.llvm.org/rG6bbf51f3ed59ae37f0fec729f25af002111c9e74 from May removed Preprocessor::getPredefines() from Clang's API, presumably as a cleanup because this method is unused in the LLVM codebase.

However, it was/is used by a small number of third-party tools and is pretty harmless, so this patch adds it back and documents why it's here.

The issue was raised in https://github.com/llvm/llvm-project/issues/57483, it would be nice to be able to land it into Clang 15 as it breaks those third-party tools and we can't easily add it back in bug fix releases.

Reviewed By: brad.king, thieta

Differential Revision: https://reviews.llvm.org/D133044

(cherry picked from commit bb9dedce5d01f5608acd784942481f386c710c0d)

21 months ago[docs] Add "Standard C++ Modules"
Chuanqi Xu [Wed, 31 Aug 2022 03:09:46 +0000 (11:09 +0800)]
[docs] Add "Standard C++ Modules"

We get some standard C++ module things done in clang15.x. But we lack a
user documentation for it. The implementation of standard C++ modules
share a big part of codes with clang modules. But they have very
different semantics and user interfaces, so I think it is necessary to
add a document for Standard C++ modules. Previously, there were also
some people ask the document for standard C++ Modules and I couldn't
offer that time.

Reviewed By: iains, Mordante, h-vetinari, ruoso, dblaikie, JohelEGP,
aaronmondal

Differential Revision: https://reviews.llvm.org/D131388

(cherry picked from commit b1d5af81249dc7e5697faf9ee33f86012ccd8668)

21 months ago[SLP]Fix PR57447: Assertion `!getTreeEntry(V) && "Scalar already in tree!"' failed.
Alexey Bataev [Tue, 30 Aug 2022 15:09:31 +0000 (08:09 -0700)]
[SLP]Fix PR57447: Assertion `!getTreeEntry(V) && "Scalar already in tree!"' failed.

The pointer operands for the ScatterVectorize node may contain
non-instruction values and they are not checked for "already being
vectorized". Need to check that such pointers are already vectorized and
gather them instead of trying to build vectorize node to avoid compiler
crash.

Differential Revision: https://reviews.llvm.org/D132949

(cherry picked from commit ec06df9459136ed538c07d32db16163999c350fe)

21 months ago[MCContext] Reverse order of DebugPrefixMap sort for generated assembly debug info
Dan McGregor [Thu, 25 Aug 2022 04:43:40 +0000 (21:43 -0700)]
[MCContext] Reverse order of DebugPrefixMap sort for generated assembly debug info

Match Clang's sorting, so that longer (more specific) prefix paths will match
before less specific paths.

Reviewed By: MaskRay, raj.khem, #debug-info

Differential Revision: https://reviews.llvm.org/D132390

(cherry picked from commit 3922ec46b84a877a9ac6ce4cfa765c4c847d097d)

21 months ago[LAA] Require AddRecs to be in the innermost loop for diff-checks.
Florian Hahn [Fri, 26 Aug 2022 19:39:52 +0000 (20:39 +0100)]
[LAA] Require AddRecs to be in the innermost loop for diff-checks.

The simpler diff-checks require pointers with add-recs from the same
innermost loop, but this property wasn't check completely. Add the
missing check to ensure both addrecs are in the innermost loop.

Fixes #57315.

(cherry picked from commit 9405af1c850139f6ddd6d35ff395756fe2aef31f)

21 months ago[LV] Add another test for incorrect runtime check generation.
Florian Hahn [Fri, 26 Aug 2022 16:28:41 +0000 (17:28 +0100)]
[LV]  Add another test for incorrect runtime check generation.

Add a variation of @nested_loop_outer_iv_addrec_invariant_in_inner with
the dependence sink and source swapped to extend test coverage.

Also simplifies the test by removing an unneeded reduction.

(cherry picked from commit e117137af0a37ac309d40db57ec7162ef3d22c29)

21 months ago[LV] Add test for incorrect runtime check generation #57315.
Florian Hahn [Fri, 26 Aug 2022 15:29:20 +0000 (16:29 +0100)]
[LV] Add test for incorrect runtime check generation #57315.

Test for PR57315 based on a test provided by @kpdev42.

(cherry picked from commit 6e56779e6bc168a3acd14f9bf2c4fd3fd9d86bd1)

21 months ago[LV] Convert runtime diff check test to use opaque pointers.
Florian Hahn [Fri, 26 Aug 2022 15:02:38 +0000 (16:02 +0100)]
[LV] Convert runtime diff check test to use opaque pointers.

Modernize the test to make it easier to extend with up-to-date IR.

(cherry picked from commit 3b135ef446d56e8542d55a1b716e9413f50da7aa)

21 months agoFix formatting in release notes
Aaron Puchert [Mon, 29 Aug 2022 17:43:33 +0000 (19:43 +0200)]
Fix formatting in release notes

Code needs double backticks, while single backticks produce italics.
Lists need to be fully indented and have blank lines around them.
Links are written "`text <url>`_".

We use links instead of `:manpage:`, because the latter is meant
more for man pages cross-referencing each other.

Reviewed By: aaron.ballman, thieta

Differential Revision: https://reviews.llvm.org/D132791

21 months ago[lld] Fix typo in 15.x release notes
Shoaib Meenai [Mon, 29 Aug 2022 11:33:53 +0000 (16:33 +0500)]
[lld] Fix typo in 15.x release notes

The flag is -femit-dwarf-unwind, not -femit-compact-unwind.

21 months ago[ReleaseNotes]: Add PowerPC release notes for LLVM 15
Amy Kwan [Sun, 28 Aug 2022 18:56:39 +0000 (13:56 -0500)]
[ReleaseNotes]: Add PowerPC release notes for LLVM 15

21 months ago[workflow] Run release tasks for me (tru) as well.
Tobias Hieta [Wed, 10 Aug 2022 08:02:12 +0000 (10:02 +0200)]
[workflow] Run release tasks for me (tru) as well.

Reviewed By: tstellar

Differential Revision: https://reviews.llvm.org/D131493

21 months ago[release] Use threaded compression with xz
Tobias Hieta [Wed, 10 Aug 2022 08:01:13 +0000 (10:01 +0200)]
[release] Use threaded compression with xz

Use xz -T0 to use your threads

Reviewed By: tstellar

Differential Revision: https://reviews.llvm.org/D131470

21 months ago[X86][FP16] Add the missing legal action for EXTRACT_SUBVECTOR
Phoebe Wang [Wed, 24 Aug 2022 15:24:41 +0000 (23:24 +0800)]
[X86][FP16] Add the missing legal action for EXTRACT_SUBVECTOR

Fixes #57340

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D132563

(cherry picked from commit 12b203ea7c65071f9fc02d420b28d58dcdc5ad4a)

21 months ago[LLD] [COFF] Fix export directives in object files from -includeoptional
Martin Storsjö [Mon, 22 Aug 2022 08:48:08 +0000 (11:48 +0300)]
[LLD] [COFF] Fix export directives in object files from -includeoptional

When an object file contains an export directive, we normally do some
amount of deferred processing of them at the end of the linking
process. The -includeoptional option was handled after this, and
any object files (defining new exports) weren't handled.

Move the handling of the -includeoptional into the same late loop
which does the fixups for e.g. export directives.

Ideally, this would also be done for object files that are pulled
in by the wrap options, and for mingw autoimports, but those changes
require more modifications, to make them safe for potentially
being executed multiple times.

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

Differential Revision: https://reviews.llvm.org/D132361

(cherry picked from commit af39e6f6fc905f3c067f022fb44136779d2f9c84)

21 months ago[NFC] Fix a misleading comment CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION
Tobias Hieta [Thu, 25 Aug 2022 07:55:52 +0000 (09:55 +0200)]
[NFC] Fix a misleading comment CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

21 months agoSONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION
H. Vetinari [Thu, 25 Aug 2022 06:35:46 +0000 (08:35 +0200)]
SONAME introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

This reverts commit bc39d7bdd4977a953b2e102f8f7eb479ad78984e.

rename CLANG_SONAME to LIBCLANG_SOVERSION

[clang][cmake] introduce option CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION

Differential Revision: https://reviews.llvm.org/D132486

21 months ago[DAG] MatchRotate - bail if we fail to match a shl/srl pair
Simon Pilgrim [Wed, 24 Aug 2022 02:04:59 +0000 (03:04 +0100)]
[DAG] MatchRotate - bail if we fail to match a shl/srl pair

extractShiftForRotate may fail to return canonicalized shifts due to constant folding or other simplification that can occur in getNode()

Fixes Issue #57283

(cherry picked from commit e624f8a3bb88075493dec521408993ea0ef7bde0)

21 months ago[runtimes] Use a response file for runtimes test suites
Petr Hosek [Thu, 18 Aug 2022 08:25:13 +0000 (08:25 +0000)]
[runtimes] Use a response file for runtimes test suites

We don't know which test suites are going to be included by runtimes
builds so we cannot include those before running the sub-build, but
that's not possible during the LLVM build configuration. We instead use
a response file that's populated by the runtimes build as a level of
indirection.

This addresses the issue described in:
https://discourse.llvm.org/t/cmake-regeneration-is-broken/62788

Differential Revision: https://reviews.llvm.org/D132438

(cherry picked from commit 992e10a3fce41255e4b11782f51d0f4b26dca14d)

21 months ago[lit] Support reading arguments from a file
Petr Hosek [Mon, 15 Aug 2022 17:59:39 +0000 (17:59 +0000)]
[lit] Support reading arguments from a file

This allows reading arguments from file using the response file syntax.
We would like to use this in the LLVM build to pass test suites from
subbuilds.

Differential Revision: https://reviews.llvm.org/D132437

(cherry picked from commit b52820edec6f3d95edef7859a56ef30878b08382)

21 months ago[runtimes] Handle interface targets in runtimes distribution components
Louis Dionne [Mon, 22 Aug 2022 16:00:40 +0000 (12:00 -0400)]
[runtimes] Handle interface targets in runtimes distribution components

As reported in [1], cxx-headers is not a valid distribution target
because it is an interface target in CMake. This breaks the most
basic MultiDistributionExample of the runtimes build.

This patch handles interface targets by getting rid of the assumption
that all distribution components have a target associated to them. It
is valid for a distribution component to only have a `install-FOO`
target.

In the case where only `cxx-headers` is provided as a distribution
component, `ninja toolchain-distribution` will not build anything
after this patch, since there is effectively nothing to build for
the `cxx-headers` target. However, running `ninja install-toolchain-distribution`
will build everything, as expected.

[1]: https://discord.com/channels/636084430946959380/636732894974312448/1010013287464828968

Differential Revision: https://reviews.llvm.org/D132387

(cherry picked from commit 5905e699342fd476d7eb9e35db5d84248a7e9156)

21 months ago[libc++] Add a missing assertion in std::span's constructor
Louis Dionne [Thu, 11 Aug 2022 14:28:43 +0000 (10:28 -0400)]
[libc++] Add a missing assertion in std::span's constructor

Also, add missing tests for assertions in span constructors. Now I
believe that all of std::span's API should be hardened, and all the
assertions should have a corresponding test.

Differential Revision: https://reviews.llvm.org/D131681

(cherry picked from commit 8c6319e30a357fb9b25db09b6f5fc9cf3e7c4aab)

21 months agoRevert "GCC ABI Compatibility: Preserve alignment of non-pod members in packed structs"
Tobias Hieta [Thu, 25 Aug 2022 07:00:25 +0000 (09:00 +0200)]
Revert "GCC ABI Compatibility: Preserve alignment of non-pod members in packed structs"

This reverts commit 277123376ce08c98b07c154bf83e4092a5d4d3c6.

See issue: https://github.com/llvm/llvm-project/issues/57346

21 months ago[GTest] Change detection of libpthread
Nemanja Ivanovic [Mon, 22 Aug 2022 15:34:19 +0000 (10:34 -0500)]
[GTest] Change detection of libpthread

We currently use CMake's find_library function to detect whether
libpthread exists on the system to determine if pthread should
be added on the link step. However, there are configurations in
which CMake's path checking fails to find the library even though
the toolchain has it.

One such case is with Clang 14.0.0 on PowerPC. Due to a recent
change, the build puts libc++ and related libraries in a
subdirectory that appears to depend on the default target triple.
CMake then uses that subdirectory to determine the architecture
and adds that name to its search paths. However, the triple for
the system GNU toolchain is different so CMake fails to find it.
Namely, Clang 14.0.0's default target triple and the subdirectory
name is powerpc64le-unknown-linux-gnu whereas the system GNU
toolchain has powerpc64le-linux-gnu. Clang's driver has no trouble
finding either the GNU includes/libraries or Clang's own. But
CMake seems to get this wrong.

The net result of this is that we can't do a shared libraries
build of ToT with Clang 14.0.0.

This patch proposes using HAVE_LIBPTHREAD which CMake seems to
determine by compiling a test file with -lpthread (or perhaps
-pthread, I can't really get CMake to tell me how it is figuring
this out). If that variable tells CMake that the build compiler
accepts the pthread option, it seems reasonable to depend on
that variable to determine if we should add it to the link step
when building the llvm_gtest library.

(cherry picked from commit 8537a99b2c1d08e9e586b3fb9e36728075ec4a03)

21 months ago[CUDA] Fix output name being replaced in device-only mode
Joseph Huber [Fri, 5 Aug 2022 18:43:23 +0000 (14:43 -0400)]
[CUDA] Fix output name being replaced in device-only mode

When performing device only compilation, there was an issue where
`cubin` outputs were being renamed to `cubin` despite the user's name.
This is required in a normal compilation flow as the Nvidia tools only
understand specific filenames instead of checking magic bytes for some
unknown reason. We do not want to perform this transformation when the
user is performing device only compilation.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D131278

(cherry picked from commit 3b52341116b794e53dec2fd07e568884e5a0b8bb)

21 months ago[clangd] Support for standard type hierarchy
Kadir Cetinkaya [Mon, 8 Aug 2022 09:22:31 +0000 (11:22 +0200)]
[clangd] Support for standard type hierarchy

This is mostly a mechanical change to adapt standard type hierarchy
support proposed in LSP 3.17 on top of clangd's existing extension support.

This does mainly two things:
- Incorporate symbolids for all the parents inside resolution parameters, so
  that they can be retrieved from index later on. This is a new code path, as
  extension always resolved them eagerly.
- Propogate parent information when resolving children, so that at least one
  branch of parents is always preserved. This is to address a shortcoming in the
  extension.

This doesn't drop support for the extension, but it's deprecated from now on and
will be deleted in upcoming releases. Currently we use the same struct
internally but don't serialize extra fields.

Fixes https://github.com/clangd/clangd/issues/826.

Differential Revision: https://reviews.llvm.org/D131385

(cherry picked from commit 83411bf06f34ae06731008eeabfc53553c1a1f86)

21 months ago[InstCombine] Refactor foldICmpMulConstant
Alexander Shaposhnikov [Sat, 30 Jul 2022 01:43:25 +0000 (01:43 +0000)]
[InstCombine] Refactor foldICmpMulConstant

This is a follow-up to 2ebfda2417
(replace "if" with "else if" since the cases nuw/nsw
were meant to be handled separately).

Test plan:
1/ ninja check-llvm check-clang check-lld
2/ Bootstrapped LLVM/Clang pass tests

(cherry picked from commit d982f1e0c69f3447c4520ae4c010520f62ed1174)

21 months ago[RISCV] Re-enable JIT support
Jonas Hahnfeld [Wed, 10 Aug 2022 20:31:05 +0000 (22:31 +0200)]
[RISCV] Re-enable JIT support

Commit 8922adf646 recently made JITTargetMachineBuilder honor the
hasJIT property of the target. LLVM supports just-in-time compilation
on RISC-V, so set the flag.

Differential Revision: https://reviews.llvm.org/D131617

(cherry picked from commit 940733d6a0a92245912361bf116514172a15f4f8)

21 months ago[NFC] Minor documentation fix for the release branch
Tobias Hieta [Mon, 22 Aug 2022 14:32:55 +0000 (16:32 +0200)]
[NFC] Minor documentation fix for the release branch

21 months ago[clang][docs] Release notes for C/C++ SVE Operators
David Truby [Mon, 22 Aug 2022 12:52:04 +0000 (13:52 +0100)]
[clang][docs] Release notes for C/C++ SVE Operators

21 months ago[Sparc] Don't use SunStyleELFSectionSwitchSyntax
Rainer Orth [Wed, 17 Aug 2022 10:59:29 +0000 (12:59 +0200)]
[Sparc] Don't use SunStyleELFSectionSwitchSyntax

As discussed in D85414 <https://reviews.llvm.org/D85414>, two tests
currently `FAIL` on Sparc since that backend uses the Sun assembler syntax
for the `.section` directive, controlled by
`SunStyleELFSectionSwitchSyntax`.

Instead of adapting the affected tests, this patch changes that default.
The internal assembler still accepts both forms as input, only the output
syntax is affected.

Current support for the Sun syntax is cursory at best: the built-in
assembler cannot even assemble some of the directives emitted by GCC, and
the set supported by the Solaris assembler is even larger: SPARC Assembly
Language Reference Manual, 3.4 Pseudo-Op Attributes
<https://docs.oracle.com/cd/E37838_01/html/E61063/gmabi.html#scrolltoc>.

A few Sparc test cases need to be adjusted. At the same time, the patch
fixes the failures from D85414 <https://reviews.llvm.org/D85414>.

Tested on `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D85415

(cherry picked from commit d9993484ee40abaab6d9e96872d3a29044202aea)

21 months ago[InstCombine] Correct strtol folding with nonnull endptr
Martin Sebor [Mon, 1 Aug 2022 22:44:53 +0000 (16:44 -0600)]
[InstCombine] Correct strtol folding with nonnull endptr

Reflect in the pointer's offset the length of the leading part
of the consumed string preceding the first converted digit.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D130912

(cherry picked from commit bcef4d238d113c61127575bf5dd0328f97bda9e9)

21 months ago[mlir][test] Require JIT support in JIT tests
Rainer Orth [Thu, 18 Aug 2022 09:26:07 +0000 (11:26 +0200)]
[mlir][test] Require JIT support in JIT tests

A number of mlir tests `FAIL` on Solaris/sparcv9 with `Target has no JIT
support`.  This patch fixes that by mimicing `clang/test/lit.cfg.py` which
implements a `host-supports-jit` keyword for this.  The gtest-based unit
tests don't support `REQUIRES:`, so lack of support needs to be hardcoded
there.

Tested on `amd64-pc-solaris2.11` (`check-mlir` results unchanged) and
`sparcv9-sun-solaris2.11` (only one unrelated failure left).

Differential Revision: https://reviews.llvm.org/D131151

(cherry picked from commit ca98e0dd6cf59907f07201c4282dcafeeea11a91)

21 months ago[clang][RISCV] Fix incorrect ABI lowering for inherited structs under hard-float...
Alex Bradbury [Fri, 19 Aug 2022 17:16:24 +0000 (18:16 +0100)]
[clang][RISCV] Fix incorrect ABI lowering for inherited structs under hard-float ABIs

The hard float ABIs have a rule that if a flattened struct contains
either a single fp value, or an int+fp, or fp+fp then it may be passed
in a pair of registers (if sufficient GPRs+FPRs are available).
detectFPCCEligibleStruct and the helper it calls,
detectFPCCEligibleStructHelper examine the type of the argument/return
value to determine if it complies with the requirements for this ABI
rule.

As reported in bug #57084, this logic produces incorrect results for C++
structs that inherit from other structs. This is because only the fields
of the struct were examined, but enumerating RD->fields misses any
fields in inherited C++ structs. This patch corrects that issue by
adding appropriate logic to enumerate any included base structs.

Differential Revision: https://reviews.llvm.org/D131677

(cherry picked from commit bc538320809fb52af12ec0366118c82201af4f40)

21 months ago[clang][RISCV][test] Add test that shows incorrect ABI lowering
Alex Bradbury [Thu, 11 Aug 2022 17:51:37 +0000 (18:51 +0100)]
[clang][RISCV][test] Add test that shows incorrect ABI lowering

As reported in <https://github.com/llvm/llvm-project/issues/57084>,
under hard float ABIs there are issues with lowering structs that
inherit from other structs.

See <https://reviews.llvm.org/D131677> for a fix.

(cherry picked from commit d17de5479c6234f9e37fb4deca9e537bf8d3932e)

21 months ago[SDAG] avoid generating libcall to function with same name
Sanjay Patel [Wed, 17 Aug 2022 18:56:33 +0000 (14:56 -0400)]
[SDAG] avoid generating libcall to function with same name

This is a potentially better alternative to D131452 that also
should avoid the infinite loop bug from:
issue #56403

This is again a minimal fix to reduce merging pain for the
release. But if this makes sense, then we might want to guard
all of the RTLIB generation (and other libcalls?) with a
similar name check.

Differential Revision: https://reviews.llvm.org/D131521

(cherry picked from commit 7f72a0f5bb3743428021df920d9a7c50f74f61ae)

21 months ago[AArch64] add test for recursive libcall lowering; NFC
Sanjay Patel [Wed, 17 Aug 2022 18:16:34 +0000 (14:16 -0400)]
[AArch64] add test for recursive libcall lowering; NFC

Issue #56403

(cherry picked from commit 8eddd1ec6066fe958313a2b1cc4907b5ee7dfbee)

21 months agoworkflows/llvm-project-tests: Workaround an issue with lldb builds on Windows
Tom Stellard [Sat, 20 Aug 2022 07:15:14 +0000 (00:15 -0700)]
workflows/llvm-project-tests: Workaround an issue with lldb builds on Windows

For some reason cmake started selecting a 32-bit version of python on
Windows instead of the 64-bit version when building windows.  Explicitly
setting the default python to 3.10 fixes this problem.

Reviewed By: thieta

Differential Revision: https://reviews.llvm.org/D132280

(cherry picked from commit 99020b3c73c1e22fa388be8fd0c44391d40b3a38)

21 months agoworkflows/version-check: Fix check for release candidates
Tom Stellard [Sat, 20 Aug 2022 04:51:00 +0000 (21:51 -0700)]
workflows/version-check: Fix check for release candidates

Reviewed By: thieta

Differential Revision: https://reviews.llvm.org/D131650

(cherry picked from commit 5b108dfc159a461c10bba1fd1f05308bf57dcd25)