platform/upstream/llvm.git
15 months agoAndroid.rules: remove mips* rules
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.

15 months ago[Driver][test] Remove remnant mips*-linux-android tests after 805f51f9fedf90d2aa0ad46...
Fangrui Song [Thu, 23 Mar 2023 22:49:38 +0000 (15:49 -0700)]
[Driver][test] Remove remnant mips*-linux-android tests after 805f51f9fedf90d2aa0ad46c61cb4c9c0c5bcfe9

15 months ago[WebAssembly] Tidy up DebugValueManager (NFC)
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

15 months ago[clang][ExtractAPI]Fix Declaration fragments for instancetype in the type position...
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

15 months ago[llvm][TextAPI] Handle implicitly upgraded deployment versions
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

15 months ago[JITLink] Add a jitlink::Section::empty operation.
Lang Hames [Thu, 23 Mar 2023 21:43:23 +0000 (14:43 -0700)]
[JITLink] Add a jitlink::Section::empty operation.

15 months agoRevert "[scudo] Add a Timer class to assist performance measurement"
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.

15 months ago[llvm] Handle duplicate call bases when applying branch funneling
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

15 months ago[OpenMP] Fix test after updating NVPTX atomic inlines
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.

15 months ago[libc][NFC] Fix misspelled variable name in cmake message
Joseph Huber [Thu, 23 Mar 2023 21:30:31 +0000 (16:30 -0500)]
[libc][NFC] Fix misspelled variable name in cmake message

15 months ago[NVPTX] Set the atomic inling threshold when targeting NVPTX directly
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

15 months ago[lld][WebAssembly] Initial support for stub libraries
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

15 months agoFix highlighting issue with _complex and initialization list with more than 2 items
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

15 months agoRemove Android-mips related tests
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.

15 months ago[lldb][NFC] makeArrayRef -> ArrayRef
Arthur Eubanks [Thu, 23 Mar 2023 18:28:49 +0000 (11:28 -0700)]
[lldb][NFC] makeArrayRef -> ArrayRef

makeArrayRef is deprecated.

15 months ago[LLDB] Fix for D139955 Summary:
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

15 months agoRevert "[JITLink] Initial AArch32 backend"
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

15 months agoRemove mips target triple for Android
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

15 months ago[PATCH] Enable targeting riscv64-linux-android
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

15 months ago[HWASAN] Fix decorate_proc_maps to work with HWASAN
Kirill Stoimenov [Thu, 23 Mar 2023 20:25:47 +0000 (20:25 +0000)]
[HWASAN] Fix decorate_proc_maps to work with HWASAN

15 months ago[lldb-server] Use Platform plugin corresponding to the host
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

15 months ago[StackProtector] attribute __stack_chk_fail as NoReturn
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

15 months ago[scudo] Add a Timer class to assist performance measurement
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

15 months ago[X86] combineVectorSizedSetCCEquality - update arguments to use individual SETCC...
Simon Pilgrim [Thu, 23 Mar 2023 19:36:29 +0000 (19:36 +0000)]
[X86] combineVectorSizedSetCCEquality - update arguments to use individual SETCC operands. NFC.

15 months ago[libc] Move fma and fmaf into generic dir
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

15 months ago[mlir][Vector] NFC - Reorganize vector patterns
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

15 months ago[TSan][Darwin] Test fix external-swift-debugging.cpp
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

15 months ago[mlir][Vector] Retire one old filter-based test
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

15 months ago[CodeGenPrepare][NFC] Pre-commit test for memory use count fix
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

15 months ago[X86] Refactor movmsk(icmp_eq(and(x,c1),0)) -> movmsk(not(shl(x,c2))) fold to use...
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.

15 months ago[support] Fix PrintNumber Test on AIX
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

15 months ago[clang-format] Allow trailing return types in macros
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

15 months ago[CodeGenPrepare] Don't give up if unable to sink first arg to a cold call
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

15 months ago[libcxx] Fix build bustage with threads disabled
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

15 months ago[libc++][ranges] P2711R1 Making multi-param constructors of views explicit
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

15 months ago[clangd] Fix indentation in HoverTests.cpp
Viktoriia Bakalova [Thu, 23 Mar 2023 17:27:10 +0000 (17:27 +0000)]
[clangd] Fix indentation in HoverTests.cpp

15 months ago[docs] Document -fomit-frame-pointer
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

15 months ago[libc] Fix some math conversion warnings
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

15 months ago[libc] enable printf using system FILE
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

15 months ago[ArgPromotion] Remove dead code produced by removing dead arguments
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

15 months ago[flang] Lowering fir.dispatch in the polymorphic op pass
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

15 months ago[MergeFunc] Don't assume constant metadata operands
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.

15 months ago[libc] Fix inline assembly for nvptx quick_exit
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.

15 months ago[NFC][AArch64] Sort Hints in armv8.3a-signed-pointer.s test
Archibald Elliott [Thu, 23 Mar 2023 15:56:07 +0000 (15:56 +0000)]
[NFC][AArch64] Sort Hints in armv8.3a-signed-pointer.s test

15 months ago[libc] Implement memory fences on NVPTX
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

15 months ago[clangd] Add provider info on symbol hover.
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

15 months ago[MemProf] Use stable_sort to avoid non-determinism
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.

15 months ago[X86] LowerVectorAllZero - lower to CMP(MOVMSK(NOT(X)),0) instead of CMP(MOVMSK(X...
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()

15 months ago[MergeFuncs] Add tests for D144682 (NFC)
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.

15 months ago[BoundsChecking] Don't crash on scalable vector sizes
Philip Reames [Thu, 23 Mar 2023 15:47:44 +0000 (08:47 -0700)]
[BoundsChecking] Don't crash on scalable vector sizes

15 months ago[lldb] Explicitly set libcxx paths when USE_SYSTEM_STDLIB is provided
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

15 months ago[OpenMP][OMPIRBuilder] Make OffloadEntriesInfoManager a member of OpenMPIRBuilder
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

15 months agoTest commit to see if write access works
Job Noorman [Thu, 23 Mar 2023 15:25:53 +0000 (16:25 +0100)]
Test commit to see if write access works

15 months ago[HWASAN] Instrument scalable load/store without crashing
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.

15 months ago[HWASAN] Disable unexpected_format_specifier_test because HWASAN doesn't provide...
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

15 months ago[AArch64] Add Missing Custom Target Operands
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

15 months ago[Clang] Fix evaluation of parameters of lambda call operator attributes
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

15 months ago[MSAN] Support load and stores of scalable vector types
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

15 months ago[AggressiveInstCombine] folding load for constant global patterened arrays and struct...
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

15 months ago[AggressiveInstCombine] Pre-Commit test for D144445 (NFC)
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

15 months agoEnable constexpr class members that are device-mapped to not be optimized out.
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

15 months ago[OpenMP] Add notifyDataUnmapped back in disassociatePtr
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

15 months ago[lldb][AArch64] Fix run-qemu.sh when only MTE is enabled.
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.

15 months ago[AIX][CodeGen] Storage Locations for Constant Pointers
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

15 months agoRevert "[ADT] add ConcurrentHashtable class."
Alexey Lapshin [Thu, 23 Mar 2023 13:40:29 +0000 (14:40 +0100)]
Revert "[ADT] add ConcurrentHashtable class."

This reverts commit 8482b238062ed7263facea9490f67119e00a037a.

15 months agoSilence unused variable warning in NDEBUG builds
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());

15 months ago[X86] LowerVectorAllZero - add 512-bit support with AVX512 vptestnmd+kortestw pattern...
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.

15 months ago[ADT] add ConcurrentHashtable class.
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

15 months ago[MLIR][LLVM] Move the LLVM inliner interface into a separate file.
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

15 months ago[Bazel] Rework `//llvm:llvm-tblgen` and `//llvm/unittests:tablegen_tests`
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`.

15 months ago[X86] LowerVectorAllZero - early out for masked v2i64 cases without PTEST. NFC.
Simon Pilgrim [Thu, 23 Mar 2023 13:07:29 +0000 (13:07 +0000)]
[X86] LowerVectorAllZero - early out for masked v2i64 cases without PTEST. NFC.

15 months ago[RISCV][test] Fix another missed test change from RV64E patch
Job Noorman [Thu, 23 Mar 2023 13:01:22 +0000 (13:01 +0000)]
[RISCV][test] Fix another missed test change from RV64E patch

c39dd7c1db97fa367cb6282067b74cd8e55ef09a missed a needed change to the
llvm-objdump test.

15 months ago[RISCV][clang][test] Fix missed test
Job Noorman [Thu, 23 Mar 2023 12:48:03 +0000 (12:48 +0000)]
[RISCV][clang][test] Fix missed test

c39dd7c1db97fa367cb6282067b74cd8e55ef09a missed the appropriate change
to clang/test/Driver/ricv-arch.c.

15 months ago[C++20][Modules] Introduce an implementation module.
Iain Sandoe [Fri, 3 Jun 2022 09:43:38 +0000 (10:43 +0100)]
[C++20][Modules] Introduce an implementation module.

We need to be able to distinguish individual TUs from the same module in cases
where TU-local entities either need to be hidden (or, for some cases of ADL in
template instantiation, need to be detected as exposures).

This creates a module type for the implementation which implicitly imports its
primary module interface per C++20:
[module.unit/8] 'A module-declaration that contains neither an export-keyword
nor a module-partition implicitly imports the primary module interface unit of
the module as if by a module-import-declaration.

Implementation modules are never serialized (-emit-module-interface for an
implementation unit is diagnosed and rejected).

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

15 months agoRevert rG6aa7cc037f2f95c237c1d82c523f8857fa3a10c3 - "[X86] LowerVectorAllZero - add...
Simon Pilgrim [Thu, 23 Mar 2023 12:37:11 +0000 (12:37 +0000)]
Revert rG6aa7cc037f2f95c237c1d82c523f8857fa3a10c3 - "[X86] LowerVectorAllZero - add 512-bit support with AVX512 vptestnmd+kortestw patterns"

Reverted - I need to adjust the implementation so we can properly refactor it into a "LowerVectorAllEqual" function

15 months ago[llvm-objdump] Fix help message for --print-imm-hex
Yi Kong [Thu, 23 Mar 2023 12:29:17 +0000 (20:29 +0800)]
[llvm-objdump] Fix help message for --print-imm-hex

Commit cc2457ca1bbd changed the default but forgot to update the help message.

15 months ago[RISCV][MC] Add support for RV64E
Job Noorman [Thu, 23 Mar 2023 12:17:57 +0000 (12:17 +0000)]
[RISCV][MC] Add support for RV64E

Implement MC support for the recently ratified RV64E base instruction
set.

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

15 months ago[X86] LowerVectorAllZero - add 512-bit support with AVX512 vptestnmd+kortestw patterns
Simon Pilgrim [Thu, 23 Mar 2023 12:18:45 +0000 (12:18 +0000)]
[X86] LowerVectorAllZero - add 512-bit support with AVX512 vptestnmd+kortestw patterns

Another step toward #53419 - this is also another step towards expanding MatchVectorAllZeroTest to match any pair of vectors and merge EmitAVX512Test into it.

15 months ago[IncludeCleaner][clangd] Mark umbrella headers as users of private
Kadir Cetinkaya [Mon, 20 Mar 2023 08:07:18 +0000 (09:07 +0100)]
[IncludeCleaner][clangd] Mark umbrella headers as users of private

Private headers inside umbrella files shouldn't be marked as unused.

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

15 months agoRevert "libclang: Pass Clang install directory to driver via argv[0]."
Aaron Ballman [Thu, 23 Mar 2023 12:05:15 +0000 (08:05 -0400)]
Revert "libclang: Pass Clang install directory to driver via argv[0]."

This reverts commit 201fdef40dd6ec193d18d39638454a3c972f1fec.

There was an issue found in post-commit by:
https://lab.llvm.org/buildbot/#/builders/91/builds/15272

15 months ago[gn] port a282ea4898efe
Nico Weber [Thu, 23 Mar 2023 11:56:33 +0000 (12:56 +0100)]
[gn] port a282ea4898efe

15 months ago[mlir] Fix call of overloaded ‘dropResults(<brace-enclosed initializer list>)’ is...
Quentin Colombet [Thu, 23 Mar 2023 11:43:34 +0000 (12:43 +0100)]
[mlir] Fix call of overloaded ‘dropResults(<brace-enclosed initializer list>)’ is ambiguous

NFC

15 months ago[lld] Fill .text section gaps with INT3 only on x86 targets.
Jacek Caban [Thu, 23 Mar 2023 11:20:37 +0000 (13:20 +0200)]
[lld] Fill .text section gaps with INT3 only on x86 targets.

It doesn't make sense on ARM and using default 0 fill is compatible
with MSVC.

(It's more noticeable ARM64EC targets, where additional padding mixed
with alignment is used for entry thunk association, so there are more
gaps).

Reviewed By: mstorsjo

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

15 months ago[llvm-lib] Use COFF archive format in llvm-lib (other archive tools don't use this...
Jacek Caban [Thu, 23 Mar 2023 11:20:15 +0000 (13:20 +0200)]
[llvm-lib] Use COFF archive format in llvm-lib (other archive tools don't use this format).

We currently just use GNU format for llvm-lib. This mostly works, but
ARM64EC needs an additional section that does not really fit GNU format.
This patch implements writing in COFF format (as in, it's what archive
reader considers as K_COFF). This mostly requires symbol emitting symbol
map. Note that, just like in case of MSVC, symbols are de-duplicated in
both usual symbol table and the new symbol map.

Reviewed By: efriedma

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

15 months ago[Object][NFC] Don't insert string table into object members vector.
Jacek Caban [Thu, 23 Mar 2023 11:19:53 +0000 (13:19 +0200)]
[Object][NFC] Don't insert string table into object members vector.

Having string table in members vector does not fit later patches in
this series. Symbol map needs to refer to objects' offsets, but string
table should not be referenced. Also for ARM64EC, the new <ECSYMBOLS>
table is inserted after string table.

Reviewed By: efriedma

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

15 months ago[Object][NFC] Factor out computeHeadersSize.
Jacek Caban [Thu, 23 Mar 2023 11:18:14 +0000 (13:18 +0200)]
[Object][NFC] Factor out computeHeadersSize.

In preparation for COFF archives support.

Reviewed By: efriedma

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

15 months ago[Local] Use most generic range if K does not dominate J or K doesn't have a !noundef
luxufan [Thu, 23 Mar 2023 11:31:29 +0000 (19:31 +0800)]
[Local] Use most generic range if K does not dominate J or K doesn't have a !noundef

Since D141386 has changed the return value of !range from IUB to poison,
metadata !range shouldn't be preserved even if K dominates J.

If this patch was accepted, I plan to adjust metadata !nonnull as well.
BTW, I found that metadata !noundef is not handled in combineMetadata,
is this intentional?

Reviewed By: nikic

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

15 months ago[gn build] Port c2de8ff92753
LLVM GN Syncbot [Thu, 23 Mar 2023 11:20:20 +0000 (11:20 +0000)]
[gn build] Port c2de8ff92753

15 months ago[gn build] Port 48f97e575137
LLVM GN Syncbot [Thu, 23 Mar 2023 11:20:19 +0000 (11:20 +0000)]
[gn build] Port 48f97e575137

15 months ago[RISCV][test] Fix broken unit test after d25751779ba
Alex Bradbury [Thu, 23 Mar 2023 11:17:40 +0000 (11:17 +0000)]
[RISCV][test] Fix broken unit test after d25751779ba

The patch had missed the RISCVISAInfoTest.cpp change.

15 months ago[mlir][Tensor] Add a FoldTensorSubsetOps pass and patterns
Nicolas Vasilache [Tue, 21 Mar 2023 21:41:20 +0000 (14:41 -0700)]
[mlir][Tensor] Add a FoldTensorSubsetOps pass and patterns

These patterns follow FoldMemRefAliasOps which is further refactored for reuse.
In the process, fix FoldMemRefAliasOps handling of strides for vector.transfer ops which was previously incorrect.

These opt-in patterns generalize the existing canonicalizations on vector.transfer ops.
In the future the blanket canonicalizations will be retired.
They are kept for now to minimize porting disruptions.

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

15 months ago[clangd] Extend CollectMainFileMacros.
Haojian Wu [Fri, 17 Mar 2023 09:33:07 +0000 (10:33 +0100)]
[clangd] Extend CollectMainFileMacros.

Extend the existing MainFileMacros structure:
- record more information (InConditionalDirective) in MacroOccurrence
- collect macro references inside macro body (fix a long-time FIXME)

So that the MainFileMacros preseve enough information, which allows a
just-in-time convertion to interop with include-cleaner::Macro for
include-cleaer features.

See the context in https://reviews.llvm.org/D146017.

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

15 months ago[FlowSensitive] Log analysis progress for debugging purposes
Sam McCall [Fri, 24 Feb 2023 13:50:00 +0000 (14:50 +0100)]
[FlowSensitive] Log analysis progress for debugging purposes

The goal is to be able to understand how the analysis executes, and what its
incremental and final findings are, by enabling logging and reading the logs.
This should include both framework and analysis-specific information.

Ad-hoc printf-debugging doesn't seem sufficient for my understanding, at least.
Being able to check in logging, turn it on in a production binary, and quickly
find particular analysis steps within complex functions seem important.

This can be enabled programmatically through DataflowAnalysisOptions, or
via the flag -dataflow-log. (Works in unittests, clang-tidy, standalone
tools...)

Important missing pieces here:
 - a logger implementation that produces an interactive report (HTML file)
   which can be navigated via timeline/code/CFG.
   (I think the Logger interface is sufficient for this, but need to prototype).
 - display of the application-specific lattice
 - more useful display for the built-in environment
   (e.g. meaningful & consistent names for values, hiding redundant variables in
   the flow condition, hiding unreachable expressions)

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

15 months ago[RISCV] Increase default vectorizer LMUL to 2
Luke Lau [Fri, 10 Feb 2023 11:03:55 +0000 (11:03 +0000)]
[RISCV] Increase default vectorizer LMUL to 2

After some discussion and experimentation, we have seen that changing the default number of vector register bits to LMUL=2 strikes a sweet spot.
Whilst we could be clever here and make the vectorizer smarter about dynamically selecting an LMUL that
a) Doesn't affect register pressure
b) Suitable for the microarchitecture
we would need to teach its heuristics about RISC-V register grouping specifics.
Instead this just does the easy, pragmatic thing by changing the default to a safe value that doesn't affect register pressure signifcantly[1], but should increase throughput and unlock more interleaving.

[1] Register spilling when compiling sqlite at various levels of `-riscv-v-register-bit-width-lmul`:

LMUL=1    2573 spills
LMUL=2    2583 spills
LMUL=4    2819 spills
LMUL=8    3256 spills

Reviewed By: craig.topper

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

15 months ago[mlir][Vector] Make sure that vector.contract preserves extra attributes while parsing
Adam Paszke [Thu, 23 Mar 2023 10:12:56 +0000 (10:12 +0000)]
[mlir][Vector] Make sure that vector.contract preserves extra attributes while parsing

The old implementation parsed the optional attribute dict, only to replace its
contents by using `assign`.

Reviewed By: ftynse

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

15 months ago[clang-tidy][NFC] Fix broken link in Release Notes
Carlos Galvez [Thu, 23 Mar 2023 10:30:01 +0000 (10:30 +0000)]
[clang-tidy][NFC] Fix broken link in Release Notes

15 months ago[JITLink] Initial AArch32 backend
Stefan Gränitz [Thu, 23 Mar 2023 10:10:39 +0000 (11:10 +0100)]
[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

15 months agoBump RV32E version to 2.0
Job Noorman [Thu, 23 Mar 2023 09:45:16 +0000 (17:45 +0800)]
Bump RV32E version to 2.0

RV32E was recently [ratified](https://github.com/riscv/riscv-isa-manual/commit/afd613691cb89ccd7584206e8a6d1866fe77ec88) so we should update the version as our MC-layer support is complete.

Reviewed By: kito-cheng

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

15 months ago[AsmParser] Avoid instantiating LLVMContext if not needed. Try 2.
Yevgeny Rouban [Thu, 23 Mar 2023 09:19:19 +0000 (16:19 +0700)]
[AsmParser] Avoid instantiating LLVMContext if not needed. Try 2.

The deleted copy constructor LLVMContext(LLVMContext &) got its
parameter changed to const to allow the latest clang compiler to
instantiatiate template std::optional<LLVMContext>.

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

15 months agoRevert "[clang-format] NFC Format.h and ClangFormatStyleOptions.rst are out of date"
mydeveloperday [Thu, 23 Mar 2023 09:52:59 +0000 (09:52 +0000)]
Revert "[clang-format] NFC Format.h and ClangFormatStyleOptions.rst are out of date"

This reverts commit 7a5b95732ade6c2de69b26f1038aa0a5afc39393.