platform/upstream/llvm.git
2 years ago[RISCV][NFC] Improve encoding/decoding tests for Zbb/Zbp/Zbt instructions
Liqin Weng [Tue, 29 Mar 2022 07:44:44 +0000 (15:44 +0800)]
[RISCV][NFC] Improve encoding/decoding tests for Zbb/Zbp/Zbt instructions

Reviewed By: benshi001

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

2 years ago[flang] prevent undefined behavior in character MAXLOC folding
Jean Perier [Mon, 28 Mar 2022 17:05:36 +0000 (19:05 +0200)]
[flang] prevent undefined behavior in character MAXLOC folding

When folding MAXLOC/MINLOC, the current element being compared was moved twice
in row in case it became the new extremum. With numeric and logical types, it
made no difference (std::move is a no-op for them), but for characters
where the string storage is actually moved, it caused the new extremum to
be set to the empty string, leading to wrong results.

Note: I could have left the first std::move relating to logical Findloc, but it
brings nothing and makes the code less auditable, so I also removed it.

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

2 years ago[RISCV][NFC] Remove redundant check and rename functions in some IR tests
Lian Wang [Tue, 22 Mar 2022 06:07:17 +0000 (06:07 +0000)]
[RISCV][NFC] Remove redundant check and rename functions in some IR tests

Reviewed By: frasercrmck

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

2 years ago[clang][DR] Test and mark DR1479 as complete
Markus Böck [Tue, 29 Mar 2022 07:28:17 +0000 (09:28 +0200)]
[clang][DR] Test and mark DR1479 as complete

DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1479

Clang has implemented this DR as far back as I could go on compiler explorer (3.0). This patch simply adds a test case and needed comments for the update script to mark it as complete.

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

2 years ago[Support/BLAKE3] Re-enable building with the simd-optimized implementations
Argyrios Kyrtzidis [Tue, 29 Mar 2022 04:00:58 +0000 (21:00 -0700)]
[Support/BLAKE3] Re-enable building with the simd-optimized implementations

2 years ago[LSR] Fixup canonicalization formula and its checker.
Serguei Katkov [Fri, 25 Mar 2022 03:19:01 +0000 (10:19 +0700)]
[LSR] Fixup canonicalization formula and its checker.

According to definition of canonical form, it is a canonical
if scale reg does not contain addrec for loop L then none of bases
should contain addrec for this loop.

The critical word here is "contains".

Current checker of canonical form checks not "containing" property
but "is". So it does not check whether it contains but whether it is.

Fix the checker and canonicalizing utility to follow definition.

Without this fix in the test attached the base formula looking as
reg((-1 * {0,+,8}<nuw><nsw><%bb2>)<nsw>) + 1*reg((8 * (%arg /u 8))<nuw>)
is considered as conanocial while base contains an addrec.
And modified formula we want to insert
reg({0,+,8}<nuw><nsw><%bb2>) + 1*reg((-8 * (%arg /u 8)))
is considered as not canonical.

Reviewed By: mkazantsev
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D122457

2 years agoCleanup includes: final pass
serge-sans-paille [Mon, 28 Mar 2022 12:10:26 +0000 (14:10 +0200)]
Cleanup includes: final pass

Cleanup a few extra files, this closes the work on libLLVM dependencies on my
side.

Impact on libLLVM preprocessed output: -35876 lines

Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup
Differential Revision: https://reviews.llvm.org/D122576

2 years ago[RISCV][test] Make PATH empty when testing --gcc-toolchain is multilib_riscv_elf_sdk
luxufan [Tue, 29 Mar 2022 03:03:33 +0000 (11:03 +0800)]
[RISCV][test] Make PATH empty when testing --gcc-toolchain is multilib_riscv_elf_sdk

Due to D79842, clang dirver would search possible tool name in both possible
locations, then moving to the next name. The gcc toolchain `llvm-project/clang/test/Driver/
Inputs/multilib_riscv_elf_sdk` don't have a `riscv64-unknown-elf-ld` executable in
`llvm-project/clang/test/Driver/Inputs/multilib_riscv_elf_sdk/bin/`. So when searching
`riscv64-unknown-elf-ld`, if there is a `riscv64-unknown-elf-ld` in `PATH`, the
test would fail.

This patch makes the `PATH` empty when testing it.

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

2 years ago[RISCV] Optimize LI+SLT to SLTI+XORI for immediates in specific range
Liqin Weng [Tue, 29 Mar 2022 06:46:17 +0000 (14:46 +0800)]
[RISCV] Optimize LI+SLT to SLTI+XORI for immediates in specific range

This transform will reduce one GPR.

Reviewed By: craig.topper, benshi001

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

2 years ago[gn build] Port 90cb325abda9
LLVM GN Syncbot [Tue, 29 Mar 2022 06:21:57 +0000 (06:21 +0000)]
[gn build] Port 90cb325abda9

2 years agoRevert "[misexpect] Re-implement MisExpect Diagnostics"
Paul Kirth [Tue, 29 Mar 2022 06:20:30 +0000 (06:20 +0000)]
Revert "[misexpect] Re-implement MisExpect Diagnostics"

This reverts commit 2add3fbd976d7b80a3a7fc14ef0deb9b1ca6beee.

2 years agoRevert "[docs][misexpect][NFC] Fix malformed table in docs"
Paul Kirth [Tue, 29 Mar 2022 06:19:53 +0000 (06:19 +0000)]
Revert "[docs][misexpect][NFC] Fix malformed table in docs"

This reverts commit a427e18896dee3cd00d5f565cfb9d7d2f26ebcec.

2 years ago[flang][OpenMP] Added parallel sections translation
Shraiysh Vaishay [Tue, 29 Mar 2022 05:12:45 +0000 (10:42 +0530)]
[flang][OpenMP] Added parallel sections translation

This patch adds translation for parallel sections from PFT to MLIR.

Reviewed By: kiranchandramohan, NimishMishra

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

2 years ago[clangd] Handle tabs in getIncrementalChangesAfterNewline()
Nathan Ridge [Mon, 28 Mar 2022 06:13:20 +0000 (02:13 -0400)]
[clangd] Handle tabs in getIncrementalChangesAfterNewline()

Tabs are not handled by columnWidthUTF8() (they are considered
non-printable) so require additional logic to handle.

Fixes https://github.com/clangd/clangd/issues/1074

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

2 years ago[OpenMP] The test does not have check lines
Johannes Doerfert [Tue, 29 Mar 2022 05:02:28 +0000 (00:02 -0500)]
[OpenMP] The test does not have check lines

2 years ago[scudo] Use template specialization on Quarantine to avoid zero-length array
Dominic Chen [Fri, 25 Mar 2022 23:44:31 +0000 (16:44 -0700)]
[scudo] Use template specialization on Quarantine to avoid zero-length array

Use a separate templated QuarantineBlocks class to avoid a zero-length array

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

2 years ago[OpenMP][FIX] Use clang++ for the C++ test case
Johannes Doerfert [Tue, 29 Mar 2022 04:14:00 +0000 (23:14 -0500)]
[OpenMP][FIX] Use clang++ for the C++ test case

2 years ago[Driver][AVR] Emit proper warnings for different options
Ben Shi [Tue, 29 Mar 2022 04:05:05 +0000 (12:05 +0800)]
[Driver][AVR] Emit proper warnings for different options

Reviewed By: MaskRay

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

2 years ago[RISCV] Pull APInt/computeKnonwbits specifics out of computeGREVOrGORC. NFC
Craig Topper [Tue, 29 Mar 2022 02:31:20 +0000 (19:31 -0700)]
[RISCV] Pull APInt/computeKnonwbits specifics out of computeGREVOrGORC. NFC

This function now takes a uint64_t instead of an APInt. The caller
is responsible for masking the shift amount, extracting and inserting
into the KnownBits APInts, and inverting to compute zeros.

This is less code and cleaner division of responsibilities.

2 years ago[OpenMP][FIX] Avoid races in the handling of to be deleted mapping entries
Johannes Doerfert [Wed, 2 Mar 2022 19:46:01 +0000 (13:46 -0600)]
[OpenMP][FIX] Avoid races in the handling of to be deleted mapping entries

If we decided to delete a mapping entry we did not act on it right away
but first issued and waited for memory copies. In the meantime some
other thread might reuse the entry. While there was some logic to avoid
colliding on the actual "deletion" part, there were two races happening:

1) The data transfer back of the thread deleting the entry and
   the data transfer back of the thread taking over the entry raced.
2) The update to the shadow map happened regardless if the entry was
   actually reused by another thread which left the shadow map in a
   inconsistent state.

To fix both issues we will now update the shadow map and delete the
entry only if we are sure the thread is responsible for deletion, hence
no other thread took over the entry and reused it. We also wait for a
potential former data transfer from the device to finish before we issue
another one that would race with it.

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

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

2 years ago[OpenMP][NFC] Add missing virtual destructor to silence warning
Johannes Doerfert [Fri, 25 Mar 2022 21:07:57 +0000 (16:07 -0500)]
[OpenMP][NFC] Add missing virtual destructor to silence warning

2 years ago[X86][regcall] Support passing / returning structures
Phoebe Wang [Tue, 29 Mar 2022 01:41:31 +0000 (09:41 +0800)]
[X86][regcall] Support passing / returning structures

Currently, the regcall calling conversion in Clang doesn't match with
ICC when passing / returning structures. https://godbolt.org/z/axxKMKrW7

This patch tries to fix the problem to match with ICC.

Reviewed By: LuoYuanke

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

2 years agoRevert D122459 "[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations"
Fangrui Song [Tue, 29 Mar 2022 03:26:21 +0000 (20:26 -0700)]
Revert D122459 "[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations"

This reverts commit 6faba31e0d88ce71e87567ddb51d2444524b8a81.

It may cause "offset is outside the section".

2 years ago[memcpyopt] Common code into performCallSlotOptzn [NFC]
Philip Reames [Tue, 29 Mar 2022 03:06:22 +0000 (20:06 -0700)]
[memcpyopt] Common code into performCallSlotOptzn [NFC]

We have the same code repeated in both callers, sink it into callee.

The motivation here isn't just code style, we can also defer the relatively expensive aliasing checks until the cheap structural preconditions have been validated.  (e.g. Don't bother aliasing if src is not an alloca.)  This helps compile time significantly.

2 years ago[slp] Delete dead scalar instructions feeding vectorized instructions
Philip Reames [Tue, 29 Mar 2022 02:28:13 +0000 (19:28 -0700)]
[slp] Delete dead scalar instructions feeding vectorized instructions

If we vectorize a e.g. store, we leave around a bunch of getelementptrs for the individual scalar stores which we removed. We can go ahead and delete them as well.

This is purely for test output quality and readability. It should have no effect in any sane pipeline.

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

2 years ago[mlir] Fix leak in case of failed parse
Jacques Pienaar [Tue, 29 Mar 2022 03:04:31 +0000 (20:04 -0700)]
[mlir] Fix leak in case of failed parse

A Block is optionally allocated & leaks in case of failed parse. Inline the
function and ensure Block gets freed unless parse is successful.

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

2 years ago[AArch64][GlobalISel] Add new MOVI pattern for fp constants
zhongyunde [Tue, 29 Mar 2022 00:39:23 +0000 (08:39 +0800)]
[AArch64][GlobalISel] Add new MOVI pattern for fp constants

GlobalISel is used in option -O0, so add MOVI pattern for it,
which is done similar in gcc.(https://godbolt.org/z/8j6fzG3h6)

Fix https://github.com/llvm/llvm-project/issues/53651

Reviewed By: dmgreen, paquette

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

2 years agoEliminate gcc7 compiler warnings
long.chen [Tue, 29 Mar 2022 02:55:37 +0000 (19:55 -0700)]
Eliminate gcc7 compiler warnings

we will get warning:```parameter ‘op’ set but not used``` when template function with empty template parameter list.

Reviewed By: jpienaar

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

2 years ago[libcxx] random_device, specify optimal entropy properties for all OS's using arc4ran...
Brad Smith [Tue, 29 Mar 2022 02:27:28 +0000 (22:27 -0400)]
[libcxx] random_device, specify optimal entropy properties for all OS's using arc4random()

Reviewed By: ldionne

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

2 years agoRevert "[scudo] Use template specialization on Quarantine to avoid zero-length array"
Dominic Chen [Tue, 29 Mar 2022 02:08:55 +0000 (19:08 -0700)]
Revert "[scudo] Use template specialization on Quarantine to avoid zero-length array"

This reverts commit 7dda44c189d74ec0a1bbe7dfff7c4d5f6b0e96d4.

2 years ago[RISCV] [NFC] add some tests for overloaded intrinsics of FP16
Chenbing Zheng [Tue, 29 Mar 2022 01:55:06 +0000 (09:55 +0800)]
[RISCV] [NFC] add some tests for overloaded intrinsics of FP16

Reviewed By: craig.topper

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

2 years ago[Attributor][OpenMP] Add assumption for non-call assembly instructions
Johannes Doerfert [Sat, 11 Sep 2021 23:34:47 +0000 (18:34 -0500)]
[Attributor][OpenMP] Add assumption for non-call assembly instructions

Inline assembly is scary but we need to support it for the OpenMP GPU
device runtime. The new assumption expresses the fact that it may not
have call semantics, that is, it will not call another function but
simply perform an operation or side-effect. This is important for
reachability in the presence of inline assembly.

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

2 years ago[InstCombineCalls] Optimize call of bitcast even w/ parameter attributes
Johannes Doerfert [Mon, 14 Feb 2022 23:12:34 +0000 (17:12 -0600)]
[InstCombineCalls] Optimize call of bitcast even w/ parameter attributes

Before we gave up if a call through bitcast had parameter attributes.
Interestingly, we allowed attributes for the return value already. We
now handle both the same way, namely, we drop the ones that are
incompatible with the new type and keep the rest. This cannot cause
"more UB" than initially present.

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

2 years ago[NFC][CodeGen] Add a setTargetDAGCombine use ArrayRef
Shao-Ce SUN [Mon, 28 Mar 2022 18:31:39 +0000 (02:31 +0800)]
[NFC][CodeGen] Add a setTargetDAGCombine use ArrayRef

Reviewed By: arsenm

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

2 years ago[AArch64] Allow .variant_pcs before the symbol is registered
Fangrui Song [Tue, 29 Mar 2022 00:52:27 +0000 (17:52 -0700)]
[AArch64] Allow .variant_pcs before the symbol is registered

glibc sysdeps/aarch64/tst-vpcs-mod.S has something like:
```
.variant_pcs    vpcs_call
.global vpcs_call
```

This is supported by GNU as but leads to an error in MC. Use getOrCreateSymbol
to support a not-yet-registered symbol: call `registerSymbol` to ensure the
symbol exists even if there is no binding directive/label, to match GNU as.

While here, improve tests to check (1) a local symbol can get
STO_AARCH64_VARIANT_PCS (2) undefined .variant_pcs (3) an alias does not
inherit STO_AARCH64_VARIANT_PCS.

Reviewed By: efriedma

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

2 years ago[docs][misexpect][NFC] Fix malformed table in docs
Paul Kirth [Mon, 28 Mar 2022 23:50:51 +0000 (23:50 +0000)]
[docs][misexpect][NFC] Fix malformed table in docs

Reviewed By: abrachet

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

2 years ago[RISCV] Add computeKnownBits support for RISCVISD::GORC.
Craig Topper [Mon, 28 Mar 2022 23:44:57 +0000 (16:44 -0700)]
[RISCV] Add computeKnownBits support for RISCVISD::GORC.

Reviewed By: luismarques

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

2 years ago[Driver] Make -moutline-atomics default for aarch64-fuchsia targets
Roland McGrath [Mon, 28 Mar 2022 21:05:23 +0000 (14:05 -0700)]
[Driver] Make -moutline-atomics default for aarch64-fuchsia targets

This makes Fuchsia consistent with Linux on AArch64.

Reviewed By: abrachet

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

2 years ago[libc] Set rtlib to compiler-rt in integration tests.
Siva Chandra Reddy [Mon, 28 Mar 2022 21:11:08 +0000 (21:11 +0000)]
[libc] Set rtlib to compiler-rt in integration tests.

The clang driver to picks up compiler runtime files using full paths.
Without this, at least for aarch64, the driver tries to pick up the
compiler runtime files from the working directory.

Reviewed By: michaelrj

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

2 years ago[gn build] Port 2add3fbd976d
LLVM GN Syncbot [Mon, 28 Mar 2022 23:38:54 +0000 (23:38 +0000)]
[gn build] Port 2add3fbd976d

2 years ago[scudo] Use cast on calls to __builtin_umul_overflow/__builtin_umull_overflow
Dominic Chen [Wed, 16 Mar 2022 20:40:58 +0000 (13:40 -0700)]
[scudo] Use cast on calls to __builtin_umul_overflow/__builtin_umull_overflow

Platforms may define uintptr_t differently, so perform an explicit cast

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

2 years ago[scudo] Use template specialization on Quarantine to avoid zero-length array
Dominic Chen [Fri, 25 Mar 2022 23:44:31 +0000 (16:44 -0700)]
[scudo] Use template specialization on Quarantine to avoid zero-length array

Use a separate templated QuarantineBlocks class to avoid a zero-length array

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

2 years ago[misexpect] Re-implement MisExpect Diagnostics
Paul Kirth [Sat, 19 Mar 2022 00:54:23 +0000 (00:54 +0000)]
[misexpect] Re-implement MisExpect Diagnostics

Reimplements MisExpect diagnostics from D66324 to reconstruct its
original checking methodology only using MD_prof branch_weights
metadata.

New checks rely on 2 invariants:

1) For frontend instrumentation, MD_prof branch_weights will always be
   populated before llvm.expect intrinsics are lowered.

2) for IR and sample profiling, llvm.expect intrinsics will always be
   lowered before branch_weights are populated from the IR profiles.

These invariants allow the checking to assume how the existing branch
weights are populated depending on the profiling method used, and emit
the correct diagnostics. If these invariants are ever invalidated, the
MisExpect related checks would need to be updated, potentially by
re-introducing MD_misexpect metadata, and ensuring it always will be
transformed the same way as branch_weights in other optimization passes.

Frontend based profiling is now enabled without using LLVM Args, by
introducing a new CodeGen option, and checking if the -Wmisexpect flag
has been passed on the command line.

Reviewed By: tejohnson

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

2 years agoSilence compiler warning after the addition of HLSL to Clang
Benjamin Kramer [Mon, 28 Mar 2022 23:21:52 +0000 (01:21 +0200)]
Silence compiler warning after the addition of HLSL to Clang

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:472:16: warning: enumeration value 'HLSL' not handled in switch [-Wswitch]
    switch (IK.getLanguage()) {
               ^

2 years ago[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations
Fangrui Song [Mon, 28 Mar 2022 23:23:13 +0000 (16:23 -0700)]
[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations

.eh_frame pieces may be dropped due to GC/ICF. When --emit-relocs adds
relocations against .eh_frame, the offsets need to be adjusted. Use the same
way as MergeInputSection with a special case handling outSecOff==-1 for an
invalid piece (see eh-frame-marker.s).

This exposes an issue in mips64-eh-abs-reloc.s that we don't reliably
handle anyway. Just add --no-check-dynamic-relocations to paper over it.

Original patch by Ayrton Muñoz

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

2 years agoRevert 29fada4a3d3db309f11f7fa7a0c61cd4021e9947
Alina Sbirlea [Mon, 28 Mar 2022 23:16:07 +0000 (16:16 -0700)]
Revert 29fada4a3d3db309f11f7fa7a0c61cd4021e9947

Seeing a test failure with asan in Halide generated code, reverting
while I investigate.

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

2 years ago[ELF][test] Refactor some .eh_frame tests
Fangrui Song [Mon, 28 Mar 2022 22:55:46 +0000 (15:55 -0700)]
[ELF][test] Refactor some .eh_frame tests

* Improve eh-frame-merge.s
* Delete invalid .eh_frame+5 test in ehframe-relocation.s

2 years ago[mlir] Update Vector dialect to prefixed accessors.
Jacques Pienaar [Mon, 28 Mar 2022 22:44:40 +0000 (15:44 -0700)]
[mlir] Update Vector dialect to prefixed accessors.

Been >2 weeks since flipped to Both, following update procedure and
flipping to prefixed.

2 years ago[Clang] Implement __builtin_source_location.
James Y Knight [Mon, 28 Mar 2022 22:27:18 +0000 (18:27 -0400)]
[Clang] Implement __builtin_source_location.

This builtin returns the address of a global instance of the
`std::source_location::__impl` type, which must be defined (with an
appropriate shape) before calling the builtin.

It will be used to implement std::source_location in libc++ in a
future change. The builtin is compatible with GCC's implementation,
and libstdc++'s usage. An intentional divergence is that GCC declares
the builtin's return type to be `const void*` (for
ease-of-implementation reasons), while Clang uses the actual type,
`const std::source_location::__impl*`.

In order to support this new functionality, I've also added a new
'UnnamedGlobalConstantDecl'. This artificial Decl is modeled after
MSGuidDecl, and is used to represent a generic concept of an lvalue
constant with global scope, deduplicated by its value. It's possible
that MSGuidDecl itself, or some of the other similar sorts of things
in Clang might be able to be refactored onto this more-generic
concept, but there's enough special-case weirdness in MSGuidDecl that
I gave up attempting to share code there, at least for now.

Finally, for compatibility with libstdc++'s <source_location> header,
I've added a second exception to the "cannot cast from void* to T* in
constant evaluation" rule. This seems a bit distasteful, but feels
like the best available option.

Reviewers: aaron.ballman, erichkeane

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

2 years ago[mlir] Update the Builtin dialect to use prefixed accessors
Jacques Pienaar [Mon, 28 Mar 2022 22:20:48 +0000 (15:20 -0700)]
[mlir] Update the Builtin dialect to use prefixed accessors

Been >2 weeks since flipped to Both, following update procedure and
flipping to prefixed.

2 years ago[Bazel] Update zlib to 1.2.12
Geoffrey Martin-Noble [Mon, 28 Mar 2022 21:48:18 +0000 (14:48 -0700)]
[Bazel] Update zlib to 1.2.12

There's a vulnerability in 1.2.11:
https://twitter.com/taviso/status/1508438583484452866

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

2 years ago[attributes] Generalize attribute 'enforce_tcb' to Objective-C methods.
Pierre d'Herbemont [Mon, 28 Mar 2022 20:24:02 +0000 (13:24 -0700)]
[attributes] Generalize attribute 'enforce_tcb' to Objective-C methods.

Calling an ObjC method from a C function marked with the 'enforce_tcb'
attribute did not produce a warning. Now it does, and on top of that
Objective-C methods can participate in TCBs themselves.

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

2 years agoLet clang-repl link privately against Clang components
Aaron Puchert [Mon, 28 Mar 2022 21:53:50 +0000 (23:53 +0200)]
Let clang-repl link privately against Clang components

First of all, this is the convention: all other tools have their
dependencies private. While it does not have an effect on linking
(there is no linking against executables), it does have an effect
on exporting: having the targets private allows installing the tools
without the libraries in a statically linked build, or a build against
libclang-cpp.so.

Reviewed By: v.g.vassilev

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

2 years agoItaniumDemangler: Update BinaryExpr::match to match the ctor
David Blaikie [Mon, 28 Mar 2022 21:21:37 +0000 (21:21 +0000)]
ItaniumDemangler: Update BinaryExpr::match to match the ctor

Not sure if this could use more testing, but hopefully this is adequate.

2 years ago[clang-tidy] Utilize comparison operation implemented in APInt
Danny Mösch [Sun, 27 Mar 2022 14:41:32 +0000 (16:41 +0200)]
[clang-tidy] Utilize comparison operation implemented in APInt

This is a fix for #53963.

Reviewed By: aaron.ballman

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

2 years ago[clang-format] Don't format qualifiers in PPDirective
owenca [Sun, 27 Mar 2022 20:19:02 +0000 (13:19 -0700)]
[clang-format] Don't format qualifiers in PPDirective

Fixes #54513

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

2 years agoAdd HLSL Language Option and Preprocessor
Chris Bieneman [Mon, 28 Mar 2022 20:01:41 +0000 (15:01 -0500)]
Add HLSL Language Option and Preprocessor

Bringing in HLSL as a language as well as language options for each of
the HLSL language standards.

While the HLSL language is unimplemented, this patch adds the
HLSL-specific preprocessor defines which enables testing of the command
line options through the driver.

Reviewed By: pete, rnk

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

2 years ago[flang][driver] Make --version and -version consistent with clang
Emil Kieri [Mon, 28 Mar 2022 18:28:51 +0000 (20:28 +0200)]
[flang][driver] Make --version and -version consistent with clang

This patch makes -version valid, and --version invalid, for
flang-new -fc1. The invocation
  flang-new --version
remains valid. This behaviour is consistent with clang
(and with clang -cc1 and clang -cc1as).

Previously, flang-new -fc1 accepted --version (as per Options.td), but
the frontend driver acutally checks for -version. As a result,
  flang-new -fc1 --version
triggered no action, emitted no message, and stalled waiting for
standard input.

Fixes #51438

Reviewed By: PeteSteinfeld, awarzynski

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

2 years ago[MC] Fix llvm_unreachable when a STB_GNU_UNIQUE symbol needs a relocation
Fangrui Song [Mon, 28 Mar 2022 20:40:48 +0000 (13:40 -0700)]
[MC] Fix llvm_unreachable when a STB_GNU_UNIQUE symbol needs a relocation

STB_GNU_UNIQUE should be treated in a way similar to STB_GLOBAL.
This fixes an "Invalid Binding" failure in an LLVM_ENABLE_ASSERTIONS=on build
for source files like glibc elf/tst-unique1mod1.c .

This bug has been benign so far because (a) Clang does not produce
%gnu_unique_object by itself (b) a non-assertion build likely picks the
STB_GLOBAL code path anyway.

2 years ago[gn build] Port c5e54e275241
LLVM GN Syncbot [Mon, 28 Mar 2022 20:09:41 +0000 (20:09 +0000)]
[gn build] Port c5e54e275241

2 years ago[InstCombine] Fold two select patterns into and-or
chenglin.bi [Mon, 28 Mar 2022 20:05:22 +0000 (16:05 -0400)]
[InstCombine] Fold two select patterns into and-or

select (~a | c), a, b -> and a, (or c, b) https://alive2.llvm.org/ce/z/bnDobs
select (~c & b), a, b -> and b, (or a, c) https://alive2.llvm.org/ce/z/k2jJHJ

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

2 years ago[clang] Make Driver tests pass when running with temp dir containing "crt"
Nico Weber [Sun, 27 Mar 2022 20:10:02 +0000 (16:10 -0400)]
[clang] Make Driver tests pass when running with temp dir containing "crt"

In a recent run, temp files got created in /tmp/lit-tmp-2wcrtcx1/foo-xxx.o.
Since the tmp path contained "crt", this made a few tests fail:
http://45.33.8.238/linux/72221/step_7.txt

Not allowing '/' as path of the file name prevents this.

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

2 years ago[mlir] tosa: build error when building with clang
lipracer [Mon, 28 Mar 2022 20:01:46 +0000 (20:01 +0000)]
[mlir] tosa: build error when building with clang

The change of https://reviews.llvm.org/D121513#3411651
has caused a build error when building with clang:

/mnt/vss/_work/1/llvm-project/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp:599:26: error: extra ';' outside of a function is incompatible with C++98 [-Werror,-Wc++98-compat-extra-semi]
ReduceFolder(ReduceAllOp);

Reviewed By: hpmorgan, Mogball

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

2 years agoAdd clang DirectX target support
Chris Bieneman [Mon, 28 Mar 2022 18:45:41 +0000 (13:45 -0500)]
Add clang DirectX target support

This change adds a stub DirectX target for clang to enable targeting
dxil targets.

Reviewed By: pete

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

2 years ago[RISCV][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI.
Craig Topper [Mon, 28 Mar 2022 19:33:53 +0000 (12:33 -0700)]
[RISCV][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI.

Modified DAGCombiner to pass the shift the bittest input and the shift amount
to hasBitTest. This matches the other call to hasBitTest in TargetLowering.h

This is an alternative to D122454.

Reviewed By: luismarques

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

2 years ago[RISCV] add tests for minnum/maxnum; NFC
Sanjay Patel [Mon, 28 Mar 2022 18:21:39 +0000 (14:21 -0400)]
[RISCV] add tests for minnum/maxnum; NFC

Issue #54554

2 years ago[mlir] Allow RegionRange to accept ArrayRef<Region *>
Mogball [Fri, 25 Mar 2022 22:44:34 +0000 (22:44 +0000)]
[mlir] Allow RegionRange to accept ArrayRef<Region *>

Adds another pointer to the union in RegionRange to allow RegionRange to work on ArrayRef<Region *> (i.e. vectors of Region *).

Reviewed By: rriddle

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

2 years ago[mlir][cf-sink] Accept a callback for sinking operations
Mogball [Fri, 25 Mar 2022 21:13:30 +0000 (21:13 +0000)]
[mlir][cf-sink] Accept a callback for sinking operations

(This was a TODO from the initial patch).

The control-flow sink utility accepts a callback that is used to sink an operation into a region.
The `moveIntoRegion` is called on the same operation and region that return true for `shouldMoveIntoRegion`.
The callback must preserve the dominance of the operation within the region. In the default control-flow
sink implementation, this is moving the operation to the start of the entry block.

Reviewed By: mehdi_amini

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

2 years ago[AMDGPU][NFC]: Remove unnecessary MFI functions
Changpeng Fang [Mon, 28 Mar 2022 19:13:33 +0000 (12:13 -0700)]
[AMDGPU][NFC]: Remove unnecessary MFI functions

Summary:
  hasHostcallPtr() and hasHeapPtr() are only used in metadata emit.
However, we can use the corresponding function attributes directly
instead introducing the functions.

Reviewers: arsenm

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

2 years ago[clang][NFC] Remove unused parameter in `Sema::ActOnDuplicateDefinition`.
Volodymyr Sapsai [Fri, 25 Mar 2022 22:05:00 +0000 (15:05 -0700)]
[clang][NFC] Remove unused parameter in `Sema::ActOnDuplicateDefinition`.

2 years ago[AIX][XCOFF] address post-commit review comments of patch https://reviews.llvm.org...
zhijian [Mon, 28 Mar 2022 19:05:41 +0000 (15:05 -0400)]
[AIX][XCOFF] address post-commit review comments of patch https://reviews.llvm.org/D82549
Summary:
Address post-commit review comments in the https://reviews.llvm.org/D82549, including

changed file name from llvm/test/tools/llvm-readobj/XCOFF/xcoff-auxiliary-header.test --> llvm/test/tools/llvm-readobj/XCOFF/auxiliary-header.test
replaced macro define by using lambda function.
added a helper function to reduce the duplicated check and print error code.

Reviewer : James Henderson
Differential Revision: https://reviews.llvm.org/D116220

2 years ago[compiler-rt][AArch64] Initialize __aarch64_have_lse_atomics for Fuchsia
Roland McGrath [Wed, 2 Feb 2022 20:18:23 +0000 (12:18 -0800)]
[compiler-rt][AArch64] Initialize __aarch64_have_lse_atomics for Fuchsia

Use Fuchsia's zx_system_get_features API to determine
whether LSE atomics are available on the machine.

Reviewed By: abrachet

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

2 years agoFix template instantiation of UDLs
Aaron Ballman [Mon, 28 Mar 2022 18:46:14 +0000 (14:46 -0400)]
Fix template instantiation of UDLs

Previously, we would instantiate the UDL by marking the function as
referenced and potentially binding to a temporary; this skipped
transforming the call when the UDL was dependent on a template
parameter.

Now, we defer all the work to instantiating the call expression for the
UDL. This ensures that constant evaluation occurs at compile time
rather than deferring until runtime.

Fixes Issue 54578.

2 years agoAdd stub DirectX backend
Chris Bieneman [Mon, 28 Mar 2022 18:21:02 +0000 (13:21 -0500)]
Add stub DirectX backend

This is the bare minimum needed to get the DirectX target compiling,
but does not actually do anything.

Reviewed By: pete, rnk, arsenm, jaebaek

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

2 years ago[libTooling] Fix indentation. NFC.
Eric Li [Mon, 28 Mar 2022 18:29:31 +0000 (18:29 +0000)]
[libTooling] Fix indentation. NFC.

2 years ago[flang] Fold NEAREST() and its relatives
Peter Klausler [Thu, 24 Mar 2022 16:03:07 +0000 (09:03 -0700)]
[flang] Fold NEAREST() and its relatives

Implement constant folding for the intrinsic function NEAREST()
and the related functions IEEE_NEXT_AFTER(), IEEE_NEXT_UP(), and
IEEE_NEXT_DOWN().

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

2 years ago[OpenMP] Fix library path missing when using OpenMP
Joseph Huber [Mon, 28 Mar 2022 16:23:21 +0000 (12:23 -0400)]
[OpenMP] Fix library path missing when using OpenMP

The changes in D122444 caused OpenMP programs built with the
LLVM_ENABLE_RUNTIMES options to stop finding the libraries. We generally
expect to link against the libraries associated with the clang
installation itself but we no longer implicitly included that directory.
This patch adds in the include path of the clang installations library
to ensure we can find them.

Reviewed By: jdoerfert, MaskRay

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

2 years ago[mlir] Flip Vector dialect accessors used to prefixed form.
Jacques Pienaar [Mon, 28 Mar 2022 18:24:47 +0000 (11:24 -0700)]
[mlir] Flip Vector dialect accessors used to prefixed form.

This has been on _Both for a couple of weeks. Flip usages in core with
intention to flip flag to _Prefixed in follow up. Needed to add a couple
of helper methods in AffineOps and Linalg to facilitate a pure flag flip
in follow up as some of these classes are used in templates and so
sensitive to Vector dialect changes.

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

2 years ago[demangler] Add StringView conversion operator
Nathan Sidwell [Tue, 1 Mar 2022 16:36:24 +0000 (08:36 -0800)]
[demangler] Add StringView conversion operator

The OutputBuffer class tries to present a NUL-terminated string API to
consumers.  But several of them would prefer a StringView.  In
particular the Microsoft demangler, juggles between NUL-terminated and
StringView, which is confusing.

This adds a StringView conversion, and adjusts the Demanglers that can
benefit from that.

Reviewed By: dblaikie

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

2 years agoPass -disable-llvm-passes to avoid running llvm passes
Akira Hatanaka [Mon, 28 Mar 2022 18:14:44 +0000 (11:14 -0700)]
Pass -disable-llvm-passes to avoid running llvm passes

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

2 years ago[mlir] Simplify LoopLikeOpInterface
Mogball [Mon, 28 Mar 2022 18:09:26 +0000 (18:09 +0000)]
[mlir] Simplify LoopLikeOpInterface

- Adds default implementations of `isDefinedOutsideOfLoop` and `moveOutOfLoop` since 99% of all implementations of these functions were identical
- `moveOutOfLoop` takes one operation and doesn't return anything anymore. 100% of all implementations of this function would always return `success` and uses would either respond with a pass failure or an `llvm_unreachable`.

2 years ago[RISCV] Add lowering for vp.fptosi and vp.sitofp.
Craig Topper [Mon, 28 Mar 2022 15:52:15 +0000 (08:52 -0700)]
[RISCV] Add lowering for vp.fptosi and vp.sitofp.

This as an alternative version of D120641. Starting from the code here
https://repo.hca.bsc.es/gitlab/rferrer/llvm-epi/-/raw/EPI/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
but with some modifications to how the interim types are calculated,
and adding support for f16.

Still need to add fptosi for mask vectors.

Lots of masked isel patterns added so we can pass the mask through
the type changes.

Reviewed By: frasercrmck, arcbbb

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

2 years ago[ELF] Fix llvm_unreachable failure when COMMON is placed in SHT_PROGBITS output section
Fangrui Song [Mon, 28 Mar 2022 18:05:52 +0000 (11:05 -0700)]
[ELF] Fix llvm_unreachable failure when COMMON is placed in SHT_PROGBITS output section

Fix a regression in aa27bab5a1a17e9c4168a741a6298ecaa92c1ecb: COMMON in an
SHT_PROGBITS output section caused llvm_unreachable failure.

2 years ago[MLIR][LLVM] Mark read/write behavior of memcpy/memset/memmove
William S. Moses [Mon, 28 Mar 2022 01:59:52 +0000 (21:59 -0400)]
[MLIR][LLVM] Mark read/write behavior of memcpy/memset/memmove

This commit adds MemWrite (and MemRead, as appropriate) to the arugments of the memset/memcpy/memmove intrinsics within the LLVM dialect

Reviewed By: ftynse

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

2 years agosanitizer_common: Remove Fuchsia support for reading flags from files
Roland McGrath [Fri, 25 Mar 2022 00:02:20 +0000 (17:02 -0700)]
sanitizer_common: Remove Fuchsia support for reading flags from files

This has never really been used in practice.  Fuchsia is moving
away from the support this requires, so don't use it.

Reviewed By: phosek

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

2 years ago[Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition
Fangrui Song [Mon, 28 Mar 2022 17:27:16 +0000 (10:27 -0700)]
[Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition

Many options (-fsyntax-only, -E, -S, etc) skip the link action phase which the
existing condition does not account for.

Since the code no longer specifies OPT_c, I think a single RUN line about -c
not leading to a warning is sufficient. Adding one for all of -E,
-fsyntax-only, -S would be excessive.

Reviewed By: benshi001

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

2 years ago[Flang] Options to lower math intrinsics to relaxed, precise variants
Kiran Chandramohan [Mon, 28 Mar 2022 17:05:59 +0000 (17:05 +0000)]
[Flang] Options to lower math intrinsics to relaxed, precise variants

Enable lowering to the relaxed and precise variants in the pgmath
library.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Peter Klausler <pklausler@nvidia.com>
Reviewed By: clementval

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

2 years agoRevert "[Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition"
Fangrui Song [Mon, 28 Mar 2022 17:11:45 +0000 (10:11 -0700)]
Revert "[Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition"

This reverts commit 16524d2f1bdc2e74ca34425edf43ac8ef5d39531.

The test caused some warnings when avr-gcc was not installed.

2 years ago[ELF] Simplify MergeInputSection::getParentOffset. NFC
Fangrui Song [Mon, 28 Mar 2022 17:02:35 +0000 (10:02 -0700)]
[ELF] Simplify MergeInputSection::getParentOffset. NFC

and remove overly verbose comments.

2 years ago[ConstraintElimination] Add tests with signed predicates and ADDs.
Florian Hahn [Mon, 28 Mar 2022 17:00:18 +0000 (18:00 +0100)]
[ConstraintElimination] Add tests with signed predicates and ADDs.

2 years ago[Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition
Fangrui Song [Mon, 28 Mar 2022 16:43:36 +0000 (09:43 -0700)]
[Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition

Many options (-fsyntax-only, -E, -S, etc) skip the link action phase which the
existing condition does not account for.

Since the code no longer specifies OPT_c, I think a single RUN line about -c
not leading to a warning is sufficient. Adding one for all of -E,
-fsyntax-only, -S would be excessive.

Reviewed By: benshi001

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

2 years ago[llvm] Fix string copy confusion
Nathan Sidwell [Thu, 24 Mar 2022 11:21:52 +0000 (04:21 -0700)]
[llvm] Fix string copy confusion

The microsoft demangler makes copies of the demangled strings, but has
some confusion between StringView representation (sans NUL), and
C-strings (with NUL).  Here we also have a use of strcpy, which
happens to work because the incoming string view happens to have a
trailing NUL.  But a simple memcpy excluding the NUL is sufficient.

Reviewed By: dblaikie, erichkeane

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

2 years ago[X86] lowerV64I8Shuffle - attempt to match with lowerShuffleAsLanePermuteAndPermute
Simon Pilgrim [Mon, 28 Mar 2022 16:21:11 +0000 (17:21 +0100)]
[X86] lowerV64I8Shuffle - attempt to match with lowerShuffleAsLanePermuteAndPermute

Fixes #54562

2 years agoApply clang-tidy fixes for readability-redundant-smartptr-get in SampleProfReader...
Kazu Hirata [Mon, 28 Mar 2022 16:18:39 +0000 (09:18 -0700)]
Apply clang-tidy fixes for readability-redundant-smartptr-get in SampleProfReader.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-redundant-smartptr-get in InstrProfReader...
Kazu Hirata [Mon, 28 Mar 2022 16:18:38 +0000 (09:18 -0700)]
Apply clang-tidy fixes for readability-redundant-smartptr-get in InstrProfReader.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-redundant-smartptr-get in TapiUniversal.cpp...
Kazu Hirata [Mon, 28 Mar 2022 16:18:36 +0000 (09:18 -0700)]
Apply clang-tidy fixes for readability-redundant-smartptr-get in TapiUniversal.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-redundant-smartptr-get in MachOUniversalWriter...
Kazu Hirata [Mon, 28 Mar 2022 16:18:35 +0000 (09:18 -0700)]
Apply clang-tidy fixes for readability-redundant-smartptr-get in MachOUniversalWriter.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-redundant-smartptr-get in MCContext.cpp (NFC)
Kazu Hirata [Mon, 28 Mar 2022 16:18:33 +0000 (09:18 -0700)]
Apply clang-tidy fixes for readability-redundant-smartptr-get in MCContext.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-redundant-smartptr-get in SummaryBasedOptimiza...
Kazu Hirata [Mon, 28 Mar 2022 16:18:31 +0000 (09:18 -0700)]
Apply clang-tidy fixes for readability-redundant-smartptr-get in SummaryBasedOptimizations.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-redundant-smartptr-get in GsymReader.cpp ...
Kazu Hirata [Mon, 28 Mar 2022 16:18:30 +0000 (09:18 -0700)]
Apply clang-tidy fixes for readability-redundant-smartptr-get in GsymReader.cpp (NFC)