platform/upstream/llvm.git
3 years ago[LV] Support sinking recipe in replicate region after another region.
Florian Hahn [Thu, 24 Jun 2021 12:55:08 +0000 (13:55 +0100)]
[LV] Support sinking recipe in replicate region after another region.

This patch handles sinking a replicate region after another replicate
region. In that case, we can connect the sink region after the target
region. This properly handles the case for which an assertion has been
added in 337d7652823f.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34842.

Reviewed By: Ayal

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

3 years ago[mlir][linalg][python] Add attribute support to the YAML codegen.
Tobias Gysi [Thu, 24 Jun 2021 09:56:16 +0000 (09:56 +0000)]
[mlir][linalg][python] Add attribute support to the YAML codegen.

Extend the yaml code generation to support the index attributes that https://reviews.llvm.org/D104711 added to the OpDSL.

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

3 years ago[DebugInfo] Enable variadic debug value salvaging
Stephen Tozer [Wed, 23 Jun 2021 14:04:37 +0000 (15:04 +0100)]
[DebugInfo] Enable variadic debug value salvaging

This patch enables the salvaging of debug values that may be calculated
from more than one SSA value, such as with binary operators that do not
use a constant argument. The actual functionality for this behaviour is
added in a previous commit (c7270567), but with the ability to actually
emit the resulting debug values switched off.

The reason for this is that the prior patch has been reverted several
times due to issues discovered downstream, some time after the actual
landing of the patch. The patch in question is rather large and touches
several widely used header files, and all issues discovered are more
related to the handling of variadic debug values as a whole rather than
the details of the patch itself. Therefore, to minimize the build time
impact and risk of conflicts involved in any potential future
revert/reapply of that patch, this significantly smaller patch (that
touches no header files) will instead be used as the capstone to enable
variadic debug value salvaging.

The review linked to this patch is mostly implemented by the previous
commit, c7270567, but also contains the changes in this patch.

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

3 years ago[ARM] Extend narrow values to allow using truncating scatters
David Green [Thu, 24 Jun 2021 12:09:11 +0000 (13:09 +0100)]
[ARM] Extend narrow values to allow using truncating scatters

As a minor adjustment to the existing lowering of offset scatters, this
extends any smaller-than-legal vectors into full vectors using a zext,
so that the truncating scatters can be used. Due to the way MVE
legalizes the vectors this should be cheap in most situations, and will
prevent the vector from being scalarized.

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

3 years ago[NFC][SimplifyCFG] Add basic test for tail-merging `resume` function terminators
Roman Lebedev [Thu, 24 Jun 2021 12:08:20 +0000 (15:08 +0300)]
[NFC][SimplifyCFG] Add basic test for tail-merging `resume` function terminators

3 years ago[MCA] Allow unlimited cycles in the timeline view
Jay Foad [Thu, 24 Jun 2021 10:00:13 +0000 (11:00 +0100)]
[MCA] Allow unlimited cycles in the timeline view

Change --max-timeline-cycles=0 to mean no limit on the number of cycles.
Use this in AMDGPU tests to show all instructions in the timeline view
instead of having it arbitrarily truncated.

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

3 years ago[X86] Exclude invalid element types for bitcast/broadcast folding.
Florian Hahn [Thu, 24 Jun 2021 11:24:04 +0000 (12:24 +0100)]
[X86] Exclude invalid element types for bitcast/broadcast folding.

It looks like the fold introduced in 63f3383ece25efa can cause crashes
if the type of the bitcasted value is not a valid vector element type,
like x86_mmx.

To resolve the crash, reject invalid vector element types. The way it is
done in the patch is a bit clunky. Perhaps there's a better way to
check?

Reviewed By: RKSimon

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

3 years ago[SCEV] Generalize MatchBinaryAddToConst to support non-add expressions.
Florian Hahn [Thu, 24 Jun 2021 09:00:27 +0000 (10:00 +0100)]
[SCEV] Generalize MatchBinaryAddToConst to support non-add expressions.

This patch generalizes MatchBinaryAddToConst to support matching
(A + C1), (A + C2), instead of just matching (A + C1), A.

The existing cases can be handled by treating non-add expressions A as
A + 0.

Reviewed By: mkazantsev

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

3 years ago[CostModel][AArch64] Improve cost model for vector reduction intrinsics
Rosie Sumpter [Tue, 15 Jun 2021 09:29:27 +0000 (10:29 +0100)]
[CostModel][AArch64] Improve cost model for vector reduction intrinsics

OR, XOR and AND entries are added to the cost table. An extra cost
is added when vector splitting occurs.

This is done to address the issue of a missed SLP vectorization
opportunity due to unreasonably high costs being attributed to the vector
Or reduction (see: https://bugs.llvm.org/show_bug.cgi?id=44593).

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

3 years ago[mlir][Linalg] Add basic lowering test to library calls
Nicolas Vasilache [Thu, 24 Jun 2021 06:41:07 +0000 (06:41 +0000)]
[mlir][Linalg] Add basic lowering test to library calls

This test shows how convert-linalg-to-std rewrites named linalg ops as library calls.
This can be coupled with a C++ shim to connect to existing libraries such as https://gist.github.com/nicolasvasilache/691ef992404c49dc9b5d543c4aa6db38.
Everything can then be linked together with mlir-cpu-runner and MLIR can call C++ (which can itself call MLIR if needed).

This should evolve into specific rewrite patterns that can be applied on op instances independently rather than having to use a full conversion.

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

3 years ago[Clang] XFAIL sanitize-coverage-old-pm.c on 32bit Armv8l
Muhammad Omair Javaid [Thu, 24 Jun 2021 10:46:41 +0000 (15:46 +0500)]
[Clang] XFAIL sanitize-coverage-old-pm.c on 32bit Armv8l

sanitize-coverage-old-pm.c started failing on arm 32 bit where
underlying architecture reported is armv8l fore 32bit arm.
This patch XFAILS sanitize-coverage-old-pm.c on armv8l similar
to armv7 and thumbv7.

3 years ago[X86] Fold nested select_cc to select (cmp*ge/le Cond0, Cond1), LHS, Y)
Simon Pilgrim [Thu, 24 Jun 2021 10:15:44 +0000 (11:15 +0100)]
[X86] Fold nested select_cc to select (cmp*ge/le Cond0, Cond1), LHS, Y)

select (cmpeq Cond0, Cond1), LHS, (select (cmpugt Cond0, Cond1), LHS, Y) --> (select (cmpuge Cond0, Cond1), LHS, Y)
etc,

We already perform this fold in DAGCombiner for MVT::i1 comparison results, but these can still appear after legalization (in x86 case with MVT::i8 results), where we need to be more careful about generating new comparison codes.

Pulled out of D101074 to help address the remaining regressions.

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

3 years ago[GlobalISel] NFC: Change LLT::vector to take ElementCount.
Sander de Smalen [Thu, 24 Jun 2021 08:58:21 +0000 (09:58 +0100)]
[GlobalISel] NFC: Change LLT::vector to take ElementCount.

This also adds new interfaces for the fixed- and scalable case:
* LLT::fixed_vector
* LLT::scalable_vector

The strategy for migrating to the new interfaces was as follows:
* If the new LLT is a (modified) clone of another LLT, taking the
  same number of elements, then use LLT::vector(OtherTy.getElementCount())
  or if the number of elements is halfed/doubled, it uses .divideCoefficientBy(2)
  or operator*. That is because there is no reason to specifically restrict
  the types to 'fixed_vector'.
* If the algorithm works on the number of elements (as unsigned), then
  just use fixed_vector. This will need to be fixed up in the future when
  modifying the algorithm to also work for scalable vectors, and will need
  then need additional tests to confirm the behaviour works the same for
  scalable vectors.
* If the test used the '/*Scalable=*/true` flag of LLT::vector, then
  this is replaced by LLT::scalable_vector.

Reviewed By: aemerson

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

3 years ago[SimplifyCFG] Tail-merging all blocks with `ret` terminator
Roman Lebedev [Thu, 24 Jun 2021 10:15:39 +0000 (13:15 +0300)]
[SimplifyCFG] Tail-merging all blocks with `ret` terminator

Based ontop of D104598, which is a NFCI-ish refactoring.
Here, a restriction, that only empty blocks can be merged, is lifted.

Reviewed By: rnk

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

3 years ago[NFC][AArch64] Un-autogenerate swifterror.ll tests
Roman Lebedev [Thu, 24 Jun 2021 09:50:41 +0000 (12:50 +0300)]
[NFC][AArch64] Un-autogenerate swifterror.ll tests

It appears the change needed in D104597 is minimal and obvious,
so let's not make them so verbose.

3 years ago[mlir][linalg][python] Add attribute support to the OpDSL.
Tobias Gysi [Thu, 24 Jun 2021 09:21:12 +0000 (09:21 +0000)]
[mlir][linalg][python] Add attribute support to the OpDSL.

Extend the OpDSL with index attributes. After tensors and scalars, index attributes are the third operand type. An index attribute represents a compile-time constant that is limited to index expressions. A use cases are the strides and dilations defined by convolution and pooling operations.

The patch only updates the OpDSL. The C++ yaml codegen is updated by a followup patch.

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

3 years ago[analyzer] Added a test case for PR46264
Denys Petrov [Wed, 16 Jun 2021 13:44:36 +0000 (16:44 +0300)]
[analyzer] Added a test case for PR46264

Summary: It's not able to reproduce the issue (https://bugs.llvm.org/show_bug.cgi?id=46264) for the latest sources. Add a reported test case to try to catch the problem if occur es.

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

Prevent: https://bugs.llvm.org/show_bug.cgi?id=46264

3 years ago[RISCV] Lower RVV vector SELECTs to VSELECTs
Fraser Cormack [Wed, 23 Jun 2021 09:11:13 +0000 (10:11 +0100)]
[RISCV] Lower RVV vector SELECTs to VSELECTs

This patch optimizes the code generation of vector-type SELECTs (LLVM
select instructions with scalar conditions) by custom-lowering to
VSELECTs (LLVM select instructions with vector conditions) by splatting
the condition to a vector. This avoids the default expansion path which
would either introduce control flow or fully scalarize.

Reviewed By: craig.topper

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

3 years ago[MLIR][OpenMP]Basic OpenMP target operation
Abid Malik [Thu, 24 Jun 2021 08:42:46 +0000 (09:42 +0100)]
[MLIR][OpenMP]Basic OpenMP target operation

This includes a basic implementation for the OpenMP target
operation. Currently, the if, thread_limit, private, shared, device, and nowait clauses are included in this implementation.

Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Reviewed By: ftynse, kiranchandramohan

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

3 years ago[hwasan] print exact mismatch offset for short granules.
Florian Mayer [Thu, 17 Jun 2021 14:23:19 +0000 (15:23 +0100)]
[hwasan] print exact mismatch offset for short granules.

Reviewed By: eugenis

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

3 years agoPartial Reapply "[DebugInfo] Use variadic debug values to salvage BinOps and GEP...
Stephen Tozer [Thu, 17 Jun 2021 15:35:17 +0000 (16:35 +0100)]
Partial Reapply "[DebugInfo] Use variadic debug values to salvage BinOps and GEP instrs with non-const operands"

This is a partial reapply of the original commit and the followup commit
that were previously reverted; this reapply also includes a small fix
for a potential source of non-determinism, but also has a small change
to turn off variadic debug value salvaging, to ensure that any future
revert/reapply steps to disable and renable this feature do not risk
causing conflicts.

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

This reverts commit 386b66b2fc297cda121a3cc8a36887a6ecbcfc68.

3 years ago[SLP] Add some tests that require memory runtime checks.
Florian Hahn [Thu, 24 Jun 2021 08:19:28 +0000 (09:19 +0100)]
[SLP] Add some tests that require memory runtime checks.

3 years agotsan: re-enable mmap_stress.cpp test
Dmitry Vyukov [Sat, 19 Jun 2021 10:52:26 +0000 (12:52 +0200)]
tsan: re-enable mmap_stress.cpp test

The comment says it was flaky in 2016,
but it wasn't possible to debug it back then.
Re-enable the test at least on linux/x86_64.
It will either work, or at least we should
see failure output from lit today.

Reviewed By: vitalybuka

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

3 years agotsan: fix mmap atomicity
Dmitry Vyukov [Sat, 19 Jun 2021 10:49:37 +0000 (12:49 +0200)]
tsan: fix mmap atomicity

Mmap interceptor is not atomic in the sense that it
exposes unmapped shadow for a brief period of time.
This breaks programs that mmap over another mmap
and access the region concurrently.
Don't unmap shadow in the mmap interceptor to fix this.
Just mapping new shadow on top should be enough to zero it.

Reviewed By: vitalybuka

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

3 years ago[scudo] Fix test on arch without MTE
Vitaly Buka [Thu, 24 Jun 2021 07:07:24 +0000 (00:07 -0700)]
[scudo] Fix test on arch without MTE

3 years ago[scudo] Avoid ifdef in test
Vitaly Buka [Thu, 24 Jun 2021 06:58:09 +0000 (23:58 -0700)]
[scudo] Avoid ifdef in test

3 years ago[scudo] Fix use of ScopedDisableMemoryTagChecks in test
Vitaly Buka [Thu, 24 Jun 2021 06:52:47 +0000 (23:52 -0700)]
[scudo] Fix use of ScopedDisableMemoryTagChecks in test

3 years ago[NFC][trace] remove dead function
Walter Erquinigo [Thu, 24 Jun 2021 06:03:26 +0000 (23:03 -0700)]
[NFC][trace] remove dead function

The Trace::GetCursorPosition function was never really implemented well and it's being replaced by a more correct TraceCursor object.

3 years ago[scudo] Enabled MTE before the first allocator
Vitaly Buka [Sun, 30 May 2021 00:11:36 +0000 (17:11 -0700)]
[scudo] Enabled MTE before the first allocator

Reviewed By: pcc

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

3 years ago[trace] Add a TraceCursor class
Walter Erquinigo [Wed, 16 Jun 2021 21:09:46 +0000 (14:09 -0700)]
[trace] Add a TraceCursor class

As a follow up of D103588, I'm reinitiating the discussion with a new proposal for traversing instructions in a trace which uses the feedback gotten in that diff.

See the embedded documentation in TraceCursor for more information. The idea is to offer an OOP way to traverse instructions exposing a minimal interface that makes no assumptions on:

- the number of instructions in the trace (i.e. having indices for instructions might be impractical for gigantic intel-pt traces, as it would require to decode the entire trace). This renders the use of indices to point to instructions impractical. Traces are big and expensive, and the consumer should try to do look linear lookups (forwards and/or backwards) and avoid random accesses (the API could be extended though, but for now I want to dicard that funcionality and leave the API extensible if needed).
- the way the instructions are represented internally by each Trace plug-in. They could be mmap'ed from a file, exist in plain vector or generated on the fly as the user requests the data.
- the actual data structure used internally for each plug-in. Ideas like having a struct TraceInstruction have been discarded because that would make the plug-in follow a certain data type, which might be costly. Instead, the user can ask the cursor for each independent property of the instruction it's pointing at.

The way to get a cursor is to ask Trace.h for the end or being cursor or a thread's trace.

There are some benefits of this approach:
- there's little cost to create a cursor, and this allows for lazily decoding a trace as the user requests data.
- each trace plug-in could decide how to cache the instructions it generates. For example, if a trace is small, it might decide to keep everything in memory, or if the trace is massive, it might decide to keep around the last thousands of instructions to speed up local searches.
- a cursor can outlive a stop point, which makes trace comparison for live processes feasible. An application of this is to compare profiling data of two runs of the same function, which should be doable with intel pt.

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

3 years ago[lld-macho] add tests for ICF, plus cleanups
Greg McGary [Tue, 22 Jun 2021 16:10:20 +0000 (09:10 -0700)]
[lld-macho] add tests for ICF, plus cleanups

Add tests for pending TODOs, plus some global cleanups:
* No fold: func has personality/LSDA
* Fold: reference to absolute symbol with different name but identical value
* No fold: reloc references to absolute symbols with different values
* No fold: N_ALT_ENTRY symbols

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

3 years ago[AMDGPU] Add 224-bit vector types and link 192-bit types to MVTs
Carl Ritson [Thu, 24 Jun 2021 00:59:55 +0000 (09:59 +0900)]
[AMDGPU] Add 224-bit vector types and link 192-bit types to MVTs

Add SReg_224, VReg_224, AReg_224, etc.
Link 224-bit types with v7i32/v7f32.
Link existing 192-bit types to newly added v3i64/v3f64/v6i32/v6f32.

Reviewed By: rampitec

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

3 years ago[ValueTypes] Define MVTs for v3i64/v3f64 to complement v6i32/v6f32
Carl Ritson [Thu, 24 Jun 2021 00:59:25 +0000 (09:59 +0900)]
[ValueTypes] Define MVTs for v3i64/v3f64 to complement v6i32/v6f32

Having type symmetry with these is somewhat necessary when implementing support for 192-bit values.

Reviewed By: craig.topper

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

3 years ago[HIP] Defer operator overloading errors
Yaxun (Sam) Liu [Wed, 16 Jun 2021 19:40:27 +0000 (15:40 -0400)]
[HIP] Defer operator overloading errors

Although clang is able to defer overloading resolution
diagnostics for common functions. It does not defer
overloading resolution caused diagnostics for overloaded
operators.

This patch extends the existing deferred
diagnostic mechanism and defers a diagnostic caused
by overloaded operator.

Reviewed by: Artem Belevich

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

3 years ago[PowerPC] Add test to show passes in O3 pipeline. NFC.
Kai Luo [Thu, 24 Jun 2021 03:20:35 +0000 (03:20 +0000)]
[PowerPC] Add test to show passes in O3 pipeline. NFC.

3 years ago[docs][NewPM] Add some instructions on how to invoke opt
Arthur Eubanks [Wed, 23 Jun 2021 20:16:04 +0000 (13:16 -0700)]
[docs][NewPM] Add some instructions on how to invoke opt

Also add link to blog post.

Reviewed By: nickdesaulniers

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

3 years agogn build: Build ubsan_minimal on Android.
Peter Collingbourne [Thu, 24 Jun 2021 02:25:01 +0000 (19:25 -0700)]
gn build: Build ubsan_minimal on Android.

3 years agoRevert "ThinLTO: Fix inline assembly references to static functions with CFI"
Zequan Wu [Thu, 24 Jun 2021 02:24:05 +0000 (19:24 -0700)]
Revert "ThinLTO: Fix inline assembly references to static functions with CFI"

This casues compiler crash: Assertion `materialized_use_empty() && "Uses remain when a value is destroyed!"'

This reverts commit e3d24b45b8f808ec66213e134c4ceda5202fbe31.

3 years agoAST: Create __va_list in the std namespace even in C.
Peter Collingbourne [Fri, 5 Feb 2021 00:14:04 +0000 (16:14 -0800)]
AST: Create __va_list in the std namespace even in C.

This ensures that the mangled type names match between C and C++,
which is significant when using -fsanitize=cfi-icall. Ideally we
wouldn't have created this namespace at all, but it's now part of
the ABI (e.g. in mangled names), so we can't change it.

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

3 years ago[hwasan] Respect llvm.asan.globals.
Evgenii Stepanov [Tue, 22 Jun 2021 23:27:11 +0000 (16:27 -0700)]
[hwasan] Respect llvm.asan.globals.

This enable no_sanitize C++ attribute to exclude globals from hwasan
testing, and automatically excludes other sanitizers' globals (such as
ubsan location descriptors).

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

3 years agoRevert "[AMDGPU] [IndirectCalls] Don't propagate attributes to address taken function...
Jon Chesterfield [Thu, 24 Jun 2021 01:33:50 +0000 (02:33 +0100)]
Revert "[AMDGPU] [IndirectCalls] Don't propagate attributes to address taken functions and their callees"

This reverts commit 6a3beb1f68d6791a4cd0190f68b48510f754a00a.
Test case that triggers an infinite loop before the revert is at
the review for D103138.

3 years agoImplement an scf.for range folding optimization pass.
Anthony Canino [Thu, 24 Jun 2021 01:00:46 +0000 (01:00 +0000)]
Implement an scf.for range folding optimization pass.

In cases where arithmetic (addi/muli) ops are performed on an scf.for loops induction variable with a single use, we can fold those ops directly into the scf.for loop.

For example, in the following code:

```
scf.for %i = %c0 to %arg1 step %c1 {
  %0 = addi %arg2, %i : index
  %1 = muli %0, %c4 : index
  %2 = memref.load %arg0[%1] : memref<?xi32>
  %3 = muli %2, %2 : i32
  memref.store %3, %arg0[%1] : memref<?xi32>
}
```

we can lift `%0` up into the scf.for loop range, as it is the only user of %i:

```
%lb = addi %arg2, %c0 : index
%ub = addi %arg2, %i : index
scf.for %i = %lb to %ub step %c1 {
  %1 = muli %0, %c4 : index
  %2 = memref.load %arg0[%1] : memref<?xi32>
  %3 = muli %2, %2 : i32
  memref.store %3, %arg0[%1] : memref<?xi32>
}
```

Reviewed By: mehdi_amini, ftynse, Anthony

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

3 years ago[LVI] Remove recursion from getValueForCondition (NFCI)
Carl Ritson [Thu, 24 Jun 2021 00:36:58 +0000 (09:36 +0900)]
[LVI] Remove recursion from getValueForCondition (NFCI)

Convert getValueForCondition to a worklist model instead of using
recursion.

In pathological cases getValueForCondition recurses heavily.
Stack frames are quite expensive on x86-64, and some operating
systems (e.g. Windows) have relatively low stack size limits.
Using a worklist avoids potential failures from stack overflow.

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

3 years ago[AIX] Emitting diagnostics error for profile options
Whitney Tsang [Thu, 24 Jun 2021 00:22:06 +0000 (00:22 +0000)]
[AIX] Emitting diagnostics error for profile options

Only LLVM-based instrumentation profile is supported on AIX.
And it currently must be used with full LTO.

Reviewed By: hubert.reinterpretcast

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

3 years ago[Clang] Check for returns_nonnull when deciding to add allocation null checks
modimo [Thu, 24 Jun 2021 00:15:12 +0000 (17:15 -0700)]
[Clang] Check for returns_nonnull when deciding to add allocation null checks

Non-throwing allocators currently will always get null-check code. However, if the non-throwing allocator is explicitly annotated with returns_nonnull the null check should be elided.

Testing:
ninja check-all
added test case correctly elides

Reviewed By: bruno

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

3 years ago[NFC] [DwarfEHPrepare] Add additional stats for EH
modimo [Thu, 24 Jun 2021 00:08:59 +0000 (17:08 -0700)]
[NFC] [DwarfEHPrepare] Add additional stats for EH

Stats added:

1. NumCleanupLandingPadsUnreachable: how many cleanup landing pads were optimized as unreachable
1. NumCleanupLandingPadsRemaining: how many cleanup landing pads remain
1. NumNoUnwind: Number of functions with nounwind attribute
1. NumUnwind: Number of functions with unwind attribute

DwarfEHPrepare is always run a single time as part of `TargetPassConfig::addISelPasses()` which makes it an ideal place near the end of the pipeline to record this information.

Example output from clang built with exceptions cumulative during thinLTO backend (NumCleanupLandingPadsUnreachable was not incremented):

"dwarfehprepare.NumCleanupLandingPadsRemaining": 123660,
"dwarfehprepare.NumNoUnwind": 323836,
"dwarfehprepare.NumUnwind": 472893,

Reviewed By: wenlei

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

3 years ago[LangRef] add note to warn-frame-size about ODR
Nick Desaulniers [Wed, 23 Jun 2021 23:28:36 +0000 (16:28 -0700)]
[LangRef] add note to warn-frame-size about ODR

As sugguested by @dblaikie in D104342.

Reviewed By: dblaikie

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

3 years ago[llvm-diff] Explicitly check ConstantStructs for differences
Bill Wendling [Tue, 22 Jun 2021 18:40:03 +0000 (11:40 -0700)]
[llvm-diff] Explicitly check ConstantStructs for differences

A ConstantStruct is renamed when the LLVM context sees a new one. This
makes global variable initializers appear different when they aren't.
Instead, check the ConstantStruct for equivalence.

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

3 years ago[CGP][RISCV] Teach CodeGenPrepare::optimizeSwitchInst to honor isSExtCheaperThanZExt.
Craig Topper [Wed, 23 Jun 2021 22:38:03 +0000 (15:38 -0700)]
[CGP][RISCV] Teach CodeGenPrepare::optimizeSwitchInst to honor isSExtCheaperThanZExt.

This optimization pre-promotes the input and constants for a
switch instruction to a legal type so that all the generated compares
share the same extend. Since RISCV prefers sext for i32 to i64
extends, we should honor that to use sext.w instead of a pair
of shifts.

Reviewed By: jrtc27

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

3 years ago[SjLj] Insert UnregisterFn before musttail call
Xun Li [Wed, 23 Jun 2021 22:33:55 +0000 (15:33 -0700)]
[SjLj] Insert UnregisterFn before musttail call

When inserting UnregisterFn, if there is a musttail call, we must insert before the call so that we don't break the musttail call contract.

Reviewed By: wenlei

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

3 years agoRevert "[SjLj] Insert UnregisterFn before musttail call"
Xun Li [Wed, 23 Jun 2021 22:31:35 +0000 (15:31 -0700)]
Revert "[SjLj] Insert UnregisterFn before musttail call"

This reverts commit f36703ada3dc18388ef5cdcbb8f39f74c27ad8e9.
Test failure: https://lab.llvm.org/buildbot#builders/104/builds/3450

3 years agomailmap: add mappings for myself
Saleem Abdulrasool [Sun, 13 Jun 2021 18:07:34 +0000 (11:07 -0700)]
mailmap: add mappings for myself

Add aliases for various alternative email addresses.

3 years ago[MCA][TimelineView] Fixed a bug that was causing instructions outside of the timeline...
Patrick Holland [Wed, 23 Jun 2021 20:03:16 +0000 (13:03 -0700)]
[MCA][TimelineView] Fixed a bug that was causing instructions outside of the timeline-max-cycles to still be printed.

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

3 years ago[libc++abi][AIX] Enable calculating addresses with DW_EH_PE_datarel
Xing Xue [Wed, 23 Jun 2021 21:54:10 +0000 (17:54 -0400)]
[libc++abi][AIX] Enable calculating addresses with DW_EH_PE_datarel

Summary:
This patch enables calculating relative addresses with the DW_EH_PE_datarel encoding using a 'base' for AIX. After setting registers for jumping to the user code in gxx_personality_v0(), 'base' is cached in exception_header member catchTemp for use in __cxa_call_unexpected if ttypeIndex is less than 0 (exception spec).

Reviewed by: MaskRay, sfertile, compnerd, libc++abi

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

3 years ago[SjLj] Insert UnregisterFn before musttail call
Xun Li [Wed, 23 Jun 2021 21:29:46 +0000 (14:29 -0700)]
[SjLj] Insert UnregisterFn before musttail call

When inserting UnregisterFn, if there is a musttail call, we must insert before the call so that we don't break the musttail call contract.

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

3 years agoReplace python3 with %python in ML inlining tests.
Jacob Hegna [Wed, 23 Jun 2021 21:06:23 +0000 (21:06 +0000)]
Replace python3 with %python in ML inlining tests.

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

3 years ago[PatternMatch] Make m_VScale compatible with opaque pointers
Nikita Popov [Wed, 23 Jun 2021 20:56:57 +0000 (22:56 +0200)]
[PatternMatch] Make m_VScale compatible with opaque pointers

Use GEP source type instead of pointer element type.

3 years ago[NFC][AArch64] Autogenerate assembly checklines in arm64-instruction-mix-remarks.ll
Roman Lebedev [Wed, 23 Jun 2021 20:52:49 +0000 (23:52 +0300)]
[NFC][AArch64] Autogenerate assembly checklines in arm64-instruction-mix-remarks.ll

3 years ago[lldb] Decouple ObjCLanguage from Symtab
Alex Langford [Thu, 10 Jun 2021 21:55:25 +0000 (14:55 -0700)]
[lldb] Decouple ObjCLanguage from Symtab

We can extend/modify `GetMethodNameVariants` to suit our purposes here.
What symtab is looking for is alternate names we may want to use to
search for a specific symbol, and asking for variants of a name makes
the most sense here.

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

3 years ago[NFC][compiler-rt] Remove iOS xfail for unpoison-alternate-stack
Emily Shi [Wed, 23 Jun 2021 20:47:53 +0000 (13:47 -0700)]
[NFC][compiler-rt] Remove iOS xfail for unpoison-alternate-stack

This test was originally xfailed because of a bug on iOS. This has since been fixed, so reenabling the test.

3 years ago[libc] Calculate ulp error after rounding MPFR result to the result type.
Siva Chandra Reddy [Sat, 19 Jun 2021 07:56:45 +0000 (07:56 +0000)]
[libc] Calculate ulp error after rounding MPFR result to the result type.

Reviewed By: lntue

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

3 years ago[lld/mac] Delete incorrect FIXME
Nico Weber [Wed, 23 Jun 2021 20:24:41 +0000 (16:24 -0400)]
[lld/mac] Delete incorrect FIXME

"""Bitcode symbols only exist before LTO runs, and only serve the purpose of
resolving visibility so LTO can better optimize. Running LTO creates ObjFiles
from BitcodeFiles, and those ObjFiles contain regular Defined symbols (with
isec set and all) that will replace the bitcode symbols. So things should
(hopefully) work as-is :)"""

  -- https://reviews.llvm.org/rGdbbc8d8333f29cf4ad6f4793da1adf71bbfdac69#inline-6081

3 years ago[flang] Tweak the conditions for the GCC 7/libstdc++ workaround
Martin Storsjö [Wed, 23 Jun 2021 11:37:01 +0000 (14:37 +0300)]
[flang] Tweak the conditions for the GCC 7/libstdc++ workaround

This adjusts the workaround from D104731.

The issue lies in libstdc++'s classes, not GCC itself, and manifests
itself in the same way if building e.g. with clang while using
libstdc++ headers from GCC 7 (e.g. if building with Clang on Ubuntu 18.04,
while using the system default C++ library).

Therefore, change the condition to look for the version of libstdc++
instead of the compiler.

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

3 years ago[Polly] Fix test after D104732.
Michael Kruse [Wed, 23 Jun 2021 19:52:59 +0000 (14:52 -0500)]
[Polly] Fix test after D104732.

The SCEV analysis has been improved to identify a write access as a MustWrite.

3 years ago[ScalarEvolution] Clarify implementation of getPointerBase().
Eli Friedman [Wed, 23 Jun 2021 19:46:57 +0000 (12:46 -0700)]
[ScalarEvolution] Clarify implementation of getPointerBase().

getPointerBase should only be looking through Add and AddRec
expressions; other expressions either aren't pointers, or can't be
looked through.

Technically, this is a functional change. For a multiply or min/max
expression, if they have exactly one pointer operand, and that operand
is the first operand, the behavior here changes. Similarly, if an AddRec
has a pointer-type step, the behavior changes. But that shouldn't be
happening in practice, and we plan to make such expressions illegal.

3 years ago[NFC][ScalarEvolution] Fix SCEVNAryExpr::getType().
Eli Friedman [Wed, 23 Jun 2021 19:42:47 +0000 (12:42 -0700)]
[NFC][ScalarEvolution] Fix SCEVNAryExpr::getType().

SCEVNAryExpr::getType() could return the wrong type for a SCEVAddExpr.
Remove it, and add getType() methods to the relevant subclasses.

NFC because nothing uses it directly, as far as I know; this is just
future-proofing.

3 years ago[IRSim] Adding basic implementation of llvm-sim.
Andrew Litteken [Mon, 7 Jun 2021 15:57:39 +0000 (10:57 -0500)]
[IRSim] Adding basic implementation of llvm-sim.

This is a similarity visualization tool that accepts a Module and
passes it to the IRSimilarityIdentifier.  The resulting SimilarityGroups
are output in a JSON file.

Tests are found in test/tools/llvm-sim and check for the file not found,
a bad module, and that the JSON is created correctly.

Reviewers: paquette, jroelofs, MaskRay

Recommit of: 15645d044bcfe2a0f63156048b302f997a717688 to fix linking
errors and GN build system.

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

3 years ago[AMDGPU] Check for pointer operand while refining LDS align
Stanislav Mekhanoshin [Wed, 23 Jun 2021 17:21:40 +0000 (10:21 -0700)]
[AMDGPU] Check for pointer operand while refining LDS align

Also skips the propagation if alignment is 1.

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

3 years ago[docs][GISel]Added GISel documentation link
pooja2299 [Sun, 13 Jun 2021 19:49:54 +0000 (01:19 +0530)]
[docs][GISel]Added GISel documentation link

Added the GISel docs link here - https://llvm.org/docs/CodeGenerator.html#instruction-selection-section

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

3 years agoIR: Fix use-list-order round-tripping for call and invoke
Duncan P. N. Exon Smith [Wed, 23 Jun 2021 18:25:04 +0000 (11:25 -0700)]
IR: Fix use-list-order round-tripping for call and invoke

Fix the use-list-order for call and invoke instructions by setting the
operands in order of their index. This matches the use-list-order
prediction. Note that the verifier precludes sharing operands in callbr
(so there was no bug to fix), but that code was updated for consistency.

Bug was found during review of https://reviews.llvm.org/D104740.

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

3 years agoReland "[AArch64] handle -Wa,-march="
Jian Cai [Wed, 23 Jun 2021 19:00:58 +0000 (12:00 -0700)]
Reland "[AArch64] handle -Wa,-march="

This reverts commit fd11a26d368c5a909fb88548fef2cee7a6c2c931, which was
reverted by 9145a3d4ab7eb05d9fb113b5392e8961df629b88 due to a test
failure on aarch64 backend, e.g.
https://lab.llvm.org/buildbot/#/builders/43/builds/7031. This patch
fixed the test failure.

Reviewed By: DavidSpickett, nickdesaulniers

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

3 years agoMove dwarfdump-invalid.test into the tools/llvm-dwarfdump directory.
Adrian Prantl [Wed, 23 Jun 2021 18:59:58 +0000 (11:59 -0700)]
Move dwarfdump-invalid.test into the tools/llvm-dwarfdump directory.

3 years ago[Constants] Handle addrspacecast with opaque pointer type
Nikita Popov [Wed, 23 Jun 2021 18:56:55 +0000 (20:56 +0200)]
[Constants] Handle addrspacecast with opaque pointer type

This is the same change as D104668, but for constant expression
addrspacecasts.

3 years agoUpdate test after https://reviews.llvm.org/D104483
Adrian Prantl [Wed, 23 Jun 2021 18:50:26 +0000 (11:50 -0700)]
Update test after https://reviews.llvm.org/D104483

3 years ago[compiler-rt][hwasan] Add InitState options to thread initialization
Leonard Chan [Fri, 18 Jun 2021 18:10:38 +0000 (11:10 -0700)]
[compiler-rt][hwasan] Add InitState options to thread initialization

Similar to InitOptions in asan, we can use this optional struct for
initializing some members thread objects before they are created. On
linux, this is unused and can remain undefined. On fuchsia, this will
just be the stack bounds.

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

3 years ago[llvm-tapi-diff] Wrap empty string around StringLiteral NFC
Cyndy Ishida [Wed, 23 Jun 2021 18:39:35 +0000 (11:39 -0700)]
[llvm-tapi-diff] Wrap empty string around StringLiteral NFC

This prevents invalid implicit conversation which caused buildbot
failure.

3 years ago[InstCombine] Use getFunctionType()
Nikita Popov [Tue, 22 Jun 2021 20:29:05 +0000 (22:29 +0200)]
[InstCombine] Use getFunctionType()

Avoid fetching pointer element type...

3 years ago[lld/mac] Don't crash on absolute symbols in unwind info generation
Nico Weber [Wed, 23 Jun 2021 18:25:08 +0000 (14:25 -0400)]
[lld/mac] Don't crash on absolute symbols in unwind info generation

Fixes a regression from d6565a2dbcbe and PR50820.

3 years ago[OpaquePtr] Support invoke instruction
Nikita Popov [Tue, 22 Jun 2021 20:10:51 +0000 (22:10 +0200)]
[OpaquePtr] Support invoke instruction

With call support in place, this is only a matter of relaxing a
bitcode reader assertion.

3 years ago[TextAPI] add symbol name prefixes to central location, NFC
Cyndy Ishida [Wed, 23 Jun 2021 15:55:39 +0000 (08:55 -0700)]
[TextAPI] add symbol name prefixes to central location, NFC

These prefixes are used for printing the symbols coming from tbd files
and they were redundant across locations

3 years agoFix flang build after D104167
River Riddle [Wed, 23 Jun 2021 18:18:38 +0000 (18:18 +0000)]
Fix flang build after D104167

3 years ago[OpaquePtr] Support call instruction
Nikita Popov [Tue, 22 Jun 2021 20:00:40 +0000 (22:00 +0200)]
[OpaquePtr] Support call instruction

Add support for call of opaque pointer, currently only possible for
indirect calls.

This requires a bit of special casing in LLParser, as calls do not
specify the callee operand type explicitly.

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

3 years agoThinLTO: Fix inline assembly references to static functions with CFI
Sami Tolvanen [Wed, 23 Jun 2021 17:09:21 +0000 (10:09 -0700)]
ThinLTO: Fix inline assembly references to static functions with CFI

Create an internal alias with the original name for static functions
that are renamed in promoteInternals to avoid breaking inline
assembly references to them.

This relands commit 4474958d3a97dede2caa0920f7c4a4dc7aac57d3
with a fix to a use-of-uninitialized-value error that tripped
MemorySanitizer.

Link: https://github.com/ClangBuiltLinux/linux/issues/1354
Reviewed By: nickdesaulniers, pcc

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

3 years ago[OpaquePtr] Mangle intrinsics with opaque pointers arguments
Zequan Wu [Tue, 15 Jun 2021 21:59:51 +0000 (14:59 -0700)]
[OpaquePtr] Mangle intrinsics with opaque pointers arguments

Mangling intrinsics with opaque pointer arguments using "op"+{address space}.

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

3 years agoclang-format llvm-dwarfdump.cpp
Adrian Prantl [Wed, 23 Jun 2021 17:43:55 +0000 (10:43 -0700)]
clang-format llvm-dwarfdump.cpp

3 years agoImprove error handling in llvm-dwarfdump.
Adrian Prantl [Wed, 23 Jun 2021 17:43:38 +0000 (10:43 -0700)]
Improve error handling in llvm-dwarfdump.

Without this patch we're only showing a generic error message derived
from the error code to the end user.

rdar://79378794

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

3 years ago[Attributor] Derive AAFunctionReachability attribute.
Kuter Dinel [Sat, 19 Jun 2021 20:50:11 +0000 (23:50 +0300)]
[Attributor] Derive AAFunctionReachability attribute.

This attribute uses Attributor's internal 'optimistic' call graph
information to answer queries about function call reachability.

Functions can become reachable over time as new call edges are
discovered.

Reviewed By: jdoerfert

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

3 years agoRevert "[MLIR][LLVM] Expose type translator from LLVM to MLIR Type"
William S. Moses [Wed, 23 Jun 2021 17:27:13 +0000 (13:27 -0400)]
Revert "[MLIR][LLVM] Expose type translator from LLVM to MLIR Type"

This reverts commit 5616a79398c7f10d92daf7d6387b195e95f2ac7e.

3 years ago[MLIR][LLVM] Expose type translator from LLVM to MLIR Type
William S. Moses [Tue, 22 Jun 2021 17:57:04 +0000 (13:57 -0400)]
[MLIR][LLVM] Expose type translator from LLVM to MLIR Type

This commit moves the type translator from LLVM to MLIR to a public header for use by external projects or other code

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

3 years ago[gn build] Port 560170fa2de5
LLVM GN Syncbot [Wed, 23 Jun 2021 17:11:10 +0000 (17:11 +0000)]
[gn build] Port 560170fa2de5

3 years ago[libcxx][views] Add drop_view.
zoecarver [Fri, 7 May 2021 00:39:53 +0000 (17:39 -0700)]
[libcxx][views] Add drop_view.

The first view in the libc++ ranges library 🚀

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

3 years ago[ConstantFold] Allow propagation of poison for and/or i1
Juneyoung Lee [Wed, 23 Jun 2021 17:03:07 +0000 (02:03 +0900)]
[ConstantFold] Allow propagation of poison for and/or i1

They were disallowed due to its bad interaction with select i1 -> and/or i1.
The transformation is now disabled by D101191, so let's revive this.

3 years ago[LAA] Make getPointersDiff() API compatible with opaque pointers
Nikita Popov [Wed, 23 Jun 2021 13:57:38 +0000 (15:57 +0200)]
[LAA] Make getPointersDiff() API compatible with opaque pointers

Make getPointersDiff() and sortPtrAccesses() compatible with opaque
pointers by explicitly passing in the element type instead of
determining it from the pointer element type.

The SLPVectorizer result is slightly non-optimal in that unnecessary
pointer bitcasts are added.

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

3 years ago[Demangle][Rust] Hide implementation details NFC
Tomasz Miąsko [Wed, 23 Jun 2021 13:59:24 +0000 (15:59 +0200)]
[Demangle][Rust] Hide implementation details NFC

Move content of the "public" header into the implementation file.

This also renames two enumerations that were previously used through
`rust_demangle::` scope, to avoid breaking a build bot with older
version of GCC that rejects uses of enumerator through `E::A` if there
is a variable with the same name as enumeration `E` in the scope.

Reviewed By: dblaikie

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

3 years agoUpdate Bazel BUILD files up to be9a87fe9b
Geoffrey Martin-Noble [Wed, 23 Jun 2021 16:25:36 +0000 (09:25 -0700)]
Update Bazel BUILD files up to be9a87fe9b

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

3 years ago[clang-format] Add IfMacros option
Vitali Lovich [Tue, 18 May 2021 20:57:07 +0000 (13:57 -0700)]
[clang-format] Add IfMacros option

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

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

3 years ago[ValueTracking] look through bitcast of vector in computeKnownBits
Sanjay Patel [Wed, 23 Jun 2021 15:31:22 +0000 (11:31 -0400)]
[ValueTracking] look through bitcast of vector in computeKnownBits

This borrows as much as possible from the SDAG version of the code
(originally added with D27129 and since updated with big endian support).

In IR, we can test more easily for correctness than we did in the
original patch. I'm using the simplest cases that I could find for
InstSimplify: we computeKnownBits on variable shift amounts to see if
they are zero or in range. So shuffle constant elements into a vector,
cast it, and shift it.

The motivating x86 example from https://llvm.org/PR50123 is also here.
We computeKnownBits in the caller code, but we only check if the shift
amount is in range. That could be enhanced to catch the 2nd x86 test -
if the shift amount is known too big, the result is 0.

Alive2 understands the datalayout and agrees that the tests here are
correct - example:
https://alive2.llvm.org/ce/z/KZJFMZ

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

3 years ago[ARM] Limit v6m unrolling with multiple live outs
David Green [Wed, 23 Jun 2021 15:36:37 +0000 (16:36 +0100)]
[ARM] Limit v6m unrolling with multiple live outs

v6m cores only have a limited number of registers available. Unrolling
can mean we spend more on stack spills and reloads than we save from the
unrolling. This patch adds an extra heuristic to put a limit on the
unroll count for loops with multiple live out values, as measured from
the LCSSA phi nodes.

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

3 years ago[InstCombine] Eliminate casts to optimize ctlz operation
Datta Nagraj [Wed, 23 Jun 2021 15:18:25 +0000 (11:18 -0400)]
[InstCombine] Eliminate casts to optimize ctlz operation

If a ctlz operation is performed on higher datatype and then
downcasted, then this can be optimized by doing a ctlz operation
on a lower datatype and adding the difference bitsize to the result
of ctlz to provide the same output:

https://alive2.llvm.org/ce/z/8uup9M

The original problem is shown in
https://llvm.org/PR50173

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

3 years ago[UpdateCCTestChecks][NFC] Permit other comments in common.py
Joel E. Denny [Wed, 23 Jun 2021 15:07:46 +0000 (11:07 -0400)]
[UpdateCCTestChecks][NFC] Permit other comments in common.py

Some parts of common.py already permit comment styles besides `;`.
Handle the remaining cases.  Specifically, a future patch will extend
update_cc_test_checks.py to call add_global_checks.

Reviewed By: jdoerfert

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