platform/upstream/llvm.git
3 years ago[AArch64][SVE] Fix missed immediate selection due to mishandling of signedness
Bradley Smith [Tue, 4 May 2021 10:18:34 +0000 (11:18 +0100)]
[AArch64][SVE] Fix missed immediate selection due to mishandling of signedness

The complex selection pattern for add/sub shifted immediates is
incorrect in it's handling of incoming constant values, in that it
does not properly anticipate the values to be signed extended to
32-bits.

Co-authored-by: Graham Hunter <graham.hunter@arm.com>
Differential Revision: https://reviews.llvm.org/D101833

3 years ago[mlir][linalg] Remove IndexedGenericOp support from FusionOnTensors...
Tobias Gysi [Thu, 13 May 2021 14:24:33 +0000 (14:24 +0000)]
[mlir][linalg] Remove IndexedGenericOp support from FusionOnTensors...

after introducing the IndexedGenericOp to GenericOp canonicalization (https://reviews.llvm.org/D101612).

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

3 years ago[mlir] Replace vector-to-scf with progressive-vector-to-scf
Matthias Springer [Thu, 13 May 2021 04:55:47 +0000 (13:55 +0900)]
[mlir] Replace vector-to-scf with progressive-vector-to-scf

Depends On D102388

Reviewed By: nicolasvasilache

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

3 years ago[mlir][linalg] Remove IndexedGenericOp support from DropUnitDims...
Tobias Gysi [Thu, 13 May 2021 13:14:47 +0000 (13:14 +0000)]
[mlir][linalg] Remove IndexedGenericOp support from DropUnitDims...

after introducing the IndexedGenericOp to GenericOp canonicalization (https://reviews.llvm.org/D101612).

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

3 years ago[TableGen] Make the NUL character invalid in .td files
Paul C. Anagnostopoulos [Tue, 11 May 2021 16:50:09 +0000 (12:50 -0400)]
[TableGen] Make the NUL character invalid in .td files

Now uses tr instead of sed.

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

3 years agoReapply [ConstantFold] Fold more operations to poison
Juneyoung Lee [Sat, 28 Nov 2020 19:26:44 +0000 (04:26 +0900)]
Reapply [ConstantFold] Fold more operations to poison

This was reverted to mitigate mitigate miscompiles caused by
the logical and/or to bitwise and/or fold. Reapply it now that
the underlying issue has been fixed by D101191.

-----

This patch folds more operations to poison.

Alive2 proof: https://alive2.llvm.org/ce/z/mxcb9G (it does not contain tests about div/rem because they fold to poison when raising UB)

Reviewed By: nikic

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

3 years ago[mlir] Migrate vector-to-loops.mlir to ProgressiveVectorToSCF
Matthias Springer [Thu, 13 May 2021 07:50:15 +0000 (16:50 +0900)]
[mlir] Migrate vector-to-loops.mlir to ProgressiveVectorToSCF

Create a copy of vector-to-loops.mlir and adapt the test for
ProgressiveVectorToSCF. Fix a small bug in getExtractOp() triggered by
this test.

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

3 years agoFix section title underlining in the release notes
Krzysztof Parzyszek [Thu, 13 May 2021 13:36:07 +0000 (08:36 -0500)]
Fix section title underlining in the release notes

3 years agoRevert "[CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions"
Oliver Stannard [Thu, 13 May 2021 13:25:40 +0000 (14:25 +0100)]
Revert "[CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions"

This reverts commit 3bf1acab5b454ad7fb2074b34663108b53620695.

This is causing the test `gcov-shared-flush.c' to fail on the 2-stage
aarch64 buildbots (https://lab.llvm.org/buildbot/#/builders/7/builds/2720).

3 years agoAdd entry about Hexagon V68 support to the release notes
Krzysztof Parzyszek [Thu, 13 May 2021 13:25:04 +0000 (08:25 -0500)]
Add entry about Hexagon V68 support to the release notes

3 years ago[AIX] XFAIL CodeGen/Generic/externally_available.ll
Jinsong Ji [Thu, 13 May 2021 13:24:45 +0000 (13:24 +0000)]
[AIX] XFAIL CodeGen/Generic/externally_available.ll

    Globals with “available_externally” linkage should never be emitted into the
    object file corresponding to the LLVM module.

    However, AIX system assembler default print error for undefined reference .
    so AIX chose to emit the available externally symbols into .s,
    so that users won't run into errors in situations like:

    clang -target powerpc-ibm-aix -xc -<<<$'extern inline
    __attribute__((__gnu_inline__)) void foo() {}\nvoid bar() { foo(); }' -O
    -Xclang -disable-llvm-passes

Reviewed By: hubert.reinterpretcast

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

3 years ago[mlir] Do not use pass labels in unrolled ProgressiveVectorToSCF
Matthias Springer [Thu, 13 May 2021 12:57:49 +0000 (21:57 +0900)]
[mlir] Do not use pass labels in unrolled ProgressiveVectorToSCF

Do not rely on pass labels to detect if the pattern was already applied in the past (which allows for more some extra optimizations to avoid extra InsertOps and ExtractOps). Instead, check if these optimizations can be applied on-the-fly.

This also fixes a bug, where vector.insert and vector.extract ops sometimes disappeared in the middle of the pass because they get folded away, but the next application of the pattern expected them to be there.

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

3 years ago[gn build] (manually) port 92f9852fc99b, clang-repl
Nico Weber [Thu, 13 May 2021 12:53:11 +0000 (08:53 -0400)]
[gn build] (manually) port 92f9852fc99b, clang-repl

3 years ago[clang-tidy] Fix test that requires Windows platofrm
Georgy Komarov [Wed, 12 May 2021 17:23:05 +0000 (20:23 +0300)]
[clang-tidy] Fix test that requires Windows platofrm

This commit fixes the cppcoreguidelines-pro-type-vararg test when it
runs on a Windows host, but the toolchain is targeted a non-Windows
platform.

Reviewed By: njames93

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

3 years ago[PowerPC] Handle inline assembly clobber of link regsiter
Stefan Pintilie [Thu, 13 May 2021 10:49:19 +0000 (05:49 -0500)]
[PowerPC] Handle inline assembly clobber of link regsiter

This patch adds the handling of clobbers of the link register LR for inline
assembly.

This patch is to fix:
https://bugs.llvm.org/show_bug.cgi?id=50147

Reviewed By: nemanjai, #powerpc

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

3 years ago[VPlan] Adjust assert in splitBlock to allow splitting at end.
Florian Hahn [Thu, 13 May 2021 11:57:39 +0000 (12:57 +0100)]
[VPlan] Adjust assert in splitBlock to allow splitting at end.

SplitAt should only be dereferenced in the assert if it does not point
to the end of the block. This fixes a crash in the added test case.

3 years ago[X86] X86ExpandPseudo.cpp - try to pass DebugLoc by const-ref to avoid costly Trackin...
Simon Pilgrim [Thu, 13 May 2021 12:27:01 +0000 (13:27 +0100)]
[X86] X86ExpandPseudo.cpp - try to pass DebugLoc by const-ref to avoid costly TrackingMDNodeRef copies. NFCI.

3 years ago[X86] X86InstrInfo.cpp - try to pass DebugLoc by const-ref to avoid costly TrackingMD...
Simon Pilgrim [Thu, 13 May 2021 12:23:19 +0000 (13:23 +0100)]
[X86] X86InstrInfo.cpp - try to pass DebugLoc by const-ref to avoid costly TrackingMDNodeRef copies. NFCI.

3 years ago[X86] VZeroUpperInserter::insertVZeroUpper - avoid DebugLoc creation by embedding...
Simon Pilgrim [Thu, 13 May 2021 12:19:13 +0000 (13:19 +0100)]
[X86] VZeroUpperInserter::insertVZeroUpper - avoid DebugLoc creation by embedding in the BuildMI calls. NFCI.

Try to pass DebugLoc by const-ref to avoid costly TrackingMDNodeRef copies.

3 years ago[Passes] Use regex to match GlobalsAA line in test.
Florian Hahn [Thu, 13 May 2021 12:22:18 +0000 (13:22 +0100)]
[Passes] Use regex to match GlobalsAA line in test.

On some platforms/compiler combinations, it appears the output is
slightly different. Update the test to use a regex, as is done at other
places in the new-pm-*default.ll tests to address buildbot failures.

3 years ago[Passes] Run GlobalsAA before LICM during LTO in new PM.
Florian Hahn [Thu, 13 May 2021 11:53:05 +0000 (12:53 +0100)]
[Passes] Run GlobalsAA before LICM during LTO in new PM.

This patch adjusts the LTO pipeline in the new PM to run GlobalsAA
before LICM to match the legacy PM.

This fixes a regression where the new PM failed to vectorize loops that
require hoisting/sinking by LICM depending on GlobalsAA info.

Reviewed By: aeubanks

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

3 years ago[RISCV][NFC] Simplify test run lines
Fraser Cormack [Thu, 13 May 2021 11:35:03 +0000 (12:35 +0100)]
[RISCV][NFC] Simplify test run lines

Several tests had -verify-machineinstrs twice, and several tests were
explicitly specifying the default FileCheck prefix of CHECK.

3 years ago[Passes] Use MemorySSA for LICM during LTO.
Florian Hahn [Thu, 13 May 2021 10:59:41 +0000 (11:59 +0100)]
[Passes] Use MemorySSA for LICM during LTO.

Split off from D102345 to commit this separately from other changes in
the patch. This aligns the behavior of the new PM with the legacy PM
for LTO, with respect to running LICM.

Together with the remaining changes in D102345, this fixes new PM
regressions where we fail to vectorize loops that are vectorized with
the legacy PM.

3 years ago[clang-repl] Fix ClangReplInterpreterTests unittest dependency.
Vassil Vassilev [Thu, 13 May 2021 10:31:59 +0000 (10:31 +0000)]
[clang-repl] Fix ClangReplInterpreterTests unittest dependency.

3 years ago[Utils] Use whoami to get username for arcanist warning message
David Spickett [Thu, 13 May 2021 10:11:43 +0000 (11:11 +0100)]
[Utils] Use whoami to get username for arcanist warning message

959eec1fddc83c90c208789f20cb6573b2a20642 changed the message
to show the local username with "$user" but this is not always set.

Some systems will have USER/USERNAME/LOGNAME, so just use "whoami"
instead.

3 years ago[PowerPC] Provide doubleword vector predicate form comparisons on Power7
Nemanja Ivanovic [Wed, 12 May 2021 17:18:52 +0000 (12:18 -0500)]
[PowerPC] Provide doubleword vector predicate form comparisons on Power7

There are two reasons this shouldn't be restricted to Power8 and up:
1. For XL compatibility
2. Because clang will expand comparison operators to these intrinsics*

*Without this patch, the following causes a selection error:

int test(vector signed long a, vector signed long b) {
  return a < b;
}

This patch provides the handling for the intrinsics in the back
end and removes the Power8 guards from the predicate functions
(vec_{all|any}_{eq|ne|gt|ge|lt|le}).

3 years ago[SCEV] Apply guards to max with non-unitary steps.
Florian Hahn [Thu, 13 May 2021 08:32:41 +0000 (09:32 +0100)]
[SCEV] Apply guards to max with non-unitary steps.

We already apply loop-guards when computing the maximum with unitary
steps. This extends the code to also do so when dealing with non-unitary
steps.

This allows us to infer a tighter maximum in some cases.

Reviewed By: nikic

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

3 years ago[TSAN] Honor failure memory orders in AtomicCAS
Bruno Cardoso Lopes [Thu, 13 May 2021 07:35:22 +0000 (00:35 -0700)]
[TSAN] Honor failure memory orders in AtomicCAS

LLVM has lifted strong requirements for CAS failure memory orders in 431e3138a and 819e0d105e84.

Add support for honoring them in `AtomicCAS`.

https://github.com/google/sanitizers/issues/970

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

3 years ago[clang-repl] Add final set of missing library dependencies.
Vassil Vassilev [Thu, 13 May 2021 08:06:52 +0000 (08:06 +0000)]
[clang-repl] Add final set of missing library dependencies.

3 years ago[libcxx] NFC. Fix misprint unodered -> unordered
Kristina Bessonova [Wed, 12 May 2021 12:32:43 +0000 (14:32 +0200)]
[libcxx] NFC. Fix misprint unodered -> unordered

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

3 years ago[NFC] Add GetInferiorAddrSize method, unify code to compute
Jason Molenda [Thu, 13 May 2021 07:46:21 +0000 (00:46 -0700)]
[NFC] Add GetInferiorAddrSize method, unify code to compute

MachProcess.mm has a sequence to get the address size in
the inferior in three places; and I'm about to add a fourth
in a future patch.  Not a fan.

3 years agoRevert "[SimpleLoopUnswitch] Port partially invariant unswitch from LoopUnswitch...
Jingu Kang [Thu, 13 May 2021 07:22:26 +0000 (08:22 +0100)]
Revert "[SimpleLoopUnswitch] Port partially invariant unswitch from LoopUnswitch to SimpleLoopUnswitch"

This reverts commit 88b259c01463c08ac2575b4432c07ea7751946b5.

It needs to fix below bugs.

https://bugs.llvm.org/show_bug.cgi?id=50279
https://bugs.llvm.org/show_bug.cgi?id=50302

3 years ago[FPEnv][X86] Implement lowering of llvm.set.rounding
Serge Pavlov [Thu, 13 May 2021 06:44:10 +0000 (13:44 +0700)]
[FPEnv][X86] Implement lowering of llvm.set.rounding

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

3 years agoUse an allow list on reserved macro identifiers
serge-sans-paille [Mon, 10 May 2021 13:56:22 +0000 (15:56 +0200)]
Use an allow list on reserved macro identifiers

The allow list is based on various official sources (see in-code comment).

This fixes https://bugs.llvm.org/show_bug.cgi?id=50248

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

3 years ago[clang-repl] Add exhaustive list of libInterpreter dependencies.
Vassil Vassilev [Thu, 13 May 2021 07:18:01 +0000 (07:18 +0000)]
[clang-repl] Add exhaustive list of libInterpreter dependencies.

This patch should appease the bots building with -DBUILD_SHARED_LIBS=On,
resolving the regression introduced in 92f9852fc99b.

3 years ago[clang-repl] Recommit "Land initial infrastructure for incremental parsing"
Vassil Vassilev [Thu, 13 May 2021 05:41:44 +0000 (05:41 +0000)]
[clang-repl] Recommit "Land initial infrastructure for incremental parsing"

Original commit message:

  In http://lists.llvm.org/pipermail/llvm-dev/2020-July/143257.html we have
  mentioned our plans to make some of the incremental compilation facilities
  available in llvm mainline.

  This patch proposes a minimal version of a repl, clang-repl, which enables
  interpreter-like interaction for C++. For instance:

  ./bin/clang-repl
  clang-repl> int i = 42;
  clang-repl> extern "C" int printf(const char*,...);
  clang-repl> auto r1 = printf("i=%d\n", i);
  i=42
  clang-repl> quit

  The patch allows very limited functionality, for example, it crashes on invalid
  C++. The design of the proposed patch follows closely the design of cling. The
  idea is to gather feedback and gradually evolve both clang-repl and cling to
  what the community agrees upon.

  The IncrementalParser class is responsible for driving the clang parser and
  codegen and allows the compiler infrastructure to process more than one input.
  Every input adds to the “ever-growing” translation unit. That model is enabled
  by an IncrementalAction which prevents teardown when HandleTranslationUnit.

  The IncrementalExecutor class hides some of the underlying implementation
  details of the concrete JIT infrastructure. It exposes the minimal set of
  functionality required by our incremental compiler/interpreter.

  The Transaction class keeps track of the AST and the LLVM IR for each
  incremental input. That tracking information will be later used to implement
  error recovery.

  The Interpreter class orchestrates the IncrementalParser and the
  IncrementalExecutor to model interpreter-like behavior. It provides the public
  API which can be used (in future) when using the interpreter library.

  Differential revision: https://reviews.llvm.org/D96033

3 years ago[mlir] Support masks in TransferOpReduceRank and TransferReadPermutationLowering
Matthias Springer [Thu, 13 May 2021 06:04:40 +0000 (15:04 +0900)]
[mlir] Support masks in TransferOpReduceRank and TransferReadPermutationLowering

These two patterns allow for more efficient codegen in VectorToSCF.

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

3 years ago[gn build] Port d8b37de8a478
LLVM GN Syncbot [Thu, 13 May 2021 05:32:35 +0000 (05:32 +0000)]
[gn build] Port d8b37de8a478

3 years ago[GC][NFC] Move GCStrategy from CodeGen to IR
Max Kazantsev [Wed, 12 May 2021 07:36:24 +0000 (14:36 +0700)]
[GC][NFC] Move GCStrategy from CodeGen to IR

We want it to be available in analyzes so that we could use the
CodeGen notion in middle-end passes (for example, to check if
a GC may free some particular pointer).

This is a preparatory patch that simply moves the files around.

Note: if this causes some build issues, this patch must just be reverted.

Differential Revision: https://reviews.llvm.org/D100557
Reviewed By: reames

3 years ago[JITLink] Expose x86-64 pointer jump stub block construction.
Lang Hames [Thu, 13 May 2021 03:56:07 +0000 (20:56 -0700)]
[JITLink] Expose x86-64 pointer jump stub block construction.

This can be useful for clients who want to define their own symbol for the
stub, or re-use some existing symbol.

3 years ago[JITLink] Add a transferDefinedSymbol operation.
Lang Hames [Thu, 13 May 2021 03:48:42 +0000 (20:48 -0700)]
[JITLink] Add a transferDefinedSymbol operation.

The transferDefinedSymbol operation updates a Symbol's target block, offset,
and size. This can be convenient when you want to redefine the content of some
symbol(s) pointing at a block, while retaining the original block in the graph.

3 years agoAdd some warnings when debugserver is running in translation
Jason Molenda [Thu, 13 May 2021 05:15:55 +0000 (22:15 -0700)]
Add some warnings when debugserver is running in translation

A debugserver launched x86_64 cannot control an arm64/arm64e
process on an Apple Silicon system.  Warn when this situation
has happened and return an error for the most common case of
attach.  I think there will be refinements to this in the
future, but start out by making it easy to spot the problem
when it happens.

rdar://76630595

3 years ago[Coroutines] Salvege Debug.values
Chuanqi Xu [Thu, 13 May 2021 05:05:05 +0000 (13:05 +0800)]
[Coroutines] Salvege Debug.values

Summary: The previous implementation of coro-split didn't collect values
used by dbg instructions into the spills which made a log debug info
unavailable with optimization on.
This patch tries to collect these uses which are used by dbg.values. In
this way, the debugbility of coroutine could be as powerful as normal
functions with optimization on.

To avoid enlarging the coroutine frame, this patch only collects
`dbg.value` whose value is already in the coroutine frame. This decision
may make some debug info getting unavailable. But if we are with
optimization on, the performance issue should be considered first. And
this patch would make the debugbility of coroutine to be better only
without changing the layout of the frame.

Test-plan: check-llvm

Reviewed By: aprantl, lxfind

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

3 years ago[mlir][tosa] Fix tosa.cast semantics to perform rounding/clipping
Rob Suderman [Thu, 13 May 2021 04:47:55 +0000 (21:47 -0700)]
[mlir][tosa] Fix tosa.cast semantics to perform rounding/clipping

Rounding to integers requires rounding (for floating points) and clipping
to the min/max values of the destination range. Added this behavior and
updated tests appropriately.

Reviewed By: sjarus, silvas

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

3 years agoRevert "[clang-repl] Land initial infrastructure for incremental parsing"
Vassil Vassilev [Thu, 13 May 2021 04:43:01 +0000 (04:43 +0000)]
Revert "[clang-repl] Land initial infrastructure for incremental parsing"

This reverts commit 44a4000181e1a25027e87f2ae4e71cb876a7a275.

We are seeing build failures due to missing dependency to libSupport and
CMake Error at tools/clang/tools/clang-repl/cmake_install.cmake
file INSTALL cannot find

3 years ago[Coroutines] Enable printing coroutine frame when dbg info is available
Chuanqi Xu [Thu, 13 May 2021 04:35:37 +0000 (12:35 +0800)]
[Coroutines] Enable printing coroutine frame when dbg info is available

Summary: This patch tries to build debug info for coroutine frame in the
middle end. Although the coroutine frame is constructed and maintained by
the compiler and the programmer shouldn't care about the coroutine frame
by the design of C++20 coroutine,
a lot of programmers told me that they want to see the layout of the
coroutine frame strongly. Although C++ is designed as an abstract layer
so that the programmers shouldn't care about the actual memory in bits,
many experienced C++ programmers  are familiar with assembler and
debugger to see the memory layout in fact, After I was been told they
want to see the coroutine frame about 3 times, I think it is an actual
and desired demand.

However, the debug information is constructed in the front end and
coroutine frame is constructed in the middle end. This is a natural and
clear gap. So I could only try to construct the debug information in the
middle end after coroutine frame constructed. It is unusual, but we are
in consensus that the approch is the best one.

One hard part is we need construct the name for variables since there
isn't a map from llvm variables to DIVar. Then here is the strategy this
patch uses:
- The name `__resume_fn `, `__destroy_fn` and `__coro_index ` are
  constructed by the patch.
- Then the name `__promise` comes from the dbg.variable of corresponding
  dbg.declare of PromiseAlloca, which shows highest priority to
construct the debug information for the member of coroutine frame.
- Then if the member is struct, we would try to get the name of the llvm
  struct directly. Then replace ':' and '.' with '_' to make it
printable for debugger.
- If the member is a basic type like integer or double, we would try to
  emit the corresponding name.
- Then if the member is a Pointer Type, we would add `Ptr` after
  corresponding pointee type.
- Otherwise, we would name it with 'UnknownType'.

Reviewered by: lxfind, aprantl, rjmcall, dblaikie

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

3 years ago[SLP] Add insertelement instructions to vectorizable tree
Anton Afanasyev [Tue, 16 Mar 2021 07:23:13 +0000 (10:23 +0300)]
[SLP] Add insertelement instructions to vectorizable tree

Add new type of tree node for `InsertElementInst` chain forming vector.
These instructions could be either removed, or replaced by shuffles during
vectorization and we can add this node to cost model, so naturally estimating
their cost, getting rid of `CompensateCost` tricks and reducing further work
for InstCombine. This fixes PR40522 and PR35732 in a natural way. Also this
patch is the first step towards revectorization of partially vectorization
(to fix PR42022 completely). After adding inserts to tree the next step is
to add vector instructions there (for instance, to merge `store <2 x float>`
and `store <2 x float>` to `store <4 x float>`).

Fixes PR40522 and PR35732.

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

3 years ago[SLP][Test] Fix and precommit tests for D98714
Anton Afanasyev [Fri, 19 Mar 2021 08:09:58 +0000 (11:09 +0300)]
[SLP][Test] Fix and precommit tests for D98714

3 years ago[SLP][Test] Fix and precommit tests for D98714
Anton Afanasyev [Fri, 19 Mar 2021 08:09:58 +0000 (11:09 +0300)]
[SLP][Test] Fix and precommit tests for D98714

3 years ago[clang-repl] Land initial infrastructure for incremental parsing
Vassil Vassilev [Wed, 12 May 2021 20:48:03 +0000 (20:48 +0000)]
[clang-repl] Land initial infrastructure for incremental parsing

In http://lists.llvm.org/pipermail/llvm-dev/2020-July/143257.html we have
mentioned our plans to make some of the incremental compilation facilities
available in llvm mainline.

This patch proposes a minimal version of a repl, clang-repl, which enables
interpreter-like interaction for C++. For instance:

./bin/clang-repl
clang-repl> int i = 42;
clang-repl> extern "C" int printf(const char*,...);
clang-repl> auto r1 = printf("i=%d\n", i);
i=42
clang-repl> quit

The patch allows very limited functionality, for example, it crashes on invalid
C++. The design of the proposed patch follows closely the design of cling. The
idea is to gather feedback and gradually evolve both clang-repl and cling to
what the community agrees upon.

The IncrementalParser class is responsible for driving the clang parser and
codegen and allows the compiler infrastructure to process more than one input.
Every input adds to the “ever-growing” translation unit. That model is enabled
by an IncrementalAction which prevents teardown when HandleTranslationUnit.

The IncrementalExecutor class hides some of the underlying implementation
details of the concrete JIT infrastructure. It exposes the minimal set of
functionality required by our incremental compiler/interpreter.

The Transaction class keeps track of the AST and the LLVM IR for each
incremental input. That tracking information will be later used to implement
error recovery.

The Interpreter class orchestrates the IncrementalParser and the
IncrementalExecutor to model interpreter-like behavior. It provides the public
API which can be used (in future) when using the interpreter library.

Differential revision: https://reviews.llvm.org/D96033

3 years ago[mlir] Support memref layout maps in vector transfer ops
Matthias Springer [Thu, 13 May 2021 04:12:30 +0000 (13:12 +0900)]
[mlir] Support memref layout maps in vector transfer ops

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

3 years ago[mlir] Unrolled progressive-vector-to-scf.
Matthias Springer [Thu, 13 May 2021 03:57:45 +0000 (12:57 +0900)]
[mlir] Unrolled progressive-vector-to-scf.

Instead of an SCF for loop, these pattern generate fully unrolled loops with no temporary buffer allocations.

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

3 years ago[mlir] Allow empty position in vector.insert and vector.extract
Matthias Springer [Thu, 13 May 2021 03:53:15 +0000 (12:53 +0900)]
[mlir] Allow empty position in vector.insert and vector.extract

Such ops are no-ops and are folded to their respective `source`/`vector` operand.

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

3 years ago[mlir] Fix masked vector transfer ops with broadcasts
Matthias Springer [Thu, 13 May 2021 02:57:10 +0000 (11:57 +0900)]
[mlir] Fix masked vector transfer ops with broadcasts

Broadcast dimensions of a vector transfer op have no corresponding dimension in the mask vector. E.g., a 2-D TransferReadOp, where one dimension is a broadcast, can have a 1-D `mask` attribute.

This commit also adds a few additional transfer op integration tests for various combinations of broadcasts, masking, dim transposes, etc.

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

3 years ago[Debug-Info] add -gstrict-dwarf support in backend
Chen Zheng [Mon, 10 May 2021 02:04:02 +0000 (22:04 -0400)]
[Debug-Info] add -gstrict-dwarf support in backend

Reviewed By: dblaikie, probinson

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

3 years agoRevert "[mlir] Fix masked vector transfer ops with broadcasts"
Matthias Springer [Thu, 13 May 2021 02:55:00 +0000 (11:55 +0900)]
Revert "[mlir] Fix masked vector transfer ops with broadcasts"

This reverts commit c9087788f7e41285445729127dd07ff7f82e3fc0.

Accidentally pushed old version of the commit.

3 years ago[mlir] Fix masked vector transfer ops with broadcasts
Matthias Springer [Mon, 3 May 2021 09:03:19 +0000 (18:03 +0900)]
[mlir] Fix masked vector transfer ops with broadcasts

Broadcast dimensions of a vector transfer op have no corresponding dimension in the mask vector. E.g., a 2-D TransferReadOp, where one dimension is a broadcast, can have a 1-D `mask` attribute.

This commit also adds a few additional transfer op integration tests for various combinations of broadcasts, masking, dim transposes, etc.

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

3 years ago[clang] Minor fix for MarkVarDeclODRUsed
Yaxun (Sam) Liu [Wed, 12 May 2021 22:29:40 +0000 (18:29 -0400)]
[clang] Minor fix for MarkVarDeclODRUsed

Merge two if as follow up of https://reviews.llvm.org/D102270

3 years agoRename human-readable name for DW_LANG_Mips_Assembler
Adrian Prantl [Thu, 13 May 2021 01:43:34 +0000 (18:43 -0700)]
Rename human-readable name for DW_LANG_Mips_Assembler

The Mips in DW_LANG_Mips_Assembler is a vendor name not an
architecture name and in lack of a proper generic DW_LANG_assembler,
some assemblers emit DWARF using this tag. Due to a warning I recently
introduced users will now be greeted with

  This version of LLDB has no plugin for the mipsassem language. Inspection of frame variables will be limited.

By renaming this to just "Assembler" this error message will make more sense.

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

rdar://77214764

3 years agoHandle unexpanded packs appearing in type-constraints.
Richard Smith [Thu, 13 May 2021 01:29:26 +0000 (18:29 -0700)]
Handle unexpanded packs appearing in type-constraints.

For a type-constraint in a lambda signature, this makes the lambda
contain an unexpanded pack; for requirements in a requires-expressions
it makes the requires-expression contain an unexpanded pack; otherwise
it's invalid.

3 years agoPR50306: When instantiating a generic lambda with a constrained 'auto',
Richard Smith [Wed, 12 May 2021 22:25:52 +0000 (15:25 -0700)]
PR50306: When instantiating a generic lambda with a constrained 'auto',
properly track that it has constraints.

Previously an instantiation of a constrained generic lambda would behave
as if unconstrained because we incorrectly cached a "has no constraints"
value that we computed before the constraints from 'auto' parameters
were attached.

3 years agoClean up handling of constrained parameters in lambdas.
Richard Smith [Wed, 12 May 2021 21:19:23 +0000 (14:19 -0700)]
Clean up handling of constrained parameters in lambdas.

No functionality change intended.

3 years agoAdd test for substitutability of variable templates in closure type
Richard Smith [Wed, 12 May 2021 20:25:52 +0000 (13:25 -0700)]
Add test for substitutability of variable templates in closure type
mangling.

3 years ago[AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S
Pushpinder Singh [Wed, 12 May 2021 11:14:36 +0000 (11:14 +0000)]
[AMDGPU][OpenMP] Emit textual IR for -emit-llvm -S

Previously clang would print a binary blob into the bundled file
for amdgcn. With this patch, it will instead print textual IR as
expected.

Reviewed By: JonChesterfield, ronlieb

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

Change-Id: I10c0127ab7357787769fdf9a2edd4b3071e790a1

3 years agoscudo: Require fault address to be in bounds for UAF.
Peter Collingbourne [Wed, 12 May 2021 22:29:41 +0000 (15:29 -0700)]
scudo: Require fault address to be in bounds for UAF.

The bounds check that we previously had here was suitable for secondary
allocations but not for UAF on primary allocations, where it is likely
to result in false positives. Fix it by using a different bounds check
for UAF that requires the fault address to be in bounds.

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

3 years ago[libcxx] modifies `_CmpUnspecifiedParam` ignore types outside its domain
Christopher Di Bella [Sun, 2 May 2021 02:21:28 +0000 (02:21 +0000)]
[libcxx] modifies `_CmpUnspecifiedParam` ignore types outside its domain

D85051's honeypot solution was a bit too aggressive swallowed up the
comparison types, which made comparing objects of different ordering
types ambiguous.

Depends on D101707.

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

3 years ago[mlir][sparse][capi][python] add sparse tensor passes
Aart Bik [Wed, 12 May 2021 21:51:16 +0000 (14:51 -0700)]
[mlir][sparse][capi][python] add sparse tensor passes

First set of "boilerplate" to get sparse tensor
passes available through CAPI and Python.

Reviewed By: stellaraccident

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

3 years ago[AMDGPU] Refactor shouldExpandAtomicRMWInIR(). NFC.
Stanislav Mekhanoshin [Wed, 12 May 2021 21:18:16 +0000 (14:18 -0700)]
[AMDGPU] Refactor shouldExpandAtomicRMWInIR(). NFC.

This is logic simplification for better readability.

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

3 years ago[mlir][Linalg] Add interface methods to get lhs and rhs of contraction
MaheshRavishankar [Wed, 12 May 2021 23:06:02 +0000 (16:06 -0700)]
[mlir][Linalg] Add interface methods to get lhs and rhs of contraction

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

3 years agoChange the context instruction for computeKnownBits in LoadStoreVectorizer pass
Justin Bogner [Wed, 12 May 2021 22:29:29 +0000 (15:29 -0700)]
Change the context instruction for computeKnownBits in LoadStoreVectorizer pass

This change enables cases for which the index value for the first
load/store instruction in a pair could be a function argument. This
allows using llvm.assume to provide known bits information in such
cases.

Patch by Viacheslav Nikolaev. Thanks!

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

3 years agoOptimize GSymCreator::finalize.
Greg Clayton [Wed, 12 May 2021 20:20:31 +0000 (13:20 -0700)]
Optimize GSymCreator::finalize.

The algorithm removing duplicates from the Funcs list used to have
amortized quadratic time complexity because it was potentially
removing each entry using std::vector::erase individually. This
patch is now using a erase-remove idiom with an adapted
removeIfBinary algorithm.

Probably this was made under the assumption that these removals are
rare, but there are cases where the case of duplicate entries is
occurring frequently. In these cases, the actual runtime was very
poor, taking hours to process a single binary of around 1 GiB size
including debug info. Another factor contributing to that is the
frequent output of the warning, which is now removed.

It seems this is particularly an issue with GCC-compiled binaries,
rather than clang-built binaries.

Reviewed By: clayborg

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

3 years ago[mlir] Fix ssa values naming bug
Eugene Zhulenev [Wed, 12 May 2021 21:30:09 +0000 (14:30 -0700)]
[mlir] Fix ssa values naming bug

Address comments in https://reviews.llvm.org/D102226 to fix the bug + style violations

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

3 years ago[lld][WebAssembly] Allow data symbols to extend past end of segment
Sam Clegg [Tue, 11 May 2021 22:16:00 +0000 (15:16 -0700)]
[lld][WebAssembly] Allow data symbols to extend past end of segment

This fixes a bug with string merging with string symbols that contain
NULLs, as is the case in the `merge-string.s` test.

The bug only showed when we run with `--relocatable` and then try read
the resulting object back in.  In this case we would end up with string
symbols that extend past the end of the segment in which they live.

The problem comes from the fact that sections which are flagged as
string mergable assume that all strings are NULL terminated.  The
merging algorithm will drop trailing chars that follow a NULL since they
are essentially unreachable.  However, the "size" attribute (in the
symbol table) of such a truncated symbol is not updated resulting a
symbol size that can overlap the end of the segment.

I verified that this can happen in ELF too given the right conditions
and the its harmless enough.  In practice Strings that contain embedded
null should not be part of a mergable section.

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

3 years ago[WebAssembly] Add TLS data segment flag: WASM_SEG_FLAG_TLS
Sam Clegg [Mon, 10 May 2021 21:58:47 +0000 (14:58 -0700)]
[WebAssembly] Add TLS data segment flag: WASM_SEG_FLAG_TLS

Previously the linker was relying solely on the name of the segment
to imply TLS.

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

3 years ago[WebAssembly] Allow Wasm EH with Emscripten SjLj
Heejin Ahn [Wed, 12 May 2021 20:19:30 +0000 (13:19 -0700)]
[WebAssembly] Allow Wasm EH with Emscripten SjLj

We explicitly made it error out in D101403, out of a good intention that
the error message will make people less confusing. Turns out, we weren't
failing all cases of wasm EH + SjLj; only a few cases were failing and
our client was able to get around by fixing source code, but now we made
it fail for all cases, even the cases that previously succeeded fail,
which we didn't intend. This reverts that change.

Reviewed By: tlively

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

3 years ago[RISCV] Remove RISCVII:VSEW enum. Make encodeVYPE operate directly on SEW.
Craig Topper [Wed, 12 May 2021 19:38:06 +0000 (12:38 -0700)]
[RISCV] Remove RISCVII:VSEW enum. Make encodeVYPE operate directly on SEW.

The VSEW encoding isn't a useful value to pass around. It's better
to use SEW or log2(SEW) directly. The only real ugliness is that
the vsetvli IR intrinsics use the VSEW encoding, but it's easy
enough to decode that when the intrinsic is processed.

3 years agoFix bad mangling of <data-member-prefix> for a closure in the initializer of a variab...
Richard Smith [Thu, 6 May 2021 01:56:58 +0000 (18:56 -0700)]
Fix bad mangling of <data-member-prefix> for a closure in the initializer of a variable at global namespace scope.

This implements the direction proposed in
https://github.com/itanium-cxx-abi/cxx-abi/pull/126.

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

3 years ago[mlir-lsp-server][NFC] Add newline between Protocol JSON serialization methods and...
River Riddle [Wed, 12 May 2021 20:02:09 +0000 (13:02 -0700)]
[mlir-lsp-server][NFC] Add newline between Protocol JSON serialization methods and class definitions.

3 years ago[mlir-lsp-server] Add support for sending diagnostics to the client
River Riddle [Wed, 12 May 2021 20:01:59 +0000 (13:01 -0700)]
[mlir-lsp-server] Add support for sending diagnostics to the client

This allows for diagnostics emitted during parsing/verification to be surfaced to the user by the language client, as opposed to just being emitted to the logs like they are now.

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

3 years ago[flang] Fix standalone builds
Shoaib Meenai [Wed, 12 May 2021 19:59:23 +0000 (12:59 -0700)]
[flang] Fix standalone builds

Flang's CMake modules directory was being added to the CMake module path
twice, and AddFlang was being included after the first addition. Remove
the unnecessary first addition and move the AddFlang include down to the
second one. This way, it occurs after LLVM's CMake modules have been
included for a standalone build, so it can make use of those modules.

3 years agoSuppress Deferred Diagnostics in discarded statements.
Erich Keane [Tue, 11 May 2021 13:40:48 +0000 (06:40 -0700)]
Suppress Deferred Diagnostics in discarded statements.

It doesn't really make sense to emit language specific diagnostics
in a discarded statement, and suppressing these diagnostics results in a
programming pattern that many users will feel is quite useful.

Basically, this makes sure we only emit errors from the 'true' side of a
'constexpr if'.

It does this by making the ExprEvaluatorBase type have an opt-in option
as to whether it should visit discarded cases.

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

3 years ago[mlir][tosa] Remove tosa.identityn operator
Suraj Sudhir [Wed, 12 May 2021 19:39:25 +0000 (12:39 -0700)]
[mlir][tosa] Remove tosa.identityn operator

Removes the identityn operator from TOSA MLIR definition.
Removes TosaToLinAlg mappings

Reviewed By: rsuderman

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

3 years ago[ELF][AVR] Add explicit relocation types to getRelExpr
Fangrui Song [Wed, 12 May 2021 19:38:27 +0000 (12:38 -0700)]
[ELF][AVR] Add explicit relocation types to getRelExpr

3 years ago[LLD] [COFF] Fix including the personality function for DWARF EH when linking with...
Martin Storsjö [Sun, 9 May 2021 20:27:35 +0000 (23:27 +0300)]
[LLD] [COFF] Fix including the personality function for DWARF EH when linking with --gc-sections

Since c579a5b1d92a9bc2046d00ee2d427832e0f5ddec we don't traverse
.eh_frame when doing GC. But the exception handling personality
function needs to be included, and is only referenced from within
.eh_frame.

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

3 years ago[libcxx] [test] Fix fs.op.last_write_time for Windows
Martin Storsjö [Sun, 2 May 2021 21:13:51 +0000 (00:13 +0300)]
[libcxx] [test] Fix fs.op.last_write_time for Windows

Don't use stat and lstat on Windows; lstat is missing, stat only provides
the modification times with second granularity (and does the wrong thing
regarding symlinks). Instead do a minimal reimplementation using the
native windows APIs.

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

3 years ago[cmake] Fix typo in function name
Shoaib Meenai [Wed, 12 May 2021 19:14:20 +0000 (12:14 -0700)]
[cmake] Fix typo in function name

Not sure how my local testing didn't trigger this path. Should fix
https://lab.llvm.org/buildbot/#/builders/132/builds/5494

3 years ago[libc++][nfc] remove duplicated __to_unsigned.
Mark de Wever [Wed, 12 May 2021 15:46:24 +0000 (17:46 +0200)]
[libc++][nfc] remove duplicated __to_unsigned.

Both `<type_traits>` and `<charconv>` implemented this function with
different names and a slightly different behavior. This removes the
version in `<charconv>` and improves the version in `<typetraits>`.

- The code can be used again in C++11.
-  The original claimed C++14 support, but `[[nodiscard]]` is not
   available in  C++14.
- Adds `_LIBCPP_INLINE_VISIBILITY`.

Reviewed By: zoecarver, #libc, Quuxplusone

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

3 years ago[InstCombine] Support one-hot merge for logical and/or
Nikita Popov [Tue, 11 May 2021 21:01:29 +0000 (23:01 +0200)]
[InstCombine] Support one-hot merge for logical and/or

If a logical and/or is used, we need to be careful not to propagate
a potential poison value from the RHS by inserting a freeze
instruction. Otherwise it works the same way as bitwise and/or.

This is intended to address the regression reported at
https://reviews.llvm.org/D101191#2751002.

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

3 years agoAdd type information to integral template argument if required.
Pratyush Das [Wed, 12 May 2021 17:28:41 +0000 (17:28 +0000)]
Add type information to integral template argument if required.

Non-comprehensive list of cases:
 * Dumping template arguments;
 * Corresponding parameter contains a deduced type;
 * Template arguments are for a DeclRefExpr that hadMultipleCandidates()

Type information is added in the form of prefixes (u8, u, U, L),
suffixes (U, L, UL, LL, ULL) or explicit casts to printed integral template
argument, if MSVC codeview mode is disabled.

Differential revision: https://reviews.llvm.org/D77598

3 years agoRevert "Produce warning for performing pointer arithmetic on a null pointer."
Nico Weber [Wed, 12 May 2021 18:53:50 +0000 (14:53 -0400)]
Revert "Produce warning for performing pointer arithmetic on a null pointer."

This reverts commit dfc1e31d49fe1380c9bab43373995df5fed15e6d.
See discussion on https://reviews.llvm.org/D98798

3 years ago[clang-tidy] Allow opt-in or out of some commonly occuring patterns in NarrowingConve...
Stephen Concannon [Wed, 12 May 2021 18:25:22 +0000 (20:25 +0200)]
[clang-tidy] Allow opt-in or out of some commonly occuring patterns in NarrowingConversionsCheck.

Within clang-tidy's NarrowingConversionsCheck.
* Allow opt-out of some common occurring patterns, such as:
  - Implicit casts between types of equivalent bit widths.
  - Implicit casts occurring from the return of a ::size() method.
  - Implicit casts on size_type and difference_type.
* Allow opt-in of errors within template instantiations.

This will help projects adopt these guidelines iteratively.
Developed in conjunction with Yitzhak Mandelbaum (ymandel).

Patch by Stephen Concannon!

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

3 years ago[PhaseOrdering] Add test for missing vectorization with NewPM.
Florian Hahn [Wed, 12 May 2021 18:16:36 +0000 (19:16 +0100)]
[PhaseOrdering] Add test for missing vectorization with NewPM.

3 years ago[SCEV] Add loop-guard pessimizing test with step = 2.
Florian Hahn [Wed, 12 May 2021 16:02:49 +0000 (17:02 +0100)]
[SCEV] Add loop-guard pessimizing test with step = 2.

3 years ago[LoopFlatten] Simplify loops so that the pass can operate on unsimplified loops.
Stelios Ioannou [Tue, 11 May 2021 13:47:19 +0000 (14:47 +0100)]
[LoopFlatten] Simplify loops so that the pass can operate on unsimplified loops.

The loop flattening pass requires loops to be in simplified form. If the
loops are not in simplified form, the pass cannot operate. This patch
simplifies all loops before flattening. As a result, all loops will be
simplified regardless of whether anything ends up being flattened.

This change was inspired by observing a certain loop that was not flatten
because the loops were not in simplified form. This loop is added as a
test to verify that it is now flattened.

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

Change-Id: I45bcabe70fb99b0d89f0effafc82eb9e0585ec30

3 years ago[cmake] Add support for multiple distributions
Shoaib Meenai [Thu, 1 Oct 2020 21:35:28 +0000 (14:35 -0700)]
[cmake] Add support for multiple distributions

LLVM's build system contains support for configuring a distribution, but
it can often be useful to be able to configure multiple distributions
(e.g. if you want separate distributions for the tools and the
libraries). Add this support to the build system, along with
documentation and usage examples.

Reviewed By: phosek

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

3 years ago[mlir][linalg] Fixed issue generating reassociation map with Rank-0 types
Rob Suderman [Tue, 11 May 2021 22:31:20 +0000 (15:31 -0700)]
[mlir][linalg] Fixed issue generating reassociation map with Rank-0 types

Rank-0 case causes a graph during linalg reshape operation.

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

3 years agoRemove AST inclusion from Basic include
Benjamin Kramer [Wed, 12 May 2021 17:51:21 +0000 (19:51 +0200)]
Remove AST inclusion from Basic include

That's a cyclic dependency. NFC.

3 years ago[mlir][openacc] Add OpenACC translation to LLVM IR (enter_data op create/copyin)
Valentin Clement [Wed, 12 May 2021 15:41:03 +0000 (11:41 -0400)]
[mlir][openacc] Add OpenACC translation to LLVM IR (enter_data op create/copyin)

This patch begins to translate acc.enter_data operation to call to tgt runtime call.
It currently only translate create/copyin operands of memref type. This acts as a basis to add support
for FIR types in the Flang/OpenACC support. It follows more or less a similar path than clang
with `omp target enter data map` directives.
This patch is taking a different approach than D100678 and perform a translation to LLVM IR
and make use of the OpenMPIRBuilder instead of doing a conversion to the LLVMIR dialect.

OpenACC support in Flang will rely on the current OpenMP runtime where 1:1 lowering can be
applied. Some extension will be added where features are not available yet.

Big part of this code will be shared for other standalone data operations in the OpenACC
dialect such as acc.exit_data and acc.update.

It is likely that parts of the lowering can also be shared later with the ops for
standalone data directives in the OpenMP dialect when they are introduced.

This is an initial translation and it probably needs more work.

Reviewed By: ftynse

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

3 years ago[NFC][clang][Codegen] Split ThunkInfo into it's own header
Roman Lebedev [Wed, 12 May 2021 17:22:22 +0000 (20:22 +0300)]
[NFC][clang][Codegen] Split ThunkInfo into it's own header

Otherwise we'll have issues with forward definition of GlobalDecl.

Split off from https://reviews.llvm.org/D100388

3 years ago[NFCI][clang][Codegen] CodeGenVTables::addVTableComponent(): use getGlobalDecl
Roman Lebedev [Tue, 13 Apr 2021 12:10:39 +0000 (15:10 +0300)]
[NFCI][clang][Codegen] CodeGenVTables::addVTableComponent(): use getGlobalDecl

It does the same thing.
Split off from https://reviews.llvm.org/D100388