mydeveloperday [Fri, 24 Mar 2023 09:27:23 +0000 (09:27 +0000)]
[clang-format] NFC Format.h and ClangFormatStyleOptions.rst are out of date
Regenerate the style documentation, requires some minor sphinx changes to avoid warnings
Reviewed By: klimek
Differential Revision: https://reviews.llvm.org/D146704
Stefan Gränitz [Thu, 23 Mar 2023 10:10:39 +0000 (11:10 +0100)]
Reland "[JITLink] Initial AArch32 backend"
This first version lays the foundations for AArch32 support in JITLink. ELFLinkGraphBuilder_aarch32 processes REL-type relocations and populates LinkGraphs from ELF object files for both big- and little-endian systems. The ArmCfg member controls subarchitecture-specific details throughout the linking process (i.e. it's passed to ELFJITLinker_aarch32).
Relocation types follow the ABI documentation's division into classes: Data (endian-sensitive), Arm (32-bit little-endian) and Thumb (2x 16-bit little-endian, "Thumb32" in the docs). The implementation of instruction encoding/decoding for relocation resolution is implemented symmetrically and is testable in isolation (see AArch32 category in JITLinkTests).
Callable Thumb functions are marked with a ThumbSymbol target-flag and stored in the LinkGraph with their real addresses. The thumb-bit is added back in when the owning JITDylib requests the address for such a symbol.
The StubsManager can generate (absolute) Thumb-state stubs for branch range extensions on v7+ targets. Proper GOT/PLT handling is not yet implemented.
This patch is based on the backend implementation in ez-clang and has just enough functionality to model the infrastructure and link a Thumb function `main()` that calls `printf()` to dump "Hello Arm!" on Armv7a. It was tested on Raspberry Pi with 32-bit Raspbian OS.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D144083
Luke Lau [Thu, 23 Mar 2023 10:59:59 +0000 (10:59 +0000)]
[RISCV] Add test for shuffles that could be done as vmerges
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D146710
Andrzej Warzynski [Thu, 23 Mar 2023 17:39:48 +0000 (17:39 +0000)]
[mlir][arith] Extend the `floordivsi` converter
This patch extends the `createConst` method so that it can generate
constant vectors (it can already generate scalars). This change is
required to be able to apply the converter for `arith.floordivsi`
(i.e. `FloorDivSIOpConverter`) to vectors.
While `arith.floordivsi` is my main motivation for this change, this
patch should also allow other Arith ops to be converted in vector cases.
In my example, the Linalg vectorizer updates `arith.floordivsi` to
operate on vectors and hence the need for this change.
Differential Revision: https://reviews.llvm.org/D146741
luxufan [Fri, 24 Mar 2023 08:35:56 +0000 (16:35 +0800)]
[NFC] Regenerate test of InstCombine/load-combine-metadata-dominance.ll
Max Kazantsev [Fri, 24 Mar 2023 08:42:23 +0000 (15:42 +0700)]
[Test] Regenerate checks in test file
Martin Storsjö [Wed, 22 Mar 2023 22:44:18 +0000 (00:44 +0200)]
[CMake] Respect variables for specifying host tools even without LLVM_USE_HOST_TOOLS set
When LLVM_NATIVE_TOOL_DIR was introduced in
d3da9067d143f3d4ce59b6d9ab4606a8ef1dc937 / D131052, it consisted
of refactoring a couple cases of manual logic for tools in
clang-tools-extra/clang-tidy, clang-tools-extra/pseudo/include
and mlir/tools/mlir-linalg-ods-gen. The former two had the same
consistent behaviour while the latter was slightly different, so
the refactoring would end up slightly adjusting one or the other.
The difference was that the clang-tools-extra tools respected the
external variable for setting the tool name, regardless of the
LLVM_USE_HOST_TOOLS variable, while mlir-linalg-ods-gen tool
only checked its external variable if LLVM_USE_HOST_TOOLS was set.
LLVM_USE_HOST_TOOLS is supposed to be enabled automatically whenever
cross compiling, so this shouldn't have been an issue.
In https://github.com/llvm/llvm-project/issues/60784, it seems like
some users do cross compile LLVM, without CMake knowing about it
(without CMAKE_CROSSCOMPILING being set). In these cases, their
build broke, as the variables for pointing to external host tools
no longer were being respected.
The fact that CMAKE_CROSSCOMPILING wasn't set stems from a
non-obvious behaviour of CMake; CMAKE_CROSSCOMPILING isn't supposed
to be set by the user (and if it was, it gets overridden), but one
has to set CMAKE_SYSTEM_NAME to indicate that one is cross compiling,
even if the target OS is the same as the current host.
Skip the checks for LLVM_USE_HOST_TOOLS and always respect the
variables for pointing to external tools (both the old tool specific
variables, and the new LLVM_NATIVE_TOOL_DIR), if they're set. This
makes the logic within setup_host_tool more exactly match the
logic for the clang-tools-extra tools from before the refactoring
in
d3da9067d143f3d4ce59b6d9ab4606a8ef1dc937. This makes the behaviour
consistent with that of the tablegen executables, which also respect
the externally set variables regardless of LLVM_USE_HOST_TOOLS.
This fixes
https://github.com/llvm/llvm-project/issues/60784.
Differential Revision: https://reviews.llvm.org/D146666
Johannes de Fine Licht [Fri, 24 Mar 2023 08:27:27 +0000 (09:27 +0100)]
[MLIR][LLVM] Add debug output to the LLVM inliner.
This revealed a test case that wasn't hitting the intended branch
because the inlinees had no function definition.
Depends on D146628
Reviewed By: gysit
Differential Revision: https://reviews.llvm.org/D146633
Martin Storsjö [Fri, 24 Mar 2023 08:23:50 +0000 (10:23 +0200)]
[LLD] [test] Add a missing REQUIRES: x86 in a new test
This test somewhat unconventionally assembles both aarch64 and
x86 object files.
This fixes test failures in build configurations with the aarch64
target enabled but x86 target disabled.
luxufan [Fri, 24 Mar 2023 08:26:32 +0000 (16:26 +0800)]
[NFC] Regenerate test NewGVN/metadata-nonnull.ll
Dmitry Chernenkov [Thu, 23 Mar 2023 16:20:42 +0000 (16:20 +0000)]
Revert "Recommit [Modules] Remove unnecessary check when generating name lookup table in ASTWriter"
This reverts commit
25557aa38a0dab76f5b7a4518942f69d879693c0.
Tobias Gysi [Fri, 24 Mar 2023 06:57:24 +0000 (07:57 +0100)]
[mlir][llvm] Switch remaining LLVM dialect tests to opaque pointers.
The revision switches the remaining LLVM dialect tests to use opaque
pointers. Selected tests are copied to a postfixed test file for the
time being.
A number of tests disappear once we fully switch to opaque pointers.
In particular, all tests that check verify a pointer element type
matches another type as well as tests of recursive types.
Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179
Reviewed By: Dinistro, zero9178
Differential Revision: https://reviews.llvm.org/D146726
Carlos Galvez [Thu, 23 Mar 2023 12:16:40 +0000 (12:16 +0000)]
[clang-tidy][NFC] Improve naming convention in google-readability-avoid-underscore-in-googletest-name
According to the Google docs, the convention is
TEST(TestSuiteName, TestName). Apply that convention to the
source code, test and documentation of the check.
Differential Revision: https://reviews.llvm.org/D146713
Michael Platings [Tue, 14 Mar 2023 19:40:58 +0000 (19:40 +0000)]
[Driver] Change multilib selection algorithm
The new algorithm is:
1. Find all multilibs with flags that are a subset of the requested
flags.
2. If more than one multilib matches, choose the last.
In addition a new selection mechanism is permitted via an overload of
MultilibSet::select() for which multiple multilibs are returned.
This allows layering multilibs on top of each other.
Since multilibs are now ordered within a list, they no longer need a
Priority field.
The new algorithm is different to the old algorithm, but in practise
the old algorithm was always used in such a way that the effect is the
same.
The old algorithm was to find the set intersection of the requested
flags (with the first character of each removed) with each multilib's
flags (ditto), and for that intersection check whether the first
character matched. However, ignoring the first characters, the
requested flags were always a superset of all the multilibs flags.
Therefore the new algorithm can be used as a drop-in replacement.
The exception is Fuchsia, which needs adjusting slightly to set both
fexceptions and fno-exceptions flags.
Differential Revision: https://reviews.llvm.org/D142905
Kazu Hirata [Fri, 24 Mar 2023 06:48:17 +0000 (23:48 -0700)]
[X86] Precommit a test
This patch precommits a test for:
https://github.com/llvm/llvm-project/issues/61365
Dave Lee [Fri, 24 Mar 2023 05:14:10 +0000 (22:14 -0700)]
[lldb] Fix type of --apply-fixits (NFC)
Xiang1 Zhang [Tue, 21 Mar 2023 09:33:54 +0000 (17:33 +0800)]
[BugFix] Fix VSELECT ISel fail
Reviewed By: Luo yuanke
Differential Revision: https://reviews.llvm.org/D146683
Kazu Hirata [Fri, 24 Mar 2023 03:20:20 +0000 (20:20 -0700)]
[AArch64] Add tests for umax(x, 1u)
This patch adds tests for umax(x, 1u).
This patch fixes:
https://github.com/llvm/llvm-project/issues/60233
It turns out that commit
86b4d8645fc1b86693fef564cef68f24599c930f on
Feb 8, 2023 already performs the instcombine transformation proposed
in the issue, so the issue requires no change on the codegen side.
Xiaodong Liu [Fri, 24 Mar 2023 03:08:21 +0000 (11:08 +0800)]
[LoongArch] Enable LoopDataPrefetch pass
Keep `EnableLoopDataPrefetch` option off for now because
we need a few more TTIs and ISels.
This patch is inspired by http://reviews.llvm.org/D17943.
Reviewed By: SixWeining
Differential Revision: https://reviews.llvm.org/D146600
Jun Zhang [Fri, 24 Mar 2023 02:28:02 +0000 (10:28 +0800)]
[InstCombine] Try to recognize bswap pattern when calling funnel shifts
Alive2: https://alive2.llvm.org/ce/z/dxxD7B
Fixes: https://github.com/llvm/llvm-project/issues/60690
Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D146637
Jun Zhang [Fri, 24 Mar 2023 02:27:02 +0000 (10:27 +0800)]
Precommit tests for #60690
Differential Revision: https://reviews.llvm.org/D146636
Signed-off-by: Jun Zhang <jun@junz.org>
XinWang10 [Fri, 24 Mar 2023 02:32:18 +0000 (22:32 -0400)]
[NFC][X86]remove trailing space in X86InstrArithmetic.td
In this file, most of the line don't have trailing spaces,
but some of them have. To keep consistent, remove the trailing
spaces.
Reviewed By: skan
Differential Revision: https://reviews.llvm.org/D146697
Kazu Hirata [Fri, 24 Mar 2023 02:26:43 +0000 (19:26 -0700)]
[InstCombine] Generate better code for std::bit_ceil
Without this patch, std::bit_ceil<uint32_t> is compiled as:
%dec = add i32 %x, -1
%lz = tail call i32 @llvm.ctlz.i32(i32 %dec, i1 false)
%sub = sub i32 32, %lz
%res = shl i32 1, %sub
%ugt = icmp ugt i32 %x, 1
%sel = select i1 %ugt, i32 %res, i32 1
With this patch, we generate:
%dec = add i32 %x, -1
%ctlz = tail call i32 @llvm.ctlz.i32(i32 %dec, i1 false)
%sub = sub nsw i32 0, %ctlz
%and = and i32 %1, 31
%sel = shl nuw i32 1, %and
ret i32 %sel
https://alive2.llvm.org/ce/z/pwezvF
This patch recognizes the specific pattern from std::bit_ceil in
libc++ and libstdc++ and drops the conditional move. In addition to
the LLVM IR generated for std::bit_ceil(X), this patch recognizes
variants like:
std::bit_ceil(X - 1)
std::bit_ceil(X + 1)
std::bit_ceil(X + 2)
std::bit_ceil(-X)
std::bit_ceil(~X)
This patch fixes:
https://github.com/llvm/llvm-project/issues/60802
Differential Revision: https://reviews.llvm.org/D145299
Kazu Hirata [Fri, 24 Mar 2023 02:26:42 +0000 (19:26 -0700)]
[SelectionDAG] Use isOneConstant (NFC)
Rahul Joshi [Thu, 23 Mar 2023 23:06:37 +0000 (16:06 -0700)]
[NFC] Fix Windows builds that use MSVC 14.x
Differential Revision: https://reviews.llvm.org/D146769
Arthur Eubanks [Fri, 24 Mar 2023 02:08:53 +0000 (19:08 -0700)]
[builtins][test] Fix divmodti4_test.c on Windows
By making the 64 bit integer literals unsigned. Otherwise some of them
are unexpectedly sign extended (and the compiler rightly diagnosed this
with warnings)
Initially added in D80506.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D146667
LiaoChunyu [Fri, 24 Mar 2023 01:04:59 +0000 (09:04 +0800)]
[LegalizeTypes][RISCV] Add a special case for (add X, -1) to ExpandIntRes_ADDSUB
On targets without ADDCARRY or ADDE, we need to emit a separate
SETCC to determine carry from the low half to the high half.
The high half is calculated by a series of ADDs.
When RHSLo and RHSHi are -1, without this patch, we get:
Hi = (add (add LHSHi,(setult Lo, LHSLo), -1)
Where as with the patch we get:
Hi = (sub LHSHi, (seteq LHSLo, 0))
Only RHSLo is -1 we can instead do (setne Lo, 0).
Similar to gcc: https://godbolt.org/z/M83f6rz39
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D146635
Quinn Dawkins [Thu, 23 Feb 2023 16:30:20 +0000 (11:30 -0500)]
[mlir][linalg] Refactor convolution to img2col conversion to use gather semantics
Following up on the comments in https://reviews.llvm.org/D144108 this
patch refactors the im2col conversion patterns for `linalg.conv_2d_nhwc_hwcf`
and `linalg.conv_2d_nchw_fchw` convolutions to use gather semantics for the im2col
packing `linalg.generic`.
Follow up work can include a similar pattern for depthwise convolutions
and a generalization of the patterns here to work with any `LinalgOp` as
well.
Differential Revision: https://reviews.llvm.org/D144678
Bruno Cardoso Lopes [Thu, 23 Mar 2023 21:34:12 +0000 (14:34 -0700)]
[Builtins] Add __builtin_assume_separate_storage
Plumbing from the language level to the assume intrinsics with
separate_storage operand bundles.
Patch by David Goldblatt (davidtgoldblatt)
Differential Revision: https://reviews.llvm.org/D136515
Fangrui Song [Thu, 23 Mar 2023 23:00:16 +0000 (16:00 -0700)]
[Driver] Remove remnant mips64el-linux-android code after D146565
Fangrui Song [Thu, 23 Mar 2023 22:58:42 +0000 (15:58 -0700)]
Android.rules: remove mips* rules
They have been obsoleted for a long time and D146565 recently removed
Clang support.
Fangrui Song [Thu, 23 Mar 2023 22:49:38 +0000 (15:49 -0700)]
[Driver][test] Remove remnant mips*-linux-android tests after
805f51f9fedf90d2aa0ad46c61cb4c9c0c5bcfe9
Heejin Ahn [Thu, 23 Mar 2023 02:14:00 +0000 (19:14 -0700)]
[WebAssembly] Tidy up DebugValueManager (NFC)
Misc. cleanups for `WebAssemblyDebugValueManager`.
- Use `Register` for registers
- Simpler for loop iteration
- Rename a variable
- Reorder methods
- Reduce `SmallVector` size for `DBG_VALUE`s to 1; one def usually have
a single `DBG_VALUE` attached to it in most cases
- Add a few more lines of comments
Reviewed By: dschuff
Differential Revision: https://reviews.llvm.org/D146743
NagaChaitanya Vellanki [Thu, 23 Mar 2023 21:38:37 +0000 (14:38 -0700)]
[clang][ExtractAPI]Fix Declaration fragments for instancetype in the type position degrade to id
Fixes https://github.com/llvm/llvm-project/issues/61481
Reviewed By: dang
Differential Revision: https://reviews.llvm.org/D146671
Cyndy Ishida [Thu, 23 Mar 2023 21:51:37 +0000 (14:51 -0700)]
[llvm][TextAPI] Handle implicitly upgraded deployment versions
Sometimes the clang driver will receive a target triple where the
deployment version is too low to support the platform + arch. In those
cases, the compiler upgrades the final minOS which is what gets recorded
ultimately by the linker in LC_BUILD_VERSION. TextAPI should also reuse
this logic for capturing minOS in recorded TBDv5 files.
Reviewed By: ributzka
Differential Revision: https://reviews.llvm.org/D145690
Lang Hames [Thu, 23 Mar 2023 21:43:23 +0000 (14:43 -0700)]
[JITLink] Add a jitlink::Section::empty operation.
Chia-hung Duan [Thu, 23 Mar 2023 21:49:02 +0000 (21:49 +0000)]
Revert "[scudo] Add a Timer class to assist performance measurement"
This reverts commit
e0361396c2281a108a36d186161ace1843925431.
Leonard Chan [Thu, 23 Mar 2023 21:44:59 +0000 (21:44 +0000)]
[llvm] Handle duplicate call bases when applying branch funneling
It's possible to segfault in `DevirtModule::applyICallBranchFunnel` when
attempting to call `getCaller` on a call base that was erased in a prior
iteration. This can occur when attempting to find devirtualizable calls
via `findDevirtualizableCallsForTypeTest` if the vtable passed to
llvm.type.test is a global and not a local. The function works by taking
the first argument of the llvm.type.test call (which is a vtable),
iterating through all uses of it, and adding any relevant all uses that
are calls associated with that intrinsic call to a vector. For most
cases where the vtable is actually a *local*, this wouldn't be an issue.
Take for example:
```
define i32 @fn(ptr %obj) #0 {
%vtable = load ptr, ptr %obj
%p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid2")
call void @llvm.assume(i1 %p)
%fptr = load ptr, ptr %vtable
%result = call i32 %fptr(ptr %obj, i32 1)
ret i32 %result
}
```
`findDevirtualizableCallsForTypeTest` will check the call base ` %result
= call i32 %fptr(ptr %obj, i32 1)`, find that it is associated with a
virtualizable call from `%vtable`, find all loads for `%vtable`, and add
any instances those load results are called into a vector. Now consider
the case where instead `%vtable` was the global itself rather than a
local:
```
define i32 @fn(ptr %obj) #0 {
%p = call i1 @llvm.type.test(ptr @vtable, metadata !"typeid2")
call void @llvm.assume(i1 %p)
%fptr = load ptr, ptr @vtable
%result = call i32 %fptr(ptr %obj, i32 1)
ret i32 %result
}
```
`findDevirtualizableCallsForTypeTest` should work normally and add one
unique call instance to a vector. However, if there are multiple
instances where this same global is used for llvm.type.test, like with:
```
define i32 @fn(ptr %obj) #0 {
%p = call i1 @llvm.type.test(ptr @vtable, metadata !"typeid2")
call void @llvm.assume(i1 %p)
%fptr = load ptr, ptr @vtable
%result = call i32 %fptr(ptr %obj, i32 1)
ret i32 %result
}
define i32 @fn2(ptr %obj) #0 {
%p = call i1 @llvm.type.test(ptr @vtable, metadata !"typeid2")
call void @llvm.assume(i1 %p)
%fptr = load ptr, ptr @vtable
%result = call i32 %fptr(ptr %obj, i32 1)
ret i32 %result
}
```
Then each call base `%result = call i32 %fptr(ptr %obj, i32 1)` will be
added to the vector twice. This is because for either call base `%result
= call i32 %fptr(ptr %obj, i32 1) `, we determine it is associated with
a virtualizable call from `@vtable`, and then we iterate through all the
uses of `@vtable`, which is used across multiple functions. So when
scanning the first `%result = call i32 %fptr(ptr %obj, i32 1)`, then
both call bases will be added to the vector, but when scanning the
second one, both call bases are added again, resulting in duplicate call
bases in the CSInfo.CallSites vector.
Note this is actually accounted for in every other instance WPD iterates
over CallSites. What everything else does is actually add the call base
to the `OptimizedCalls` set and just check if it's already in the set.
We can't reuse that particular set since it serves a different purpose
marking which calls where devirtualized which `applyICallBranchFunnel`
explicitly says it doesn't. For this fix, we can just account for
duplicates with a map and do the actual replacements afterwards by
iterating over the map.
Differential Revision: https://reviews.llvm.org/D146267
Joseph Huber [Thu, 23 Mar 2023 21:41:25 +0000 (16:41 -0500)]
[OpenMP] Fix test after updating NVPTX atomic inlines
Summary:
The previous patch fixed how we handle emitting atomics for targeting
NVPTX directly. This is the only other file that really does that and
has atomics and I forgot to update it.
Joseph Huber [Thu, 23 Mar 2023 21:30:31 +0000 (16:30 -0500)]
[libc][NFC] Fix misspelled variable name in cmake message
Joseph Huber [Thu, 23 Mar 2023 19:15:01 +0000 (14:15 -0500)]
[NVPTX] Set the atomic inling threshold when targeting NVPTX directly
Since Clang 16.0.0 users can target the `NVPTX` architecture directly
via `--target=nvptx64-nvidia-cuda`. However, this does not set the
atomic inlining size correctly. This leads to spurious warnings and
emission of runtime atomics that are never implemented. This patch
ensures that we set this to the appropriate pointer width. This will
always be 64 in the future as `nvptx64` will only be supported moving
forward.
Fixes: https://github.com/llvm/llvm-project/issues/61410
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D146750
Sam Clegg [Wed, 7 Dec 2022 00:49:13 +0000 (16:49 -0800)]
[lld][WebAssembly] Initial support for stub libraries
See the docs in lld/docs/WebAssembly.rst for more on this.
This feature unlocks a lot of simplification in the emscripten toolchain
since we can represent the JS libraries to wasm-ld as stub libraries.
See https://github.com/emscripten-core/emscripten/issues/18875
Differential Revision: https://reviews.llvm.org/D145308
NagaChaitanya Vellanki [Thu, 23 Mar 2023 21:16:25 +0000 (14:16 -0700)]
Fix highlighting issue with _complex and initialization list with more than 2 items
Fixes https://github.com/llvm/llvm-project/issues/61518
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D146503
AdityaK [Thu, 23 Mar 2023 20:54:58 +0000 (13:54 -0700)]
Remove Android-mips related tests
Split from: https://reviews.llvm.org/D146565, already reviewed there.
Arthur Eubanks [Thu, 23 Mar 2023 18:28:49 +0000 (11:28 -0700)]
[lldb][NFC] makeArrayRef -> ArrayRef
makeArrayRef is deprecated.
Alexander Yermolovich [Thu, 23 Mar 2023 20:20:38 +0000 (13:20 -0700)]
[LLDB] Fix for D139955 Summary:
Fixing a small typo.
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D146659
Gulfem Savrun Yeniceri [Thu, 23 Mar 2023 20:54:21 +0000 (20:54 +0000)]
Revert "[JITLink] Initial AArch32 backend"
This reverts commit
c2de8ff92753acdb1ace7a27cc11cb09f28eb8fa.
It caused a segmentation fault while running ExecutionEngine
tests on Mac.
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-mac-x64/
b8785839382041226465/overview
AdityaK [Tue, 21 Mar 2023 22:42:25 +0000 (15:42 -0700)]
Remove mips target triple for Android
Reviewers: enh, phosek, srhines, MaskRay
thanks to @enh for pointing these out.
Differential Revision: https://reviews.llvm.org/D146565
Colin Cross [Thu, 23 Mar 2023 20:22:32 +0000 (13:22 -0700)]
[PATCH] Enable targeting riscv64-linux-android
Reviewers: ccross, asb, phosek, enh, srhines, hiraditya
Putting: https://android.googlesource.com/toolchain/llvm_android/+/refs/heads/master/patches/Enable-targeting-riscv64-linux-android.patch for review.
Differential Revision: https://reviews.llvm.org/D146560
Kirill Stoimenov [Thu, 23 Mar 2023 20:25:47 +0000 (20:25 +0000)]
[HWASAN] Fix decorate_proc_maps to work with HWASAN
Alex Langford [Wed, 22 Mar 2023 23:17:49 +0000 (16:17 -0700)]
[lldb-server] Use Platform plugin corresponding to the host
In
ee232506b870ce5282cc4da5ca493d41d361feb3 I moved UnixSignal
initialization from lldbTarget to the various platform plugins. This
inadvertently broke lldb-server because lldb-server doesn't use
Platform plugins. lldb-server still needs to be able to create a
UnixSignals object for the host platform so we can add the relevant
platform plugin to lldb-server to make sure we always have a
HostPlatform.
Differential Revision: https://reviews.llvm.org/D146668
Nick Desaulniers [Thu, 23 Mar 2023 19:38:57 +0000 (12:38 -0700)]
[StackProtector] attribute __stack_chk_fail as NoReturn
When GCC added support for stack smashing protections, it was defined
that:
> This hook returns a CALL_EXPR that alerts the runtime that the stack
> protect guard variable has been modified. This expression should
> involve a call to a noreturn function.
> The default version of this hook invokes a function called
> ‘__stack_chk_fail’, taking no arguments.
Do so as well for __stack_smash_handler for OpenBSD.
Every libc implementation I could find has __stack_chk_fail marked
noreturn, or the implementation calls abort, exit, or panic (which
themselves are noreturn).
Glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=debug/stack_chk_fail.c
Musl: https://git.musl-libc.org/cgit/musl/tree/src/env/__stack_chk_fail.c
Bionic: https://android.googlesource.com/platform/bionic/+/refs/heads/master/libc/bionic/__stack_chk_fail.cpp
FreeBSD: https://cgit.freebsd.org/src/tree/lib/libc/secure/stack_protector.c
OpenBSD: https://github.com/openbsd/src/blob/master/lib/libc/sys/stack_protector.c
NetBSD: https://github.com/NetBSD/src/blob/trunk/lib/libc/misc/stack_protector.c
Linux Kernel: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/panic.c
Apple: https://opensource.apple.com/source/Libc/Libc-1439.40.11/sys/OpenBSD/stack_protector.c.auto.html
Link: https://gcc.gnu.org/onlinedocs/gccint/Stack-Smashing-Protection.html#Stack-Smashing-Protection
This will later help us diagnose functions that fall through to other
functions vs end in calls to functions that are noreturn.
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D146339
Chia-hung Duan [Thu, 23 Mar 2023 19:38:48 +0000 (19:38 +0000)]
[scudo] Add a Timer class to assist performance measurement
Add Timer and TimingManager which provide convenient way to meause the
execution time of code snippets. The output looks like,
```
-- Average Operation Time -- -- Name (# of Calls) --
1747.2(ns) popBatch (59)
92.3(ns) popBatchImpl (73)
101.6(ns) EmptyBatchProcess (5)
2587.0(ns) pushBlocksImpl (13)
```
Note that `EmptyBatchProcess` is nested under the timer `popBatchImpl`.
Reviewed By: cferris
Differential Revision: https://reviews.llvm.org/D143626
Simon Pilgrim [Thu, 23 Mar 2023 19:36:29 +0000 (19:36 +0000)]
[X86] combineVectorSizedSetCCEquality - update arguments to use individual SETCC operands. NFC.
Alex Brachet [Thu, 23 Mar 2023 18:43:09 +0000 (18:43 +0000)]
[libc] Move fma and fmaf into generic dir
Differential Revision: https://reviews.llvm.org/D146740
Nicolas Vasilache [Thu, 23 Mar 2023 15:32:48 +0000 (08:32 -0700)]
[mlir][Vector] NFC - Reorganize vector patterns
Vector dialect patterns have grown enormously in the past year to a point where they are now impenetrable.
Start reorganizing them towards finer-grained control.
Differential Revision: https://reviews.llvm.org/D146736
Julian Lettner [Thu, 23 Mar 2023 18:01:33 +0000 (11:01 -0700)]
[TSan][Darwin] Test fix external-swift-debugging.cpp
My recent change [1] extended the external-swift-debugging.cpp test, but
didn't account for PAC under which function pointers aren't trivially
comparable. We could use `ptrauth_strip()`, but for the test it's easier
to just the symbol name.
[1] https://reviews.llvm.org/D146264
Nicolas Vasilache [Thu, 23 Mar 2023 17:47:04 +0000 (10:47 -0700)]
[mlir][Vector] Retire one old filter-based test
Differential Revision: https://reviews.llvm.org/D146742
Momchil Velikov [Thu, 23 Mar 2023 17:38:07 +0000 (17:38 +0000)]
[CodeGenPrepare][NFC] Pre-commit test for memory use count fix
Reviewed By: mkazantsev
Differential Revision: https://reviews.llvm.org/D145705
Simon Pilgrim [Thu, 23 Mar 2023 17:49:39 +0000 (17:49 +0000)]
[X86] Refactor movmsk(icmp_eq(and(x,c1),0)) -> movmsk(not(shl(x,c2))) fold to use KnownBits
We don't need an explicit AND mask, we can use KnownBits to determine if each element has (the same) single non-zero bit and shift that into the msb/signbit for MOVMSK to access directly.
Paul Kirth [Thu, 23 Mar 2023 17:13:35 +0000 (17:13 +0000)]
[support] Fix PrintNumber Test on AIX
When fixing the test earlier, we missed the JSON case for NaN and INF,
so handle those the same as for non-JSON, by creating the string
dynamically.
Reviewed By: abhina.sreeskantharajan
Differential Revision: https://reviews.llvm.org/D146739
Emilia Dreamer [Thu, 23 Mar 2023 17:31:39 +0000 (19:31 +0200)]
[clang-format] Allow trailing return types in macros
The trailing return type arrow checker verifies that a declaration is
being parsed, however, this isn't true when inside of macros.
It turns out the existence of the auto keyword is enough to make
sure that we're dealing with a trailing return type, and whether we're
in a declaration doesn't matter.
Fixes https://github.com/llvm/llvm-project/issues/47664
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D141811
Momchil Velikov [Thu, 23 Mar 2023 17:16:31 +0000 (17:16 +0000)]
[CodeGenPrepare] Don't give up if unable to sink first arg to a cold call
Reviewed By: mkazantsev
Differential Revision: https://reviews.llvm.org/D143892
Mike Hommey [Thu, 23 Mar 2023 17:09:00 +0000 (17:09 +0000)]
[libcxx] Fix build bustage with threads disabled
Building with -DLIBCXX_ENABLE_THREADS=OFF -DLIBCXXABI_ENABLE_THREADS=OFF
(like e.g. for wasm) fails after D146228 because of a misplaced std
namespace begin/end.
Reviewed By: philnik, #libc
Differential Revision: https://reviews.llvm.org/D146682
Hristo Hristov [Wed, 22 Mar 2023 21:24:22 +0000 (23:24 +0200)]
[libc++][ranges] P2711R1 Making multi-param constructors of views explicit
Implemented [[ https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2711r1.html | P2711R1 ]] for existing views.
(`join_with_view` is not yet implemented)
Reviewed By: #libc, philnik
Differential Revision: https://reviews.llvm.org/D144822
Viktoriia Bakalova [Thu, 23 Mar 2023 17:27:10 +0000 (17:27 +0000)]
[clangd] Fix indentation in HoverTests.cpp
Fangrui Song [Thu, 23 Mar 2023 17:19:10 +0000 (10:19 -0700)]
[docs] Document -fomit-frame-pointer
Close #61322
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D146603
Alex Brachet [Thu, 23 Mar 2023 17:07:19 +0000 (17:07 +0000)]
[libc] Fix some math conversion warnings
Differential Revision: https://reviews.llvm.org/D146738
Michael Jones [Mon, 13 Mar 2023 23:43:05 +0000 (16:43 -0700)]
[libc] enable printf using system FILE
The printf and fprintf implementations use our internal implementation
to improve performance when it's available, but this patch enables using
the public FILE API for overlay mode.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D146001
Jeff Byrnes [Wed, 15 Mar 2023 19:11:20 +0000 (12:11 -0700)]
[ArgPromotion] Remove dead code produced by removing dead arguments
ArgPromotion currently produces phantom / dead loads. A good example of this is store-into-inself.ll. First, ArgPromo finds the promotable argument %p in @l. Then it inserts a load of %p in the caller, and passes instead the loaded value / transforms the function body. PromoteMem2Reg is able to optimize out the entire function body, resulting in an unused argument. In a subsequent ArgPromotion pass, it removes the dead argument, resulting in a dead load in the caller. These dead loads may reduce effectiveness of other transformations (e.g. SimplifyCFG, MergedLoadStoreMotion).
This patch removes loads and geps that are made dead in the caller after removal of dead args.
Differential Revision: https://reviews.llvm.org/D146327
Renaud-K [Tue, 21 Mar 2023 23:32:26 +0000 (16:32 -0700)]
[flang] Lowering fir.dispatch in the polymorphic op pass
Differential revision: https://reviews.llvm.org/D146594
Nikita Popov [Thu, 23 Mar 2023 16:32:23 +0000 (17:32 +0100)]
[MergeFunc] Don't assume constant metadata operands
We should not call mdconst::extract, unless we know that the
metadata in question is ConstantAsMetadata.
For now we consider all other metadata as equal. The noalias test
shows that this is not correct, but at least it doesn't crash
anymore.
Joseph Huber [Thu, 23 Mar 2023 16:27:20 +0000 (11:27 -0500)]
[libc] Fix inline assembly for nvptx quick_exit
Summary:
The `exit` function in NVPTX has no intrinsic, but the assembly requires
a semicolon in the ptx, otherwise it will fail.
Archibald Elliott [Thu, 23 Mar 2023 15:56:07 +0000 (15:56 +0000)]
[NFC][AArch64] Sort Hints in armv8.3a-signed-pointer.s test
Joseph Huber [Thu, 23 Mar 2023 14:05:34 +0000 (09:05 -0500)]
[libc] Implement memory fences on NVPTX
Memory fences are not handled by the NVPTX backend. We need to replace
them with a memory barrier intrinsic function. This doesn't include the
ordering, but should perform the necessary functionality, albeit slower.
Reviewed By: tianshilei1992
Differential Revision: https://reviews.llvm.org/D146725
Viktoriia Bakalova [Tue, 28 Feb 2023 16:27:05 +0000 (16:27 +0000)]
[clangd] Add provider info on symbol hover.
Differential Revision: https://reviews.llvm.org/D144976
Teresa Johnson [Thu, 23 Mar 2023 16:15:57 +0000 (09:15 -0700)]
[MemProf] Use stable_sort to avoid non-determinism
Switch from std::sort to std::stable_sort when sorting callsites to
avoid non-determinism when the comparisons are equal. This showed up in
internal testing of
fe27495be2040007c7b20844a9371b06156ab405.
Simon Pilgrim [Thu, 23 Mar 2023 16:10:32 +0000 (16:10 +0000)]
[X86] LowerVectorAllZero - lower to CMP(MOVMSK(NOT(X)),0) instead of CMP(MOVMSK(X),65535)
In most cases the NOT will still be scalarized, but it allows us to perform the CMP(X,0) combines inside combineCMP()
Ding Xiang Fei [Thu, 23 Mar 2023 16:04:21 +0000 (17:04 +0100)]
[MergeFuncs] Add tests for D144682 (NFC)
I forgot to git add this test when committing the change.
Philip Reames [Thu, 23 Mar 2023 15:47:44 +0000 (08:47 -0700)]
[BoundsChecking] Don't crash on scalable vector sizes
Felipe de Azevedo Piovezan [Thu, 23 Mar 2023 12:18:53 +0000 (08:18 -0400)]
[lldb] Explicitly set libcxx paths when USE_SYSTEM_STDLIB is provided
For tests marked as "USE_SYSTEM_STDLIB", the expectation is that the
system's standard library should be used. However, the implementation of
this flag is such that we simply don't pass _any_ libcxxx-related flags
to Clang; in turn, Clang will use its defaults.
For a Clang/Libcxx pair compiled together, Clang defaults to:
1. The headers of the sibling libcxx.
2. The libraries of the system.
This mismatch is actually a bug in the driver; once fixed, however, (2)
would point to the sibling libcxx as well, which is _not_ what test
authors intended with the USE_SYSTEM_STDLIB flag.
As such, this patch explicitly sets a path to the system's libraries.
This change is done only in Apple platforms so that we can test this
works in this case first.
Differential Revision: https://reviews.llvm.org/D146714
Jan Sjodin [Tue, 21 Mar 2023 17:38:54 +0000 (13:38 -0400)]
[OpenMP][OMPIRBuilder] Make OffloadEntriesInfoManager a member of OpenMPIRBuilder
This patch adds the OffloadEntriesInfoManager to the OpenMPIRBuilder, and
allows the OffloadEntriesInfoManager to access the Configuration in the
OpenMPIRBuilder. With the shared Config there is no risk for inconsistencies,
and there is no longer the need for clang to have a separate
OffloadEntriesInfoManager.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D146549
Job Noorman [Thu, 23 Mar 2023 15:25:53 +0000 (16:25 +0100)]
Test commit to see if write access works
Philip Reames [Thu, 23 Mar 2023 15:09:32 +0000 (08:09 -0700)]
[HWASAN] Instrument scalable load/store without crashing
We can simply push them down the existing call slowpath with some minor changes to how we compute the size argument.
Kirill Stoimenov [Wed, 22 Mar 2023 18:09:00 +0000 (18:09 +0000)]
[HWASAN] Disable unexpected_format_specifier_test because HWASAN doesn't provide a printf interceptor
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D146647
Archibald Elliott [Wed, 22 Mar 2023 13:25:08 +0000 (13:25 +0000)]
[AArch64] Add Missing Custom Target Operands
I noticed, when examining the generated Asm Matcher table, that some of
these custom immediate operands are missing, and so we are not parsing
some hint aliases into the correct MCInst.
Where this becomes apparent is when you parse e.g. `hint #7` into an
MCInst - without these cases, it becomes the MCInst `(HINT 17)`, which
will always be printed as `hint #17`. With these cases, it becomes the
MCInst `XPACLRI`, which will be printed as `xpaclri` with pauth, or
`hint #17` without, matching how `xpaclri` is parsed.
We only handle some specific hint aliases in this manner, usually where
these hints have specific effects that need to be modelled for accurate
code-generation. Otherwise, we just use the normal `InstAlias` system
to have the aliases parsed into a `(HINT N)` MCInst.
Differential Revision: https://reviews.llvm.org/D146630
Corentin Jabot [Tue, 21 Mar 2023 15:57:43 +0000 (16:57 +0100)]
[Clang] Fix evaluation of parameters of lambda call operator attributes
Fix a regresion introduced by D124351.
Attributes of lambda call operator were evaluated in the
context of the closure object type rather than its operator,
causing an assertion failure.
This was because we temporarily switch to the class lambda to
produce the mangling of the lambda, but we stayed in that
context too long.
Reviewed By: eandrews, aaron.ballman
Differential Revision: https://reviews.llvm.org/D146535
Philip Reames [Thu, 23 Mar 2023 14:23:36 +0000 (07:23 -0700)]
[MSAN] Support load and stores of scalable vector types
This adds support for scalable vector types - at least far enough to get basic load and store cases working. It turns out that load/store without origin tracking already worked; I apparently got that working with one of the pre patches to use TypeSize utilities and didn't notice. The code changes here are required to enable origin tracking.
For origin tracking, a 4 byte value - the origin - is broadcast into a shadow region whose size exactly matches the type being accessed. This origin is only written if the shadow value is non-zero. The details of how shadow is computed from the original value being stored aren't relevant for this patch.
The code changes involve two related primitives.
First, we need to be able to perform that broadcast into a scalable sized memory region. This requires the use of a loop, and appropriate bound. The fixed size case optimizes with larger stores and alignment; I did not bother with that for the scalable case for now. We can optimize this codepath later if desired.
Second, we need a way to test if the shadow is zero. The mechanism for this in the code is to convert the shadow value into a scalar, and then zero check that. There's an assumption that this scalar is zero exactly when all elements of the shadow value are zero. As a result, we use an OR reduction on the scalable vector. This is analogous to how e.g. an array is handled. I landed a bunch of cleanup changes to remove other direct uses of the scalar conversion to convince myself there were no other undocumented invariants.
Differential Revision: https://reviews.llvm.org/D146157
khei4 [Thu, 9 Mar 2023 09:46:14 +0000 (18:46 +0900)]
[AggressiveInstCombine] folding load for constant global patterened arrays and structs by alignment
Differential Revision: https://reviews.llvm.org/D144445
Reviewed By: nikic
fix: wrong arrow
khei4 [Thu, 9 Mar 2023 06:31:11 +0000 (15:31 +0900)]
[AggressiveInstCombine] Pre-Commit test for D144445 (NFC)
Differential Revision: https://reviews.llvm.org/D145355
tweak: test
Doru Bercea [Tue, 21 Mar 2023 18:07:57 +0000 (14:07 -0400)]
Enable constexpr class members that are device-mapped to not be optimized out.
This patch fixes an issue whereby a constexpr class member which is
mapped to the device is being optimized out thus leading to a runtime
error.
Patch: https://reviews.llvm.org/D146552
Ye Luo [Thu, 23 Mar 2023 13:56:47 +0000 (08:56 -0500)]
[OpenMP] Add notifyDataUnmapped back in disassociatePtr
Fix regression introduced by https://reviews.llvm.org/D123446
Reviewed By: tianshilei1992
Differential Revision: https://reviews.llvm.org/D146689
David Spickett [Thu, 23 Mar 2023 13:46:49 +0000 (13:46 +0000)]
[lldb][AArch64] Fix run-qemu.sh when only MTE is enabled.
SVE and MTE both require a CPU with that feature before
you can use the other options, but we only added the "max"
cpu when SVE was enabled too.
Qiongsi Wu [Thu, 23 Mar 2023 13:16:18 +0000 (09:16 -0400)]
[AIX][CodeGen] Storage Locations for Constant Pointers
This patch adds an `llc` option `-mroptr` to specify storage locations for constant pointers on AIX.
When the `-mroptr` option is specified, constant pointers, virtual function tables, and virtual type tables are placed in read-only storage. Otherwise, by default, pointers, virtual function tables, and virtual type tables are placed are placed in read/write storage.
https://reviews.llvm.org/D144190 enables the `-mroptr` option for `clang`.
Reviewed By: hubert.reinterpretcast, stephenpeckham, myhsu, MaskRay, serge-sans-paille
Differential Revision: https://reviews.llvm.org/D144189
Alexey Lapshin [Thu, 23 Mar 2023 13:40:29 +0000 (14:40 +0100)]
Revert "[ADT] add ConcurrentHashtable class."
This reverts commit
8482b238062ed7263facea9490f67119e00a037a.
Benjamin Kramer [Thu, 23 Mar 2023 13:41:03 +0000 (14:41 +0100)]
Silence unused variable warning in NDEBUG builds
I usually would fold this into the assert, but the comment there
suggests side effects. NFC.
ModuleMap.cpp:938:9: error: unused variable 'MainFile' [-Werror,-Wunused-variable]
auto *MainFile = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID());
Simon Pilgrim [Thu, 23 Mar 2023 13:37:04 +0000 (13:37 +0000)]
[X86] LowerVectorAllZero - add 512-bit support with AVX512 vptestnmd+kortestw patterns (REAPPLIED)
Another step toward #53419 - this is also another step towards expanding MatchVectorAllZeroTest to match any pair of vectors and merge EmitAVX512Test into it.
Alexey Lapshin [Wed, 22 Mar 2023 16:37:15 +0000 (17:37 +0100)]
[ADT] add ConcurrentHashtable class.
ConcurrentHashTable - is a resizeable concurrent hashtable.
The range of resizings is limited up to x2^32. The hashtable allows only concurrent insertions.
Concurrent hashtable is necessary for the D96035 patch.
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/D132455
Johannes de Fine Licht [Thu, 23 Mar 2023 13:22:15 +0000 (14:22 +0100)]
[MLIR][LLVM] Move the LLVM inliner interface into a separate file.
A fully fledged LLVM inliner will require a lot of logic. Since
`LLVMDialect.cpp` is large enough as it is, preemptively outline the
inlining logic into a separate `.cpp` file. This will also allow us to
add a `DEBUG_TYPE` for debugging the inliner.
The name `LLVMInlining` was chosen over `LLVMInlinerInterface` to keep
the option open for exposing inlining functionality even when not
invoked through the `DialectInlinerInterface`.
Depends on D146616
Reviewed By: gysit
Differential Revision: https://reviews.llvm.org/D146628
NAKAMURA Takumi [Wed, 22 Mar 2023 23:47:55 +0000 (08:47 +0900)]
[Bazel] Rework `//llvm:llvm-tblgen` and `//llvm/unittests:tablegen_tests`
`llvm/utils/TableGen/GlobalISel` should be exported.
FYI, after D144351,`tablegen_tests` behaved same
as `llvm-tblgen -print-records`.
It suceeded because stdin is `/dev/null`.