platform/upstream/llvm.git
23 months ago[clang-cl] Expose the /volatile:{iso,ms} choice via _ISO_VOLATILE
David Majnemer [Tue, 23 Aug 2022 14:18:24 +0000 (14:18 +0000)]
[clang-cl] Expose the /volatile:{iso,ms} choice via _ISO_VOLATILE

MSVC allows interpreting volatile loads and stores, when combined with
/volatile:iso, as having acquire/release semantics. MSVC also exposes a
define, _ISO_VOLATILE, which allows users to enquire if this feature is
enabled or disabled.

23 months ago[flang] Allow configuring building the flang runtime standalone
Martin Storsjö [Tue, 19 Jul 2022 21:47:02 +0000 (00:47 +0300)]
[flang] Allow configuring building the flang runtime standalone

This allows building the flang runtime and libFortranDecimal standalone,
without setting up the full llvm build, by pointing cmake to these
directories.

This is the other one out of two essential steps for building the flang runtimes
for a foreign target, i.e. setting up cross compiling with flang.

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

23 months ago[flang] Make runtimes headers independent of the main llvm headers
Martin Storsjö [Wed, 20 Jul 2022 13:32:31 +0000 (16:32 +0300)]
[flang] Make runtimes headers independent of the main llvm headers

llvm/Support/Compiler.h requires llvm-config.h, i.e. to include it,
you'd need to actually set up building llvm for that target.

If using flang to cross compile code for a different target, we need
the runtimes built for that target, but we might not want to build
llvm itself for that target.

This is one out of two essential steps for building the flang runtimes
for a foreign target, i.e. setting up cross compiling with flang.

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

23 months ago[clang/test] Correctly specify simulator env in target flag in fsanitize.c
Nico Weber [Mon, 22 Aug 2022 17:34:42 +0000 (13:34 -0400)]
[clang/test] Correctly specify simulator env in target flag in fsanitize.c

Putting "simulator" in the `-target` flag requires putting it in the
"environment" part of the triple, which is the 4th `-`-separated component.

Some places in the tests currently use "iossimulator" which puts it in the
OS field. The triple parsing code in llvm::Triple uses startswith("ios")
in parseOS(), so that successfully sets the OS to "iOS", and all these
triples use an intel arch, and iOS + intel triple implicitly make the
driver convert the environment to "simulator", so this happened to work --
but it led to the somewhat strange "simulator-simulator" in the diag
in the test.

No behavior change.

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

23 months ago[clang] Remove a FIXME that we can't fix
Nico Weber [Mon, 22 Aug 2022 17:42:46 +0000 (13:42 -0400)]
[clang] Remove a FIXME that we can't fix

I added this recently, but it looks like several tests very intentionally
check that `-mios-version-min=foo --target=x86_64-apple-ios` does simulator
builds. So we can't easily remove this hack, even though it makes little
sense in an arm mac world. (Here, you _have_ to say
`-mios-simulator-version-min=` or `--target=arm64-apple-ios-simulator`.)

The tests that check this:
  Clang :: Driver/darwin-ld.c
  Clang :: Driver/darwin-simulator-macro.c
  Clang :: Driver/darwin-version.c

No behavior change.

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

23 months ago[NFC] LoopAccess: Move expressions close to usage
Aditya Kumar [Mon, 22 Aug 2022 00:19:37 +0000 (17:19 -0700)]
[NFC] LoopAccess: Move expressions close to usage

Avoids useless evaluation of these expressions.

Reviewed By: michaelmaitland, fhahn

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

23 months ago[libc++] Update oss-fuzz.sh to use LLVM_ENABLE_RUNTIMES
Louis Dionne [Tue, 23 Aug 2022 14:06:15 +0000 (10:06 -0400)]
[libc++] Update oss-fuzz.sh to use LLVM_ENABLE_RUNTIMES

23 months ago[DebugInfo][InstrRef] Handle transfers of variadic debug values in LDV
Stephen Tozer [Mon, 20 Jun 2022 11:06:00 +0000 (12:06 +0100)]
[DebugInfo][InstrRef] Handle transfers of variadic debug values in LDV

This patch adds the last of the changes required to enable
DBG_VALUE_LIST handling in InstrRefLDV, handling variadic debug values
during the transfer tracking step. Most of the changes are fairly
straightforward, and based around tracking multiple locations per
variable in TransferTracker::VLocTracker.

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

23 months agoRevert the removal of LLVM_ENABLE_PROJECTS for libc++ and libc++abi
Louis Dionne [Tue, 23 Aug 2022 13:48:36 +0000 (09:48 -0400)]
Revert the removal of LLVM_ENABLE_PROJECTS for libc++ and libc++abi

This commit reverts the following commits:

952f90b72b3546d6b6b038d410f07ce520c59b48
e6a0800532bb409f6d1c62f3698bdd6994a877dc (D132298)
176db3b3ab25ff8a9b2405f50ef5a8bd9304a6d5 (D132324)

These commits caused CI instability and need to be reverted in order
to figure things out again. See the discussion in https://llvm.org/D132324
for more information.

23 months ago[PowerPC] Autogenerate crbits.ll . NFC
Amaury Séchet [Tue, 23 Aug 2022 13:40:01 +0000 (13:40 +0000)]
[PowerPC] Autogenerate crbits.ll . NFC

23 months ago[lldb] [gdb-remote] Use Communication::WriteAll() over Write()
Michał Górny [Mon, 22 Aug 2022 16:59:08 +0000 (18:59 +0200)]
[lldb] [gdb-remote] Use Communication::WriteAll() over Write()

Replace the uses of Communication::Write() with WriteAll() to avoid
partial writes.  None of the call sites actually accounted for that
possibility and even if it is unlikely to actually happen, there doesn't
seem to be any real harm from using WriteAll() instead.

Ideally, we'd remove Write() from the public API.  However, that would
change the API of SBCommunication.  The alternative would be to alias it
to WriteAll().

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D132395

23 months ago[llvm][Cmake] Expand "all" in LLVM_ENABLE_PROJECTS before other checks
Kadir Cetinkaya [Tue, 23 Aug 2022 09:04:44 +0000 (11:04 +0200)]
[llvm][Cmake] Expand "all" in LLVM_ENABLE_PROJECTS before other checks

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

23 months ago[OffloadPackager] Add necessary move statement on returned value
Joseph Huber [Tue, 23 Aug 2022 13:44:13 +0000 (08:44 -0500)]
[OffloadPackager] Add necessary move statement on returned value

Summary:
Some older compilers cannot automatically elide the returned vector of
unique pointers, causing build errors. This patch explicitly moves the
returned value instead which should solve the problem.

23 months ago[pseudo] Eliminate a false parse of structured binding declaration.
Haojian Wu [Fri, 19 Aug 2022 19:55:39 +0000 (21:55 +0200)]
[pseudo] Eliminate a false parse of structured binding declaration.

Using the guard to implement part of the rule https://eel.is/c++draft/dcl.pre#6.

```
void foo() {
  // can be parsed as
  //   - structured-binding declaration (a false parse)
  //   - assignment expression
  array[index] = value;
}
```

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

23 months ago[NFC] Fix typo in dbg message in RegisterCoalescer.
Thomas Symalla [Tue, 23 Aug 2022 13:14:45 +0000 (15:14 +0200)]
[NFC] Fix typo in dbg message in RegisterCoalescer.

funcion => function

23 months ago[pseudo] Fix HeadsPartition is not initialized correctly.
Haojian Wu [Tue, 23 Aug 2022 13:08:26 +0000 (15:08 +0200)]
[pseudo] Fix HeadsPartition is not initialized correctly.

The bug was that if we recover from the token 0, we will make the
Heads empty (Line646), which results no recovery being applied.

Reviewed By: sammccall

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

23 months ago[MLIR] Harden gpu.func verification
Christian Sigg [Tue, 23 Aug 2022 10:45:49 +0000 (12:45 +0200)]
[MLIR] Harden gpu.func verification

GPUFuncOpLowering moves the body out of gpu.func op and erases it. An empty gpu.func may fail verification but should not crash it. Verification of an erased op is triggered e.g. with debug printing on.

Reviewed By: akuegel

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

23 months ago[OffloadPackager] Add option to extract files from images
Joseph Huber [Wed, 17 Aug 2022 18:10:04 +0000 (14:10 -0400)]
[OffloadPackager] Add option to extract files from images

We use the `clang-offload-packager` too bundle many files into a single
binary format containing metadata. This is used for offloading
compilation which may contain multiple device binaries of different
types and architectures in a single file. We use this special binary
format to store these files along with some necessary metadata around
them. We use this format because of the difficulty of determining the
filesize of the various binary inputs that will be passed to the
offloading toolchain rather than engineering a solution for each input.

Previously we only support packaing many files into a single binary.
This patch adds support for doing the reverse by using the same
`--image=` syntax. To unpackage a binary we now present an input file
instead of an output.

Reviewed By: tra

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

23 months ago[runtimes] Handle interface targets in runtimes distribution components
Louis Dionne [Mon, 22 Aug 2022 16:00:40 +0000 (12:00 -0400)]
[runtimes] Handle interface targets in runtimes distribution components

As reported in [1], cxx-headers is not a valid distribution target
because it is an interface target in CMake. This breaks the most
basic MultiDistributionExample of the runtimes build.

This patch handles interface targets by getting rid of the assumption
that all distribution components have a target associated to them. It
is valid for a distribution component to only have a `install-FOO`
target.

In the case where only `cxx-headers` is provided as a distribution
component, `ninja toolchain-distribution` will not build anything
after this patch, since there is effectively nothing to build for
the `cxx-headers` target. However, running `ninja install-toolchain-distribution`
will build everything, as expected.

[1]: https://discord.com/channels/636084430946959380/636732894974312448/1010013287464828968

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

23 months ago[Globals] Treat nobuiltin fns as maybe-derefined.
Florian Hahn [Tue, 23 Aug 2022 12:44:59 +0000 (13:44 +0100)]
[Globals] Treat nobuiltin fns as maybe-derefined.

Callsites could be marked as `builtin` while calling `nobuiltin`
functions. This can lead to problems, if local optimizations apply
transformations based on the semantics of the builtin, but then IPO
treats the function as `nobuiltin` and applies a transform that breaks
builtin semantics (assumed earlier).

To avoid this, mark such functions as maybey-derefined, to avoid IPO
transforms on them that may break assumptions of earlier calls.

Fixes #57075
Fixes #48366

Reviewed By: ychen

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

23 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

23 months agoRevert "[reland][NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 12:40:07 +0000 (12:40 +0000)]
Revert "[reland][NFC][libc] standardize string_view"

This reverts commit df99774ef7d9c910941fe915689f9126258800ee.

23 months agobuffer-deallocation: consider aliases introduced by arith.select.
Johannes Reifferscheid [Tue, 23 Aug 2022 12:21:40 +0000 (14:21 +0200)]
buffer-deallocation: consider aliases introduced by arith.select.

Currently, buffer deallocation considers arith.select to be
non-aliasing, which results in deallocs being inserted incorrectly. Since
arith.select doesn't implement any useful interfaces, this change just handles
it explicitly. Eventually this should probably be fixed properly, if this pass
is going to be used long term.

Reviewed By: springerm

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

23 months ago[DebugInfo][InstrRef][NFC] Emit variadic debug values from InstrRefLDV
Stephen Tozer [Mon, 20 Jun 2022 11:46:08 +0000 (12:46 +0100)]
[DebugInfo][InstrRef][NFC] Emit variadic debug values from InstrRefLDV

In preparation for supporting DBG_VALUE_LIST in InstrRefLDV, this patch
adds the logic for emitting DBG_VALUE_LIST instructions from
InstrRefLDV. The logical changes here are fairly simple, with the main
change being that instead of directly prepending offsets to the DIExpr,
we use appendOpsToArg to modify the expression for individual debug
operands in the expression. The function emitLoc is also changed to take
a list of debug ops, with an empty list meaning an undef value.

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

23 months ago[mlir][Bufferization] Use DestinationStyleOpInterface where possible.
Adrian Kuegel [Tue, 23 Aug 2022 11:42:19 +0000 (13:42 +0200)]
[mlir][Bufferization] Use DestinationStyleOpInterface where possible.

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

23 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

23 months ago[DeadArgElim] Add test case for #48366, #57075
Florian Hahn [Tue, 23 Aug 2022 12:08:38 +0000 (13:08 +0100)]
[DeadArgElim] Add test case for #48366, #57075

23 months agoRevert "[reland][NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 11:50:56 +0000 (11:50 +0000)]
Revert "[reland][NFC][libc] standardize string_view"

This reverts commit 522d29a6a745e38d635739b05383770804bac311.

23 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

23 months ago[gn build] Port 134d017b88ca
LLVM GN Syncbot [Tue, 23 Aug 2022 11:31:54 +0000 (11:31 +0000)]
[gn build] Port 134d017b88ca

23 months ago[ADT] Add unittest coverage for ADT/bit.h header
Simon Pilgrim [Tue, 23 Aug 2022 11:23:11 +0000 (12:23 +0100)]
[ADT] Add unittest coverage for ADT/bit.h header

23 months ago[mlir] Extract DestinationStyleOpInterface from LinalgStructuredInterface.
Adrian Kuegel [Tue, 23 Aug 2022 10:34:58 +0000 (12:34 +0200)]
[mlir] Extract DestinationStyleOpInterface from LinalgStructuredInterface.

There are several use cases where a destination style operation needs an interface
that contains a subset of the methods from LinalgStructuredInterface.
In this change, we move all such methods to a new interface, and add forwarding
methods to LinalgStructuredInterface to make the change the less invasive.
It may be possible to refactor the code later to get rid of (some or all) of the
forwarding methods.
This change also removes the cloneWithMapper interface methods, as it is not used anywhere.

RFC:
https://discourse.llvm.org/t/rfc-interface-for-destination-style-ops/64056

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

23 months agoRevert "[reland][NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 11:00:22 +0000 (11:00 +0000)]
Revert "[reland][NFC][libc] standardize string_view"

This reverts commit 187099da1c415bd8f717eb5adc75bb1d73c7a0ba.

23 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

23 months ago[CodeGen][InstrRef] Remove unused variables from test case
Stephen Tozer [Tue, 23 Aug 2022 09:59:14 +0000 (10:59 +0100)]
[CodeGen][InstrRef] Remove unused variables from test case

23 months agoRevert "[NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 10:43:11 +0000 (10:43 +0000)]
Revert "[NFC][libc] standardize string_view"

This reverts commit abe0fa6b17d866ef21e7c2abb799658c490b8508.

23 months ago[AArch64] Fix list of features for Cortex-X1C
Lucas Prates [Thu, 18 Aug 2022 09:21:22 +0000 (10:21 +0100)]
[AArch64] Fix list of features for Cortex-X1C

This patch fixes the list of subtarget features enabled for the
Cortex-X1C processor, including the following:

* Fix incorrect version used for FeatureRCPC:
  * Use FEAT_LRCPC2 instead of FEAT_LRCPC.
* Add missing v8.4-A features included in the TRM:
  * Flag Manipulation Instructions - FeatureFlagM (FEAT_FlagM)
  * Large System Extension 2 - FeatureLSE2 (FEAT_LSE2)

Reviewed By: vhscampos

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

23 months ago[StructurizeCFG] Autogenerate checks
Jay Foad [Tue, 23 Aug 2022 10:22:14 +0000 (11:22 +0100)]
[StructurizeCFG] Autogenerate checks

23 months ago[AMDGPU][MC][GFX9][NFC] Consolidate tests by encoding
Dmitry Preobrazhensky [Tue, 23 Aug 2022 10:09:47 +0000 (13:09 +0300)]
[AMDGPU][MC][GFX9][NFC] Consolidate tests by encoding

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

23 months ago[NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[NFC][libc] standardize string_view

23 months ago[tensor][bufferize] Use affine.apply instead of arith.addi in PadOp lowering
Matthias Springer [Tue, 23 Aug 2022 09:38:54 +0000 (11:38 +0200)]
[tensor][bufferize] Use affine.apply instead of arith.addi in PadOp lowering

Affine exprs compose better than arith ops.

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

23 months ago[docs] Add examples for printing asynchronous stack for coroutines
Chuanqi Xu [Tue, 23 Aug 2022 08:34:01 +0000 (16:34 +0800)]
[docs] Add examples for printing asynchronous stack for coroutines

Previously when I wrote this document, I felt the completed scripts was
lengthy, redundant and not easy to read. So I didn't add complete
examples in the previous commit.

However, in the recent discussion with @avogelsgesang, I found people
may not know how to use debugging scripts to improve their debugging
efficiency. So now, I feel like it is helpful to put the examples even
if they are a little bit long.

Test Plan: make docs-clang-html

Reviewed By: avogelsgesang

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

23 months ago[ADT] Add llvm::popcount to <bit> helper wrapper
Simon Pilgrim [Tue, 23 Aug 2022 09:36:32 +0000 (10:36 +0100)]
[ADT] Add llvm::popcount to <bit> helper wrapper

This patch proposes to move the llvm::detail::PopulationCounter internal helpers into ADT/bit.h and provide a llvm::popcount implementation.

I've left the countPopulation implementation in place in MathExtras.h for now, but updated it to use llvm::popcount.

Hopefully I've got the type_traits correct - I don't use them very often.

Someday we'll move to C++20 with an actual <bit> std header, and we already have this header in place to simplify matters. We'd probably benefit from moving the other <bit> helpers here at some point, but this is a first step.

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

23 months ago[TwoAddressInstruction] Handle pointer compare sunk past statepoint.
Denis Antrushin [Fri, 19 Aug 2022 11:31:15 +0000 (18:31 +0700)]
[TwoAddressInstruction] Handle pointer compare sunk past statepoint.

CodeGenPrepare pass can sink pointer comparison across statepoint
to the point of use (see comment in IR/SafepointIRVerifier.cpp)
Due to specifics of statepoints, it is still legal to have tied
def and use rewritten to the same register in TwoAddress pass.
However, properly updating LiveIntervals and LiveVariables becomes
complicated. For simplicity, let's fall back to generic handling of
tied registers when we detect such case.
TODO: This fixes functional (assertion) failure. Ideally we should
try to recompute new live range/liveness in place.

Reviewed By: skatkov

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

23 months ago[LoopUtils] Remove unused Loop arg from addDiffRuntimeChecks (NFC).
Florian Hahn [Tue, 23 Aug 2022 09:15:27 +0000 (10:15 +0100)]
[LoopUtils] Remove unused Loop arg from addDiffRuntimeChecks (NFC).

The argument is no longer used, remove it.

23 months ago[LoongArch] Optimize the atomic store with amswap_db.[w/d]
gonglingqin [Tue, 23 Aug 2022 08:58:22 +0000 (16:58 +0800)]
[LoongArch] Optimize the atomic store with amswap_db.[w/d]

When AtomicOrdering is release or stronger, use
    amswap_db.[w/d] $zero, $a1, $a0
instead of
    dbar 0
    st.[w/d] $a0, $a1, 0

Thanks to @xry111 for the suggestion: https://reviews.llvm.org/D128901#3626635

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

23 months ago[NFC][LoopVectorize] Precommit masked vector function call tests
Graham Hunter [Tue, 23 Aug 2022 08:45:18 +0000 (09:45 +0100)]
[NFC][LoopVectorize] Precommit masked vector function call tests

23 months ago[mlir][Linalg] Retire LinalgStrategyGeneralizePass
Guray Ozen [Tue, 23 Aug 2022 08:02:13 +0000 (10:02 +0200)]
[mlir][Linalg] Retire LinalgStrategyGeneralizePass

This revision deletes LinalgStrategyGeneralizePass.

Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785

Reviewed By: nicolasvasilache

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

23 months ago[NFC] Remove undef from xfailed SimplifyCFG test
Dmitry Makogon [Tue, 23 Aug 2022 07:51:29 +0000 (14:51 +0700)]
[NFC] Remove undef from xfailed SimplifyCFG test

The test fails not because of undef, so replacing with
normal condition.

23 months ago[mlir][Linalg] Retire Linalg generic interchange pattern and pass
Guray Ozen [Tue, 23 Aug 2022 07:28:16 +0000 (09:28 +0200)]
[mlir][Linalg] Retire Linalg generic interchange pattern and pass

This revision removes the Linalg generic interchange pattern and pass.

It also changes transform-patterns test to make use of transform dialect.

Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785

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

23 months ago[clang][AST] RecursiveASTVisitor should visit owned TagDecl of friend type.
Balázs Kéri [Tue, 23 Aug 2022 06:51:54 +0000 (08:51 +0200)]
[clang][AST] RecursiveASTVisitor should visit owned TagDecl of friend type.

A FriendDecl node can have a friend record type that owns a RecordDecl
object. This object is different than the one got from TypeSourceInfo
object of the FriendDecl. When building a ParentMapContext this owned
tag decaration has to be encountered to have the parent set for it.

Reviewed By: sammccall

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

23 months ago[mlir][Linalg] Remove unused method declaration.
Adrian Kuegel [Fri, 19 Aug 2022 13:20:06 +0000 (15:20 +0200)]
[mlir][Linalg] Remove unused method declaration.

The "real" method declaration is in LinalgInterfaces.h

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

23 months ago[llvm-profdata][NFC] fix warning
liaochunyu [Tue, 23 Aug 2022 05:53:06 +0000 (13:53 +0800)]
[llvm-profdata][NFC] fix warning

warning: unused variable ‘FC’

Reviewed By: kazu

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

23 months ago[gn build] Port 15b65bcd6519
LLVM GN Syncbot [Tue, 23 Aug 2022 05:49:48 +0000 (05:49 +0000)]
[gn build] Port 15b65bcd6519

23 months ago[Clang][LoongArch] Add initial LoongArch target and driver support
Weining Lu [Tue, 23 Aug 2022 05:11:32 +0000 (13:11 +0800)]
[Clang][LoongArch] Add initial LoongArch target and driver support

With the initial support added, clang can compile `helloworld` C
to executable file for loongarch64. For example:

```
$ cat hello.c
int main() {
  printf("Hello, world!\n");
  return 0;
}
$ clang --target=loongarch64-unknown-linux-gnu --gcc-toolchain=xxx --sysroot=xxx hello.c
```

The output a.out can run within qemu or native machine. For example:

```
$ file ./a.out
./a.out: ELF 64-bit LSB pie executable, LoongArch, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-loongarch-lp64d.so.1, for GNU/Linux 5.19.0, with debug_info, not stripped
$ ./a.out
Hello, world!
```

Currently gcc toolchain and sysroot can be found here:
https://github.com/loongson/build-tools/releases/download/2022.08.11/loongarch64-clfs-5.1-cross-tools-gcc-glibc.tar.xz

Reference: https://github.com/loongson/LoongArch-Documentation
The last commit hash (main branch) is:
99016636af64d02dee05e39974d4c1e55875c45b

Note loongarch32 is not fully tested because there is no reference
gcc toolchain yet.

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

23 months ago[CMake] Support passing arguments to build tool (bootstrap).
Carlos Alberto Enciso [Tue, 23 Aug 2022 04:45:25 +0000 (05:45 +0100)]
[CMake] Support passing arguments to build tool (bootstrap).

For bootstrap builds (CLANG_ENABLE_BOOTSTRAP=ON) allow
arguments to be passed to the native tool used in CMake
for the stage2 step.

Can be used to pass extra arguments for enhanced versions
of build tools, e.g. distributed build options.

Reviewed By: phosek

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

23 months ago[VE] Support inlineasm memory operand
Kazushi (Jam) Marukawa [Mon, 22 Aug 2022 14:31:44 +0000 (23:31 +0900)]
[VE] Support inlineasm memory operand

Support inline asm memory operand for VE.  Add regression tests also.

Reviewed By: efocht

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

23 months ago[LV][NFC] Modify code comments
liqinweng [Tue, 23 Aug 2022 04:13:06 +0000 (12:13 +0800)]
[LV][NFC] Modify code comments

Reviewed By: jacquesguan

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

23 months ago[NFC]] Use llvm::all_of instead of std::all_of
liqinweng [Tue, 23 Aug 2022 04:09:31 +0000 (12:09 +0800)]
[NFC]] Use llvm::all_of instead of std::all_of

Reviewed By: kazu

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

23 months ago[clang-format] Remove an extraneous test in TokenAnnotatorTest.cpp
owenca [Tue, 23 Aug 2022 04:15:26 +0000 (21:15 -0700)]
[clang-format] Remove an extraneous test in TokenAnnotatorTest.cpp

This removes an obsolete test case introduced by mistake from
commit 2e36120726ee46cbfd3eee1e9244bdd756dee92d.

23 months ago[ADT] Add all_equal predicate
Jakub Kuderski [Tue, 23 Aug 2022 03:55:05 +0000 (23:55 -0400)]
[ADT] Add all_equal predicate

`llvm::all_equal` checks if all values in the given range are equal, i.e., there are no two elements that are not equal.
Similar to `llvm::all_of`, it returns `true` when the range is empty.

`llvm::all_equal` is intended to supersede `llvm::is_splat`, which will be deprecated and removed in future patches.
See the discussion thread for more details:
https://discourse.llvm.org/t/adt-is-splat-and-empty-ranges/64692.

Reviewed By: dblaikie, shchenz

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

23 months ago[clang-format] Fix regressions in WhitespaceSensitiveMacros
owenca [Tue, 16 Aug 2022 23:30:40 +0000 (16:30 -0700)]
[clang-format] Fix regressions in WhitespaceSensitiveMacros

Fixes #54522.
Fixes #57158.

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

23 months ago[mlir][spirv] Use spv.store instead of init in var
Stanley Winata [Tue, 23 Aug 2022 03:37:05 +0000 (23:37 -0400)]
[mlir][spirv] Use spv.store instead of init in var

- Add spv.store instead of init for spv.variable to fix data issues in
  some GPU drivers

Reviewed By: antiagainst
Patch By: raikonenfnu

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

23 months ago[mlir][spirv] Add vector.fma lowering to CL.fma
Stanley Winata [Tue, 23 Aug 2022 03:32:51 +0000 (23:32 -0400)]
[mlir][spirv] Add vector.fma lowering to CL.fma

Reviewed By: antiagainst
Patch By: raikonenfnu

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

23 months ago[X86][AVX512FP16] Relax limitation to AVX512FP16 intrinsics. NFCI
Phoebe Wang [Mon, 22 Aug 2022 01:59:42 +0000 (09:59 +0800)]
[X86][AVX512FP16] Relax limitation to AVX512FP16 intrinsics. NFCI

Since we have enabled the support for `_Float16` on SSE2, we can relax
the limitation for AVX512FP16 now. This helps for user to use AVX512FP16
mixed with unsupported versions, e.g., multiversioning.

Also fix lit fails due to missing const modifier. Found during this change.

Reviewed By: RKSimon

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

23 months ago[InstCombine] add tests for shuf bitcast. nfc
Chenbing Zheng [Tue, 23 Aug 2022 03:01:18 +0000 (11:01 +0800)]
[InstCombine] add tests for shuf bitcast. nfc

23 months ago[gn build] port e78208f082f0
Nico Weber [Tue, 23 Aug 2022 01:46:36 +0000 (21:46 -0400)]
[gn build] port e78208f082f0

23 months ago[clang][deps] Allow switching between lazily/eagerly loaded PCMs
Jan Svoboda [Mon, 22 Aug 2022 18:33:07 +0000 (11:33 -0700)]
[clang][deps] Allow switching between lazily/eagerly loaded PCMs

This patch introduces new option `-eager-load-pcm` to `clang-scan-deps`, which controls whether the resulting command-lines will load PCM files eagerly (at the start of compilation) or lazily (when handling import directive). This patch also switches the default from eager to lazy.

To reduce the potential for churn in LIT tests in the future, this patch also removes redundant checks of command-line arguments and introduces new test `modules-dep-args.c` as a substitute.

Reviewed By: benlangmuir

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

23 months ago[llvm][utils] Make lldb data formatters show both summaries and children
Dave Lee [Thu, 18 Aug 2022 01:51:37 +0000 (18:51 -0700)]
[llvm][utils] Make lldb data formatters show both summaries and children

When a type has a summary and synthetic child provider, the children are shown
only if `--expand`/`-e` is given.

This updates `lldbDataFormatters.py` to expand children of types that have both
a summary and synthetic children.

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

23 months ago[mlir][vulkan-runner] Use aligned pointer for host buffer
jackalcooper [Tue, 23 Aug 2022 00:37:26 +0000 (20:37 -0400)]
[mlir][vulkan-runner] Use aligned pointer for host buffer

Fix incorrect pointer usage in Vulkan buffer and Memref descriptor binding:
- Vulkan runtime produced incorrect result if there is alignment.
- There was illegal memory access if binding a LLVM global materialized
  from a constant op (0xdeadbeef).

Reviewed By: antiagainst

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

23 months ago[mlir] Populate default attributes on op creation
Jacques Pienaar [Mon, 22 Aug 2022 23:49:46 +0000 (16:49 -0700)]
[mlir] Populate default attributes on op creation

Default attributes were only handled by ODS accessors generated with the
intention that these behave as if set attributes. This addresses the
long standing TODO to address this inconsistency. Moving the
initialization to construction vs every access. Removing need for
duplicated default attribute population in python bindings.

Switch some of the OpenMP ones to optional attribute with default as the
currently set default values are not legal. May need to dig more there.

Switched LinAlg generated ones to optional attribute with default as its
quite widely used and unclear where it falls on two different
interpretations.

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

23 months agoRevert "[compiler-rt][builtins] Add compiler flags to catch potential errors"
Akira Hatanaka [Mon, 22 Aug 2022 23:37:33 +0000 (16:37 -0700)]
Revert "[compiler-rt][builtins] Add compiler flags to catch potential errors"

This reverts commit 5f886adbfd7c09f7883589ec9d85c04a08335043.

It broke clang-hip-vega20.

https://lab.llvm.org/buildbot/#/builders/165/builds/23675

23 months ago[compiler-rt][lit] initialize LIT LLVMConfig instance
Yuanfang Chen [Mon, 22 Aug 2022 23:01:09 +0000 (16:01 -0700)]
[compiler-rt][lit] initialize LIT LLVMConfig instance

to handle lit tools searching. Otherwise
compiler-rt depends on system environment variable PATH for lit tools
which diverge from the other LLVM projects. This reverts D83486 which
really should be implemented in LIT itself when the PATH is constructed.

Reviewed By: vitalybuka

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

23 months ago[compiler-rt][builtins] Add compiler flags to catch potential errors
Akira Hatanaka [Mon, 22 Aug 2022 23:25:59 +0000 (16:25 -0700)]
[compiler-rt][builtins] Add compiler flags to catch potential errors
that can lead to security vulnerabilities

Also, fix a few places that were causing -Wshadow and
-Wformat-nonliteral warnings to be emitted.

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

23 months ago[libc][Obvious] Move some macros definitions to sys/stat.h.
Siva Chandra Reddy [Mon, 22 Aug 2022 23:12:35 +0000 (23:12 +0000)]
[libc][Obvious] Move some macros definitions to sys/stat.h.

They were previously incorrectly listed in fcntl.h

23 months ago[clang][libcxx] renames `__remove_reference`
Christopher Di Bella [Mon, 22 Aug 2022 22:30:12 +0000 (22:30 +0000)]
[clang][libcxx] renames `__remove_reference`

libc++ prior to LLVM 15 has a bug in it due to it excluding
`remove_reference_t` when `__remove_reference` is available as a
compiler built-in. This went unnoticed until D116203 because it wasn't
available in any compiler.

To work around this, we're renaming `__remove_reference` to
`__remove_reference_t`.

TEST=Tested locally, tested using emscripten

23 months ago[llvm-objcopy][MachO] Remove more sections with llvm-bitcode-strip
Keith Smiley [Fri, 19 Aug 2022 23:33:30 +0000 (16:33 -0700)]
[llvm-objcopy][MachO] Remove more sections with llvm-bitcode-strip

This adds the other potential bitcode sections that can exist and should
be stripped with `-r` from `llvm-bitcode-strip`.

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

23 months ago[DFSan] Fix handling of libAtomic external functions.
Andrew Browne [Wed, 17 Aug 2022 21:26:43 +0000 (14:26 -0700)]
[DFSan] Fix handling of libAtomic external functions.

Implementation based on MSan.

Reviewed By: vitalybuka

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

23 months ago[CodeGen] Sort llvm.global_ctors by lexing order before emission
Yuanfang Chen [Mon, 22 Aug 2022 22:59:51 +0000 (15:59 -0700)]
[CodeGen] Sort llvm.global_ctors by lexing order before emission

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

The lexing order is already bookkept in DelayedCXXInitPosition but we
were not using it based on the wrong assumption that inline variable is
unordered. This patch fixes it by ordering entries in llvm.global_ctors
by orders in DelayedCXXInitPosition.

for llvm.global_ctors entries without a lexing order, ordering them by
the insertion order.

(This *mostly* orders the template instantiation in
https://reviews.llvm.org/D126341 intuitively, minus one tweak for which I'll
submit a separate patch.)

Reviewed By: efriedma

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

23 months ago[lldb] Remove prefer-dynamic-value test override
Dave Lee [Mon, 22 Aug 2022 04:48:14 +0000 (21:48 -0700)]
[lldb] Remove prefer-dynamic-value test override

Remove the test override of `target.prefer-dynamic-value`.

Previously, the lldb default was `no-dynamic-values`. In rG9aa7e8e9ffbe (in
2015), the default was changed to `no-run-target`, but at that time the tests
were changed to be run with `no-dynamic-value`. I don't know the reasons for
not changing the tests, perhaps to avoid determining which tests to change, and
what about them to change.

Because `no-run-target` is the lldb default, I think it makes sense to make it
the test default too. It puts the test config closer to what's used in
practice.

This change removes the `target.prefer-dynamic-value` override, and for those
tests that failed, they have been updated to explicitly use
`no-dynamic-values`. Future changes could update these tests to use dynamic
values too, or they can be left as is to exercise non-dynamic typing.

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

23 months ago[mlir][tosa] Switch TosaFoldConstantTranspose to use ElementsAttr.
Jacques Pienaar [Mon, 22 Aug 2022 22:45:23 +0000 (15:45 -0700)]
[mlir][tosa] Switch TosaFoldConstantTranspose to use ElementsAttr.

Also avoid redoing index calculation.

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

23 months ago[AMDGPU] Add builtin s_sendmsg_rtn
Yaxun (Sam) Liu [Thu, 18 Aug 2022 15:14:09 +0000 (11:14 -0400)]
[AMDGPU] Add builtin s_sendmsg_rtn

Reviewed by: Brian Sumner, Artem Belevich

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

Fixes: SWDEV-352017

23 months ago[DirectX] Remove broken assert
Chris Bieneman [Mon, 22 Aug 2022 22:25:09 +0000 (17:25 -0500)]
[DirectX] Remove broken assert

This assert always fails. It is unclear to me what it was attempting to
test, but removing it gets our tests passing, so it clearly isn't
checking the right thing.

23 months ago[TTI] Use OperandValueInfo in getArithmeticInstrCost implementation [NFC]
Philip Reames [Sat, 20 Aug 2022 15:07:28 +0000 (08:07 -0700)]
[TTI] Use OperandValueInfo in getArithmeticInstrCost implementation [NFC]

This change completes the process of replacing OperandValueKind and OperandValueProperties which were previously passed independently in this API with a single container class which contains both.

This is the change which motivated the whole sequence which preceeded it.  In an original spike version of this change, I'd noticed a nasty bug: I'd changed the signature without changing names, and as result, we silently passed additional information through a callsite which previously dropped the power-of-two fact.  This might be harmless in most cases, but at least a couple clearly dependend for correctness on not passing that property through.

I did my best to split off prior changes which reduced the scope of this one, and which made it possible to use compiler assistance.  For instance, every parameter which changes type in this change also changes name.  This was intentional to make sure that every call site possible effected must show up in the diff.  This let me audit each one closely.

23 months ago[mlir][shape] refine shape.func and shape.with_shape
Jacques Pienaar [Mon, 22 Aug 2022 18:47:15 +0000 (11:47 -0700)]
[mlir][shape] refine shape.func and shape.with_shape

- shape.with_shape supports ExtentTensorType
- add helper to create shape.func

Reviewed By: jpienaar

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

23 months agoModify all register values whose byte size matches the address size to be formatter...
Greg Clayton [Tue, 12 Jul 2022 00:51:00 +0000 (17:51 -0700)]
Modify all register values whose byte size matches the address size to be formatter as eFormatAddressInfo.

This allows users to see similar output to what the "register read" command emits in LLDB's command line.

Added a test to verify that the PC has the correct value with contains a pointer followed by the module + function name and the source line info. Something like:

0x0000000100000a64 a.out`main + 132 at main.cpp:17:11

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

23 months agoDon't create sections for SHN_ABS symbols in ELF files.
Greg Clayton [Thu, 11 Aug 2022 04:08:04 +0000 (21:08 -0700)]
Don't create sections for SHN_ABS symbols in ELF files.

Symbols that have the section index of SHN_ABS were previously creating extra top level sections that contained the value of the symbol as if the symbol's value was an address. As far as I can tell, these symbol's values are not addresses, even if they do have a size. To make matters worse, adding these extra sections can stop address lookups from succeeding if the symbol's value + size overlaps with an existing section as these sections get mapped into memory when the image is loaded by the dynamic loader. This can cause stack frames to appear empty as the address lookup fails completely.

This patch:
- doesn't create a section for any SHN_ABS symbols
- makes symbols that are absolute have values that are not addresses
- add accessors to SBSymbol to get the value and size of a symbol as raw integers. Prevoiusly there was no way to access a symbol's value from a SBSymbol because the only accessors were:

  SBAddress SBSymbol::GetStartAddress();
  SBAddress SBSymbol::GetEndAddress();

  and these accessors would return an invalid SBAddress if the symbol's value wasn't an address
- Adds a test to ensure no ".absolute.<symbol-name>" sections are created
- Adds a test to test the new SBSymbol APIs

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

23 months ago[InstCombine] add tests for mul+add common factor; NFC
Sanjay Patel [Mon, 22 Aug 2022 21:19:34 +0000 (17:19 -0400)]
[InstCombine] add tests for mul+add common factor; NFC

23 months ago[NFC] Rename dx.shader to hlsl.shader
Chris Bieneman [Fri, 19 Aug 2022 14:55:47 +0000 (09:55 -0500)]
[NFC] Rename dx.shader to hlsl.shader

This metadata annotation is HLSL-specific not DirectX specific. It will
need to be attached for shaders regardless of whether they are targeting
DXIL.

23 months ago[X86][AArch64][WebAsm][RISCV] Query operand properties instead of using enums directl...
Philip Reames [Mon, 22 Aug 2022 19:03:36 +0000 (12:03 -0700)]
[X86][AArch64][WebAsm][RISCV] Query operand properties instead of using enums directly [nfc]

This is part of an ongoing transition to use OperandValueInfo which combines OperandValueKind and OperandValueProperties.  This change adds some accessor methods and uses them to simplify backend code.  The primary motivation of doing so is removing uses of the parameters so that an upcoming api change is less error prone.

23 months ago[X86][TTI] Rename OpNInfo to OpNKind [nfc]
Philip Reames [Mon, 22 Aug 2022 18:30:47 +0000 (11:30 -0700)]
[X86][TTI] Rename OpNInfo to OpNKind [nfc]

Both are reasonable names; this is solely that an upcoming change can use the OpNInfo name, and the compiler can tell me if I forgot to update something (instead of silently passing along properties that might not hold.)

23 months agoRevert "[ARM] Use getSymbolPreferLocal() in GetARMGVSymbol"
Alan Zhao [Mon, 22 Aug 2022 20:16:37 +0000 (16:16 -0400)]
Revert "[ARM] Use getSymbolPreferLocal() in GetARMGVSymbol"

This reverts commit 6db15a82cc0966458c2b7d84b39f42ef09d2ac20.

Reverted because this breaks offical Chrome builds targeting Android on
arm: https://crbug.com/1354305

Repro: https://drive.google.com/file/d/1pgQI2adwx3DJJqIYvMY4i249ouHU0rmu/view?usp=sharing

23 months ago[clang-cl] Add _M_FP_* #defines for floating point modes
David Majnemer [Sun, 21 Aug 2022 20:03:22 +0000 (20:03 +0000)]
[clang-cl] Add _M_FP_* #defines for floating point modes

This keeps clang compatible with MSVC defines for the FP environment.
These defines are used by the CRT and other libraries to interrogate
what to expect. Perhaps most importantly, they feed into the definition
of float_t and double_t which may result in ODR violations between MSVC
and clang.

23 months ago[MachO] Fix formatting. NFC
Shoaib Meenai [Mon, 22 Aug 2022 18:58:46 +0000 (21:58 +0300)]
[MachO] Fix formatting. NFC

The style guide says that all arms of an if-else should have braces if
any arm does [1].

[1] https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

23 months ago[InstrRef] Fix unused variable in InstrRefLDVTest
Stephen Tozer [Mon, 22 Aug 2022 19:52:47 +0000 (20:52 +0100)]
[InstrRef] Fix unused variable in InstrRefLDVTest

23 months ago[DebugInfo] Let InstrRefBasedLDV handle joins for lists of debug ops
Stephen Tozer [Sat, 18 Jun 2022 00:09:13 +0000 (01:09 +0100)]
[DebugInfo] Let InstrRefBasedLDV handle joins for lists of debug ops

In preparation for adding support for DBG_VALUE_LIST instructions in
InstrRefLDV, this patch updates the logic for joining variables at block
joins to support joining variables that use multiple debug operands.
This is one of the more meaty "logical" changes, although the line count
isn't too high - this changes pickVPHILoc to find a valid joined
location for every operand, with part of the function being split off
into pickValuePHILoc which finds a location for a single operand.

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

23 months ago[Sema][ObjC] Don't warn about implicitly-retained self in an unevaluated
Akira Hatanaka [Mon, 22 Aug 2022 19:13:48 +0000 (12:13 -0700)]
[Sema][ObjC] Don't warn about implicitly-retained self in an unevaluated
context

23 months ago[ModuloSchedule] Add interface call to accept/reject SMS schedules
David Penry [Thu, 30 Jun 2022 18:03:50 +0000 (11:03 -0700)]
[ModuloSchedule] Add interface call to accept/reject SMS schedules

This interface allows a target to reject a proposed
SMS schedule.  For Hexagon/PowerPC, all schedules
are accepted, leaving behavior unchanged.  For ARM,
schedules which exceed register pressure limits are
rejected.

Also, two RegisterPressureTracker methods now need to be public so
that register pressure can be computed by more callers.

Reapplication of D128941/(reversion:D132037) with small fix.

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

23 months ago[InstCombine] Change order of canonicalization of ADD and AND
Jay Foad [Mon, 18 Jul 2022 15:09:41 +0000 (16:09 +0100)]
[InstCombine] Change order of canonicalization of ADD and AND

Canonicalize ((x + C1) & C2) --> ((x & C2) + C1) for suitable constants
C1 and C2, instead of the other way round. This should allow more
constant ADDs to be matched as part of addressing modes for loads and
stores.

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

23 months ago[InstCombine] Try not to demand low order bits for Add
Jay Foad [Mon, 18 Jul 2022 18:32:40 +0000 (19:32 +0100)]
[InstCombine] Try not to demand low order bits for Add

Don't demand low order bits from the LHS of an Add if:
- they are not demanded in the result, and
- they are known to be zero in the RHS, so they can't possibly
  overflow and affect higher bit positions

This is intended to avoid a regression from a future patch to change
the order of canonicalization of ADD and AND.

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