Commit Graph

455657 Commits

Author SHA1 Message Date
Johannes de Fine Licht
a94d2bd5b5 [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
2023-03-24 09:33:42 +01:00
Martin Storsjö
09aa3f7bb5 [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.
2023-03-24 10:28:49 +02:00
luxufan
558b33c5aa [NFC] Regenerate test NewGVN/metadata-nonnull.ll 2023-03-24 16:26:32 +08:00
Dmitry Chernenkov
3048c9e154 Revert "Recommit [Modules] Remove unnecessary check when generating name lookup table in ASTWriter"
This reverts commit 25557aa38a.
2023-03-24 07:59:04 +00:00
Tobias Gysi
b0cd5b2a47 [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
2023-03-24 08:24:58 +01:00
Carlos Galvez
f957b8fe1e [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
2023-03-24 07:22:04 +00:00
Michael Platings
d30bc9e912 [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
2023-03-24 06:58:07 +00:00
Kazu Hirata
1e4325f30c [X86] Precommit a test
This patch precommits a test for:

https://github.com/llvm/llvm-project/issues/61365
2023-03-23 23:48:17 -07:00
Dave Lee
abddb83598 [lldb] Fix type of --apply-fixits (NFC) 2023-03-23 22:49:29 -07:00
Xiang1 Zhang
cc86e6b0a8 [BugFix] Fix VSELECT ISel fail
Reviewed By: Luo yuanke

Differential Revision: https://reviews.llvm.org/D146683
2023-03-24 13:13:35 +08:00
Kazu Hirata
d8efbcf9dc [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 86b4d8645f on
Feb 8, 2023 already performs the instcombine transformation proposed
in the issue, so the issue requires no change on the codegen side.
2023-03-23 20:20:20 -07:00
Xiaodong Liu
11674147e4 [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
2023-03-24 11:09:18 +08:00
Jun Zhang
cea938390e [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
2023-03-24 10:51:36 +08:00
Jun Zhang
3ca6e69b6e Precommit tests for #60690
Differential Revision: https://reviews.llvm.org/D146636

Signed-off-by: Jun Zhang <jun@junz.org>
2023-03-24 10:51:32 +08:00
XinWang10
4950104e24 [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
2023-03-23 22:32:45 -04:00
Kazu Hirata
231fa27435 [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
2023-03-23 19:26:43 -07:00
Kazu Hirata
5f48b861f8 [SelectionDAG] Use isOneConstant (NFC) 2023-03-23 19:26:42 -07:00
Rahul Joshi
24657a95c1 [NFC] Fix Windows builds that use MSVC 14.x
Differential Revision: https://reviews.llvm.org/D146769
2023-03-23 19:16:44 -07:00
Arthur Eubanks
ccd96b3e03 [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
2023-03-23 19:08:59 -07:00
LiaoChunyu
24847a90aa [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
2023-03-24 09:45:43 +08:00
Quinn Dawkins
c82803097f [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
2023-03-23 19:38:53 -04:00
Bruno Cardoso Lopes
07ef7b1ff2 [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
2023-03-23 16:35:30 -07:00
Fangrui Song
399f313f27 [Driver] Remove remnant mips64el-linux-android code after D146565 2023-03-23 16:00:17 -07:00
Fangrui Song
ccc2f362db Android.rules: remove mips* rules
They have been obsoleted for a long time and D146565 recently removed
Clang support.
2023-03-23 15:58:43 -07:00
Fangrui Song
bb0ecb7bf0 [Driver][test] Remove remnant mips*-linux-android tests after 805f51f9fe 2023-03-23 15:49:38 -07:00
Heejin Ahn
999643f151 [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
2023-03-23 15:35:26 -07:00
NagaChaitanya Vellanki
c13ccf1fba [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
2023-03-23 15:10:27 -07:00
Cyndy Ishida
397486566e [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
2023-03-23 14:58:41 -07:00
Lang Hames
ec2333d885 [JITLink] Add a jitlink::Section::empty operation. 2023-03-23 14:52:17 -07:00
Chia-hung Duan
2e9bcadb7c Revert "[scudo] Add a Timer class to assist performance measurement"
This reverts commit e0361396c2.
2023-03-23 21:49:02 +00:00
Leonard Chan
53a9175951 [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
2023-03-23 21:44:59 +00:00
Joseph Huber
9ddc03a17d [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.
2023-03-23 16:41:25 -05:00
Joseph Huber
d11e49f0c8 [libc][NFC] Fix misspelled variable name in cmake message 2023-03-23 16:30:31 -05:00
Joseph Huber
af54d1e852 [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
2023-03-23 16:30:07 -05:00
Sam Clegg
3111784ff7 [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
2023-03-23 14:26:27 -07:00
NagaChaitanya Vellanki
1c9173365a 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
2023-03-23 14:18:02 -07:00
AdityaK
805f51f9fe Remove Android-mips related tests
Split from: https://reviews.llvm.org/D146565, already reviewed there.
2023-03-23 14:06:50 -07:00
Arthur Eubanks
088da8a0e5 [lldb][NFC] makeArrayRef -> ArrayRef
makeArrayRef is deprecated.
2023-03-23 14:05:06 -07:00
Alexander Yermolovich
d557384b43 [LLDB] Fix for D139955 Summary:
Fixing a small typo.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D146659
2023-03-23 14:03:42 -07:00
Gulfem Savrun Yeniceri
f23dcb2f2a Revert "[JITLink] Initial AArch32 backend"
This reverts commit c2de8ff927.
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
2023-03-23 20:56:43 +00:00
AdityaK
156d966ec4 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
2023-03-23 13:52:38 -07:00
Colin Cross
1d30afdc2d [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
2023-03-23 13:33:52 -07:00
Kirill Stoimenov
4b398ec456 [HWASAN] Fix decorate_proc_maps to work with HWASAN 2023-03-23 20:29:50 +00:00
Alex Langford
0c5cee7799 [lldb-server] Use Platform plugin corresponding to the host
In ee232506b8 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
2023-03-23 12:59:25 -07:00
Nick Desaulniers
d10110a8a6 [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
2023-03-23 12:45:40 -07:00
Chia-hung Duan
e0361396c2 [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
2023-03-23 19:40:15 +00:00
Simon Pilgrim
30e89166d7 [X86] combineVectorSizedSetCCEquality - update arguments to use individual SETCC operands. NFC. 2023-03-23 19:36:33 +00:00
Alex Brachet
a86cc8341d [libc] Move fma and fmaf into generic dir
Differential Revision: https://reviews.llvm.org/D146740
2023-03-23 18:43:09 +00:00
Nicolas Vasilache
2bc4c3e920 [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
2023-03-23 11:30:25 -07:00
Julian Lettner
637048f122 [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
2023-03-23 11:28:15 -07:00