platform/upstream/llvm.git
19 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

19 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

19 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.

19 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.

19 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

19 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

19 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

19 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.

19 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()

19 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.

19 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

19 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

19 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

19 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

19 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.

19 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

19 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

19 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

19 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

19 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

19 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

19 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

19 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

19 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.

19 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

19 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.

19 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());

19 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.

19 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

19 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

19 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`.

19 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.

19 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.

19 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.

19 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

19 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

19 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.

19 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

19 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.

19 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

19 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

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

19 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

19 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

19 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

19 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

19 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

19 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

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

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

19 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.

19 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

19 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

19 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

19 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

19 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

19 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

19 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

19 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

19 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

19 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.

19 months ago[clang-format] NFC Format.h and ClangFormatStyleOptions.rst are out of date
mydeveloperday [Thu, 23 Mar 2023 09:45:00 +0000 (09:45 +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

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

19 months ago[X86] LowerVectorAllZero - early out if the type size is not pow2. NFC.
Simon Pilgrim [Thu, 23 Mar 2023 09:42:45 +0000 (09:42 +0000)]
[X86] LowerVectorAllZero - early out if the type size is not pow2. NFC.

19 months ago[llvm][ARM] Refactor isMnemonicVPTPredicable
David Spickett [Wed, 22 Mar 2023 10:05:48 +0000 (10:05 +0000)]
[llvm][ARM] Refactor isMnemonicVPTPredicable

Fixes #61607

Several names were repeated in this giant list. I have refactored
it and removed the duplicates.

Reviewed By: dmgreen

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

19 months ago[gn] Port e655d8a54880 more
Nico Weber [Thu, 23 Mar 2023 09:34:29 +0000 (10:34 +0100)]
[gn] Port e655d8a54880 more

19 months agoRevert "[clang][Interp][NFC] Add tests for __fp16"
Timm Bäder [Thu, 23 Mar 2023 09:33:03 +0000 (10:33 +0100)]
Revert "[clang][Interp][NFC] Add tests for __fp16"

This reverts commit 0691bcb18024a28e82e8dd9a08ab0820b40c9a37.

Looks like this breaks builders, e.g.
https://lab.llvm.org/buildbot#builders/231/builds/9790

19 months agoclang-tidy: Detect use-after-move in CXXCtorInitializer
MarcoFalke [Tue, 14 Mar 2023 13:23:07 +0000 (14:23 +0100)]
clang-tidy: Detect use-after-move in CXXCtorInitializer

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

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

19 months ago[XCOFF] support the ref directive for object generation.
esmeyi [Thu, 23 Mar 2023 09:09:47 +0000 (05:09 -0400)]
[XCOFF] support the ref directive for object generation.

Summary: A R_REF relocation as a non-relocating reference is required to prevent garbage collection (by the binder) of the ref symbol in object generation.

Reviewed By: shchenz

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

19 months ago[clang][Interp][NFC] Add tests for __fp16
Timm Bäder [Mon, 20 Mar 2023 16:43:26 +0000 (17:43 +0100)]
[clang][Interp][NFC] Add tests for __fp16

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

19 months ago[mlir][Analysis][NFC] Make BoundType a top-level enum
Matthias Springer [Thu, 23 Mar 2023 08:40:51 +0000 (09:40 +0100)]
[mlir][Analysis][NFC] Make BoundType a top-level enum

`BoundType` is no longer a nested member of `IntegerRelation` but a top-level enum in the `presburger` namespace.

This allows `BoundType` to be predeclared in header files. Nested members cannot be predeclared.

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

19 months ago[MLIR][Affine] Fix bug and MSAN issue in affine loop utils
Uday Bondhugula [Thu, 23 Mar 2023 07:45:22 +0000 (13:15 +0530)]
[MLIR][Affine] Fix bug and MSAN issue in affine loop utils

Fix bug and MSAN issue in affine loop utils introduced by
d25e022cd19b83c22a6022edb78c4b97a5fc1b49 (D146495). While on it,
fix/clean up issues in immediately surrounding code.

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

19 months ago[mlir][Analysis][NFC] Split FlatAffineValueConstraints into multiple classes
Matthias Springer [Thu, 23 Mar 2023 08:25:01 +0000 (09:25 +0100)]
[mlir][Analysis][NFC] Split FlatAffineValueConstraints into multiple classes

The new class hierarchy is as follows:

* `IntegerRelation` (no change)
* `IntegerPolyhedron` (no change)
* `FlatLinearConstraints`: provides an AffineExpr-based API
* `FlatLinearValueConstraints`: stores an additional mapping of non-local vars to SSA values
* `FlatAffineValueConstraints`: provides additional helper functions for Affine dialect ops
* `FlatAffineRelation` (no change)

`FlatConstraints` and `FlatValueConstraints` are moved from `MLIRAffineAnalysis` to `MLIRAnalysis` and can be used without depending on the Affine dialect.

This change is in preparation of D145681, which adds an MLIR interface that depends on `FlatConstraints` (and cannot depend on the Affine dialect or any other dialect).

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

19 months ago[clang-tidy] Ignore DISABLED_ in test suite name in google-avoid-underscore-in-google...
Carlos Galvez [Wed, 22 Mar 2023 18:47:48 +0000 (18:47 +0000)]
[clang-tidy] Ignore DISABLED_ in test suite name in google-avoid-underscore-in-googletest-name

Test suite name can also be disabled with DISABLED_, not just
the test case name.

Fix also broken link in the test that refers to the explanation
as to why underscores may not be used.

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

19 months ago[clang][dataflow] Fix crash when RHS of `&&` or `||` calls `noreturn` func.
Martin Braenne [Thu, 23 Mar 2023 07:45:40 +0000 (07:45 +0000)]
[clang][dataflow] Fix crash when RHS of `&&` or `||` calls `noreturn` func.

The crash happened because the transfer fucntion for `&&` and `||`
unconditionally tried to retrieve the value of the RHS. However, if the RHS
is unreachable, there is no environment for it, and trying to retrieve the
operand's value causes an assertion failure.

See also the comments in the code for further details.

Reviewed By: xazax.hun, ymandel, sgatev, gribozavr2

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

19 months ago[NFC] Fix typo lld::wasm in comment
Congcong Cai [Thu, 23 Mar 2023 07:40:55 +0000 (15:40 +0800)]
[NFC] Fix typo lld::wasm in comment

19 months ago[mlir][llvm] Switch rountrip tests to opaque pointers.
Tobias Gysi [Thu, 23 Mar 2023 07:13:54 +0000 (08:13 +0100)]
[mlir][llvm] Switch rountrip tests to opaque pointers.

The revision switches all remaining LLVM dialect roundtrip
tests to opaque pointers. Selected tests are copied to a
postfixed test file for the time being.

Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179

Reviewed By: zero9178

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

19 months ago[clang][Sema][NFC] Make local variable const
Timm Bäder [Thu, 23 Mar 2023 07:22:23 +0000 (08:22 +0100)]
[clang][Sema][NFC] Make local variable const

19 months ago[mlir][llvm] Add poison constant.
Théo Degioanni [Thu, 23 Mar 2023 06:58:37 +0000 (07:58 +0100)]
[mlir][llvm] Add poison constant.

This patch introduces the poison constant from LLVM in the LLVM IR dialect. It also adds import and export support for it, along with roundtrip tests.

Reviewed By: gysit

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

19 months ago[InstCombine] Precommit tests
Kazu Hirata [Thu, 23 Mar 2023 06:27:59 +0000 (23:27 -0700)]
[InstCombine] Precommit tests

This patch precommits tests for:

https://github.com/llvm/llvm-project/issues/61183

19 months ago[TableGen] Change push_back back to emplace_back.
Craig Topper [Thu, 23 Mar 2023 06:17:15 +0000 (23:17 -0700)]
[TableGen] Change push_back back to emplace_back.

This was a mistake I made in 021edda0b20468e20a72b1788721b2b70228bffb.

19 months ago[TableGen] Simplify CodeGenHwModes constructor. NFC
Craig Topper [Thu, 23 Mar 2023 06:00:06 +0000 (23:00 -0700)]
[TableGen] Simplify CodeGenHwModes constructor. NFC

Remove the loop that erases the DefaultMode from the Record vector.
Instead we can skip over in the loop that creates HwMode objects.

19 months ago[libfuzzer] add test of cov file-id in control file
Wu, Yingcong [Thu, 23 Mar 2023 04:49:19 +0000 (21:49 -0700)]
[libfuzzer] add test of cov file-id in control file

There is test for ft file-id in control file, but no test for cov line.
Without the test, a invalid cov file-id would cause crash.

Reviewed By: vitalybuka

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

19 months ago[Pseudo Probe] Use the name from debug info to compute GUID in probe desc
wlei [Wed, 22 Mar 2023 20:13:27 +0000 (13:13 -0700)]
[Pseudo Probe] Use the name from debug info to compute GUID in probe desc

This is to fix a GUID mismatch while decoding pseudo probe, a GUID from the inline tree is not in the GUID2FuncDescMap. It turned out that frontend could change the function name making it different from the one in debug info(https://reviews.llvm.org/D111009). Here change to use the function name from debug info to be consistent with the probe name from the inline stack.

Reviewed By: hoy, wenlei

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

19 months ago[llvm] Skip getAPIntValue (NFC)
Kazu Hirata [Thu, 23 Mar 2023 05:10:25 +0000 (22:10 -0700)]
[llvm] Skip getAPIntValue (NFC)

ConstantSDNode provides some convenience functions like isZero,
getZExtValue, and isMinSignedValue that are named identically to those
provided by APInt, so we can "skip" getAPIntValue.

19 months ago[ARM] Use isNullConstant (NFC)
Kazu Hirata [Thu, 23 Mar 2023 05:10:23 +0000 (22:10 -0700)]
[ARM] Use isNullConstant (NFC)

19 months ago[InstCombine] Precommit a test
Kazu Hirata [Thu, 23 Mar 2023 05:10:22 +0000 (22:10 -0700)]
[InstCombine] Precommit a test

This patch precommits a test for:

https://github.com/llvm/llvm-project/issues/61183

19 months ago[InstCombine] Precommit tests
Kazu Hirata [Thu, 23 Mar 2023 05:10:20 +0000 (22:10 -0700)]
[InstCombine] Precommit tests

This patch precommits tests for:

https://github.com/llvm/llvm-project/issues/60802

19 months ago[TLI] Fold ~X >/< ~Y --> Y >/< X
Jun Zhang [Thu, 23 Mar 2023 04:49:05 +0000 (12:49 +0800)]
[TLI] Fold ~X >/< ~Y --> Y >/< X

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

Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D146512

19 months agoPrecommit test for #61120
Jun Zhang [Thu, 23 Mar 2023 04:48:59 +0000 (12:48 +0800)]
Precommit test for #61120

Signed-off-by: Jun Zhang <jun@junz.org>
19 months ago[-Wunsafe-buffer-usage] Add [[fallthrough]] after D143206
Fangrui Song [Thu, 23 Mar 2023 04:02:00 +0000 (21:02 -0700)]
[-Wunsafe-buffer-usage] Add [[fallthrough]] after D143206

19 months agoRecommit [Modules] Remove unnecessary check when generating name lookup table in...
Chuanqi Xu [Thu, 23 Mar 2023 03:21:35 +0000 (11:21 +0800)]
Recommit [Modules] Remove unnecessary check when generating name lookup table in ASTWriter

Close https://github.com/llvm/llvm-project/issues/61065.

We will avoid writing the names from external AST naturally. But
currently its check is often false positive since we may have already
marked the declarations as external but
DeclContext::hasNeedToReconcileExternalVisibleStorage would be false
after reconciling.

Tested with libcxx's modular build.

This patch can improve 8% compilation time in an internal workloads.

See the discussion in
https://reviews.llvm.org/rG1e0709167f5edd330889f51bb203c458bdb5e359
to see the information for recommitting.

19 months ago[mlir][tosa] TosaToLinalg: Lower TOSA.Cast via RoundEven according to TOSA spec 0...
Matthias Gehre [Thu, 23 Mar 2023 01:08:43 +0000 (01:08 +0000)]
[mlir][tosa] TosaToLinalg: Lower TOSA.Cast via RoundEven according to TOSA spec 0.60.0

TOSA now specifies rounding of ties to even in section 1.8.2., "Main Inference Profile"

Reviewed By: eric-k256, rsuderman

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

19 months ago[mlir][affine] Prevent vectorizer test from crash without any map
Kai Sasaki [Thu, 23 Mar 2023 00:59:29 +0000 (09:59 +0900)]
[mlir][affine] Prevent vectorizer test from crash without any map

If the vectorizer test pass does not get any affine map, it should output nothing instead of crash.

Issue: https://github.com/llvm/llvm-project/issues/61534

Reviewed By: nicolasvasilache, dcaballe

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

19 months ago[libc] Adjust NVPTX startup code
Joseph Huber [Thu, 23 Mar 2023 00:58:08 +0000 (19:58 -0500)]
[libc] Adjust NVPTX startup code

Summary:
The startup code needs to include the environment pointer so we add this
to the arguments. Also we need to ensure that the `crt1.o` file is made
with `-fgpu-rdc` set so we can actually use it without undefined
reference errors.

19 months ago[RISCV][NFC] Add more tests for SLP vectorization (binops on load/store)
Ben Shi [Tue, 14 Mar 2023 09:27:47 +0000 (17:27 +0800)]
[RISCV][NFC] Add more tests for SLP vectorization (binops on load/store)

Reviewed By: reames

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

19 months ago[mlir] Fix typo for unknown operation
Kai Sasaki [Thu, 23 Mar 2023 00:50:40 +0000 (09:50 +0900)]
[mlir] Fix typo for unknown operation

Reviewed By: rriddle

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

19 months agoAdd "REQUIRES: asserts" to test that uses --debug-only flag
Amy Huang [Wed, 22 Mar 2023 22:55:18 +0000 (15:55 -0700)]
Add "REQUIRES: asserts" to test that uses --debug-only flag

19 months ago[NVPTX] Port GenericToNVVM to the new PM.
Pavel Kopyl [Thu, 16 Mar 2023 20:53:14 +0000 (21:53 +0100)]
[NVPTX] Port GenericToNVVM to the new PM.

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

19 months ago[mlir][arith] Fix typos in WIE. NFC.
Jakub Kuderski [Wed, 22 Mar 2023 23:15:12 +0000 (19:15 -0400)]
[mlir][arith] Fix typos in WIE. NFC.

19 months ago[mlir][arith] Add `sitofp` support to WIE
Jakub Kuderski [Wed, 22 Mar 2023 23:09:48 +0000 (19:09 -0400)]
[mlir][arith] Add `sitofp` support to WIE

This depends on the handling of `uitofp` in D146606.

Reviewed By: antiagainst

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