platform/upstream/llvm.git
3 years ago[NFC] MemoryDependenceAnalysis cleanup.
Daniil Fukalov [Wed, 12 May 2021 19:43:16 +0000 (22:43 +0300)]
[NFC] MemoryDependenceAnalysis cleanup.

1. Removed redundant includes,
2. Removed never defined and used `releaseMemory()`.
3. Fixed member functions names first letter case.
4. Renamed duplicate (in nested struct `NonLocalPointerInfo`) name
   `NonLocalDeps` to `NonLocalDepsMap`.

Reviewed By: nikic

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

3 years ago[mlir][linalg] Cleanup LinalgOp usage in verification (NFC).
Tobias Gysi [Mon, 31 May 2021 13:30:56 +0000 (13:30 +0000)]
[mlir][linalg] Cleanup LinalgOp usage in verification (NFC).

Replace the uses of deprecated Structured Op Interface methods in LinalgInterfaces.cpp. This patch is based on https://reviews.llvm.org/D103394.

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

3 years agoRevert "[clang] Add support for the "abstract" contextual keyword of MSVC"
Mikhail Goncharov [Mon, 31 May 2021 13:33:15 +0000 (15:33 +0200)]
Revert "[clang] Add support for the "abstract" contextual keyword of MSVC"

This reverts commit 818338add77411f5e9713247ea66142f332ef350.

Tests fail under sanitizer: https://lab.llvm.org/buildbot/#/builders/5/builds/8150

3 years ago[mlir][linalg] Update Structured Op Interface (NFC).
Tobias Gysi [Mon, 31 May 2021 12:46:32 +0000 (12:46 +0000)]
[mlir][linalg] Update Structured Op Interface (NFC).

Adding methods to access operand properties via OpOperands and mark outdated methods as deprecated.

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

3 years ago[SDAG] add check to sext-of-setcc fold to bypass changing a legal op
Sanjay Patel [Mon, 31 May 2021 12:53:09 +0000 (08:53 -0400)]
[SDAG] add check to sext-of-setcc fold to bypass changing a legal op

I accidentaly pushed a draft of D103280 that was discussed
during the review, but it was not supposed to be the final
version.

Rather than revert and recommit, I'm updating the existing
code. This way we have a record of the codegen diff that
would result if we decide to remove this predicate in the
future.

3 years ago[libunwind] fix -Wc++98-compat-extra-semi without _LIBUNWIND_HIDE_SYMBOLS
Nico Weber [Mon, 31 May 2021 12:53:07 +0000 (08:53 -0400)]
[libunwind] fix -Wc++98-compat-extra-semi without _LIBUNWIND_HIDE_SYMBOLS

3 years ago[MLIR][Shape] Remove duplicate operands of `shape.assuming_all` op
Frederik Gossen [Mon, 31 May 2021 11:51:20 +0000 (13:51 +0200)]
[MLIR][Shape] Remove duplicate operands of `shape.assuming_all` op

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

3 years ago[NFC] ScalarEvolution: apply SSO to the ExprValueMap value
Roman Lebedev [Mon, 31 May 2021 11:38:26 +0000 (14:38 +0300)]
[NFC] ScalarEvolution: apply SSO to the ExprValueMap value

ExprValueMap is a map from SCEV * to a set-vector of (Value *, ConstantInt *) pair,
and while the map itself will likely be big-ish (have many keys),
it is a reasonable assumption that each key will refer to a small-ish
number of pairs.

In particular looking at n=512 case from
https://bugs.llvm.org/show_bug.cgi?id=50384,
the small-size of 4 appears to be the sweet spot,
it results in the least allocations while minimizing memory footprint.
```
$ for i in $(ls heaptrack.opt.*.gz); do echo $i; heaptrack_print $i | tail -n 6; echo ""; done
heaptrack.opt.0-orig.gz
total runtime: 14.32s.
calls to allocation functions: 8222442 (574192/s)
temporary memory allocations: 2419000 (168924/s)
peak heap memory consumption: 190.98MB
peak RSS (including heaptrack overhead): 239.65MB
total memory leaked: 67.58KB

heaptrack.opt.1-n1.gz
total runtime: 13.72s.
calls to allocation functions: 7184188 (523705/s)
temporary memory allocations: 2419017 (176338/s)
peak heap memory consumption: 191.38MB
peak RSS (including heaptrack overhead): 239.64MB
total memory leaked: 67.58KB

heaptrack.opt.2-n2.gz
total runtime: 12.24s.
calls to allocation functions: 6146827 (502355/s)
temporary memory allocations: 2418997 (197695/s)
peak heap memory consumption: 163.31MB
peak RSS (including heaptrack overhead): 211.01MB
total memory leaked: 67.58KB

heaptrack.opt.3-n4.gz
total runtime: 12.28s.
calls to allocation functions: 6068532 (494260/s)
temporary memory allocations: 2418985 (197017/s)
peak heap memory consumption: 155.43MB
peak RSS (including heaptrack overhead): 201.77MB
total memory leaked: 67.58KB

heaptrack.opt.4-n8.gz
total runtime: 12.06s.
calls to allocation functions: 6068042 (503321/s)
temporary memory allocations: 2418992 (200646/s)
peak heap memory consumption: 166.03MB
peak RSS (including heaptrack overhead): 213.55MB
total memory leaked: 67.58KB

heaptrack.opt.5-n16.gz
total runtime: 12.14s.
calls to allocation functions: 6067993 (499958/s)
temporary memory allocations: 2418999 (199307/s)
peak heap memory consumption: 187.24MB
peak RSS (including heaptrack overhead): 233.69MB
total memory leaked: 67.58KB
```

While that test may be an edge worst-case scenario,
https://llvm-compile-time-tracker.com/compare.php?from=dee85d47d9f15fc268f7b18f279dac2774836615&to=98a57e31b1947d5bcdf4a5605ac2ab32b4bd5f63&stat=instructions
agrees that this also results in improvements in the usual situations.

3 years ago[MLIR] Fix warnings in AffineOps.cpp
Uday Bondhugula [Mon, 31 May 2021 12:27:22 +0000 (17:57 +0530)]
[MLIR] Fix warnings in AffineOps.cpp

Fix warnings in AffineOps.cpp.

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

3 years ago[AMDGPU][Libomptarget][NFC] Split host and device malloc
Pushpinder Singh [Mon, 31 May 2021 07:19:41 +0000 (07:19 +0000)]
[AMDGPU][Libomptarget][NFC] Split host and device malloc

This patch splits the code path for host and device malloc.

Reviewed By: JonChesterfield

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

3 years ago[llvm-objcopy][NFC] Refactor CopyConfig structure - remove lazy options processing.
Alexey Lapshin [Thu, 27 May 2021 11:07:35 +0000 (14:07 +0300)]
[llvm-objcopy][NFC] Refactor CopyConfig structure - remove lazy options processing.

During reviewing D102277 it was decided to remove lazy options processing
from llvm-objcopy CopyConfig structure. This patch transforms processing of ELF
lazy options into the in-place processing.

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

3 years agofix test for symlinked clang c1ee4fb5af49a
Mikhail Goncharov [Mon, 31 May 2021 11:29:33 +0000 (13:29 +0200)]
fix test for symlinked clang c1ee4fb5af49a

3 years ago[SDAG] try harder to fold casts into vector compare
Sanjay Patel [Mon, 31 May 2021 11:14:01 +0000 (07:14 -0400)]
[SDAG] try harder to fold casts into vector compare

sext (vsetcc X, Y) --> vsetcc (zext X), (zext Y) --
(when the zexts are free and a bunch of other conditions)

We have a couple of similar folds to this already for vector selects,
but this pattern slips through because it is only a setcc.

The tests are based on the motivating case from:
https://llvm.org/PR50055
...but we need extra logic to get that example, so I've left that as
a TODO for now.

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

3 years agofix broken clang tests after 7161bb87c914
Juneyoung Lee [Mon, 31 May 2021 10:25:06 +0000 (19:25 +0900)]
fix broken clang tests after  7161bb87c914

3 years ago[LiveDebugVariables] Stop trimming locations of non-inlined vars
Djordje Todorovic [Fri, 21 May 2021 12:29:23 +0000 (05:29 -0700)]
[LiveDebugVariables] Stop trimming locations of non-inlined vars

The D35953, D62650 and D73691 introduced trimming of variables locations
in LiveDebugVariables pass, since there are some cases where after
the virtregrewrite we have exploded number of DBG_VALUEs created for some
inlined variables. As it looks, all problematic cases were regarding
inlined variables, so it seems reasonable to stop trimming the location
ranges for non-inlined variables.
It has very good impact on the llvm-locstats report.

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

3 years ago[RISCV] Scale scalably-typed split argument offsets by VSCALE
Fraser Cormack [Thu, 27 May 2021 15:47:36 +0000 (16:47 +0100)]
[RISCV] Scale scalably-typed split argument offsets by VSCALE

This patch fixes a bug in lowering scalable-vector types in RISC-V's
main calling convention. When scalable-vector types are split and passed
indirectly, the target is responsible for scaling the offset --
initially set to the known-minimum store size -- by the scalable factor.

Before this we were issuing overlapping loads or stores to the different
parts, leading to incorrect codegen.

Credit to @HsiangKai for spotting this.

Reviewed By: HsiangKai

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

3 years ago[InsCombine] Fix a few remaining vec transforms to use poison instead of undef
Juneyoung Lee [Mon, 31 May 2021 09:40:40 +0000 (18:40 +0900)]
[InsCombine] Fix a few remaining vec transforms to use poison instead of undef

This is a patch that replaces shufflevector and insertelement's placeholder value with poison.

Underlying motivation is to fix the semantics of shufflevector with undef mask to return poison instead
(D93818)
The consensus has been made in the late 2020 via mailing list as well as the thread in https://bugs.llvm.org/show_bug.cgi?id=44185 .

This patch is a simple syntactic change to the existing code, hence directly pushed as a commit.

3 years ago[DSE] Remove stores in the same loop iteration
David Green [Mon, 31 May 2021 09:22:37 +0000 (10:22 +0100)]
[DSE] Remove stores in the same loop iteration

DSE will currently only remove stores in the same block unless they can
be guaranteed to be loop invariant. This expands that to any stores that
are in the same Loop, at the same loop level. This should still account
for where AA/MSSA will not handle aliasing between loops, but allow the
dead stores to be removed where they overlap in the same loop iteration.
It requires adding loop info to DSE, but that looks fairly harmless.

The test case this helps is from code like this, which can come up in
certain matrix operations:
  for(i=..)
    dst[i] = 0;
    for(j=..)
      dst[i] += src[i*n+j];

After LICM, this becomes:
for(i=..)
  dst[i] = 0;
  sum = 0;
  for(j=..)
    sum += src[i*n+j];
  dst[i] = sum;

The first store is dead, and with this patch is now removed.

Differntial Revision: https://reviews.llvm.org/D100464

3 years ago[lldb][NFC] Remove unused var in SBDebugger::GetInternalVariableValue
Raphael Isemann [Mon, 31 May 2021 09:06:55 +0000 (11:06 +0200)]
[lldb][NFC] Remove unused var in SBDebugger::GetInternalVariableValue

This variable was originally just the default return value but got unused
in 6920b52be6f8731692a9bff4fe6a7b596cda00c5 .

3 years ago[RISCV] Support vector conversions between fp and i1
Fraser Cormack [Fri, 28 May 2021 11:06:15 +0000 (12:06 +0100)]
[RISCV] Support vector conversions between fp and i1

This patch custom lowers FP_TO_[US]INT and [US]INT_TO_FP conversions
between floating-point and boolean vectors. As the default action is
scalarization, this patch both supports scalable-vector conversions and
improves the code generation for fixed-length vectors.

The lowering for these conversions can piggy-back on the existing
lowering, which lowers the operations to a supported narrowing/widening
conversion and then either an extension or truncation.

Reviewed By: craig.topper

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

3 years ago[clang] NFC: split HeaderMapTest to have re-usable header map implementation for...
Dmitry Polukhin [Thu, 27 May 2021 07:57:26 +0000 (00:57 -0700)]
[clang] NFC: split HeaderMapTest to have re-usable header map implementation for testing

NFC changes required for https://reviews.llvm.org/D103142

Test Plan: check-clang

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

3 years agoRevert "[WebAssembly][CodeGen] IR support for WebAssembly local variables"
Andy Wingo [Mon, 31 May 2021 08:55:15 +0000 (10:55 +0200)]
Revert "[WebAssembly][CodeGen] IR support for WebAssembly local variables"

This reverts commit bf35f4af51cddd743435bb6b94a45592c967891a.  There was
an error in a shared-library build.

3 years ago[clang] Add support for the "abstract" contextual keyword of MSVC
Abbas Sabra [Mon, 31 May 2021 08:38:17 +0000 (10:38 +0200)]
[clang] Add support for the "abstract" contextual keyword of MSVC

https://docs.microsoft.com/en-us/cpp/extensions/abstract-cpp-component-extensions?view=msvc-160
Note: like the already supported "sealed" keyword, the "abstract"
keyword is supported by MSVC by default.

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

3 years ago[WebAssembly][CodeGen] IR support for WebAssembly local variables
Andy Wingo [Wed, 21 Apr 2021 13:41:48 +0000 (15:41 +0200)]
[WebAssembly][CodeGen] IR support for WebAssembly local variables

This patch adds TargetStackID::WasmLocal.  This stack holds locations of
values that are only addressable by name -- not via a pointer to memory.
For the WebAssembly target, these objects are lowered to WebAssembly
local variables, which are managed by the WebAssembly run-time and are
not addressable by linear memory.

For the WebAssembly target IR indicates that an AllocaInst should be put
on TargetStackID::WasmLocal by putting it in the non-integral address
space WASM_ADDRESS_SPACE_WASM_VAR, with value 1.  SROA will mostly lift
these allocations to SSA locals, but any alloca that reaches instruction
selection (usually in non-optimized builds) will be assigned the new
TargetStackID there.  Loads and stores to those values are transformed
to new WebAssemblyISD::LOCAL_GET / WebAssemblyISD::LOCAL_SET nodes,
which then lower to the type-specific LOCAL_GET_I32 etc instructions via
tablegen patterns.

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

3 years ago[mlir][NFC] Remove illegal TanhOp in LLVMConversionTarget
Tres Popp [Sun, 30 May 2021 17:50:54 +0000 (19:50 +0200)]
[mlir][NFC] Remove illegal TanhOp in LLVMConversionTarget

No tests fail and this seems to be technical debt from when the math
dialect was created. This should not be there as it prevents users from
configuring their converion target freely and results in unexpected
behavior on seemingly unrelated ops.

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

3 years ago[mlir] Support permutation maps in vector transfer op folder
Matthias Springer [Mon, 31 May 2021 08:22:35 +0000 (17:22 +0900)]
[mlir] Support permutation maps in vector transfer op folder

Fold away in_bounds attribute even if the transfer op has a non-identity permutation map.

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

3 years ago[LangRef] update according to unwinding support in inline asm
cynecx [Mon, 31 May 2021 08:00:35 +0000 (09:00 +0100)]
[LangRef] update according to unwinding support in inline asm

https://reviews.llvm.org/D95745 introduced a new `unwind` keyword for inline assembler expressions. Inline asms marked with the `unwind` keyword allows stack unwinding from inline assembly because the compiler emits unwinding information ("around" the inline asm) as it would for calls/invokes. Unwinding the stack from within non-unwind inline asm may cause UB.

Reviewed By: Amanieu

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

3 years ago[libcxx] [test] Add UNSUPPORTED: msvc in a couple verify.cpp tests
Martin Storsjö [Fri, 28 May 2021 09:53:27 +0000 (09:53 +0000)]
[libcxx] [test] Add UNSUPPORTED: msvc in a couple verify.cpp tests

Due to issues with the detection of the clang-verify feature, these
tests have been skipped in the Windows CI configuration so far.

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

3 years ago[mlir][NFC] Rename MathToLLVM->MathToLibm
Tres Popp [Sun, 30 May 2021 17:43:27 +0000 (19:43 +0200)]
[mlir][NFC] Rename MathToLLVM->MathToLibm

3 years ago[clangd] Move gtest include to TestTU.cpp from TestTU.h
Kadir Cetinkaya [Mon, 31 May 2021 05:42:15 +0000 (07:42 +0200)]
[clangd] Move gtest include to TestTU.cpp from TestTU.h

3 years ago[InstCombine] Fix miscompile on GEP+load to icmp fold (PR45210)
Hyeongyu Kim [Mon, 31 May 2021 05:05:29 +0000 (14:05 +0900)]
[InstCombine] Fix miscompile on GEP+load to icmp fold (PR45210)

As noted in PR45210: https://bugs.llvm.org/show_bug.cgi?id=45210
...the bug is triggered as Eli say when sext(idx) * ElementSize overflows.

```
   // assume that GV is an array of 4-byte elements
   GEP = gep GV, 0, Idx // this is accessing Idx * 4
   L = load GEP
   ICI = icmp eq L, value
 =>
   ICI = icmp eq Idx, NewIdx
```

The foldCmpLoadFromIndexedGlobal function simplifies GEP+load operation to icmp.
And there is a problem because Idx * ElementSize can overflow.

Let's assume that the wanted value is at offset 0.
Then, there are actually four possible values for Idx to match offset 0: 0x00..00, 0x40..00, 0x80..00, 0xC0..00.
We should return true for all these values, but currently, the new icmp only returns true for 0x00..00.

This problem can be solved by masking off (trailing zeros of ElementSize) bits from Idx.

```
   ...
 =>
   Idx' = and Idx, 0x3F..FF
   ICI = icmp eq Idx', NewIdx
```

Reviewed By: efriedma

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

3 years ago[AVR][NFC] Refactor 8-bit & 16-bit shifts
Ben Shi [Mon, 31 May 2021 02:30:46 +0000 (10:30 +0800)]
[AVR][NFC] Refactor 8-bit & 16-bit shifts

Reviewed By: dylanmckay

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

3 years ago[lldb] Fix typos. NFC.
Bruce Mitchener [Sun, 30 May 2021 14:14:17 +0000 (21:14 +0700)]
[lldb] Fix typos. NFC.

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

3 years ago[CSE] Make domInfo a stored property, cut use of DominanceInfo::hasDominanceInfo...
Chris Lattner [Sun, 30 May 2021 19:22:08 +0000 (12:22 -0700)]
[CSE] Make domInfo a stored property, cut use of DominanceInfo::hasDominanceInfo. NFC.

CSE is the only client of this API, refactor it a bit to pull the query
internally to make changes to DominanceInfo a bit easier.  This commit
also improves comments a bit.

3 years ago[ORC-RT] Add common.h -- Logging, casting and remote dispatch utilities.
Lang Hames [Sat, 29 May 2021 18:42:09 +0000 (11:42 -0700)]
[ORC-RT] Add common.h -- Logging, casting and remote dispatch utilities.

3 years ago[ORC-RT] Add OrcRTCWrapperFunctionResult.
Lang Hames [Sat, 29 May 2021 00:08:23 +0000 (17:08 -0700)]
[ORC-RT] Add OrcRTCWrapperFunctionResult.

OrcRTCWrapperFunctionResult is a C struct that can be used to return serialized
results from "wrapper functions" -- functions that deserialize an argument
buffer, call through to an actual implementation function, then serialize and
return the result of that function. Wrapper functions allow calls between ORC
and the ORC Runtime to be written using a single signature,
WrapperFunctionResult(const char *ArgData, size_t ArgSize), and without coupling
either side to a particular transport mechanism (in-memory, TCP, IPC, ... the
actual mechanism will be determined by the TargetProcessControl implementation).

OrcRTCWrapperFunctionResult is designed to allow small serialized buffers to
be returned by value, with larger serialized results stored on the heap. They
also provide an error state to report failures in serialization/deserialization.

3 years ago[ARM] Guard against loop variant gather ptr operands
David Green [Sun, 30 May 2021 17:02:14 +0000 (18:02 +0100)]
[ARM] Guard against loop variant gather ptr operands

This ensures that the operands of any gather/scatter instructions that
we attempt to push out of the loop are invariant, preventing invalid IR
from being generated.

3 years ago[AVR] Improve inline assembly
Ben Shi [Sun, 30 May 2021 15:44:43 +0000 (23:44 +0800)]
[AVR] Improve inline assembly

Reviewed By: dylanmckay

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

3 years ago[LoopDeletion] Add more tests with infinite sub-loops & mustprogress.
Florian Hahn [Sun, 30 May 2021 15:34:30 +0000 (16:34 +0100)]
[LoopDeletion] Add more tests with infinite sub-loops & mustprogress.

A couple of additional tests inspired by PR50511.

3 years ago[mlir] StandardToLLVM: option to disable AllocOp lowering
Butygin [Wed, 19 May 2021 19:04:29 +0000 (22:04 +0300)]
[mlir] StandardToLLVM: option to disable AllocOp lowering

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

3 years ago[clang][AVR] Add avr-libc/include to clang system include paths
Ben Shi [Sun, 30 May 2021 14:39:07 +0000 (22:39 +0800)]
[clang][AVR] Add avr-libc/include to clang system include paths

Reviewed By: dylanmckay

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

3 years agoRevert "[clang-tidy] Simplify static assert check"
Roman Lebedev [Sun, 30 May 2021 13:40:01 +0000 (16:40 +0300)]
Revert "[clang-tidy] Simplify static assert check"

This patch starts to produce a very obvious false-positives,
despite the fact the preexisting tests already cover the pattern.
they clearly don't actually cover it.

https://godbolt.org/z/3zdqvbfxj

This reverts commit 1709bb8c7395418236ec94fe3b9d91fed746452b.

3 years ago[VectorCombine] Add tests with noundef index for load scalarization.
Florian Hahn [Sun, 30 May 2021 11:11:18 +0000 (12:11 +0100)]
[VectorCombine] Add tests with noundef index for load scalarization.

3 years ago[InstCombine] fix miscompile from vector select substitution
Sanjay Patel [Sun, 30 May 2021 10:43:33 +0000 (06:43 -0400)]
[InstCombine] fix miscompile from vector select substitution

This is similar to the fix in c590a9880d7a ( PR49832 ), but
we missed handling the pattern for select of bools (no compare
inst).

We can't substitute a vector value because the equality condition
replacement that we are attempting requires that the condition
is true/false for the entire value. Vector select can be partly
true/false.

I added an assert for vector types, so we shouldn't hit this again.
Fixed formatting while auditing the callers.

https://llvm.org/PR50500

3 years ago[DAGCombine] Poison-prove scalarizeExtractedVectorLoad.
Florian Hahn [Sat, 29 May 2021 17:50:14 +0000 (18:50 +0100)]
[DAGCombine] Poison-prove scalarizeExtractedVectorLoad.

extractelement is poison if the index is out-of-bounds, so just
scalarizing the load may introduce an out-of-bounds load, which is UB.

To avoid introducing new UB, we can mask the index so it only contains
valid indices.

Fixes PR50382.

Reviewed By: efriedma

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

3 years ago[NFCI] Move DEBUG_TYPE definition below #includes
Mindong Chen [Sun, 30 May 2021 09:13:48 +0000 (17:13 +0800)]
[NFCI] Move DEBUG_TYPE definition below #includes

When you try to define a new DEBUG_TYPE in a header file, DEBUG_TYPE
definition defined around the #includes in files include it could
result in redefinition warnings even compile errors.

Reviewed By: tejohnson

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

3 years ago[SafeStack] Use proper API to get stack guard
Pengxuan Zheng [Mon, 17 May 2021 19:16:07 +0000 (12:16 -0700)]
[SafeStack] Use proper API to get stack guard

Using the proper API automatically sets `__stack_chk_guard` to `dso_local` if
`Reloc::Static`. This wasn't strictly necessary until recently when dso_local was
no longer implied by `TargetMachine::shouldAssumeDSOLocal` for
`__stack_chk_guard`. By using the proper API, we can avoid generating unnecessary
GOT relocations.

Reviewed By: vitalybuka

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

3 years agoRevert "[TargetLowering] Only inspect attributes in the arguments for ArgListEntry"
Arthur Eubanks [Sun, 30 May 2021 06:08:15 +0000 (23:08 -0700)]
Revert "[TargetLowering] Only inspect attributes in the arguments for ArgListEntry"

This reverts commit 1c7f32334d4becc725b9025fd32291a0e5729acd.

Some code still needs to properly set parameter ABI attributes, see
D101806.

3 years agoRevert "[NFC] Use ArgListEntry indirect types more in ISel lowering"
Arthur Eubanks [Sun, 30 May 2021 05:40:07 +0000 (22:40 -0700)]
Revert "[NFC] Use ArgListEntry indirect types more in ISel lowering"

This reverts commit bc7d15c61da78864b35e3c114294d6e4db645611.

Dependent change is to be reverted.

3 years ago[analyzer] MallocSizeof: sizeof pointer type is compatible with void*
Xuanda Yang [Sun, 30 May 2021 01:51:41 +0000 (09:51 +0800)]
[analyzer] MallocSizeof: sizeof pointer type is compatible with void*

source: https://bugs.llvm.org/show_bug.cgi?id=50214

Make sizeof pointer type compatible with void* in MallocSizeofChecker.

Reviewed By: NoQ

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

3 years ago[libc++] Alphabetize and include-what-you-use. NFCI.
Arthur O'Dwyer [Wed, 19 May 2021 15:57:04 +0000 (11:57 -0400)]
[libc++] Alphabetize and include-what-you-use. NFCI.

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

3 years ago[libc++] [modules] Add __threading_support to the modulemap.
Arthur O'Dwyer [Sat, 29 May 2021 17:12:16 +0000 (13:12 -0400)]
[libc++] [modules] Add __threading_support to the modulemap.

It looks to me as if *every* helper header needs to be added to the modulemap,
actually; which is unfortunate since we keep proliferating them at such a
rapid pace.

3 years ago[InstrProfiling][test] Improve tests
Fangrui Song [Sat, 29 May 2021 21:30:44 +0000 (14:30 -0700)]
[InstrProfiling][test] Improve tests

3 years ago[libc++] [test] Update "test_compare.h" users to avoid removed-in-C++20 members....
Arthur O'Dwyer [Sat, 29 May 2021 14:13:14 +0000 (10:13 -0400)]
[libc++] [test] Update "test_compare.h" users to avoid removed-in-C++20 members. NFCI.

Drive-by minor improvements to a couple of uses of min_pointer.

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

3 years ago[ARM] Guard against WhileLoopStart kill flags
David Green [Sat, 29 May 2021 20:04:26 +0000 (21:04 +0100)]
[ARM] Guard against WhileLoopStart kill flags

If the operand of the WhileLoopStart is flagged as killed, that
currently gets propogated to both the t2CMPri as the instruction is
reverted, and the newly created t2DoLoopStart. Only the second should
remain as killing the operand, the first dropping the flags.

3 years ago[Dominance] Speed up recalculate noticable, NFC.
Chris Lattner [Sat, 29 May 2021 17:50:15 +0000 (10:50 -0700)]
[Dominance] Speed up recalculate noticable, NFC.

This avoids trying to find the RegionKindInterface for every
operation in the program, we only need it if they have regions.

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

3 years ago[Verifier] Inline a method to simplify the code in preparation for bigger changes...
Chris Lattner [Sat, 29 May 2021 17:33:20 +0000 (10:33 -0700)]
[Verifier] Inline a method to simplify the code in preparation for bigger changes, NFC.

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

3 years ago[clang-format] successive C# attributes cause line breaking issues
mydeveloperday [Sat, 29 May 2021 15:43:55 +0000 (16:43 +0100)]
[clang-format] successive C# attributes cause line breaking issues

{D74265} reduced the aggressiveness of line breaking following C# attributes, however this change removed any support for attributes on properties, causing significant ugliness to be introduced.

This revision goes some way to addressing that by re-introducing the more aggressive check to `mustBreakBefore()`, but constraining it to the most common cases where we use properties which should not impact the "caller info attributes"  or the "[In , Out]" decorations that are normally put on pinvoke

It does not address my additional concerns of the original change regarding multiple C# attributes, as these are somewhat incorrectly handled by virtue of the fact its not recognising the second attribute as an attribute at all. But instead thinking its an array.

The purpose of this revision is to get back to where we were for the most common of cases as a stepping stone to resolving this. However {D74265} has broken a lot of C# code and this revision will go someway alone to addressing the majority.

Reviewed By: jbcoe, HazardyKnusperkeks, curdeius

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

3 years agoRevert "[RISCV] Remove -riscv-no-aliases in favour of new -M no-aliases"
Jessica Clarke [Sat, 29 May 2021 14:11:37 +0000 (15:11 +0100)]
Revert "[RISCV] Remove -riscv-no-aliases in favour of new -M no-aliases"

The replacement doesn't work for llc, but it is needed by
patchable-function-entry.ll.

This reverts commit aa9a30b83a06e3e5e68e32ea645ec2d9edc27efc.

3 years ago[Support] Fix getMainExecutable on FreeBSD when called via an absolute path
Jessica Clarke [Sat, 29 May 2021 13:59:46 +0000 (14:59 +0100)]
[Support] Fix getMainExecutable on FreeBSD when called via an absolute path

On FreeBSD, absolute paths are passed unmodified in AT_EXECPATH, but
relative paths are resolved to absolute paths, and any symlinks will be
followed in the process. This means that the resource dir calculation
will be wrong if Clang is invoked as an absolute path to a symlink, and
this currently causes clang/test/Driver/rocm-detect.hip to fail on
FreeBSD. Thus, make sure to call realpath on the result, just like is
done on macOS.

Whilst here, clean up the old fallback auxargs loop to use the actual
type for auxargs rather than using lots of hacky casts that rely on
addresses and pointers being the same (which is not the case on CHERI,
and thus Arm's prototype Morello, although for little-endian systems it
happens to work still as the word-sized integer will be padded to a full
pointer, and it's someone academic given dereferencing past the end of
environ will give a bounds fault, but CheriBSD is new enough that the
elf_aux_info path will be used). This also makes the code easier to
follow, and removes the confusing double-increment of p.

Reviewed By: dim, arichardson

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

3 years ago[RISCV] Remove -riscv-no-aliases in favour of new -M no-aliases
Jessica Clarke [Sat, 29 May 2021 13:57:19 +0000 (14:57 +0100)]
[RISCV] Remove -riscv-no-aliases in favour of new -M no-aliases

Whilst here, also remove a couple of unnecessary -o - instances.

Reviewed By: MaskRay

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

3 years ago[InstCombine] fold zext of masked bit set/clear
Sanjay Patel [Sat, 29 May 2021 12:52:26 +0000 (08:52 -0400)]
[InstCombine] fold zext of masked bit set/clear

This does not solve PR17101, but it is one of the
underlying diffs noted here:
https://bugs.llvm.org/show_bug.cgi?id=17101#c8

We could ease the one-use checks for the 'clear'
(no 'not' op) half of the transform, but I do not
know if that asymmetry would make things better
or worse.

Proofs:
https://rise4fun.com/Alive/uVB

Name: masked bit set
%sh1 = shl i32 1, %y
%and = and i32 %sh1, %x
%cmp = icmp ne i32 %and, 0
%r = zext i1 %cmp to i32
=>
%s = lshr i32 %x, %y
%r = and i32 %s, 1

Name: masked bit clear
%sh1 = shl i32 1, %y
%and = and i32 %sh1, %x
%cmp = icmp eq i32 %and, 0
%r = zext i1 %cmp to i32
=>
%xn = xor i32 %x, -1
%s = lshr i32 %xn, %y
%r = and i32 %s, 1

Note: this is a re-post of a patch that I committed at:
rGa041c4ec6f7a

The commit was reverted because it exposed another bug:
rGb212eb7159b40

But that has since been corrected with:
rG8a156d1c2795189 ( D101191 )

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

3 years ago[InstCombine] reduce code duplication; NFC
Sanjay Patel [Fri, 28 May 2021 20:03:09 +0000 (16:03 -0400)]
[InstCombine] reduce code duplication; NFC

3 years ago[analyzer] Use Optional as a return type of StoreManager::castRegion
Denys Petrov [Fri, 28 May 2021 13:52:44 +0000 (16:52 +0300)]
[analyzer]  Use Optional as a return type of StoreManager::castRegion

Summary: Make StoreManager::castRegion function usage safier. Replace `const MemRegion *` with `Optional<const MemRegion *>`. Simplified one of related test cases due to suggestions in D101635.

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

3 years ago[SystemZ] Set getExtendForAtomicOps to ISD::ANY_EXTEND
Ulrich Weigand [Sat, 29 May 2021 10:15:18 +0000 (12:15 +0200)]
[SystemZ] Set getExtendForAtomicOps to ISD::ANY_EXTEND

The implementation of subword atomics does not actually
guarantee the result is zero-extended, which now caused
build bot failures after https://reviews.llvm.org/D101342
was landed.

3 years ago[gn build] Port b13edf6e907b
LLVM GN Syncbot [Sat, 29 May 2021 07:51:43 +0000 (07:51 +0000)]
[gn build] Port b13edf6e907b

3 years agoRevert "[libc++] NFC: Move unwrap_iter to its own header"
Mark de Wever [Sat, 29 May 2021 07:50:26 +0000 (09:50 +0200)]
Revert "[libc++] NFC: Move unwrap_iter to its own header"

This reverts commit 9968896cd62a62b11ac61085534dd598c4bd3c60.

This commit seems to cause the build failures of main.

3 years ago[LoopUnroll] Make DomTree explicitly required (NFC)
Nikita Popov [Sat, 29 May 2021 07:31:28 +0000 (09:31 +0200)]
[LoopUnroll] Make DomTree explicitly required (NFC)

Some of the code was already assuming that DT is non-null, so
make that requirement more explicit and remove unnecessary null
checks.

3 years ago[AtomicExpandPass][AArch64] Promote xchg with floating-point types to integer ones
LemonBoy [Sat, 29 May 2021 06:50:34 +0000 (08:50 +0200)]
[AtomicExpandPass][AArch64] Promote xchg with floating-point types to integer ones

Follow the same strategy used for atomic loads/stores by converting the operands to equally-sized integer types.
This change prevents the atomic expansion pass from generating illegal LL/SC pairs when targeting AArch64: `expand-atomicrmw-xchg-fp.ll` would previously instantiate intrinsics such as `llvm.aarch64.ldaxr.p0f32` that cannot be lowered.

Reviewed By: efriedma

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

3 years ago[InstrProfiling][test] Fix stale linkage.ll
Fangrui Song [Sat, 29 May 2021 04:33:32 +0000 (21:33 -0700)]
[InstrProfiling][test] Fix stale linkage.ll

3 years ago[InstrProfiling][test] Fix stale tests
Fangrui Song [Sat, 29 May 2021 04:14:03 +0000 (21:14 -0700)]
[InstrProfiling][test] Fix stale tests

* Change linkage/visibility of __profn_ variables to match the reality
* alwaysinline.ll: Add "EnableValueProfiling", otherwise it doesn't test available_externally alwaysinline.
* Delete PR23499.ll - covered by other comdat tests.

3 years ago[RISCV] Enable interleaved vectorization for RVV
Luke [Wed, 28 Apr 2021 15:25:31 +0000 (23:25 +0800)]
[RISCV] Enable interleaved vectorization for RVV

Enable interleaved vectorization for RVV.

Reviewed By: craig.topper

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

3 years ago[lld/mac] Don't crash on -order_file with assembly inputs on arm64
Nico Weber [Sat, 29 May 2021 00:37:39 +0000 (20:37 -0400)]
[lld/mac] Don't crash on -order_file with assembly inputs on arm64

.s files with `-g` generate __debug_aranges on darwin/arm64 for some
reason, and those lead to `nullptr` symbols. Don't crash on that.

Fixes PR50517.

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

3 years ago[Internalize] Simplify comdat renaming with noduplicates after D103043
Fangrui Song [Fri, 28 May 2021 23:58:38 +0000 (16:58 -0700)]
[Internalize] Simplify comdat renaming with noduplicates after D103043

I realized that we can use `comdat noduplicates` which is available on ELF.
Add a special case for wasm which doesn't support the feature.

3 years ago[AArch64][GlobalISel] Fix a crash during selection of a G_ZEXT(s8 = G_LOAD)
Amara Emerson [Fri, 28 May 2021 22:33:02 +0000 (15:33 -0700)]
[AArch64][GlobalISel] Fix a crash during selection of a G_ZEXT(s8 = G_LOAD)

We have special handling for a zext of a load <32b because the load does a zext
for free. In that case, we just select the G_ZEXT as if it were a copy but this
triggered the copy checking code to balk at the mismatched size.

This was being hidden because normally these get combined into G_ZEXTLOAD but
for atomics this doesn't happen. The test case here just uses a normal load
because the particular atomic isn't supported yet anyway.

3 years ago[clang-format] New BreakInheritanceList style AfterComma
Zhihao Yuan [Wed, 26 May 2021 20:22:44 +0000 (13:22 -0700)]
[clang-format] New BreakInheritanceList style AfterComma

This inheritance list style has been widely adopted by Symantec,
a division of Broadcom Inc. It breaks after the commas that
separate the base-specifiers:

    class Derived : public Base1,
                    private Base2
    {
    };

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

3 years ago[Verifier] Significantly speed up IsolatedFromAbove checking. NFC.
Chris Lattner [Fri, 28 May 2021 22:12:44 +0000 (15:12 -0700)]
[Verifier] Significantly speed up IsolatedFromAbove checking. NFC.

The implementation had a couple of problems, including checking
"isProperAncestor" in an inefficient way.  It also recursed into
other "isolated from above" ops.  In the case of CIRCT, we get
three levels of isolated ops:

  mlir::ModuleOp
    firrtl::CircuitOp
       firrtl::FModuleOp

The verification for module would recurse into the circuits and
fmodules checking them.  The verifier hook for circuit would
recurse into all the modules reverifying them, fmoduleop would
then reverify them.  The same happens for mlir::ModuleOp and Func.

While here, fix an old design problem: IsolatedFromAbove checking
was implemented by a method on the Region class, which isn't
actually general and isn't used by anything else.  Move it over
to be a trait impl verifier method like the others and specialize
it for its task.

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

3 years ago[CGAtomic] Delete outdated code comparing success/failure ordering for cmpxchg.
Eli Friedman [Fri, 28 May 2021 22:32:36 +0000 (15:32 -0700)]
[CGAtomic] Delete outdated code comparing success/failure ordering for cmpxchg.

This doesn't actually have any effect: we only call this code with
SequentiallyConsistent orderings.  But delete it anyway for consistency
with other recent changes.

3 years ago[lld-macho][test] Simplify --allow-empty with count 0
Fangrui Song [Fri, 28 May 2021 22:15:59 +0000 (15:15 -0700)]
[lld-macho][test] Simplify --allow-empty with count 0

3 years ago[LoopUnroll] Use changeToUnreachable() (NFC)
Nikita Popov [Fri, 28 May 2021 20:38:36 +0000 (22:38 +0200)]
[LoopUnroll] Use changeToUnreachable() (NFC)

When fulling unrolling with a non-latch exit, the latch block is
folded to unreachable. Replace this folding with the existing
changeToUnreachable() helper, rather than performing it manually.

This also moves the fold to happen after the manual DT update
for exit blocks. I believe this is correct in that the conversion
of an unconditional backedge into unreachable should not affect
the DT at all.

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

3 years ago[RISCV] Add separate MxList tablegen classes for widening/narrowing and sext.zext...
Craig Topper [Fri, 28 May 2021 21:04:04 +0000 (14:04 -0700)]
[RISCV] Add separate MxList tablegen classes for widening/narrowing and sext.zext.vf2/4/8. NFC

This is cleaner than slicing the MxList to remove elements from
the beginning or end since that requires hardcoding the size.

I don't expect the size of the list to change, but we shouldn't
repeat it in multiple places.

3 years ago[LoopUnroll] Add store to unreachable latch test (NFC)
Nikita Popov [Fri, 28 May 2021 20:48:23 +0000 (22:48 +0200)]
[LoopUnroll] Add store to unreachable latch test (NFC)

This is to show that we currently only convert the terminator to
unreachable, but don't clean up instructions before it (unless
trivial DCE removes them).

Also clean up excessive whitespace in this test.

3 years ago[LoopUnroll] Clean up exit folding (NFC)
Nikita Popov [Fri, 28 May 2021 18:14:32 +0000 (20:14 +0200)]
[LoopUnroll] Clean up exit folding (NFC)

This does some non-functional cleanup of exit folding during
unrolling. The two main changes are:

 * First rewrite latch->header edges, which is unrelated to exit
   folding.
 * Combine folding for latch and non-latch exits. After the
   previous change, the only difference in their logic is that
   for non-latch exits we currently only fold "known non-exit"
   cases, but not "known exit" cases.

I think this helps a lot to clarify this code and prepare it for
future changes.

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

3 years ago[RISCV] Pre-commit test cases for D103211. NFC
Craig Topper [Fri, 28 May 2021 19:59:34 +0000 (12:59 -0700)]
[RISCV] Pre-commit test cases for D103211. NFC

3 years ago[NFC] Remove confusing info about MainLoop VF/UF from debug message
Bardia Mahjour [Fri, 28 May 2021 20:10:04 +0000 (16:10 -0400)]
[NFC] Remove confusing info about MainLoop VF/UF from debug message

3 years ago[dsymutil tests] Try to make eh_frames.test run on other platforms
Nico Weber [Thu, 27 May 2021 19:35:41 +0000 (15:35 -0400)]
[dsymutil tests] Try to make eh_frames.test run on other platforms

We now have llvm-otool :)

3 years ago[clang-format] [docs] Regenerate style options documentation.
Marek Kurdej [Fri, 28 May 2021 19:48:13 +0000 (21:48 +0200)]
[clang-format] [docs] Regenerate style options documentation.

Forgotten in commits fce8c10b9363aa908d93d7ff.

3 years ago[AArch64][RISCV] Make sure isel correctly honors failure orderings.
Eli Friedman [Thu, 27 May 2021 20:35:59 +0000 (13:35 -0700)]
[AArch64][RISCV] Make sure isel correctly honors failure orderings.

If a cmpxchg specifies acquire or seq_cst on failure, make sure we
generate code consistent with that ordering even if the success ordering
is not acquire/seq_cst.

At one point, it was ambiguous whether this sort of construct was valid,
but the C++ standad and LLVM now accept arbitrary combinations of
success/failure orderings.

This doesn't address the corresponding issue in AtomicExpand. (This was
reported as https://bugs.llvm.org/show_bug.cgi?id=33332 .)

Fixes https://bugs.llvm.org/show_bug.cgi?id=50512.

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

3 years ago[gn build] manually port 982e3c05108b6 (check-lld needs dsymutil)
Nico Weber [Fri, 28 May 2021 19:39:12 +0000 (15:39 -0400)]
[gn build] manually port 982e3c05108b6 (check-lld needs dsymutil)

3 years ago[libc++] [test] Constexpr-ify a couple of insert-iterator tests.
Arthur O'Dwyer [Fri, 28 May 2021 13:46:01 +0000 (09:46 -0400)]
[libc++] [test] Constexpr-ify a couple of insert-iterator tests.

This should have been done in D96385; thanks ldionne for the catch!
Also, make the back/front inserter behavior tests a little more thorough,
which incidentally caught a cut-and-paste-bug in `nasty_list`, so fix that.

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

3 years ago[gn build] Port 9968896cd62a
LLVM GN Syncbot [Fri, 28 May 2021 18:57:30 +0000 (18:57 +0000)]
[gn build] Port 9968896cd62a

3 years ago[RISCV] Add octuple to LMULInfo tablegen class, remove octuple_from_str. NFCI
Craig Topper [Fri, 28 May 2021 18:51:20 +0000 (11:51 -0700)]
[RISCV] Add octuple to LMULInfo tablegen class, remove octuple_from_str. NFCI

octuple_from_str was always used with the MX field from an
LMULInfo. Might as well just precompute it and put it in the class.

3 years agoRevert "[clang][Parse] Add parsing support for C++ attributes on using-declarations"
Nico Weber [Fri, 28 May 2021 18:49:18 +0000 (14:49 -0400)]
Revert "[clang][Parse] Add parsing support for C++ attributes on using-declarations"

This reverts commit dc672999a9b12a156991891dc400308b52d569ba.
Breaks check-clang everywhere, see https://reviews.llvm.org/D91630

3 years ago[VP] Make getMaskParamPos/getVectorLengthParamPos return unsigned. Lowercase function...
Craig Topper [Fri, 28 May 2021 18:28:45 +0000 (11:28 -0700)]
[VP] Make getMaskParamPos/getVectorLengthParamPos return unsigned. Lowercase function names.

Parameter positions seem like they should be unsigned.

While there, make function names lowercase per coding standards.

Reviewed By: frasercrmck

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

3 years ago[SelectionDAG] Fix typo in assert. NFC
Craig Topper [Fri, 28 May 2021 17:24:54 +0000 (10:24 -0700)]
[SelectionDAG] Fix typo in assert. NFC

3 years ago[VectorCombine] Check indices for all extracts we scalarize.
Florian Hahn [Fri, 28 May 2021 17:20:01 +0000 (18:20 +0100)]
[VectorCombine] Check indices for all extracts we scalarize.

We need to make sure that the indices of all extracts we scalarize are
valid.

3 years ago[VectorCombine] Add variants of multi-extract tests with assumes.
Florian Hahn [Fri, 28 May 2021 14:41:24 +0000 (15:41 +0100)]
[VectorCombine] Add variants of multi-extract tests with assumes.

3 years agoRevert "Return "[LoopDeletion] Break backedge if we can prove that the loop is exited...
Stefan Pintilie [Fri, 28 May 2021 16:35:25 +0000 (11:35 -0500)]
Revert "Return "[LoopDeletion] Break backedge if we can prove that the loop is exited on 1st iteration" (try 2)"

This reverts commit be1a23203b1de655b8c7dac7549818d975a0cbbf.

3 years agoRevert "[NFCI][LoopDeletion] Only query SCEV about loop successor if another successo...
Stefan Pintilie [Fri, 28 May 2021 16:35:12 +0000 (11:35 -0500)]
Revert "[NFCI][LoopDeletion] Only query SCEV about loop successor if another successor is also in loop"

This reverts commit b0b2bf3b5da950679db1431aae431a6dedea2245.

3 years agoRevert "[NFC] Formatting fix"
Stefan Pintilie [Fri, 28 May 2021 16:34:02 +0000 (11:34 -0500)]
Revert "[NFC] Formatting fix"

This reverts commit 59d938e649e62db0cef4903d495e838fbc6a6eb8.