Commit Graph

455632 Commits

Author SHA1 Message Date
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
Nicolas Vasilache
73bec2b2c3 [mlir][Vector] Retire one old filter-based test
Differential Revision: https://reviews.llvm.org/D146742
2023-03-23 11:00:35 -07:00
Momchil Velikov
5c9a26238a [CodeGenPrepare][NFC] Pre-commit test for memory use count fix
Reviewed By: mkazantsev

Differential Revision: https://reviews.llvm.org/D145705
2023-03-23 17:55:05 +00:00
Simon Pilgrim
cc8a34b11b [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.
2023-03-23 17:49:46 +00:00
Paul Kirth
8088f5bf2d [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
2023-03-23 17:49:03 +00:00
Emilia Dreamer
c70e360b35 [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
2023-03-23 19:37:53 +02:00
Momchil Velikov
6a2a5f08de [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
2023-03-23 17:31:09 +00:00
Mike Hommey
101cfe18f7 [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
2023-03-23 17:30:34 +00:00
Hristo Hristov
40aaa272f1 [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
2023-03-23 19:30:21 +02:00
Viktoriia Bakalova
40e5d212cf [clangd] Fix indentation in HoverTests.cpp 2023-03-23 17:27:10 +00:00
Fangrui Song
5f883cdbfb [docs] Document -fomit-frame-pointer
Close #61322

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D146603
2023-03-23 10:19:10 -07:00
Alex Brachet
7d11a592c5 [libc] Fix some math conversion warnings
Differential Revision: https://reviews.llvm.org/D146738
2023-03-23 17:07:19 +00:00
Michael Jones
de939c6cd8 [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
2023-03-23 09:56:45 -07:00
Jeff Byrnes
7739be7c6b [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
2023-03-23 09:43:35 -07:00
Renaud-K
4c5dee7773 [flang] Lowering fir.dispatch in the polymorphic op pass
Differential revision: https://reviews.llvm.org/D146594
2023-03-23 09:40:47 -07:00
Nikita Popov
2f5fdbfab8 [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.
2023-03-23 17:34:53 +01:00
Joseph Huber
e33f8ac9d8 [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.
2023-03-23 11:28:33 -05:00
Archibald Elliott
5525087e4c [NFC][AArch64] Sort Hints in armv8.3a-signed-pointer.s test 2023-03-23 16:26:43 +00:00
Joseph Huber
9c8bdbcbc5 [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
2023-03-23 11:26:35 -05:00
Viktoriia Bakalova
2bececb8be [clangd] Add provider info on symbol hover.
Differential Revision: https://reviews.llvm.org/D144976
2023-03-23 16:21:51 +00:00
Teresa Johnson
dc2f2d2180 [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 fe27495be2.
2023-03-23 09:20:39 -07:00
Simon Pilgrim
ec294d2f8f [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()
2023-03-23 16:10:37 +00:00
Ding Xiang Fei
16b6826bdd [MergeFuncs] Add tests for D144682 (NFC)
I forgot to git add this test when committing the change.
2023-03-23 17:05:10 +01:00
Philip Reames
2cfd06ba67 [BoundsChecking] Don't crash on scalable vector sizes 2023-03-23 08:53:41 -07:00
Felipe de Azevedo Piovezan
c640a146c4 [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
2023-03-23 11:53:13 -04:00
Jan Sjodin
85faee6992 [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
2023-03-23 11:46:28 -04:00