463140 Commits

Author SHA1 Message Date
Caslyn Tonelli
0a168131b4 [scudo] Add 'inline' to static secondary.h function
This patches an error flaged by Fuchsia builds e.g.
https://ci.chromium.org/ui/p/turquoise/builders/global.try/core.x64-asan/b8779376650819379137/overview)

```
build failed:

[87176/332302](525) CXX user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o
FAILED: user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o
../../prebuilt/third_party/python3/linux-x64/bin/python3.8 -S ../../build/rbe/cxx_remote_wrapper.py --exec_strategy=remote_local_fallback --  ../../prebuilt/third_party/clang/linux-x64/bin/clang++ -MD -MF user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o.d -o user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o -D_LIBCPP...
In file included from ../../zircon/system/ulib/c/scudo/gwp_asan_info.cc:7:
In file included from ../../third_party/scudo/src/allocator_config.h:12:
In file included from ../../third_party/scudo/src/combined.h:22:
../../third_party/scudo/src/secondary.h:67:13: error: 'static' function 'unmap' declared in header file should be declared 'static inline' [-Werror,-Wunneeded-internal-declaration]
static void unmap(LargeBlock::Header *H) {
            ^
1 error generated.
```

Differential Revision: https://reviews.llvm.org/D152038
2023-06-02 23:47:27 +00:00
Nico Weber
ddc7625e3d [gn] port 6b3ae49d3243 2023-06-02 19:37:10 -04:00
Kazu Hirata
d6f994acb3 [InlineCost] Check for conflicting target attributes early
When we inline a callee into a caller, the compiler needs to make sure
that the caller supports a superset of instruction sets that the
callee is allowed to use.  Normally, we check for the compatibility of
target features via functionsHaveCompatibleAttributes, but that
happens after we decide to honor call site attribute
Attribute::AlwaysInline.  If the caller contains a call marked with
Attribute::AlwaysInline, which can happen with
__attribute__((flatten)) placed on the caller, the caller could end up
with code that cannot be lowered to assembly code.

This patch fixes the problem by checking the target feature
compatibility before we honor Attribute::AlwaysInline.

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

Differential Revision: https://reviews.llvm.org/D150396
2023-06-02 16:00:47 -07:00
Matt Arsenault
14c44dfbcf clang: Update tests after InstSimplify change
Update tests after 1536e299e63d7788f38117b0212ca50eb76d7a3b
2023-06-02 18:47:58 -04:00
Teresa Johnson
456468a08a [ThinLTO] Fix internalization decisions for weak/linkonce ODR
This fixes a runtime error that occurred due to incorrect
internalization of linkonce_odr functions where function pointer
equality was broken. This was hit because the prevailing copy was in a
native object, so the IR copies were not exported, and the existing code
internalized all of the IR copies. It could be fixed by guarding this
internalization on whether the defs are (local_)unnamed_addr, meaning
that their address is not significant (which we have in the summary
currently for linkonce_odr via the CanAutoHide flag). Or we can
propagate reference attributes as we do when determining whether a
global variable is read or write-only (reference edges are annotated
with whether they are read-only, write-only, or neither, and taking the
address of a function would result in a reference edge to the function
that is not read or write-only).

However, this exposed a larger issue with the internalization handling.
Looking at test cases, it appears the intent is to internalize when
there is a single definition of a linkonce/weak ODR symbol (that isn't
exported). This makes sense in the case of functions, because the
inliner can apply its last call to static heuristic when appropriate. In
the case where there is no prevailing copy in IR, internalizing all of
the IR copies of a linkonce_odr, even if legal, just increases binary
size. In that case it is better to fall back to the normal handling of
converting all non-prevailing copies to available_externally so that
they are eliminated after inlining.

In the case of variables, the existing code was attempting to
internalize the non-exported linkonce/weak ODR variables if they were
read or write-only. While this is legal (we propagate reference
attributes to determine this information), we don't even need to
internalize these here as there is later separate handling that
internalizes read and write-only variables when we process the module at
the start of the ThinLTO backend (processGlobalForThinLTO). Instead, we
can also internalize any non-exported variable when there is only one
(IR) definition, which is prevailing. And in that case, we don't need to
require that it is read or write-only, since we are guaranteed that all
uses must use that single definition.

In the new LTO API, if there are multiple defs of a linkonce or weak ODR
it will be marked exported, but it isn't clear that this will always be
true for the legacy LTO API. Therefore, require that there is only a
single (non-local) def, and that it is prevailing.

The test cases changes are both to reflect the change in the handling of
linkonce_odr IR copies where the prevailing def is not in IR (the main
correctness bug fix here), and to reflect the more aggressive
internalization of variables when there is only a single def, it is in
IR, and not exported.

I've also added some additional testing via the new LTO API.

Differential Revision: https://reviews.llvm.org/D151965
2023-06-02 15:34:14 -07:00
Florian Mayer
6a2e0cb418 Properly restore SP tag on exceptions
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D152036
2023-06-02 15:33:14 -07:00
Nick Desaulniers
f5371eb3d3 [Damangle] convert dlangDemangle to use std::string_view
I was doing this API conversion to use std::string_view top-down in
D149104, but this exposed issues in individual demanglers that needed to
get fixed first. There's no issue with the conversion for the D language
demangler, so convert it.

I have a more aggressive refactoring of the entire D language demangler
to use std::string_view more extensively, but the interface with
llvm::nonMicrosoftDemangle is the more interesting one.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D151003
2023-06-02 15:19:41 -07:00
Matt Arsenault
2ca21e8775 InstSimplify: Remove null parent checks
The feature to operate on incomplete IR was barely used
an poorly tested.
2023-06-02 18:14:28 -04:00
Matt Arsenault
1536e299e6 InstSimplify: Require instruction be parented
Unlike every other analysis and transform, simplifyInstruction
permitted operating on instructions which are not inserted
into a function. This created an edge case no other code needs
to really worry about, and limited transforms in cases that
can make use of the context function. Only the inliner and a handful
of other utilities were making use of this, so just fix up these
edge cases. Results in some IR ordering differences since
cloned blocks are inserted eagerly now. Plus some additional
simplifications trigger (e.g. some add 0s now folded out that
previously didn't).
2023-06-02 18:14:28 -04:00
Nick Desaulniers
12d967c95f [Damangle] convert rustDemangle to use std::string_view
I was doing this API conversion to use std::string_view top-down in
D149104, but this exposed issues in individual demanglers that needed to
get fixed first. There's no issue with the conversion for the Rust
demangler, so convert it first.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D149784
2023-06-02 15:08:14 -07:00
Nick Desaulniers
61e1c3d80d [Demangle] convert itaniumDemangle and nonMicrosoftDemangle to use std::string_view
D149104 converted llvm::demangle to use std::string_view. Enabling
"expensive checks" (via -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON) causes
lld/test/wasm/why-extract.s to fail. The reason for this is obscure:

Reason #10007 why std::string_view is dangerous:
Consider the following pattern:

  std::string_view s = ...;
  const char *c = s.data();
  std::strlen(c);

Is c a NUL-terminated C style string? It depends; but if it's not then
it's not safe to call std::strlen on the std::string_view::data().
std::string_view::length() should be used instead.

Fixing this fixes the one lone test that caught this.

microsoftDemangle, rustDemangle, and dlangDemangle should get this same
treatment, too. I will do that next.

Reviewed By: MaskRay, efriedma

Differential Revision: https://reviews.llvm.org/D149675
2023-06-02 14:53:49 -07:00
Kun Wu
fa98bdbd95 [mlir][sparse][gpu] make computeType mandatory
Differential Revision: https://reviews.llvm.org/D152018
2023-06-02 21:47:44 +00:00
Slava Zakharin
1c8b7c5299 [flang][hlfir] Added allocatable/pointer support in hlfir::convertToValue.
The code is used, for example, when passing arguments to IO or intrinsic
calls as value. The allocatable/pointer boxes must be dereferenced,
and trivial values have to be loaded. Character and derived values
have to stay boxed.
I am not sure what to do for the array cases, and I have not seen
any test triggering it, so I leave it as a TODO.

Reviewed By: tblah, clementval

Differential Revision: https://reviews.llvm.org/D151925
2023-06-02 14:45:34 -07:00
Vitaly Buka
99dc68387b [NFC][lsan] Use hash table to track root regions
This avoid O(N) in __lsan_unregister_root_region.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D151784
2023-06-02 14:38:01 -07:00
Vitaly Buka
0375a2dc7d [NFC][sanitizer] Avoid O(N^2) algorithm
Usually root_regions size is small so unlikey
this change will provide a noticable difference.

However it's easy to make sure that even with
large number of root_regions it works reasonably
fast.

Differential Revision: https://reviews.llvm.org/D151781
2023-06-02 14:32:03 -07:00
Vitaly Buka
c42e555dc2 [NFC][sanitizer] Delegate ArrayRef constructors 2023-06-02 14:32:03 -07:00
Artem Belevich
0f49116e26 [CUDA] Update Kepler(sm_3*) support info.
sm_30 and sm_32 were removed in cuda-11.0
sm_35 and sm_37 were removed in cuda-12.0

Differential Revision: https://reviews.llvm.org/D152027
2023-06-02 14:16:13 -07:00
Mehdi Amini
a6a7a1bae4 Fully qualify MLIR type in TableGen emitter
This is important for users that don't enclose their dialect within the MLIR
namespace.
2023-06-02 14:07:56 -07:00
Joseph Huber
48bb7bb868 [libc] Disable the string_to_float test on NVPTX
This test began failing after recent changes. Disable it for now.

Differential Revision: https://reviews.llvm.org/D152032
2023-06-02 15:56:39 -05:00
Vitaly Buka
6b3ae49d32 [sanitizer] Calculate Range sets intersection
Will be used to handle Root Regions in LSAN D151781.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D151779
2023-06-02 13:51:00 -07:00
Stanislav Mekhanoshin
a15eb89aba [TableGen] Allow bit fields in SearchableTables.
Differential Revision: https://reviews.llvm.org/D151756
2023-06-02 13:49:07 -07:00
Manna, Soumi
82659941cc [NFC][CLANG] Fix Static Code Analyzer Concerns with dereference null return value in applyObjCTypeArgs()
This patch uses castAs instead of getAs to resolve dereference issue with nullptr boundObjC when calling
canAssignObjCInterfaces() or isObjCIdType() in applyObjCTypeArgs() since getAs returns nullptr.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D151964
2023-06-02 13:40:45 -07:00
Manna, Soumi
02ce49afb9 [NFC][CLANG] Fix bug with dereference null return value in GetFunctionTypeForVTable()
This patch uses castAs instead of getAs which will assert if the type doesn't match in clang::CodeGen::CodeGenTypes::GetFunctionTypeForVTable(clang::GlobalDecl).

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D151957
2023-06-02 13:28:06 -07:00
Craig Topper
1f30087332 [RISCV] Remove optype parameter from most V instruction multiclasses. NFC
For the most part we already had the classes split and instantiated
in a way that the type is always the same for all instantiations of
the class.
2023-06-02 13:24:36 -07:00
Craig Topper
18ccca4da8 [UBSan] Consider zero input to __builtin_clz/ctz to be undefined independent of the target.
Previously we checked isCLZForZeroUndef and only added UBSan checks
if it returned true.

The builtin should be considered undefined for 0 regardless of
the target so that code using it is portable. The isCLZForZeroUndef
was only intended to disable optimizations in the middle end and
backend.

See https://discourse.llvm.org/t/should-ubsan-detect-0-input-to-builtin-clz-ctz-regardless-of-target/71060

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D152023
2023-06-02 13:01:05 -07:00
Sami Tolvanen
2831a271c8 [KCFI] Emit debugtrap to make indirect call checks recoverable
KCFI traps should always be recoverable, but as Intrinsic::trap
is marked noreturn, it's not possible to continue execution after
handling the trap as the compiler is free to assume we never
return. Switch to debugtrap instead to ensure we have the option
to resume execution after the trap.
2023-06-02 19:39:13 +00:00
Andrew Gozillon
70fc081f74 [Flang][OpenMP][Parser] Resolve Declare Target Directive Symbols
Currently symbols are not resolved for declare target
after they've been modified by prior passes. This can
lead to missing or incorrect symbols in subsequent
compiler phases when declare target is used with
more complex types e.g. common block.

This patch should allow these symbols to be
resolved appropriately.

Reviewers: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D151993
2023-06-02 14:28:48 -05:00
Joseph Huber
cfde5f2d89 [libc] Implement 'errno' on the GPU as a global integer internally
The C standard asserts that the `errno` value is an l-value thread local
integer. We cannot provide a generic thread local integer on the GPU
currently without some workarounds. Previously, we worked around this by
implementing the `errno` value as a special consumer class that made all
the writes disappear. However, this is problematic for internal tests.
Currently there are build failures because of this handling and it's
only likely to cause more problems the more we do this.

This patch instead makes the internal target used for testing export the
`errno` value as a simple global integer. This allows us to use and test
the `errno` interface correctly assuming we run with a single thread.
Because this is only used for the non-exported target we still do not
provide this feature in the version that users will use so we do not
need to worrk about it being incorrect in general.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D152015
2023-06-02 14:16:24 -05:00
Krzysztof Parzyszek
c6b2d25927 Constexprify all eligible functions in MCRegister and Register 2023-06-02 12:00:23 -07:00
Fangrui Song
583e02831c [test] Add -Wno-msvc-not-found to fix linker-opts.c on *-windows-msvc 2023-06-02 11:59:23 -07:00
Craig Topper
bbf96e68b1 [RISCV] Simplify vector instruction multiclasses. NFC
Remove 'string vw' template parameter from classes where it always
has a one value.

For the 2 classes that need it, make it required instead of having a
default.
2023-06-02 11:27:31 -07:00
Joseph Huber
860e439fb2 [Clang] Fix missing libraries for the include cleaner check
Summary:
Recently, the changes in https://reviews.llvm.org/D148793 introduced
some extra dependencies that caused link failured on my machine. This
patch adds the necessary libraries to resolve the link failures and
allow me to build again.
2023-06-02 12:43:55 -05:00
Simon Pilgrim
4fcbe5fbed Revert rG2f9a4d308d4517eee85e373bc09920f85f91fdcd "[GlobalISel][X86] Add G_CTLZ_ZERO_UNDEF legalization handling"
Unintentional commit - G_CTLZ_ZERO_UNDEF will have to be custom handled as BSR needs the bits flipping (and we don't have a pattern for that yet).
2023-06-02 18:43:11 +01:00
Haojian Wu
c5564a0075 [bazel] Add include-cleaner targets, fix clang-tidy build for c28506ba4b6961950849f8fdecd0cf7e503a14f9 2023-06-02 19:38:08 +02:00
Peiming Liu
ce6f8c5afe [mlir][sparse] fix various bug to support sparse pooling
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D151776
2023-06-02 17:34:47 +00:00
Simon Pilgrim
2f9a4d308d [GlobalISel][X86] Add G_CTLZ_ZERO_UNDEF legalization handling 2023-06-02 18:25:03 +01:00
Nico Weber
d72545b293 [gn build] Port c28506ba4b69 more 2023-06-02 13:24:33 -04:00
Nico Weber
eb354f016f [gn build] Port c28506ba4b69 2023-06-02 13:20:13 -04:00
Louis Dionne
3b12d34a70 [libc++] Remove min_max_macros test
This test is redundant since we already test the same thing in our
nasty_macros test.

Differential Revision: https://reviews.llvm.org/D152007
2023-06-02 10:05:43 -07:00
Louis Dionne
c0f4b12da4 [libc++] Transition several remaining generated tests to the new .gen format
In addition to reducing the amount of boilerplate we need to generate
whenever a new header is added, this also improves the existing tests
by running them in separate Lit tests (so they can be parallelized).
This also creates separate translation units for most header tests,
which is what we really should have done from the start since it
isolates each header we're testing.

Differential Revision: https://reviews.llvm.org/D151654
2023-06-02 10:02:15 -07:00
Stefan Pintilie
94cefe41e6 [PowerPC] Add DFP compare instructions.
This patch adds the DFP compare instructions:
dcmpu, dcmpuq, dcmpo, dcmpoq

Reviewed By: amyk

Differential Revision: https://reviews.llvm.org/D150899
2023-06-02 12:48:40 -04:00
Fangrui Song
5b77e752dc [Driver] Move -nostdinc like options into IncludePath_Group
With only a link action, we claim all CompileOnly_Group options (including -f*,
-m*, -i*, etc). It makes sense to claim -nostdinc family options as well.
We can achieve this by placing these options into IncludePath_Group, a derivative of
CompileOnly_Group.

Reviewed By: theuni

Differential Revision: https://reviews.llvm.org/D151944
2023-06-02 09:33:08 -07:00
Chia-hung Duan
2f08a08f61 [scudo] Support importing custom configuration
To define custom allocation, you only need to put the configuration in
custom_scudo_config.h and define two required aliases, then you will be
switched to the customized config and the tests will also run with your
configuration.

In this CL, we also have a minor refactor the structure of
configuration. Now the essential fields are put under the associated
hierarchy and which will make the defining new configuration easier.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D150481
2023-06-02 16:28:00 +00:00
Kazu Hirata
8b5dbc37a8 [CodeGen] Use llvm::LLVMContext::MD_invariant_load (NFC) 2023-06-02 09:25:00 -07:00
Joel E. Denny
19841e4dca [OpenMP] Fix transformed loop's var privacy
Without this patch, the following example crashes Clang:

```
 #pragma omp target map(i)
 #pragma omp tile sizes(2)
 for (i = 0; i < N; ++i)
   ;
```

This patch fixes the crash by changing `Sema::isOpenMPPrivateDecl` not
to identify `i` as private just because it's the loop variable of a
`tile` construct.

While OpenMP TR11 and earlier do specify privacy for loop variables of
loops *generated* from a `tile` construct, I haven't found text
stating that the original loop variable must be private in the above
example, so this patch leaves it shared.  Even so, it is a bit
unexpected that value of `i` after the loop is `N - 1` instead of `N`.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D151356
2023-06-02 12:18:13 -04:00
Andrzej Warzynski
726835cd51 [mlir] Update how scalable indices are printed
This patch makes sure that scalable indices (that would normally
represent scalable tile or vector sizes) are printed correctly, i.e.
with additional square brackets:
```
%1, %loop = transform.structured.tile %0 [2, 8, [4]]
```

This change complements https://reviews.llvm.org/D150944 and is a part
of a larger effort to enable scalable vectorisation in Linalg. See this
RFC for more context:
  * https://discourse.llvm.org/t/rfc-scalable-vectorisation-in-linalg/

Differential Revision: https://reviews.llvm.org/D151978
2023-06-02 16:47:56 +01:00
Viktoriia Bakalova
5c2072e74b [clang-tidy] Fix docs. 2023-06-02 15:31:55 +00:00
Simon Pilgrim
4c5355db81 [GlobalIsel][X86] Merge LZCNT 32-bit and 64-bit test coverage 2023-06-02 16:26:35 +01:00
Viktoriia Bakalova
c28506ba4b [clang-tidy] Implement an include-cleaner check.
Differential Revision: https://reviews.llvm.org/D148793
2023-06-02 15:21:20 +00:00
Tue Ly
f9753ef189 [libc][Obvious] Fix a typo in setting FMA control option for RISCV64. 2023-06-02 11:15:29 -04:00