platform/upstream/llvm.git
3 years ago[SimplifyCFG] 'Fold branch to common dest': don't overestimate the cost
Roman Lebedev [Tue, 23 Mar 2021 15:22:30 +0000 (18:22 +0300)]
[SimplifyCFG] 'Fold branch to common dest': don't overestimate the cost

`FoldBranchToCommonDest()` has a certain budget (`-bonus-inst-threshold=`)
for bonus instruction duplication. And currently it calculates the cost
as-if it will actually duplicate into each predecessor.

But ignoring the budget, it won't always duplicate into each predecessor,
there are some correctness and profitability checks.
So when calculating the cost, we should first check into which blocks
will we *actually* duplicate, and only then use that block count
to do budgeting.

3 years ago[NFC][SimplifyCFG] 'Fold branch to common dest': add test for cost overestimation
Roman Lebedev [Tue, 23 Mar 2021 15:08:23 +0000 (18:08 +0300)]
[NFC][SimplifyCFG] 'Fold branch to common dest': add test for cost overestimation

We should not count the cost of duplication into predecessors into which
we won't ultimately duplicate.

3 years ago[flang][cmake] Improve how CLANG_DIR is handled
Andrzej Warzynski [Mon, 22 Mar 2021 17:04:01 +0000 (17:04 +0000)]
[flang][cmake] Improve how CLANG_DIR is handled

* Added a sanity check with `Clang_FOUND` to verify that find_package
succeeded
* Made sure that find_package won't use any of CMake's standard paths
to guarantee that only the path provided with CLANG_DIR is considered
(implemented through NO_DEFAULT_PATH)
* Made the call to get_filename_component more explicit (so that it is
clear what the base directory is)
* Updated comments to clarify what CLANG_DIR means

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

3 years agoRevert "[MLIR] Canonicalize `shape.assuming` op to yield only inner values"
Frederik Gossen [Tue, 23 Mar 2021 15:05:55 +0000 (16:05 +0100)]
Revert "[MLIR] Canonicalize `shape.assuming` op to yield only inner values"

This reverts commit 5f8acd4fd233cdce5892958df56ed1f000f75f9e.

3 years ago[MCA] Improved handling of negative read-advance cycles.
Andrea Di Biagio [Tue, 23 Mar 2021 14:47:01 +0000 (14:47 +0000)]
[MCA] Improved handling of negative read-advance cycles.

Before this patch, register writes were always invalidated by the
RegisterFile at instruction commit stage. So,
the RegisterFile was often losing the knowledge about the `execute
cycle` of writes already committed. While this was not problematic
for non-delayed reads, this was sometimes leading to inaccurate read
latency computations in the presence of negative read-advance cycles.

This patch fixes the issue by changing how the RegisterFile component
internally keeps track of the `execute cycle` information of each
write. On every instruction executed, the RegisterFile gets notified
by the RetireStage, so that it can internally record the execute
cycle of each executed write.
The `execute cycle` information is stored within WriteRef itself, and
it is not invalidated when the write is committed.

3 years ago[SimplifyCFG] FoldBranchToCommonDest(): properly handle same-block external uses...
Roman Lebedev [Tue, 23 Mar 2021 14:33:40 +0000 (17:33 +0300)]
[SimplifyCFG] FoldBranchToCommonDest(): properly handle same-block external uses (PR49510/PR49689)

We clone bonus instructions to the end of the predecessor block,
and then use `SSAUpdater::RewriteUseAfterInsertions()`.
But that only deals with the cases where the use-to-be-rewritten
are either in different block from the def, or come after the def.

But in some loop cases, the external use may be in the beginning of
predecessor block, before the newly cloned bonus instruction.
`SSAUpdater::RewriteUseAfterInsertions()` does not deal with that.
Notably, the external use can't happen to be both in the same block
and *after* the newly-cloned instruction, because of the fold preconditions.

To properly handle these cases, when the use is in the same block,
we should instead use `SSAUpdater::RewriteUse()`.
TBN, they do the same thing for PHI users.

Fixes https://bugs.llvm.org/show_bug.cgi?id=49510
Likely Fixes https://bugs.llvm.org/show_bug.cgi?id=49689

3 years ago[clang][parser] Don't prohibit attributes on objc @try/@throw
Timm Bäder [Wed, 24 Feb 2021 10:24:28 +0000 (11:24 +0100)]
[clang][parser] Don't prohibit attributes on objc @try/@throw

This line has a TODO comment, but the answer to it seems to be "no"
given that clang itself uses attributes on @try statements in its tests.

This ProhibitAttributes() statement is also dead code since
ProhibitAttributs() does not handle GNU attributes at the moment but
those are the only attributes valid in objc.

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

3 years agoRevert "[Orc] Allow OrcGenericABI variant of LazyCallThroughManager"
Stefan Gränitz [Tue, 23 Mar 2021 14:23:22 +0000 (15:23 +0100)]
Revert "[Orc] Allow OrcGenericABI variant of LazyCallThroughManager"

This reverts commit 61974268269f96b672a50eac40a5a8eeb4acd6d3.

3 years ago[RISCV] Further optimize BUILD_VECTORs with repeated elements
Fraser Cormack [Fri, 19 Mar 2021 12:21:23 +0000 (12:21 +0000)]
[RISCV] Further optimize BUILD_VECTORs with repeated elements

This patch builds upon the initial BUILD_VECTOR work introduced in
D98700. It further optimizes the lowering of BUILD_VECTOR by using
VSELECT operations to effectively insert repeated elements into the
vector with relatively few instructions. This allows us to optimize more
BUILD_VECTORs without significantly increasing the size of the generated
code.

Reviewed By: craig.topper

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

3 years ago[SimplifyCFG] use profile metadata to refine merging branch conditions
Sanjay Patel [Tue, 23 Mar 2021 13:55:04 +0000 (09:55 -0400)]
[SimplifyCFG] use profile metadata to refine merging branch conditions

2nd try (original: 27ae17a6b014) with fix/test for crash. We must make
sure that TTI is available before trying to use it because it is not
required (might be another bug).

Original commit message:

This is one step towards solving:
https://llvm.org/PR49336

In that example, we disregard the recommended usage of builtin_expect,
so an expensive (unpredictable) branch is folded into another branch
that is guarding it.
Here, we read the profile metadata to see if the 1st (predecessor)
condition is likely to cause execution to bypass the 2nd (successor)
condition before merging conditions by using logic ops.

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

3 years ago[gn build] (manually) port d709dcc09097
Nico Weber [Tue, 23 Mar 2021 14:12:53 +0000 (10:12 -0400)]
[gn build] (manually) port d709dcc09097

3 years agoRevert "A new option -print-on-crash that prints the IR as it was upon entering the...
Jamie Schmeiser [Tue, 23 Mar 2021 14:09:27 +0000 (10:09 -0400)]
Revert "A new option -print-on-crash that prints the IR as it was upon entering the last pass when there is a crash."

This reverts commit 9544a32287eccb42a4367cff9b5888855d6b8756.

3 years ago[PowerPC][NFC] Use valid type for offset in altivec.h
Nemanja Ivanovic [Tue, 23 Mar 2021 13:43:16 +0000 (08:43 -0500)]
[PowerPC][NFC] Use valid type for offset in altivec.h

We currently use signed long long instead of ptrdiff_t for offsets
in altivec.h. This has never really presented a problem because
all platforms where we use these are 64-bit. However, now that
we have 32-bit targets, we need to use a meaningful type.

3 years agoA new option -print-on-crash that prints the IR as it was upon entering the last...
Jamie Schmeiser [Tue, 23 Mar 2021 13:27:30 +0000 (09:27 -0400)]
A new option -print-on-crash that prints the IR as it was upon entering the last pass when there is a crash.
Summary:
The IR is saved in its print form before each pass is started and a
signal handler is registered.  If the compilation crashes, the signal
handler will print the saved IR to dbgs().  This option
can be modified using -print-module-scope to get the IR for the complete
module.  Note that this option only works with the new pass manager.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: aeubanks (Arthur Eubanks) yrouban (Yevgeny Rouban)
Differential Revision: https://reviews.llvm.org/D86657

3 years agoIntroduce a generic operator to apply complex operations to BitVector
serge-sans-paille [Mon, 8 Mar 2021 13:57:39 +0000 (14:57 +0100)]
Introduce a generic operator to apply complex operations to BitVector

This avoids temporary and memcpy call when computing large expressions.

It's basically some kind of poor man's expression template, but it seems easier
to maintain to have a single generic `apply` call instead of the whole
expression template machinery here.

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

3 years ago[llvm-symbolizer][llvm-nm] Fix AArch64 and ARM mapping symbols handling.
Yvan Roux [Tue, 23 Mar 2021 13:09:49 +0000 (14:09 +0100)]
[llvm-symbolizer][llvm-nm] Fix AArch64 and ARM mapping symbols handling.

Exclude AArch64 mapping symbols ($x and $d) for symtab symbolization as
it was done for ARM since D95916 tom bring bots back to green state.

This is implemented by setting SF_FormatSpecific such that
llvm-symbolizer will ignore them, and use this flag to re-implement
llvm-nm --special-syms option which make it work for both targets.

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

3 years ago[openacc][openmp] Reduce number of generated file and prefer inclusion of .inc
Valentin Clement [Tue, 23 Mar 2021 13:10:04 +0000 (09:10 -0400)]
[openacc][openmp] Reduce number of generated file and prefer inclusion of .inc

Follow up from D92955 and D83636. This patch makes the base cpp files
OMP.cpp and ACC.cpp normal files and they now include the XXX.inc file
generated by tablegen. This reduces the number of file generated by the
DirectiveEmitter backend and makes it closer to the proposal in D83636.

Reviewed By: Meinersbur

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

3 years agoGlobalISel: Lower funnel shifts
Matt Arsenault [Fri, 20 Mar 2020 02:48:13 +0000 (22:48 -0400)]
GlobalISel: Lower funnel shifts

3 years ago[Orc] Allow OrcGenericABI variant of LazyCallThroughManager
Stefan Gränitz [Tue, 23 Mar 2021 12:50:20 +0000 (13:50 +0100)]
[Orc] Allow OrcGenericABI variant of LazyCallThroughManager

Apply the way createLocalIndirectStubsManagerBuilder() deals with unsupported achritectures to createLocalLazyCallThroughManager(). The returned call-through manager is dysfunctional: It runs into an unreachable as soon as a lazy JIT attempts to use it. However, this results in broader platform support for lli in default (greedy) ORC mode where no lazy materialization is required.

3 years ago[RISCV][NFC] Fix RVV intrinsic tests.
Zakk Chen [Mon, 22 Mar 2021 15:20:48 +0000 (08:20 -0700)]
[RISCV][NFC] Fix RVV intrinsic tests.

1. Skip the temporary file
2. Test cc1 with -S to verify codegen work well. Add '-target-feature
   +m' because the backend requires it to calculate the vscaled size/offset.

Reviewed By: craig.topper

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

3 years ago[gn build] Port 274907c0a4d6
LLVM GN Syncbot [Tue, 23 Mar 2021 13:01:57 +0000 (13:01 +0000)]
[gn build] Port 274907c0a4d6

3 years ago[ASTImporter] Split out Objective-C related unit tests
Raphael Isemann [Tue, 23 Mar 2021 12:55:44 +0000 (13:55 +0100)]
[ASTImporter] Split out Objective-C related unit tests

This moves the two tests we have for importing Objective-C nodes to their own
file. The motivation is that this means I can add more Objective-C tests without
making the compilation time of ASTImporterTest even longer. Also it seems nice
to separate the Apple-specific stuff from the ASTImporter test.

Reviewed By: martong

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

3 years ago[SLP] allow matching integer min/max intrinsics as reduction ops
Sanjay Patel [Tue, 23 Mar 2021 12:30:19 +0000 (08:30 -0400)]
[SLP] allow matching integer min/max intrinsics as reduction ops

As noted in D98152, we need to patch SLP to avoid regressions when
we start canonicalizing to integer min/max intrinsics.
Most of the real work to make this possible was in:
7202f47508

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

3 years ago[NFC] clang-format llvm/lib/Transforms/Utils/CloneFunction.cpp
Luke Drummond [Tue, 23 Mar 2021 11:40:49 +0000 (11:40 +0000)]
[NFC] clang-format llvm/lib/Transforms/Utils/CloneFunction.cpp

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

3 years ago[NFC] Minor refactor
Luke Drummond [Tue, 23 Mar 2021 11:31:59 +0000 (11:31 +0000)]
[NFC] Minor refactor

- Give unwieldy repeated expression a name
- Use a ranged `for` basic block iterator

Reviewed by: nikic, dexonsmith
Differential Revisision: https://reviews.llvm.org/D98957

3 years ago[NFCI] cleanup CloneFunctionInto
Luke Drummond [Tue, 23 Mar 2021 11:27:29 +0000 (11:27 +0000)]
[NFCI] cleanup CloneFunctionInto

Hoist early return for decl-only clones to before DIFinder
calculation.
Also fix an out of date assert message after invariants changed in
22a52dfddce.

Reviewed by: nikic, dexonsmith
Differential Revisision: https://reviews.llvm.org/D98957

3 years ago[AArch64] Fix unused variable warning
Benjamin Kramer [Tue, 23 Mar 2021 12:42:14 +0000 (13:42 +0100)]
[AArch64] Fix unused variable warning

3 years ago[LangRef] Fix typos in the vector-type memory layout section
Fraser Cormack [Tue, 23 Mar 2021 09:42:26 +0000 (09:42 +0000)]
[LangRef] Fix typos in the vector-type memory layout section

Reviewed By: bjope

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

3 years ago[llvm-opt] Bug fix within combining FP vectors
Nashe Mncube [Tue, 9 Mar 2021 12:18:20 +0000 (12:18 +0000)]
[llvm-opt] Bug fix within combining FP vectors

A bug was found within InstCombineCasts where a function call
is only implemented to work with FixedVectors. This caused a
crash when a ScalableVector was passed to this function.
This commit introduces a regression test which recreates the
failure and a bug fix.

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

3 years ago[lldb] Silence GCC warnings about format not being a string literal in LLDB_SCOPED_TIMER
Martin Storsjö [Mon, 22 Mar 2021 22:08:11 +0000 (00:08 +0200)]
[lldb] Silence GCC warnings about format not being a string literal in LLDB_SCOPED_TIMER

Pass "%s" as the format string literal and LLVM_PRETTY_FUNCTION as
argument to it.

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

3 years ago[AnnotationRemarks] Use subprogram location for summary remarks.
Florian Hahn [Tue, 23 Mar 2021 11:59:08 +0000 (11:59 +0000)]
[AnnotationRemarks] Use subprogram location for summary remarks.

The summary remarks are generated on a per-function basis. Using the
first instruction's location is sub-optimal for 2 reasons:
  1. Sometimes the first instruction is missing !dbg
  2. The location of the first instruction may be mis-leading.

Instead, just use the location of the function directly.

3 years ago[clang] Fix a crash when CTAD fails
Kadir Cetinkaya [Tue, 23 Mar 2021 05:58:11 +0000 (06:58 +0100)]
[clang] Fix a crash when CTAD fails

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

3 years ago[ARM] Additional Upper bound unrolling test. NFC
David Green [Tue, 23 Mar 2021 12:00:40 +0000 (12:00 +0000)]
[ARM] Additional Upper bound unrolling test. NFC

3 years ago[AnnotationRemarks] Add test for annotation remarks with dbg locations.
Florian Hahn [Tue, 23 Mar 2021 11:50:58 +0000 (11:50 +0000)]
[AnnotationRemarks] Add test for annotation remarks with dbg locations.

The test illustrates that we not pick the debug location from the
function directly. This will be fixed in a follow-up patch.

3 years ago[ARM] Handle debug instrs in ARM Low Overhead Loop pass
Victor Campos [Fri, 19 Mar 2021 11:19:32 +0000 (11:19 +0000)]
[ARM] Handle debug instrs in ARM Low Overhead Loop pass

In function ConvertVPTBlocks(), it is assumed that every instruction
within a vector-predicated block is predicated. This is false for debug
instructions, used by LLVM.

Because of this, an assertion failure is reached when an input contains
debug instructions inside VPT blocks. In non-assert builds, an out of
bounds memory access took place.

The present patch properly covers the case of debug instructions.

Reviewed By: dmgreen

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

3 years ago[dexter] Fix DexLimitSteps when breakpoint can't be set at requested location
OCHyams [Tue, 23 Mar 2021 11:12:59 +0000 (11:12 +0000)]
[dexter] Fix DexLimitSteps when breakpoint can't be set at requested location

Using a DexLimitSteps command forces dexter to use the ConditionalController
debugger controller. At each breakpoint the ConditionalController needs to
understand which one has been hit. Prior to this patch, upon hitting a
breakpoint, dexter used the current source location to look up which requested
breakpoint had been hit.

A breakpoint may not get set at the exact location that the user (dexter)
requests. For example, if the requested breakpoint location doesn't exist
in the line table then then debuggers will (usually, AFAICT) set the breakpoint
at the next available valid breakpoint location.

This meant that, occasionally in unoptimised programs and frequently in
optimised programs, the ConditionalController was failing to determine which
breakpoint had been hit.

This is the fix:

Change the DebuggerBase breakpoint interface to use opaque breakpoint ids
instead of using source location to identify breakpoints, and update the
ConditionalController to track breakpoints instead of locations.

These now return a breakpoint id:

    add_breakpoint(self, file_, line)
    _add_breakpoint(self, file_, line)
    add_conditional_breakpoint(self, file_, line, condition)
    _add_conditional_breakpoint(self, file_, line, condition)

Replace:

    delete_conditional_breakpoint(self, file_, line, condition)
    _delete_conditional_breakpoint(self, file_, line, condition)

with:

    delete_breakpoint(self, id)

Add:

    get_triggered_breakpoint_ids(self)

A breakpoint id is guaranteed to be unique for each requested breakpoint, even
for duplicate breakpoint requests. Identifying breakpoints like this, instead
of by location, removes the possibility of mixing up requested and bound
breakpoints.

This closely matches the LLDB debugger interface so little work was required in
LLDB.py, but some extra bookkeeping is required in VisualStudio.py to maintain
the new breakpoint id semantics. No implementation work has been done in
dbgeng.py as DexLimitSteps doesn't seem to support dbgeng at the moment.

Testing
Added:
dexter/feature_tests/commands/perfect/limit_steps/limit_steps_line_mismatch.cpp

There were no unexpected failures running the full debuginfo-tests suite.

The regression tests use dbgeng on windows by default, and as mentioned above
dbgeng isn't supported yet, so I have also manually tested (i.e. without lit)
that this specific test works as expected with clang and Visual Studio 2017 on
Windows.

Reviewed By: TWeaver

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

3 years ago[MLIR] Canonicalize `shape.assuming` op to yield only inner values
Frederik Gossen [Tue, 23 Mar 2021 11:00:16 +0000 (12:00 +0100)]
[MLIR] Canonicalize `shape.assuming` op to yield only inner values

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

3 years ago[LoopVectorize][NFC] Refactor code to use IRBuilder::CreateStepVector
David Sherwood [Mon, 1 Mar 2021 09:01:06 +0000 (09:01 +0000)]
[LoopVectorize][NFC] Refactor code to use IRBuilder::CreateStepVector

In places where we create a ConstantVector whose elements are a
linear sequence of the form <start, start + 1, start + 2, ...>
I've changed the code to make use of CreateStepVector, which creates
a vector with the sequence <0, 1, 2, ...>, and a vector addition
operation. This patch is a non-functional change, since the output
from the vectoriser remains unchanged for fixed length vectors and
there are existing asserts that still fire when attempting to use
scalable vectors for vectorising induction variables.

In a later patch we will enable support for scalable vectors
in InnerLoopVectorizer::getStepVector(), which relies upon the new
stepvector intrinsic in IRBuilder::CreateStepVector.

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

3 years ago[MLIR][Shape] Canonicalize duplicate operands in `shape.cstr_broadcastable`
Frederik Gossen [Tue, 23 Mar 2021 11:09:05 +0000 (12:09 +0100)]
[MLIR][Shape] Canonicalize duplicate operands in `shape.cstr_broadcastable`

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

3 years ago[AMDGPU] Use non-compressed exports in a test. NFC.
Jay Foad [Tue, 23 Mar 2021 10:31:58 +0000 (10:31 +0000)]
[AMDGPU] Use non-compressed exports in a test. NFC.

I don't think there's any need for this test to use compressed exports.
Using normal exports seems a bit more straightforwards and avoids a tiny
bit of bitcasting.

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

3 years ago[NFC] Formatting changes
Abhina Sreeskantharajan [Tue, 23 Mar 2021 11:17:33 +0000 (07:17 -0400)]
[NFC] Formatting changes

This patch addresses some formatting changes from the comments in https://reviews.llvm.org/D97785.

Reviewed By: anirudhp

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

3 years agoTemporarily revert "[lli] Make -jit-kind=orc the default JIT engine"
Stefan Gränitz [Tue, 23 Mar 2021 11:01:30 +0000 (12:01 +0100)]
Temporarily revert "[lli] Make -jit-kind=orc the default JIT engine"

This reverts commit eaee4f269645094f03f3aaff6b365176d63ab3e8.

3 years ago[PowerPC] Add more missing overloads to altivec.h
Nemanja Ivanovic [Tue, 23 Mar 2021 10:51:19 +0000 (05:51 -0500)]
[PowerPC] Add more missing overloads to altivec.h

Add overloads that perform subtraction on v1i128 that take and
produce vector unsigned char to avoid needing to use __int128.
The overloads are suffixed with _u128 and are needed for targets
where __int128 isn't supported (AIX).

3 years ago[MLIR] Add callback builder for `shape.assuming` op
Frederik Gossen [Tue, 23 Mar 2021 08:17:31 +0000 (09:17 +0100)]
[MLIR] Add callback builder for `shape.assuming` op

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

3 years ago[IR][SVE] Add new llvm.experimental.stepvector intrinsic
David Sherwood [Mon, 8 Feb 2021 15:46:24 +0000 (15:46 +0000)]
[IR][SVE] Add new llvm.experimental.stepvector intrinsic

This patch adds a new llvm.experimental.stepvector intrinsic,
which takes no arguments and returns a linear integer sequence of
values of the form <0, 1, ...>. It is primarily intended for
scalable vectors, although it will work for fixed width vectors
too. It is intended that later patches will make use of this
new intrinsic when vectorising induction variables, currently only
supported for fixed width. I've added a new CreateStepVector
method to the IRBuilder, which will generate a call to this
intrinsic for scalable vectors and fall back on creating a
ConstantVector for fixed width.

For scalable vectors this intrinsic is lowered to a new ISD node
called STEP_VECTOR, which takes a single constant integer argument
as the step. During lowering this argument is set to a value of 1.
The reason for this additional argument at the codegen level is
because in future patches we will introduce various generic DAG
combines such as

  mul step_vector(1), 2 -> step_vector(2)
  add step_vector(1), step_vector(1) -> step_vector(2)
  shl step_vector(1), 1 -> step_vector(2)
  etc.

that encourage a canonical format for all targets. This hopefully
means all other targets supporting scalable vectors can benefit
from this too.

I've added cost model tests for both fixed width and scalable
vectors:

  llvm/test/Analysis/CostModel/AArch64/neon-stepvector.ll
  llvm/test/Analysis/CostModel/AArch64/sve-stepvector.ll

as well as codegen lowering tests for fixed width and scalable
vectors:

  llvm/test/CodeGen/AArch64/neon-stepvector.ll
  llvm/test/CodeGen/AArch64/sve-stepvector.ll

See this thread for discussion of the intrinsic:
https://lists.llvm.org/pipermail/llvm-dev/2021-January/147943.html

3 years ago[CMAKE] Fix cross-compilation build
Vladislav Vinogradov [Thu, 18 Mar 2021 12:35:20 +0000 (15:35 +0300)]
[CMAKE] Fix cross-compilation build

Call `get_errc_messages` only if `LLVM_INCLUDE_TESTS` was set.

Reviewed By: zero9178, abhina.sreeskantharajan, jhenderson

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

3 years ago[OpenCL] Remove mixed signedness atomic_fetch_ from opencl-c.h
Sven van Haastregt [Tue, 23 Mar 2021 10:20:13 +0000 (10:20 +0000)]
[OpenCL] Remove mixed signedness atomic_fetch_ from opencl-c.h

The OpenCL C specification v3.0.6 s6.15.12.7.5 mentions:

    For atomic_fetch and modify functions with key = or, xor, and, min
    and max on atomic type atomic_intptr_t, M is intptr_t, and on
    atomic type atomic_uintptr_t, M is uintptr_t.

Remove the atomic_fetch_* overloads from opencl-c.h that mix intptr_t
and uintptr_t in the same declaration.

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

3 years ago[RISCV] Optimize all-constant mask BUILD_VECTORs
Fraser Cormack [Wed, 17 Mar 2021 09:05:55 +0000 (09:05 +0000)]
[RISCV] Optimize all-constant mask BUILD_VECTORs

This patch adds an optimization for mask-vector BUILD_VECTOR nodes whose
elements are all constants or undef. It lowers such operations by
building up the vector via a series of integer operations, in which
multiple mask elements are inserted into a vector at a time via
i8/i16/i32/i64 element types. The final result is then bitcast from that
integer vector.

We restrict this optimization in certain circumstances when optimizing
for size. If we are required to use more than one integer insert
operation, then it will likely increase code size compared with using a
load from a constant pool.

Reviewed By: craig.topper

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

3 years ago[PowerPC] Add more missing overloads to altivec.h
Nemanja Ivanovic [Tue, 23 Mar 2021 10:06:28 +0000 (05:06 -0500)]
[PowerPC] Add more missing overloads to altivec.h

Add overloads that perform addition on v1i128 that take and produce
vector unsigned char to avoid needing to use __int128. The overloads
are suffixed with _u128 and are needed for targets where __int128
isn't supported (AIX).

3 years ago[mlir] Remove deprecated methods from mlir::OpState
Christian Sigg [Tue, 23 Mar 2021 07:33:22 +0000 (08:33 +0100)]
[mlir] Remove deprecated methods from mlir::OpState

Reviewed By: rriddle

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

3 years ago[VPlan] Include name when printing after 93a9d2de8f4f.
Florian Hahn [Mon, 22 Mar 2021 18:23:32 +0000 (18:23 +0000)]
[VPlan] Include name when printing after 93a9d2de8f4f.

The name is included when printing in DOT mode. Also print it in non-DOT
mode after 93a9d2de8f4f.

This will become more important to distinguish different plans once
VPlans are gradually refined.

3 years ago[lli] Fix ppc64le-clang-lnt-test bot: Keep test-call.ll a MCJIT-only test
Stefan Gränitz [Tue, 23 Mar 2021 09:47:35 +0000 (10:47 +0100)]
[lli] Fix ppc64le-clang-lnt-test bot: Keep test-call.ll a MCJIT-only test

No callback manager available for powerpc64le-unknown-linux-gnu

3 years ago[X86][AVX] Narrow VPBROADCASTQ->VPBROADCASTD if we don't need the upper bits.
Simon Pilgrim [Tue, 23 Mar 2021 09:40:54 +0000 (09:40 +0000)]
[X86][AVX] Narrow VPBROADCASTQ->VPBROADCASTD if we don't need the upper bits.

Helps fix cases where we've splatted smaller types to a wider vector element type without needing the upper bits.

Avoid this on AVX512 targets as that can affect broadcast folding.

3 years ago[lli] Make -jit-kind=orc the default JIT engine
Stefan Gränitz [Tue, 23 Mar 2021 09:22:06 +0000 (10:22 +0100)]
[lli] Make -jit-kind=orc the default JIT engine

MCJIT served well as the default JIT engine in lli for a long time, but the code is getting old and maintenance efforts don't seem to be in sight. In the meantime Orc became mature enough to fill that gap. The newly added greddy mode is very similar to the execution model of MCJIT. It should work as a drop-in replacement for common JIT tasks.

Reviewed By: lhames

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

3 years ago[lit] Reliable progress indicator and ETA
Roman Lebedev [Tue, 23 Mar 2021 07:50:18 +0000 (10:50 +0300)]
[lit] Reliable progress indicator and ETA

Quality of progress bar and ETA in lit has always bothered me.

For example, given `./bin/llvm-lit /repositories/llvm-project/clang/test/CodeGen* -sv`
at 1%, it says it will take 10 more minutes,
at 25%, it says it will take 1.25 more minutes,
at 50%, it says it will take 30 more seconds,
and in the end finishes with `Testing Time: 39.49s`. That's rather wildly unprecise.

Currently, it assumes that every single test will take the same amount of time to run on average.
This is is a somewhat reasonable approximation overall, but it is quite clearly imprecise,
especially in the beginning.

But, we can do better now, after D98179! We now know how long the tests took to run last time.
So we can build a better ETA predictor, by accumulating the time spent already,
the time that will be spent on the tests for which we know the previous time,
and for the test for which we don't have previous time, again use the average time
over the tests for which we know current or previous run time.
It would be better to use median, but i'm wary of the cost that may incur.

Now, on **first** run of `./bin/llvm-lit /repositories/llvm-project/clang/test/CodeGen* -sv`
at 10%, it says it will take 30 seconds,
at 25%, it says it will take 50 more seconds,
at 50%, it says it will take 27 more seconds,
and in the end finishes with `Testing Time: 41.64s`. That's pretty reasonable.

And on second run of `./bin/llvm-lit /repositories/llvm-project/clang/test/CodeGen* -sv`
at 1%, it says it will take 1 minutes,
at 25%, it says it will take 30 more seconds,
at 50%, it says it will take 19 more seconds,
and in the end finishes with `Testing Time: 39.49s`. That's amazing i think!

I think people will love this :)

Reviewed By: yln

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

3 years ago[clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.
Balázs Kéri [Tue, 23 Mar 2021 08:10:22 +0000 (09:10 +0100)]
[clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.

Update ASTImporter to import value of FieldDecl::getCapturedVLAType.

Reviewed By: shafik, martong

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

3 years agoReland "[InstCombine] Add simplification of two logical and/ors"
Juneyoung Lee [Tue, 23 Mar 2021 04:46:19 +0000 (13:46 +0900)]
Reland "[InstCombine] Add simplification of two logical and/ors"

This relands 07c3b97e184d5bd828b8a680cdce46e73f3db9fc (D96945) which was reverted by
commit f49354838e526671e616d16199ebdee653b9f6fa.
The two-stage compilation successfully tests passes on my machine.

3 years ago[SanitizerCoverage] Use External on Windows
Fangrui Song [Tue, 23 Mar 2021 06:05:36 +0000 (23:05 -0700)]
[SanitizerCoverage] Use External on Windows

This should fix https://reviews.llvm.org/D98903#2643589 though
it is not clear to me why ExternalWeak does not work.

3 years ago[RS4GC] Fix hang on infinite loop
Serguei Katkov [Mon, 22 Mar 2021 03:30:41 +0000 (10:30 +0700)]
[RS4GC] Fix hang on infinite loop

meetBDVState utility may sets the base pointer for the conflict state.
At this moment the base for conflict state does not have any meaning but
is used in comparison of BDV states. This comparison is used as an indicator
of progress done on iteration and RS4GC pass uses infinite loop to reach
fixed point.
As a result for added test on each iteration state for some phi nodes is updated
with other base value for conflict state and it indicates as a progress while
for conflict state there is no any progress more possible.
In reality the base value is transferred from one state to another and pass
detects the progress on these states.

The test is very fragile. The traversal order of states and operands of phi nodes
plays important role.

Reviewers: reames, dantrushin
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D99058

3 years ago[TableGen] Tiny enhancement
Serge Pavlov [Tue, 23 Mar 2021 05:46:34 +0000 (12:46 +0700)]
[TableGen] Tiny enhancement

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

3 years ago[GlobalISel][AMDGPU] Lower G_UMULO/G_SMULO
Pushpinder Singh [Tue, 9 Mar 2021 06:10:00 +0000 (06:10 +0000)]
[GlobalISel][AMDGPU] Lower G_UMULO/G_SMULO

Reviewed By: foad

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

3 years ago[NFC] Fix typo longre -> longer
Max Kazantsev [Tue, 23 Mar 2021 05:13:19 +0000 (12:13 +0700)]
[NFC] Fix typo longre -> longer

3 years ago[TableGen] Allow BitsInit to init integer in pseudo expansion
Serge Pavlov [Sat, 20 Mar 2021 06:06:46 +0000 (13:06 +0700)]
[TableGen] Allow BitsInit to init integer in pseudo expansion

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

3 years ago[lsan][lsan] Use --std=c++14 to fix Windows test
Vitaly Buka [Tue, 23 Mar 2021 04:38:15 +0000 (21:38 -0700)]
[lsan][lsan] Use --std=c++14 to fix Windows test

3 years ago[llvm-readelf, propeller] Add fallthrough bit to basic block metadata in BB-Address...
Rahman Lavaee [Tue, 23 Mar 2021 04:36:32 +0000 (21:36 -0700)]
[llvm-readelf, propeller] Add fallthrough bit to basic block metadata in BB-Address-Map section.

This patch adds a fallthrough bit to basic block metadata, indicating whether the basic block can fallthrough without taking any branches. The bit will help us avoid an intel LBR bug which results in occasional duplicate entries at the beginning of the LBR stack.

This patch uses `MachineBasicBlock::canFallThrough()` to set the bit. This is not a const method because it eventually calls `TargetInstrInfo::analyzeBranch`, but it calls this function with the default `AllowModify=false`. So we can either make the argument to the `getBBAddrMapMetadata` non-const, or we can use `const_cast` when calling `canFallThrough`. I decide to go with the latter since this is purely due to legacy code, and in general we should not allow the BasicBlock to be mutable during `getBBAddrMapMetadata`.

Reviewed By: tmsriram

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

3 years ago[AMDGPU] Reserve ELF code
Tony [Mon, 22 Mar 2021 22:28:11 +0000 (22:28 +0000)]
[AMDGPU] Reserve ELF code

Reserve AMD GPU ELF machine code 0x040.

Minor AMDGPUUsage format consistency change.

Reviewed By: kzhuravl

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

3 years ago[PowerPC] Add more missing overloads to altivec.h
Nemanja Ivanovic [Tue, 23 Mar 2021 04:08:40 +0000 (23:08 -0500)]
[PowerPC] Add more missing overloads to altivec.h

Add vec_permi as a synonym for vec_xxpermdi (but only for
doubleword vectors).

3 years ago[RISCV] Add scheduler classes to Zfh instructions.
Craig Topper [Tue, 23 Mar 2021 03:30:06 +0000 (20:30 -0700)]
[RISCV] Add scheduler classes to Zfh instructions.

Reviewed By: HsiangKai

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

3 years ago[RISCV] Remove unused SchedWrites WriteFConv32/WriteFConv64/WriteFMov32/WriteFMov64.
Craig Topper [Tue, 23 Mar 2021 03:29:15 +0000 (20:29 -0700)]
[RISCV] Remove unused SchedWrites WriteFConv32/WriteFConv64/WriteFMov32/WriteFMov64.

It doesn't look like any instructions have ever been assigned to these classes.

Reviewed By: HsiangKai

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

3 years ago[PowerPC] Add more missing overloads to altivec.h
Nemanja Ivanovic [Tue, 23 Mar 2021 03:25:28 +0000 (22:25 -0500)]
[PowerPC] Add more missing overloads to altivec.h

Add vec_gbb as a synonym for vec_vgbbd but for doubleword vectors.

3 years ago[PowerPC] Add more missing overloads to altivec.h
Nemanja Ivanovic [Tue, 23 Mar 2021 03:08:29 +0000 (22:08 -0500)]
[PowerPC] Add more missing overloads to altivec.h

Add vec_cvf as a synonym for vec_doublee/vec_floate.

3 years ago[AMDGPU] Only unbundle memory accesses in SIMemoryLegalizer
Carl Ritson [Tue, 23 Mar 2021 01:56:56 +0000 (10:56 +0900)]
[AMDGPU] Only unbundle memory accesses in SIMemoryLegalizer

This restores previous behaviour and is a step toward removing
unbundling entirely.

Reviewed By: foad, rampitec

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

3 years ago[RISCV] Rename Zb* extension tests to use lower case 'Z' in file names.
Craig Topper [Tue, 23 Mar 2021 02:16:08 +0000 (19:16 -0700)]
[RISCV] Rename Zb* extension tests to use lower case 'Z' in file names.

As discussed in D99009

3 years ago[test] precommit another test for point-in-time deref semantics
Philip Reames [Tue, 23 Mar 2021 02:09:07 +0000 (19:09 -0700)]
[test] precommit another test for point-in-time deref semantics

3 years agoImprove module dumping for debugging.
Richard Smith [Tue, 23 Mar 2021 00:45:39 +0000 (17:45 -0700)]
Improve module dumping for debugging.

  * List inferred lists of imports in `#pragma clang __debug module_map`.

  * Add `#pragma clang __debug modules {all,visible,building}` to dump
    lists of known / visible module names or the building modules stack.

3 years ago[tests] Expand tests for point-in-time dereferenceability
Philip Reames [Tue, 23 Mar 2021 01:56:50 +0000 (18:56 -0700)]
[tests] Expand tests for point-in-time dereferenceability

3 years agoRevert "[sanitizer] Support dynamic premapped R/W range in primary allocator."
Vitaly Buka [Tue, 23 Mar 2021 01:48:14 +0000 (18:48 -0700)]
Revert "[sanitizer] Support dynamic premapped R/W range in primary allocator."

Fails on Windows https://lab.llvm.org/buildbot/#/builders/127/builds/7999
and Android https://lab.llvm.org/buildbot/#/builders/77/builds/4839

This reverts commit bca0cf768b6021124f5e5315be333c2f45f14fca.

3 years agoRevert "[RISCV][NFC] Fix RVV intrinsic tests."
Zakk Chen [Tue, 23 Mar 2021 01:51:48 +0000 (18:51 -0700)]
Revert "[RISCV][NFC] Fix RVV intrinsic tests."

This reverts commit ab082b582dd01becc0e0dbb0ff28371e0ce392a9.

3 years agoMinor format tweak to deref analysis printer
Philip Reames [Tue, 23 Mar 2021 01:44:06 +0000 (18:44 -0700)]
Minor format tweak to deref analysis printer

3 years ago[dsymutil] Fix spurious warnings for missing symbols with thinLTO
Jonas Devlieghere [Mon, 22 Mar 2021 23:33:01 +0000 (16:33 -0700)]
[dsymutil] Fix spurious warnings for missing symbols with thinLTO

Fix spurious warnings for missing symbols with thinLTO. The latter
appends a unique suffix to avoid collisions for exported private
symbols, resulting in dsymutil complaining it couldn't find the symbol
in the object file.

rdar://75434058

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

3 years ago[deref] Split a test to show both global and pointwise semantics
Philip Reames [Mon, 22 Mar 2021 21:58:33 +0000 (14:58 -0700)]
[deref] Split a test to show both global and pointwise semantics

While doing so, also split one monster test into individually named test functions.

3 years ago[RISCV][NFC] Fix RVV intrinsic tests.
Zakk Chen [Mon, 22 Mar 2021 15:20:48 +0000 (08:20 -0700)]
[RISCV][NFC] Fix RVV intrinsic tests.

1. Skip the temporary file
2. Test cc1 with -S to verify codegen work well. Add '-target-feature
   +m' because the backend requires it to calculate the vscaled size/offset.

Reviewed By: craig.topper

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

3 years ago[PowerPC] Add more missing overloads to altivec.h
Nemanja Ivanovic [Tue, 23 Mar 2021 01:22:21 +0000 (20:22 -0500)]
[PowerPC] Add more missing overloads to altivec.h

Add vec_ctd which is similar to vec_ctf except the return type is
vector double rather than vector float.

3 years ago[mlir][OpAsmFormat] Add support for an "else" group on optional elements
River Riddle [Tue, 23 Mar 2021 01:07:09 +0000 (18:07 -0700)]
[mlir][OpAsmFormat] Add support for an "else" group on optional elements

The "else" group of an optional element is a collection of elements that get parsed/printed when the anchor of the main element group is *not* present. This is useful when there is a special syntax when an element is not present. The new syntax for an optional element is shown below:

```
optional-group: `(` elements `)` (`:` `(` else-elements `)`)? `?`
```

An example of how this might be used is shown below:

```tablegen
def FooOp : ... {
  let arguments = (ins UnitAttr:$foo);

  let assemblyFormat = "attr-dict (`foo_is_present` $foo^):(`foo_is_absent`)?";
}
```

would be formatted as such:

```mlir
// When the `foo` attribute is present:
foo.op foo_is_present

// When the `foo` attribute is not present:
foo.op foo_is_absent
```

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

3 years ago[mlir] Tune error message for assertion.
Sean Silva [Tue, 16 Mar 2021 20:40:35 +0000 (13:40 -0700)]
[mlir] Tune error message for assertion.

This assertion can fire in the case of different contexts as well, which
is not difficult to do from Python bindings, for example.

3 years agoRevert "[Passes] Add relative lookup table converter pass"
Gulfem Savrun Yeniceri [Tue, 23 Mar 2021 00:36:21 +0000 (00:36 +0000)]
Revert "[Passes] Add relative lookup table converter pass"

This reverts commit 78a65cd945d006ff02f9d24d9cc20a302ed93b08 which
caused buildbot failures.

3 years agoRename FrozenRewritePatternList -> FrozenRewritePatternSet; NFC.
Chris Lattner [Tue, 23 Mar 2021 00:36:27 +0000 (17:36 -0700)]
Rename FrozenRewritePatternList -> FrozenRewritePatternSet; NFC.

This nicely aligns the naming with RewritePatternSet.  This type isn't
as widely used, but we keep a using declaration in to help with
downstream consumption of this change.

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

3 years agoAdd a mechanism for Dialects to customize printing/parsing operations when they are...
Mehdi Amini [Tue, 23 Mar 2021 00:33:03 +0000 (00:33 +0000)]
Add a mechanism for Dialects to customize printing/parsing operations when they are unregistered

Reviewed By: rriddle

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

3 years ago[darwin][driver] Pass through -global-isel LLVM flags to ld.
Amara Emerson [Mon, 22 Mar 2021 23:52:11 +0000 (16:52 -0700)]
[darwin][driver] Pass through -global-isel LLVM flags to ld.

GlobalISel is currently not enabled when using -flto since the front-end
-mvllm flags don't get passed through. This change fixes this for Darwin
platforms. We have to do this in the driver because the code generator choice
isn't embedded into the bitcode file.

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

3 years agoTidy up some docs.
Chris Lattner [Tue, 23 Mar 2021 00:19:46 +0000 (17:19 -0700)]
Tidy up some docs.

Depends on D99127.

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

3 years ago[PatternMatch] Big mechanical rename OwningRewritePatternList -> RewritePatternSet...
Chris Lattner [Mon, 22 Mar 2021 23:58:34 +0000 (16:58 -0700)]
[PatternMatch] Big mechanical rename OwningRewritePatternList -> RewritePatternSet and insert -> add.  NFC

This doesn't change APIs, this just cleans up the many in-tree uses of these
names to use the new preferred names.  We'll keep the old names around for a
couple weeks to help transitions.

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

3 years agoReland "[SimplifyCFG] Update FoldBranchToCommonDest to be poison-safe"
Juneyoung Lee [Mon, 22 Mar 2021 21:26:53 +0000 (06:26 +0900)]
Reland "[SimplifyCFG] Update FoldBranchToCommonDest to be poison-safe"

This relands commit 99108c791de0285ee726a10e8274772b18cee73c (D95026) which was
reverted by 8d5a981a135a0f0ae0a10c59b7c8093aae1c28de because the underlying
problem (https://llvm.org/pr49495) is fixed.

3 years agoRevert "Revert "Revert "Revert "Revert "[lld-macho] Implement -dependency_info (parti...
Mehdi Amini [Tue, 23 Mar 2021 00:18:20 +0000 (00:18 +0000)]
Revert "Revert "Revert "Revert "Revert "[lld-macho] Implement -dependency_info (partially - more opcodes needed)"""""

This reverts commit 3c21166a94ea02b946e9eea75c5e9bdfa8c43ae6.
The build is broken (clang-8 host compiler):

lld/MachO/DriverUtils.cpp:271:8: error: use of overloaded operator '<<' is ambiguous (with operand types 'llvm::raw_fd_ostream' and 'lld::macho::DependencyTracker::DepOpCode')
    os << opcode;
    ~~ ^  ~~~~~~

3 years agoRevert "Revert "Revert "Revert "[lld-macho] Implement -dependency_info (partially...
Vy Nguyen [Mon, 22 Mar 2021 20:11:09 +0000 (16:11 -0400)]
Revert "Revert "Revert "Revert "[lld-macho] Implement -dependency_info (partially - more opcodes needed)""""

This reverts commit 9670d2e4af4c996098089e31b03ca138bc8d27e9.

Second attemp to reland D98559. New changes:
 - inline functions removed from cpp file.
 - updated tests to use CHECK-DAG instead of CHECK-NEXT
 - fixed ambiguous "<<" operator by switching `char` to uint8_t

3 years ago[PatternRewriter] Rename OwningRewritePatternList -> RewritePatternSet and insert...
Chris Lattner [Mon, 22 Mar 2021 22:02:04 +0000 (15:02 -0700)]
[PatternRewriter] Rename OwningRewritePatternList -> RewritePatternSet and insert -> add

This maintains the old name to have minimal source impact on downstream codes, and
does not do the huge mechanical patch.  I expect the huge mechanical patch to land
sometime this week, but we can keep around the old names for a couple weeks to reduce
impact on downstream projects.

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

3 years ago[doc] Fix typo in rel lookup table converter pass
Gulfem Savrun Yeniceri [Mon, 22 Mar 2021 23:08:55 +0000 (23:08 +0000)]
[doc] Fix typo in rel lookup table converter pass

Add additonal hypens to match the title size that was introduced in 78a65cd.

3 years ago[AST] Add introspection support for Decls
Stephen Kelly [Wed, 17 Mar 2021 22:56:39 +0000 (22:56 +0000)]
[AST] Add introspection support for Decls

The test code has lots of interesting locations which are not yet
introspected, but those will come later:

 http://ce.steveire.com/z/3T90hR

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

3 years ago[libc++] Include <__config> first in all standard headers.
Arthur O'Dwyer [Mon, 22 Mar 2021 17:12:31 +0000 (13:12 -0400)]
[libc++] Include <__config> first in all standard headers.

Mostly, *don't* include <experimental/__config> from C++17 <any>,
because that doesn't make any sense. I think it was just a cut-and-paste
typo when this header moved from experimental/.

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

3 years ago[gn build] fix typo in 78a65cd945d
Nico Weber [Mon, 22 Mar 2021 22:38:17 +0000 (18:38 -0400)]
[gn build] fix typo in 78a65cd945d

3 years ago[COFF] Only consider associated EH sections during ICF
Reid Kleckner [Mon, 22 Mar 2021 21:56:44 +0000 (14:56 -0700)]
[COFF] Only consider associated EH sections during ICF

The only known reason why ICF should not merge otherwise identical
sections with differing associated sections has to do with exception
handling tables. It's not clear what ICF should do when there are other
kinds of associated sections. In every other case when this has come up,
debug info and CF guard metadata, we have opted to make ICF ignore the
associated sections.

For comparison, ELF doesn't do anything for comdat groups. Instead,
.eh_frame is parsed to figure out if a section has an LSDA, and if so,
ICF is disabled.

Another issue is that the order of associated sections is not defined.
We have had issues in the past (crbug.com/1144476) where changing the
order of the .xdata/.pdata sections in the object file lead to large ICF
slowdowns.

To address these issues, I decided it would be best to explicitly
consider only .pdata and .xdata sections during ICF. This makes it easy
to ignore the object file order, and I think it makes the intention of
the code clearer.

I've also made the children() accessor return an empty list for
associated sections. This mostly only affects ICF and GC. This was the
behavior before I made this a linked list, so the behavior change should
be good. This had positive effects on chrome.dll: more .xdata sections
were merged that previously could not be merged because they were
associated with distinct .pdata sections.

Reviewed By: mstorsjo

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