platform/upstream/llvm.git
2 years ago[mlir] Add assertion in NamedAttrList to prevent adding null attributes
Tres Popp [Mon, 23 Aug 2021 17:24:12 +0000 (19:24 +0200)]
[mlir] Add assertion in NamedAttrList to prevent adding null attributes

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

2 years ago[gn build] Port 48958d02d294
LLVM GN Syncbot [Wed, 25 Aug 2021 09:02:08 +0000 (09:02 +0000)]
[gn build] Port 48958d02d294

2 years ago[NFC][AMDGPU] Reduce includes dependencies.
Daniil Fukalov [Mon, 23 Aug 2021 20:50:19 +0000 (23:50 +0300)]
[NFC][AMDGPU] Reduce includes dependencies.

1. Splitted out some parts of R600 target to separate modules/headers.
2. Reduced some include lists in headers.
3. Found and fixed issue with override `GCNTargetMachine::getSubtargetImpl()`
   and `R600TargetMachine::getSubtargetImpl()` had different return value type
   than base class.
4. Minor forward declarations cleanup.

Reviewed By: foad

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

2 years ago[clang][deps] Use top-level modules as precompiled dependencies
Jan Svoboda [Wed, 25 Aug 2021 08:36:03 +0000 (10:36 +0200)]
[clang][deps] Use top-level modules as precompiled dependencies

The `ASTReader` populates `Module::PresumedModuleMapFile` only for top-level modules, not submodules. To avoid generating empty `-fmodule-map-file=` arguments, make discovered modules depend on top-level precompiled modules. The granularity of submodules is not important here.

The documentation of `Module::PresumedModuleMapFile` says this field is non-empty only when building from preprocessed source. This means there can still be cases where the dependency scanner generates empty `-fmodule-map-file=` arguments. That's being addressed in separate patch: D108544.

Reviewed By: dexonsmith

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

2 years agoHave lit preserve SOURCE_DATE_EPOCH
serge-sans-paille [Wed, 18 Aug 2021 21:48:14 +0000 (23:48 +0200)]
Have lit preserve SOURCE_DATE_EPOCH

This environment variable has been standardized for reproducible builds. Setting
it can help to have reproducible tests too, so keep it as part of the testing
env when set.

See https://reproducible-builds.org/docs/source-date-epoch/

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

2 years ago[clang][deps] Collect precompiled deps from submodules too
Jan Svoboda [Wed, 25 Aug 2021 08:14:15 +0000 (10:14 +0200)]
[clang][deps] Collect precompiled deps from submodules too

In this patch, the dependency scanner starts collecting precompiled dependencies from all encountered submodules, not only from top-level modules.

Reviewed By: dexonsmith

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

2 years ago[hwasan] do not check if freed pointer belonged to allocator.
Florian Mayer [Mon, 23 Aug 2021 13:03:16 +0000 (14:03 +0100)]
[hwasan] do not check if freed pointer belonged to allocator.

In that case it is very likely that there will be a tag mismatch anyway.

We handle the case that the pointer belongs to neither of the allocators
by getting a nullptr from allocator.GetBlockBegin.

Reviewed By: hctim, eugenis

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

2 years ago[GlobalISel] Do not generate illegal G_SEXTLOADs after legalization
Konstantin Schwarz [Tue, 24 Aug 2021 13:13:39 +0000 (15:13 +0200)]
[GlobalISel] Do not generate illegal G_SEXTLOADs after legalization

The sext_inreg_of_load combine did not have the isLegalOrBeforeLegalizer check,
leading to the generation of potentially illegal G_SEXTLOADs when run after legalization.

Reviewed By: foad

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

2 years ago[CUDA] Fix static device variables with -fgpu-rdc
Jonas Hahnfeld [Fri, 20 Aug 2021 11:28:37 +0000 (13:28 +0200)]
[CUDA] Fix static device variables with -fgpu-rdc

NVPTX does not allow dots in the identifier, so ptxas errors out with
   fatal   : Parsing error near '.static': syntax error
because it parses .static as a directive. Avoid this problem by using
two underscores, similar to what OpenMP does for outlined functions.

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

2 years ago[clang] Don't generate warn-stack-size when the warning is ignored
Yi Kong [Tue, 24 Aug 2021 09:06:08 +0000 (17:06 +0800)]
[clang] Don't generate warn-stack-size when the warning is ignored

8ace12130526 introduced a regression for code that explicitly ignores the
-Wframe-larger-than= warning. Make sure we don't generate the
warn-stack-size attribute for that case.

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

2 years agoAdd "REQUIRES: arm-registered-target" line to test added in D108603.
Douglas Yung [Wed, 25 Aug 2021 05:22:16 +0000 (22:22 -0700)]
Add "REQUIRES: arm-registered-target" line to test added in D108603.

This should fix the test failure on the PS4 build bot.

2 years ago[MachineCopyPropagation] Check CrossCopyRegClass for cross-class copys
Vang Thao [Fri, 13 Aug 2021 04:39:32 +0000 (21:39 -0700)]
[MachineCopyPropagation] Check CrossCopyRegClass for cross-class copys

On some AMDGPU subtargets, copying to and from AGPR registers using another
AGPR register is not possible. A intermediate VGPR register is needed for AGPR
to AGPR copy. This is an issue when machine copy propagation forwards a
COPY $agpr, replacing a COPY $vgpr which results in $agpr = COPY $agpr. It is
removing a cross class copy that may have been optimized by previous passes and
potentially creating an unoptimized cross class copy later on.

To avoid this issue, check CrossCopyRegClass if a different register class will
be needed for the copy. If so then avoid forwarding the copy when the
destination does not match the desired register class and if the original copy
already matches the desired register class.

Issue seen while attempting to optimize another AGPR to AGPR issue:

Live-ins: $agpr0
$vgpr0 = COPY $agpr0
$agpr1 = V_ACCVGPR_WRITE_B32 $vgpr0
$agpr2 = COPY $vgpr0
$agpr3 = COPY $vgpr0
$agpr4 = COPY $vgpr0

After machine-cp:

$vgpr0 = COPY $agpr0
$agpr1 = V_ACCVGPR_WRITE_B32 $vgpr0
$agpr2 = COPY $agpr0
$agpr3 = COPY $agpr0
$agpr4 = COPY $agpr0

Machine-cp propagated COPY $agpr0 to replace $vgpr0 creating 3 AGPR to AGPR
copys. Later this creates a cross-register copy from AGPR->VGPR->AGPR for each
copy when the prior VGPR->AGPR copy was already optimal.

Reviewed By: lkail, rampitec

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

2 years ago[JITLink][MachO] Add more detail to error message.
Lang Hames [Wed, 25 Aug 2021 03:31:06 +0000 (13:31 +1000)]
[JITLink][MachO] Add more detail to error message.

2 years ago[ORC] Fix typo in debugging output
Lang Hames [Wed, 25 Aug 2021 01:18:00 +0000 (11:18 +1000)]
[ORC] Fix typo in debugging output

2 years ago[DAGCombine] Pre-commit test for D108619
Carl Ritson [Wed, 25 Aug 2021 03:11:51 +0000 (12:11 +0900)]
[DAGCombine] Pre-commit test for D108619

2 years ago[InstrProfiling] Keep profd non-private for non-renamable comdat functions
Fangrui Song [Wed, 25 Aug 2021 03:14:02 +0000 (20:14 -0700)]
[InstrProfiling] Keep profd non-private for non-renamable comdat functions

The NS==0 condition used by D103717 missed a corner case: if the current copy
does not have a hash suffix (e.g. weak_odr), a copy with value profiling (with a
different CFG) may exist. This is super rare, but is possible with pre-inlining
PGO instrumentation (which can make a weak_odr function inlines its callees
differently, sometimes with value profiling while sometimes without).

If the current copy with private profd is prevailing, the non-prevailing copy
may get an undefined symbol if a caller inlining the non-prevailing function
references its profd. If the other copy with non-private profd is prevailing,
the current copy may cause a "relocation to discarded section" linker error.

The fix is straightforward: just keep non-private profd in such a `DataReferencedByCode` case.

With this change, a stage 2 (`-DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_BUILD_INSTRUMENTED=IR`)
clang is 0.08% larger (172431496/172286720-1).
`stat -c %s **/*.o | awk '{s+=$1}END{print s}' is 0.026% larger.
The majority of D103717's benefits remains.

Reviewed By: xur

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

2 years agoPR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.
Richard Smith [Wed, 25 Aug 2021 01:34:38 +0000 (18:34 -0700)]
PR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.

Previously when emitting a C++ guarded initializer, we tried to work out what
the enclosing function would be used for and added it to the COMDAT containing
the variable if we thought that doing so would be correct. But this was done
from a context in which we didn't -- and realistically couldn't -- correctly
infer how the enclosing function would be used.

Instead, add the initialization function to a COMDAT from the code that
creates it, in the case where it makes sense to do so: when we know that
the one and only reference to the initialization function is in
@llvm.global.ctors and that reference is in the same COMDAT.

Reviewed By: rjmccall

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

2 years ago[WebAssembly] Fix some UB from ca541aa319cd
Thomas Lively [Wed, 25 Aug 2021 02:44:03 +0000 (19:44 -0700)]
[WebAssembly] Fix some UB from ca541aa319cd

2 years agoRevert D108432 "[InstrProfiling] Keep profd non-private for non-renamable comdat...
Fangrui Song [Wed, 25 Aug 2021 02:16:07 +0000 (19:16 -0700)]
Revert D108432 "[InstrProfiling] Keep profd non-private for non-renamable comdat functions"

This reverts commit f653beea88d2684cdc8117e662b321ba04666771.

It broke Windows coverage-inline.cpp because link.exe has a limitation
that external symbols in IMAGE_COMDAT_SELECT_ASSOCIATIVE don't work.

It essentially dropped the previous size optimization for coverage
because coverage doesn't rename comdat by default.
Needs more investigation what we should do.

2 years ago[mlir][tosa] Quantized tosa.avg_pool2d lowering to linalg
Rob Suderman [Wed, 25 Aug 2021 01:23:21 +0000 (18:23 -0700)]
[mlir][tosa] Quantized tosa.avg_pool2d lowering to linalg

Includes the quantized version of average pool lowering to linalg dialect.
This includes a lit test for the transform. It is not 100% correct as the
multiplier / shift should be done in i64 however this is negligable rounding
difference.

Reviewed By: NatashaKnk

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

2 years ago[mlir][tosa] Table did not apply offset before extract on i8 input
Rob Suderman [Wed, 25 Aug 2021 01:14:47 +0000 (18:14 -0700)]
[mlir][tosa] Table did not apply offset before extract on i8 input

Lowering to table was incorrect as it did not apply a 128 offset before
extracting the value from the table. Fixed and correct tensor length on input
table.

Reviewed By: NatashaKnk

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

2 years ago[mlir][SCF] Generalize AffineMinSCFCanonicalization to min/max ops
Matthias Springer [Wed, 25 Aug 2021 01:28:01 +0000 (10:28 +0900)]
[mlir][SCF] Generalize AffineMinSCFCanonicalization to min/max ops

* Add support for affine.max ops to SCF loop peeling pattern.
* Add support for affine.max ops to `AffineMinSCFCanonicalizationPattern`.
* Rename `AffineMinSCFCanonicalizationPattern` to `AffineOpSCFCanonicalizationPattern`.
* Rename `AffineMinSCFCanonicalization` pass to `SCFAffineOpCanonicalization`.

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

2 years ago[mlir][sparse] Correcting the use of emplace_back
wren romano [Wed, 25 Aug 2021 01:29:05 +0000 (18:29 -0700)]
[mlir][sparse] Correcting the use of emplace_back

The emplace commands are variadic and should take all the constructor arguments directly, since they implicitly call the constructor themselves in order to avoid the cost of constructing and then moving/copying temporaries.

Reviewed By: aartbik

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

2 years ago[WebAssembly] Use SSAUpdaterBulk in LowerEmscriptenSjLj
Heejin Ahn [Tue, 17 Aug 2021 06:30:02 +0000 (23:30 -0700)]
[WebAssembly] Use SSAUpdaterBulk in LowerEmscriptenSjLj

We update SSA in two steps in Emscripten SjLj:
1. Rewrite uses of `setjmpTable` and `setjmpTableSize` variables and
   place `phi`s where necessary, which are updated where we call
   `saveSetjmp`.
2. Do a whole function level SSA update for all variables, because we
   split BBs where `setjmp` is called and there are possibly variable
   uses that are not dominated by a def.
   (See https://github.com/llvm/llvm-project/blob/955b91c19c00ed4c917559a5d66d14c669dde2e3/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp#L1314-L1324)

We have been using `SSAUpdater` to do this, but `SSAUpdaterBulk` class
was added after this pass was first created, and for the step 2 it looks
like a better alternative with a possible performance benefit. Not sure
the author is aware of it, but `SSAUpdaterBulk` seems to have a
limitation: it cannot handle a use within the same BB as a def but
before it. For example:
```
... = %a + 1
%a = foo();
```
or
```
%a = %a + 1
```
The uses `%a` in RHS should be rewritten with another SSA variable of
`%a`, most likely one generated from a `phi`. But `SSAUpdaterBulk`
thinks all uses of `%a` are below the def of `%a` within the same BB.
(`SSAUpdater` has two different functions of rewriting because of this:
`RewriteUse` and `RewriteUseAfterInsertions`.) This doesn't affect our
usage in the step 2 because that deals with possibly non-dominated uses
by defs after block splitting. But it does in the step 1, which still
uses `SSAUpdater`.

But this CL also simplifies the step 1 by using `make_early_inc_range`,
removing the need to advance the iterator before rewriting a use.

This is NFC; the test changes are just the order of PHI nodes.

Reviewed By: dschuff

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

2 years ago[mlir][tosa] Fix conv/depthwise conv padding for quantized values
Rob Suderman [Wed, 25 Aug 2021 01:08:07 +0000 (18:08 -0700)]
[mlir][tosa] Fix conv/depthwise conv padding for quantized values

When padding quantized operations, the padding needs to equal the zero point
of the input value. Corrected the pass to change the padding value if quantized.

Reviewed By: NatashaKnk

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

2 years ago[WebAssembly] Add Wasm SjLj option support for clang
Heejin Ahn [Mon, 23 Aug 2021 10:55:55 +0000 (03:55 -0700)]
[WebAssembly] Add Wasm SjLj option support for clang

This adds support for Wasm SjLj in clang. Also this sets the new
`-mllvm -wasm-enable-eh` option for Wasm EH.

Note there is a little unfortunate inconsistency there: Wasm EH is
enabled by a clang option `-fwasm-exceptions`, which sets
`-mllvm -wasm-enable-eh` in the backend options. It also sets
`-exception-model=wasm` but this is done in the common code.

Wasm SjLj doesn't have a clang-level option like `-fwasm-exceptions`.
`-fwasm-exceptions` was added because each exception model has its
corresponding `-f***-exceptions`, but I'm not sure if adding a new
option like `-fwasm-sjlj` or something is a good idea.

So the current plan is Emscripten sets `-mllvm -wasm-enable-sjlj` if
Wasm SJLj is enabled in its settings.js, as it does for Emscripten
EH/SjLj (it sets `-mllvm -enable-emscripten-cxx-exceptions` for
Emscripten EH and `-mllvm -enable-emscripten-sjlj` for Emscripten SjLj).
And setting this enables the exception handling feature, and also sets
`-exception-model=wasm`, but this time this is not done in the common
code so we do it ourselves.

Also note that other exception models have 1-to-1 correspondance with
their `-f***-exceptions` flag and their `-exception-model=***` flag, but
because we use `-exception-model=wasm` also for Wasm SjLj while
`-fwasm-exceptions` still means Wasm EH, there is also a little
inconsistency there, but I think it is manageable.

Also this adds various error checking and tests.

Reviewed By: dschuff

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

2 years ago[clang] allow -fstack-clash-protection on FreeBSD
Ed Maste [Mon, 23 Aug 2021 16:12:43 +0000 (12:12 -0400)]
[clang] allow -fstack-clash-protection on FreeBSD

-fstack-clash-protection was added in Clang commit e67cbac81211 but was
enabled only on Linux.  Allow it on FreeBSD as well, as it works fine.

Reviewed By: serge-sans-paille

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

2 years ago[gn build] Manually port dbed061b more
Nico Weber [Wed, 25 Aug 2021 01:01:20 +0000 (21:01 -0400)]
[gn build] Manually port dbed061b more

2 years ago[WebAssembly] Tidy up EH/SjLj options
Heejin Ahn [Sat, 7 Aug 2021 02:35:18 +0000 (19:35 -0700)]
[WebAssembly] Tidy up EH/SjLj options

This CL is small, but the description can be a little long because I'm
trying to sum up the status quo for Emscripten/Wasm EH/SjLj options.

First, this CL adds an option for Wasm SjLj (`-wasm-enable-sjlj`), which
handles SjLj using Wasm EH. The implementation for this will be added as
a followup CL, but this adds the option first to do error checking.

This also adds an option for Wasm EH (`-wasm-enable-eh`), which has been
already implemented. Before we used `-exception-model=wasm` as the same
meaning as enabling Wasm EH, but after we add Wasm SjLj, it will be
possible to use Wasm EH instructions for Wasm SjLj while not enabling
EH, so going forward, to use Wasm EH, `opt` and `llc` will need this
option. This only affects `opt` and `llc` command lines and does not
affect Emscripten user interface.

Now we have two modes of EH (Emscripten/Wasm) and also two modes of SjLj
(also Emscripten/Wasm). The options corresponding to each of are:
- Emscripten EH: `-enable-emscripten-cxx-exceptions`
- Emscripten SjLj: `-enable-emscripten-sjlj`
- Wasm EH: `-wasm-enable-eh -exception-model=wasm`
           `-mattr=+exception-handling`
- Wasm SjLj: `-wasm-enable-sjlj -exception-model=wasm`
             `-mattr=+exception-handling`
The reason Wasm EH/SjLj's options are a little complicated are
`-exception-model` and `-mattr` are common LLVM options ane not under
our control. (`-mattr` can be omitted if it is embedded within the
bitcode file.)

And we have the following rules of the option composition:
- Emscripten EH and Wasm EH cannot be turned on at the same itme
- Emscripten SjLj and Wasm SjLj cannot be turned on at the same time
- Wasm SjLj should be used with Wasm EH

Which means we now allow these combinations:
- Emscripten EH + Emscripten SjLj: the current default in `emcc`
- Wasm EH + Emscripten SjLj:
  This is allowed, but only as an interim step in which we are testing
  Wasm EH but not yet have a working implementation of Wasm SjLj. This
  will error out (D107687) in compile time if `setjmp` is called in a
  function in which Wasm exception is used.
- Wasm EH + Wasm SjLj:
  This will be the default mode later when using Wasm EH. Currently Wasm
  SjLj implementation doesn't exist, so it doesn't work.
- Emscripten EH + Wasm SjLj will not work.

This CL moves these error checking routines to
`WebAssemblyPassConfig::addIRPasses`. Not sure if this is an ideal place
to do this, but I couldn't find elsewhere. Currently some checking is
done within LowerEmscriptenEHSjLj, but these checks only run if
LowerEmscriptenEHSjLj runs so it may not run when Wasm EH is used. This
moves that to `addIRPasses` and adds some more checks.

Currently LowerEmscriptenEHSjLj pass is responsible for Emscripten EH
and Emscripten SjLj. Wasm EH transformations are done in multiple
places, including WasmEHPrepare, LateEHPrepare, and CFGStackify. But in
the followup CL, LowerEmscriptenEHSjLj pass will be also responsible for
a part of Wasm SjLj transformation, because WasmSjLj will also be using
several Emscripten library functions, and we will be sharing more than
half of the transformation to do that between Emscripten SjLj and Wasm
SjLj.

Currently we have `-enable-emscripten-cxx-exceptions` and
`-enable-emscripten-sjlj` but these only work for `llc`, because for
`llc` we feed these options to the pass but when we run the pass using
`opt` the pass will be created with no options and the default options
will be used, which turns both Emscripten EH and Emscripten SjLj on.

Now we have one more SjLj option to care for, LowerEmscriptenEHSjLj pass
needs a finer way to control these options. This CL removes those
default parameters and make LowerEmscriptenEHSjLj pass read directly
from command line options specified. So if we only run
`opt -wasm-lower-em-ehsjlj`, currently both Emscripten EH and Emscripten
SjLj will run, but with this CL, none will run unless we additionally
pass `-enable-emscripten-cxx-exceptions` or `-enable-emscripten-sjlj`,
or both. This does not affect users; this only affects our `opt` tests
because `emcc` will not call either `opt` or `llc`. As a result of this,
our existing Emscripten EH/SjLj tests gained one or both of those
options in their `RUN` lines.

Reviewed By: dschuff

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

2 years ago[GlobalOpt] Fix the assert for null check of global value
Shimin Cui [Wed, 25 Aug 2021 00:47:33 +0000 (20:47 -0400)]
[GlobalOpt] Fix the assert for null check of global value

This is to fix the reported assert - https://bugs.llvm.org/show_bug.cgi?id=51608.

Reviewed By: asbirlea

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

2 years ago[mlir][docs] A friendlier improvement for the Toy tutorial chapter 4.
Chenggang Zhao [Wed, 25 Aug 2021 00:41:35 +0000 (00:41 +0000)]
[mlir][docs] A friendlier improvement for the Toy tutorial chapter 4.

Add notes for discarding private-visible functions in the Toy tutorial chapter 4.

Reviewed By: mehdi_amini

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

2 years ago[libomptarget][amdgpu] Fix debug build from D104696
Jon Chesterfield [Wed, 25 Aug 2021 00:26:45 +0000 (01:26 +0100)]
[libomptarget][amdgpu] Fix debug build from D104696

2 years ago[WebAssembly] Fix up out-of-range BUILD_VECTOR lane constants
Thomas Lively [Wed, 25 Aug 2021 00:24:03 +0000 (17:24 -0700)]
[WebAssembly] Fix up out-of-range BUILD_VECTOR lane constants

Fixes PR51605 in which a DAG combine and legalization sequence generated
out-of-range constants in BUILD_VECTOR lanes. In the v16i8 case, the constants
were 255, which would be in range if DAG ISel used unsigned constants, but it is
out of range because DAG ISel uses signed constants.

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

2 years ago[msan] Unpoison trailing nullptr in wordexp interceptor
Vitaly Buka [Tue, 24 Aug 2021 21:43:59 +0000 (14:43 -0700)]
[msan] Unpoison trailing nullptr in wordexp interceptor

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

2 years ago[msan] Don't EXPECT_POISONED beyond the we_wordv
Vitaly Buka [Wed, 25 Aug 2021 00:11:51 +0000 (17:11 -0700)]
[msan] Don't EXPECT_POISONED beyond the we_wordv

Partially reverts commit 629411d799223d7bc7aad98661b1443a4788c0c5.

EXPECT_POISONED argument is outside of the allocation so we can't
assume the state of shadow there.

2 years agoExtend diagnostic for out of date AST input file.
Richard Smith [Fri, 23 Jul 2021 00:52:16 +0000 (17:52 -0700)]
Extend diagnostic for out of date AST input file.

If the size has changed, list the old and new sizes; if the mtime has
changed, list the old and new mtimes (as raw time_t values).

2 years ago[mlir][linalg] Replace AffineMinSCFCanonicalizationPattern with SCF reimplementation
Matthias Springer [Tue, 24 Aug 2021 23:47:05 +0000 (08:47 +0900)]
[mlir][linalg] Replace AffineMinSCFCanonicalizationPattern with SCF reimplementation

Use the new canonicalization pattern in the SCF dialect.

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

2 years ago[msan] Fix wordexp after D108646
Vitaly Buka [Tue, 24 Aug 2021 23:23:50 +0000 (16:23 -0700)]
[msan] Fix wordexp after D108646

I introduced this bug reformating the patch before commit.

2 years agoRevert "[AArch64][GlobalISel] Don't contract cross-bank copies into truncating stores."
Amara Emerson [Tue, 24 Aug 2021 23:08:08 +0000 (16:08 -0700)]
Revert "[AArch64][GlobalISel] Don't contract cross-bank copies into truncating stores."

This reverts commit 67bf3ac7446bd8ba16bb5ef82fa9f28a848616da.

The reason is that this change is now superseded by 04fb9b729a53 which fixes the
underlying problem in the selector. Now it's fine to generate truncating FP stores
since the selector code will just generate subreg copies to handle them.

2 years ago[mlir][sparse] enable a few vectorized runs in integration tests
Aart Bik [Tue, 24 Aug 2021 22:18:29 +0000 (15:18 -0700)]
[mlir][sparse] enable a few vectorized runs in integration tests

Recent changes outside sparse compiler exposed the requirement of running a
new pass (lower-affine) but this only became apparent with private testing.
By adding some vectorized runs to integration test, we will detect the need
for such changes earlier and also widen codegen coverage of course.

Reviewed By: gussmith23

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

2 years ago[AArch64][GlobalISel] Fix incorrect handling of fp truncating stores.
Amara Emerson [Tue, 24 Aug 2021 20:56:01 +0000 (13:56 -0700)]
[AArch64][GlobalISel] Fix incorrect handling of fp truncating stores.

When the tablegen patterns fail to select a truncating scalar FPR store,
our manual selection code also failed to handle it silently, trying to
generate an invalid copy. Fix this by adding support in the manual code
to generate a proper subreg copy before selecting a non-truncating store.

2 years ago[InstrProfiling] Keep profd non-private for non-renamable comdat functions
Fangrui Song [Tue, 24 Aug 2021 22:59:35 +0000 (15:59 -0700)]
[InstrProfiling] Keep profd non-private for non-renamable comdat functions

The NS==0 condition used by D103717 missed a corner case: if the current copy
does not have a hash suffix (e.g. weak_odr), a copy with value profiling (with a
different CFG) may exist. This is super rare, but is possible with pre-inlining
PGO instrumentation (which can make a weak_odr function inlines its callees
differently, sometimes with value profiling while sometimes without).

If the current copy with private profd is prevailing, the non-prevailing copy
may get an undefined symbol if a caller inlining the non-prevailing function
references its profd. If the other copy with non-private profd is prevailing,
the current copy may cause a "relocation to discarded section" linker error.

The fix is straightforward: just keep non-private profd in this case.

With this change, a stage 2 (`-DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_BUILD_INSTRUMENTED=IR`)
clang is 0.08% larger (172431496/172286720-1).
`stat -c %s **/*.o | awk '{s+=$1}END{print s}' is 0.026% larger.
The majority of D103717's benefits remains.

Reviewed By: xur

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

2 years ago[mlir][scf] Add general affine.min canonicalization pattern
Matthias Springer [Tue, 24 Aug 2021 12:21:12 +0000 (21:21 +0900)]
[mlir][scf] Add general affine.min canonicalization pattern

This canonicalization simplifies affine.min operations inside "for loop"-like operations (e.g., scf.for and scf.parallel) based on two invariants:
* iv >= lb
* iv < lb + step * ((ub - lb - 1) floorDiv step) + 1

This commit adds a new pass `canonicalize-scf-affine-min` (instead of being a canonicalization pattern) to avoid dependencies between the Affine dialect and the SCF dialect.

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

2 years agoRevert "[lldb] Add support for debugging via the dynamic linker."
Rumeet Dhindsa [Tue, 24 Aug 2021 22:20:52 +0000 (15:20 -0700)]
Revert "[lldb] Add support for debugging via the dynamic linker."

This reverts commit 1cbdc07ec015d83038c08dc562d55eccfd808591.

Buildbot failure started after this patch with failure in
api/multithreaded/TestMultithreaded.py:
https://lab.llvm.org/buildbot/#/builders/68/builds/17556

2 years ago[mlir] Fix attachInterface typo
Logan Chien [Tue, 24 Aug 2021 21:39:59 +0000 (14:39 -0700)]
[mlir] Fix attachInterface typo

This commit fixes the documentation typo regarding `attachInterface`.

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

2 years ago[DFSan] Add wrapper for getentropy().
Andrew Browne [Tue, 24 Aug 2021 01:33:25 +0000 (18:33 -0700)]
[DFSan] Add wrapper for getentropy().

Reviewed By: morehouse

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

2 years ago[sanitizer coverage] add a basic default implementation of callbacks for -fsanitize...
Kostya Serebryany [Thu, 19 Aug 2021 20:45:36 +0000 (13:45 -0700)]
[sanitizer coverage] add a basic default implementation of callbacks for -fsanitize-coverage=inline-8bit-counters,pc-table

[sanitizer coverage] add a basic default implementation of callbacks for -fsanitize-coverage=inline-8bit-counters,pc-table

Reviewed By: kostik

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

2 years ago[LLDB] Remove typos from NativeRegisterContextLinux_arm*
Muhammad Omair Javaid [Tue, 24 Aug 2021 21:53:31 +0000 (02:53 +0500)]
[LLDB] Remove typos from NativeRegisterContextLinux_arm*

This patch removed some typos from NativeRegisterContextLinux_arm and
NativeRegisterContextLinux_arm64. Some of the log/error messages were
being reported as x86_64.

2 years agoRevert "[lldb] Refactor Module::LookupInfo constructor"
Alex Langford [Tue, 24 Aug 2021 21:52:17 +0000 (14:52 -0700)]
Revert "[lldb] Refactor Module::LookupInfo constructor"

This reverts commit cd2134e42aa7d1168a3ed54e41793b022f961b1f.

Seems like this broke some tests on arm and aarch64 boxes. Will
investigate before re-landing.

2 years ago[MSAN] Fix wordexp interception when WRDE_DOOFFS is used
Justin Cady [Tue, 24 Aug 2021 19:34:41 +0000 (12:34 -0700)]
[MSAN] Fix wordexp interception when WRDE_DOOFFS is used

Handle the case of wordexp being invoked with WRDE_DOOFFS and
we.we_offs set to a positive value, which will result in NULL
entries prepended to the result. With this change the entire
result, containing both NULL and actual entries, is unpoisoned.

Reviewed By: vitalybuka

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

2 years ago[tests] Add a couple tests for intersection of ec8d87e and D108651
Philip Reames [Tue, 24 Aug 2021 21:28:57 +0000 (14:28 -0700)]
[tests] Add a couple tests for intersection of ec8d87e and D108651

2 years ago[clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction
Bob Haarman [Sat, 21 Aug 2021 00:14:32 +0000 (00:14 +0000)]
[clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction

CodeGenAction::ExecuteAction creates a BackendConsumer for the
purpose of handling diagnostics. The BackendConsumer's
DiagnosticHandlerImpl method expects CurLinkModule to be set,
but this did not happen on the code path that goes through
ExecuteAction. This change makes it so that the BackendConsumer
constructor used by ExecuteAction requires the Module to be
specified and passes the appropriate module in ExecuteAction.

The change also adds a test that fails without this change
and passes with it. To make the test work, the FIXME in the
handling of DK_Linker diagnostics was addressed so that warnings
and notes are no longer silently discarded. Since this introduces
a new warning diagnostic, a flag to control it (-Wlinker-warnings)
has also been added.

Reviewed By: xur

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

2 years ago[SCEV] Infer nuw from nw for addrecs
Philip Reames [Tue, 24 Aug 2021 21:23:03 +0000 (14:23 -0700)]
[SCEV] Infer nuw from nw for addrecs

This was previously committed in 914836b, and reverted due to confusion on the status of the review.

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

2 years ago[orc] Fix unit tests that use ORC C API
Ben Langmuir [Tue, 24 Aug 2021 18:10:11 +0000 (11:10 -0700)]
[orc] Fix unit tests that use ORC C API

* c_api_tests was failing to build after the API change to
  __orc_rt_CWrapperFunctionResultAllocate

* wrapper_function_utils_test was causing an assertion failure, because
  it was creating a result for `void(void)` with Size = 0, but seeing an
  uninitialized pointer, which it considered to be an out-of-bound
  error.

I noticed locally that making modifications to c_api.h is not causing
these unit tests to be rebuilt, which may be how the bug slipped in in
the first place.

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

2 years ago[test] Prcommit tests for D108651
Philip Reames [Tue, 24 Aug 2021 21:18:50 +0000 (14:18 -0700)]
[test] Prcommit tests for D108651

2 years ago[hwasan] Always untag short granule in shadow.
Mitch Phillips [Tue, 24 Aug 2021 21:10:02 +0000 (14:10 -0700)]
[hwasan] Always untag short granule in shadow.

Fixes a regression when the allocator is disabled, and a dirty
allocation is re-used. This only occurs when the allocator is disabled,
so a test-only fix, but still necessary.

Reviewed By: eugenis

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

2 years ago[X86] Add explicit library dependency on LLVMInstrumentation
Min-Yih Hsu [Tue, 24 Aug 2021 21:07:21 +0000 (14:07 -0700)]
[X86] Add explicit library dependency on LLVMInstrumentation

Patch 9588b685c6b2 introduced dependency on ASAN. But it didn't
explicitly put LLVMInstrumentation as one of the library dependencies
such that the build will fail if we're building LLVM as shared libraries
(i.e. -DBUILD_SHARED_LIBS=ON).
This patch explicitly links X86CodeGen against the Instrumentation
component.

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

2 years ago[AArch64][GlobalISel] Legalize narrow scalar FP arithmetic
Jessica Paquette [Tue, 24 Aug 2021 20:21:15 +0000 (13:21 -0700)]
[AArch64][GlobalISel] Legalize narrow scalar FP arithmetic

Widen narrow fp arithmetic ops (e.g. G_FADD). When we don't have full FP16
support, widen to s32. Otherwise widen to s16.

https://godbolt.org/z/TbT9Pqa7e

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

2 years ago[lldb] Refactor Module::LookupInfo constructor
Alex Langford [Tue, 17 Aug 2021 17:55:05 +0000 (10:55 -0700)]
[lldb] Refactor Module::LookupInfo constructor

Module::LookupInfo's constructor currently goes over supported languages
trying to figure out the best way to search for a symbol name. This
seems like a great candidate for refactoring. Specifically, this is work
that can be delegated to language plugins.

Once again, the goal here is to further decouple plugins from
non-plugins. The idea is to have each language plugin take a name and
give you back some information about the name from the perspective of
the language. Specifically, each language now implements a
`GetFunctionNameInfo` method which returns an object of type
`Language::FunctionNameInfo`. Right now, it consists of a basename,
a context, and a FunctionNameType. Module::LookupInfo's constructor will
call `GetFunctionNameInfo` with the appropriate language plugin(s) and
then decide what to do with that information. I have attempted to maintain
existing behavior as best as possible.

A nice side effect of this change is that lldbCore no longer links
against the ObjC Language plugin.

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

2 years ago[libc++abi] Apply simplify scan_eh_tab to SjLj
Kazushi (Jam) Marukawa [Tue, 24 Aug 2021 20:51:21 +0000 (16:51 -0400)]
[libc++abi] Apply simplify scan_eh_tab to SjLj

Previous "simplify scan_eh_tab" patch, https://reviews.llvm.org/D93190,
saves landingpad if and only if the target is not using SjLj exceptions.
However, the landingpad is used by SjLj exception handler also.  This
patch changes to set landingpad for both exception handlers.

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

2 years ago[lldb] Add support for debugging via the dynamic linker.
Rumeet Dhindsa [Tue, 24 Aug 2021 20:38:45 +0000 (13:38 -0700)]
[lldb] Add support for debugging via the dynamic linker.

This patch adds support for shared library load when the executable is
called through ld.so.

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

2 years ago[gn build] (manually) port 87dd51983cf9
Nico Weber [Tue, 24 Aug 2021 20:40:44 +0000 (16:40 -0400)]
[gn build] (manually) port 87dd51983cf9

2 years agoMake WindowsManifestMerger::merge() take a MemoryBufferRef
Nico Weber [Tue, 24 Aug 2021 20:38:34 +0000 (16:38 -0400)]
Make WindowsManifestMerger::merge() take a MemoryBufferRef

No behavior change.

2 years agollvm-xray {convert,extract}: Add --demangle
Fangrui Song [Tue, 24 Aug 2021 20:35:19 +0000 (13:35 -0700)]
llvm-xray {convert,extract}: Add --demangle

No demangling may be a better default in the future.
Add `--demangle` for migration convenience.

Reviewed By: Enna1

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

2 years ago[MCA] Adding an AMDGPUCustomBehaviour implementation.
Patrick Holland [Fri, 23 Jul 2021 00:46:39 +0000 (17:46 -0700)]
[MCA] Adding an AMDGPUCustomBehaviour implementation.

This implementation allows mca to model the desired behaviour of the s_waitcnt
instruction. This patch also adds the RetireOOO flag to the AMDGPU instructions
within the scheduling model. This flag is only used by mca and allows
instructions to finish out-of-order which helps mca's simulations more closely
model the actual device.

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

2 years agoRevert "[asan] Implemented intrinsic for the custom calling convention similar used...
Kirill Stoimenov [Tue, 24 Aug 2021 20:01:21 +0000 (13:01 -0700)]
Revert "[asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86."

This reverts commit 9588b685c6b2d90e4b6dd68e02e6a44affd77c3f. Breaks a bunch of builds.

Reviewed By: GMNGeoffrey

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

2 years ago[libc] Fix too long number in strtoul_test
Michael Jones [Tue, 24 Aug 2021 19:59:29 +0000 (19:59 +0000)]
[libc] Fix too long number in strtoul_test

I think this is the last windows type conversion fix, the rest of the
build seems to be okay.

Reviewed By: sivachandra

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

2 years ago[M68k][test] Migrate MC tests related to MOVEM instruciton
Min-Yih Hsu [Tue, 24 Aug 2021 19:50:28 +0000 (12:50 -0700)]
[M68k][test] Migrate MC tests related to MOVEM instruciton

Since we're now supporting the (correct) assembly syntax for MOVEM since
47f52f989b06. The remaining MOVEM MC tests can not be migrated into
test/MC/M68k.

2 years ago[Clang][OpenMP] Use enum to dereference children data array in OMPAtomicDirective
Shilei Tian [Tue, 24 Aug 2021 20:00:17 +0000 (16:00 -0400)]
[Clang][OpenMP] Use enum to dereference children data array in OMPAtomicDirective

Reviewed By: ABataev

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

2 years ago[libc] Fix type errors on Windows
Michael Jones [Tue, 24 Aug 2021 18:38:40 +0000 (18:38 +0000)]
[libc] Fix type errors on Windows

Fix the errors caused by having some numbers too large for a 32 bit
number in the tests for windows. Also fix the base causing some type
confusion.

Reviewed By: sivachandra

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

2 years ago[InstSimplify] fold or+shifted -1 to -1
Sanjay Patel [Tue, 24 Aug 2021 19:14:21 +0000 (15:14 -0400)]
[InstSimplify] fold or+shifted -1 to -1

These are similar to the rotate pattern added with:
dcf659e8219b
...but we don't have guard ops on the shift amount,
so we don't canonicalize to the intrinsic.

  declare void @llvm.assume(i1)

  define i32 @src(i32 %shamt, i32 %bitwidth) {
    ; subtract must be in range of bitwidth
    %lt = icmp ule i32 %bitwidth, 32
    call void @llvm.assume(i1 %lt)

    %r = lshr i32 -1, %shamt
    %s = sub i32 %bitwidth, %shamt
    %l = shl i32 -1, %s
    %o = or i32 %r, %l
    ret i32 %o
  }

  define i32 @tgt(i32 %shamt, i32 %bitwidth) {
    ret i32 -1
  }

https://alive2.llvm.org/ce/z/aF7WHx

2 years ago[InstSimplify] add tests for or-of-shifted-one-bits; NFC
Sanjay Patel [Tue, 24 Aug 2021 17:06:38 +0000 (13:06 -0400)]
[InstSimplify] add tests for or-of-shifted-one-bits; NFC

2 years ago[asan] Implemented intrinsic for the custom calling convention similar used by HWASan...
Kirill Stoimenov [Tue, 10 Aug 2021 17:49:48 +0000 (17:49 +0000)]
[asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

The implementation uses the int_asan_check_memaccess intrinsic to instrument the code. The intrinsic is replaced by a call to a function which performs the access check. The generated function names encode the input register name as a number using Reg - X86::NoRegister formula.

Reviewed By: vitalybuka

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

2 years ago[ARC] Add codegen for the readcyclecounter intrinsic along with disassembly for assoc...
Thomas Johnson [Tue, 24 Aug 2021 17:22:34 +0000 (10:22 -0700)]
[ARC] Add codegen for the readcyclecounter intrinsic along with disassembly for associated instructions

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

2 years ago[Polly][test] Add missing %loadPolly.
Michael Kruse [Tue, 24 Aug 2021 18:44:48 +0000 (13:44 -0500)]
[Polly][test] Add missing %loadPolly.

This fixes check-polly when using the -load mechanism,
i.e. LLVM_POLLY_LINK_INTO_TOOLS=OFF.

2 years ago[NFC] Add tests for i128 fshl on a few targets.
Eli Friedman [Tue, 24 Aug 2021 18:43:35 +0000 (11:43 -0700)]
[NFC] Add tests for i128 fshl on a few targets.

In preparation for D108058.

2 years agoSupport alias.scope and noalias metadata
Tyler Augustine [Tue, 24 Aug 2021 18:38:32 +0000 (20:38 +0200)]
Support alias.scope and noalias metadata

Introduces new Ops to represent 1. alias.scope metadata in LLVM, and 2. domains for these scopes. These correspond to the metadata described in https://llvm.org/docs/LangRef.html#noalias-and-alias-scope-metadata. Lists of scopes are modeled the same way as access groups - as an ArrayAttr on the Op (added in https://reviews.llvm.org/D97944).

Lowering 'noalias' attributes on function parameters is already supported. However, lowering `noalias` metadata on individual Ops is not, which is added in this change. LLVM uses the same keyword for these, but this change introduces a separate attribute name 'noalias_scopes' to represent this distinct concept.

Reviewed By: mehdi_amini

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

2 years ago[libc++] Remove support for CloudABI, which has been abandoned
Louis Dionne [Tue, 24 Aug 2021 15:40:05 +0000 (11:40 -0400)]
[libc++] Remove support for CloudABI, which has been abandoned

Based on https://github.com/NuxiNL/cloudlibc, it appears that the CloudABI
project has been abandoned. This patch removes a bunch of CloudABI specific
logic that had been added to support that platform.

Note that some knobs like LIBCXX_ENABLE_STDIN and LIBCXX_ENABLE_STDOUT
coud be useful in their own right, however those are currently broken.
If we want to re-add such knobs in the future, we can do it like we've
done it for localization & friends so that we can officially support
that configuration.

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

2 years agoAllow rematerialization of virtual reg uses
Stanislav Mekhanoshin [Thu, 19 Aug 2021 18:42:09 +0000 (11:42 -0700)]
Allow rematerialization of virtual reg uses

Currently isReallyTriviallyReMaterializableGeneric() implementation
prevents rematerialization on any virtual register use on the grounds
that is not a trivial rematerialization and that we do not want to
extend liveranges.

It appears that LRE logic does not attempt to extend a liverange of
a source register for rematerialization so that is not an issue.
That is checked in the LiveRangeEdit::allUsesAvailableAt().

The only non-trivial aspect of it is accounting for tied-defs which
normally represent a read-modify-write operation and not rematerializable.

The test for a tied-def situation already exists in the
/CodeGen/AMDGPU/remat-vop.mir,
test_no_remat_v_cvt_f32_i32_sdwa_dst_unused_preserve.

The change has affected ARM/Thumb, Mips, RISCV, and x86. For the targets
where I more or less understand the asm it seems to reduce spilling
(as expected) or be neutral. However, it needs a review by all targets'
specialists.

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

2 years ago[libc] fix string conversion tests for windows
Michael Jones [Mon, 23 Aug 2021 22:37:08 +0000 (22:37 +0000)]
[libc] fix string conversion tests for windows

There were some copy paste errors as well as some oddities around how
windows handles the difference between long and long long types. This
change fixes those.

Reviewed By: sivachandra

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

2 years ago[AArch64][GlobalISel] Legalize + select v2p0 -> v264 G_PTRTOINT
Jessica Paquette [Tue, 24 Aug 2021 04:59:27 +0000 (21:59 -0700)]
[AArch64][GlobalISel] Legalize + select v2p0 -> v264 G_PTRTOINT

1) Just mark this case as legal because it can just be a copy.

2) Ensure the copy in the existing code actually gets selected. Without doing
this, we'll crash because the destination won't have a register class.

This fell back 35 times in a build of clang with GISel for AArch64.

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

2 years ago[OpenMP][amdgcn] Don't use in-tree clang if not available.
Michael Kruse [Tue, 24 Aug 2021 17:38:00 +0000 (12:38 -0500)]
[OpenMP][amdgcn] Don't use in-tree clang if not available.

The use of `$<TARGET_FILE:clang>` was adapted too broadly from D101265.

Fixes llvm.org/PR51579

Also see discussion in D108534.

Reviewed By: JonChesterfield

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

2 years ago[llvm-reduce] Check if module data strings are empty before attempting to reduce
Arthur Eubanks [Tue, 24 Aug 2021 17:22:34 +0000 (10:22 -0700)]
[llvm-reduce] Check if module data strings are empty before attempting to reduce

2 years ago[tsan] Fix sigaction interceptor after D107186
Vitaly Buka [Tue, 24 Aug 2021 06:38:17 +0000 (23:38 -0700)]
[tsan] Fix sigaction interceptor after D107186

Set SA_SIGINFO only if we set sighandler, or we can set the flag, and
return it as 'old' without actual sigaction set.

Reviewed By: melver

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

2 years agoTry to fix build with modules enabled after D108422
Andrei Elovikov [Tue, 24 Aug 2021 17:16:07 +0000 (10:16 -0700)]
Try to fix build with modules enabled after D108422

D108422 removed Basic/X86Target.def but didn't delete the entry in
module.modulemap. Do it now. Hopefully it will fix the build.

2 years agoFix compilation errors in C API when using C compiler
Ben Langmuir [Thu, 12 Aug 2021 20:55:16 +0000 (13:55 -0700)]
Fix compilation errors in C API when using C compiler

* Cannot use sizeof() on another union member
* nullptr vs NULL
* () vs (void)

Incidentally, fix an incorrect comment about memory ownership on the
argument to __orc_rt_CreateCWrapperFunctionResultFromOutOfBandError,
which is copied, not moved.

2 years ago[NFC] Add and use AttributeList::removeFnAttributes()
Arthur Eubanks [Tue, 24 Aug 2021 16:53:39 +0000 (09:53 -0700)]
[NFC] Add and use AttributeList::removeFnAttributes()

2 years ago[llvm-reduce] Remove various module data
Arthur Eubanks [Mon, 23 Aug 2021 17:58:16 +0000 (10:58 -0700)]
[llvm-reduce] Remove various module data

This removes the data layout, target triple, source filename, and module
identifier when possible.

Reviewed By: swamulism

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

2 years agoRevert "[AST] Pick last tentative definition as the acting definition"
Benson Chu [Tue, 24 Aug 2021 16:40:38 +0000 (11:40 -0500)]
Revert "[AST] Pick last tentative definition as the acting definition"

This reverts commit 9a5f3888505630cea88f8372d3068b2d63cfb381.

The written test breaks some builds on Mach-O.

2 years ago[CSPGO] Fix lost IRPGOFlag in CSPGO instrumentation
Rong Xu [Tue, 24 Aug 2021 16:04:37 +0000 (09:04 -0700)]
[CSPGO] Fix lost IRPGOFlag in CSPGO instrumentation

The IRPGOFlag symbol (__llvm_profile_raw_version) is dropped when
identified as non-prevailing for either regular or thin LTO during
the mixed-LTO mode compilation. This happens in the module where
IRPGOFlag is marked as non-prevailing. This variable
is emitted in the final object from the prevailing module.

This is still problematic because we currently query this symbol
to coordinate some actions between PGOInstrumentation pass
and InstrProfiling lowering pass, like whether to do value
profiling, whether to do comdat renaming.

This problem is bought up by YolandaCY in
https://reviews.llvm.org/D107034
YolandCY reported unresolved symbol linker errors in
CSPGO instrumentation build for chromium.

This patch let LTO retain IRPGOFlag decl by adding it to
CompilerUsed list and relax the check in isIRPGOFlagSet() when
doing the InstrProfiling lowering.

The test case in the patch is from D107034
<https://reviews.llvm.org/D107034>.

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

2 years ago[compiler-rt] change internal internal libc invariants
Michael Jones [Wed, 18 Aug 2021 18:56:46 +0000 (18:56 +0000)]
[compiler-rt] change internal internal libc invariants

llvm-libc is expected to be built with sanitizers and not use interceptors in
the long run. For now though, we have a hybrid process, where functions
implemented in llvm-libc are instrumented, and glibc fills and sanitizer
interceptors fill in the rest.

Current sanitizers have an invariant that the REAL(...) function called from
inside of an interceptor is uninstrumented. A lot of interceptors call strlen()
in order to figure out the size of the region to check/poison. Switch these
callsites over to the internal, unsanitized implementation.

Reviewed By: hctim, vitalybuka

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

2 years ago[flang] runtime: fix WRITE after BACKSPACE on variable-length file
peter klausler [Mon, 23 Aug 2021 20:56:22 +0000 (13:56 -0700)]
[flang] runtime: fix WRITE after BACKSPACE on variable-length file

BACKSPACE leaves "recordLength" set, which is fine for a later READ,
but it causes a later WRITE to fail due to a misinterpretation of the
knowledge of the record length as indication of a fixed-length record
file (RECL=).  Fix.

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

2 years ago[flang] Extension: reduced scope for some implied DO loop indices
peter klausler [Fri, 20 Aug 2021 22:18:21 +0000 (15:18 -0700)]
[flang] Extension: reduced scope for some implied DO loop indices

The index of an implied DO loop in a DATA statement or array
constructor is defined by Fortran 2018 to have scope over its
implied DO loop.  This definition is unfortunate, because it
requires the implied DO loop's bounds expressions to be in the
scope of the index variable.  Consequently, in code like

  integer, parameter :: j = 5
  real, save :: a(5) = [(j, j=1, j)]

the upper bound of the loop is a reference to the index variable,
not the parameter in the enclosing scope.

This patch limits the scope of the index variable to the "body"
of the implied DO loop as one would naturally expect, with a warning.
I would have preferred to make this a hard error, but most Fortran
compilers treat this case as f18 now does.  If the standard
were to be fixed, the warning could be made optional.

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

2 years agoRevert "[SCEV] Infer nsw/nuw from nw for addrecs"
Philip Reames [Tue, 24 Aug 2021 16:27:53 +0000 (09:27 -0700)]
Revert "[SCEV] Infer nsw/nuw from nw for addrecs"

This reverts commit 914836b1c8b36d4a317ef6c233746f6ec37b57a5.  Further comments on review came up after initial approval.  Reverting while addressing.

2 years ago[NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def
Andrei Elovikov [Tue, 24 Aug 2021 15:59:05 +0000 (08:59 -0700)]
[NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def

Reviewed By: RKSimon

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

2 years ago[AArch64][GlobalISel] Select @llvm.aarch64.neon.ld4.*
Jessica Paquette [Tue, 24 Aug 2021 15:55:04 +0000 (08:55 -0700)]
[AArch64][GlobalISel] Select @llvm.aarch64.neon.ld4.*

Reuse the selection code from the ld2 case. This is similar to how SDAG handles
things in AArch64ISelDAGToDAG. (See SelectLoad)

This fell back ~100 times while building clang with GISel enabled for AArch64.

Factoring out the gross subreg copy part ought to make selecting the rest of
this family fairly easy.

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

2 years agoRevert "Special case common branch patterns in breakLoopBackedge"
Philip Reames [Tue, 24 Aug 2021 15:53:42 +0000 (08:53 -0700)]
Revert "Special case common branch patterns in breakLoopBackedge"

This reverts commit aec08e86004bb3b8a7c5a86992945c936593db59.

Several problems have been reported with malformed loopinfo after this change, see discussion on https://reviews.llvm.org/rGaec08e86004b.

2 years ago[SCEV] Infer nsw/nuw from nw for addrecs
Philip Reames [Tue, 24 Aug 2021 00:52:09 +0000 (17:52 -0700)]
[SCEV] Infer nsw/nuw from nw for addrecs

If we no an addrec doesn't self-wrap, the increment is strictly positive, and the start value is the smallest representable value, then we know that the corresponding wrap type can not occur.

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

2 years ago[mlir][sparse] use new permutation utility to avoid codedup
Aart Bik [Tue, 24 Aug 2021 15:20:08 +0000 (08:20 -0700)]
[mlir][sparse] use new permutation utility to avoid codedup

Reviewed By: ftynse

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

2 years ago[X86] Freeze vXi8 shl(x,1) -> add(x,x) vector fold (PR50468)
Simon Pilgrim [Tue, 24 Aug 2021 15:08:09 +0000 (16:08 +0100)]
[X86] Freeze vXi8 shl(x,1) -> add(x,x) vector fold (PR50468)

We don't have any vXi8 shift instructions (other than on XOP which is handled separately), so replace the shl(x,1) -> add(x,x) fold with shl(x,1) -> add(freeze(x),freeze(x)) to avoid the undef issues identified in PR50468.

Split off from D106675 as I'm still looking at whether we can fix the vXi16/i32/i64 issues with the D106679 alternative.

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