platform/upstream/llvm.git
3 years ago[SimplifyCFG] MergeBlockIntoPredecessor() already knows how to preserve DomTree
Roman Lebedev [Wed, 16 Dec 2020 19:34:05 +0000 (22:34 +0300)]
[SimplifyCFG] MergeBlockIntoPredecessor() already knows how to preserve DomTree

... so just ensure that we pass DomTreeUpdater it into it.

Fixes DomTree preservation for a large number of tests,
all of which are marked as such so that they do not regress.

3 years ago[SimplifyCFG] removeUnreachableBlocks() already knows how to preserve DomTree
Roman Lebedev [Wed, 16 Dec 2020 18:48:29 +0000 (21:48 +0300)]
[SimplifyCFG] removeUnreachableBlocks() already knows how to preserve DomTree

... so just ensure that we pass DomTreeUpdater it into it.

Apparently, there were no dedicated tests just for that functionality,
so i'm adding one here.

3 years ago[NFCI][SimplifyCFG] Mark all the SimplifyCFG tests that already don't invalidate...
Roman Lebedev [Wed, 16 Dec 2020 18:26:43 +0000 (21:26 +0300)]
[NFCI][SimplifyCFG] Mark all the SimplifyCFG tests that already don't invalidate DomTree as such

First step after e1133179587dd895962a2fe4d6eb0cb1e63b5ee2,
in these tests, DomTree is valid afterwards, so mark them as such,
so that they don't regress.

In further steps, SimplifyCFG transforms shall taught to preserve DomTree,
in as small steps as possible.

3 years ago[AArch64InstPrinter] Use * 4096 instead of << 12
Fangrui Song [Wed, 16 Dec 2020 22:02:25 +0000 (14:02 -0800)]
[AArch64InstPrinter] Use * 4096 instead of << 12

Left shirting a negative integer is undefined before C++20.

3 years ago[libc++] Fix CI Dockerfile
Louis Dionne [Wed, 16 Dec 2020 22:00:09 +0000 (17:00 -0500)]
[libc++] Fix CI Dockerfile

Installing clang-format-11 doesn't seem to work if it's done before
we've installed LLVM. I must admit I didn't try to get to the bottom
of the issue, since installing it after seems to work.

3 years agoFix split-debug.c test on Windows
Reid Kleckner [Wed, 16 Dec 2020 21:48:47 +0000 (13:48 -0800)]
Fix split-debug.c test on Windows

3 years ago[PGO] Use the sum of profile counts to fix the function entry count
Rong Xu [Wed, 16 Dec 2020 21:11:59 +0000 (13:11 -0800)]
[PGO] Use the sum of profile counts to fix the function entry count

Raw profile count values for each BB are not kept after profile
annotation. We record function entry count and branch weights
and use them to compute the count when needed.  This mechanism
works well in a perfect world, but often breaks in real programs,
because of number prevision, inconsistent profile, or bugs in
BFI). This patch uses sum of profile count values to fix
function entry count to make the BFI count close to real profile
counts.

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

3 years ago[libc++] Install git-clang-format on CI nodes.
Marek Kurdej [Wed, 16 Dec 2020 21:33:10 +0000 (16:33 -0500)]
[libc++] Install git-clang-format on CI nodes.

Two problems fixed:
* an old version of clang-format get installed by default (6.0).
* git-clang-format is not present, only git-clang-format-<version> (e.g. git-clang-format-6.0).

Solution:
* install clang-format-11 with explicit version
* make symlink git-clang-format to the latest version of git-clang-format-<version>

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

3 years agoFix XCore test on Windows, the register order is reversed, for reasons unknown
Reid Kleckner [Wed, 16 Dec 2020 21:33:06 +0000 (13:33 -0800)]
Fix XCore test on Windows, the register order is reversed, for reasons unknown

3 years ago[VectorCombine] adjust test alignments for better coverage; NFC
Sanjay Patel [Wed, 16 Dec 2020 21:13:55 +0000 (16:13 -0500)]
[VectorCombine] adjust test alignments for better coverage; NFC

3 years ago[libc++abi] Remove redundant null pointer check in operator delete
Fangrui Song [Wed, 16 Dec 2020 21:29:40 +0000 (13:29 -0800)]
[libc++abi] Remove redundant null pointer check in operator delete

Similar to D52401. Normally operator delete is defined in libc++abi
(LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS is off by default).

C89 4.10.3.2 The free function
C99 7.20.3.2 The free function
C11 7.22.3.3 The free function

    If ptr is a null pointer, no action shall occur.

free on MSDN:

    If memblock is NULL, the pointer is ignored and free immediately returns.

Reviewed By: #libc_abi, ldionne

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

3 years ago[DSE] Pass MemoryLocation by const ref (NFC)
Nikita Popov [Wed, 16 Dec 2020 20:34:47 +0000 (21:34 +0100)]
[DSE] Pass MemoryLocation by const ref (NFC)

3 years ago[NFC] Remove unused prefixes in llvm/test/CodeGen/X86
Mircea Trofin [Tue, 15 Dec 2020 17:00:05 +0000 (09:00 -0800)]
[NFC] Remove unused prefixes in llvm/test/CodeGen/X86

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

3 years ago[VectorCombine] optimize alignment for load transform
Sanjay Patel [Wed, 16 Dec 2020 19:22:46 +0000 (14:22 -0500)]
[VectorCombine] optimize alignment for load transform

Here's another minimal step suggested by D93229 / D93397 .
(I'm trying to be extra careful in these changes because
load transforms are easy to get wrong.)

We can optimistically choose the greater alignment of a
load and its pointer operand. As the test diffs show, this
can improve what would have been unaligned vector loads
into aligned loads.

When we enhance with gep offsets, we will need to adjust
the alignment calculation to include that offset.

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

3 years agoPrint source location in the error message when parens are missing around sizeof...
Shivanshu Goyal [Wed, 16 Dec 2020 20:01:54 +0000 (12:01 -0800)]
Print source location in the error message when parens are missing around sizeof typename and the expression is inside macro expansion

Given the following code:

```
void Foo(int);

void Baz()
{
Bar(sizeof int);
}
```

The error message which is printed today is this:
```
error: expected parentheses around type name in sizeof expression
```

There is no source location printed whatsoever, so fixing a compile break like this becomes extremely hard in a large codebase.

My change improves the error message. But it doesn't output a FixItHint because I wasn't able to figure out how to get the locations for left and right parens. So any tips would be appreciated.

```
<source>:7:6: error: expected parentheses around type name in sizeof expression
        Bar(sizeof int);
            ^
```

Reviewed By: rsmith

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

3 years agoPR47474: Add test for Clang's current behavior.
Richard Smith [Wed, 16 Dec 2020 19:59:57 +0000 (11:59 -0800)]
PR47474: Add test for Clang's current behavior.

Our current behavior rejects the example, following the current language
rules, but it's likely the rules will be revised to allow this example.

3 years ago[sanitizer-common] Pickup llvm-symbolizer from $OUT/bin IFF exists.
Mitch Phillips [Wed, 16 Dec 2020 19:57:55 +0000 (11:57 -0800)]
[sanitizer-common] Pickup llvm-symbolizer from $OUT/bin IFF exists.

Fix-forward for D93352.

Slight rework of the same idea, pickup the external symbolizer from the
binary directory iff it exists.

3 years ago[clang-offload-bundler] Add option -allow-missing-bundles
Yaxun (Sam) Liu [Thu, 10 Dec 2020 21:30:24 +0000 (16:30 -0500)]
[clang-offload-bundler] Add option -allow-missing-bundles

There are out-of-tree tools using clang-offload-bundler to extract
bundles from bundled files. When a bundle is not in the bundled
file, clang-offload-bundler is expected to emit an error message
and return non-zero value. However currently clang-offload-bundler
silently generates empty file for the missing bundles.

Since OpenMP/HIP toolchains expect the current behavior, an option
-allow-missing-bundles is added to let clang-offload-bundler
create empty file when a bundle is missing when unbundling.
The unbundling job action is updated to use this option by
default.

clang-offload-bundler itself will emit error when a bundle
is missing when unbundling by default.

Changes are also made to check duplicate targets in -targets
option and emit error.

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

3 years agoMark implicit coroutine variables as being implicit
Emma Blink [Wed, 16 Dec 2020 19:42:07 +0000 (14:42 -0500)]
Mark implicit coroutine variables as being implicit

This prevents the clang-tidy readability-identifier-naming check from
triggering on implicit __coro_gro and __promise variables in coroutines.

3 years ago[mlir] Async: re-enable tests after fixing fkakines
Eugene Zhulenev [Wed, 16 Dec 2020 10:17:53 +0000 (02:17 -0800)]
[mlir] Async: re-enable tests after fixing fkakines

Test flakiness was fixed by: https://github.com/llvm/llvm-project/commit/9edcedf7f222ce7c893d1e3bf19b3a7a1f0f2218

Runs these tests to verify that all parts of the lowering work correctly.

Reviewed By: mehdi_amini

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

3 years ago[mlir] AsyncRuntime: mode runtime declarations to mlir::runtime namespace
Eugene Zhulenev [Wed, 16 Dec 2020 13:14:12 +0000 (05:14 -0800)]
[mlir] AsyncRuntime: mode runtime declarations to mlir::runtime namespace

Define Async runtime related typedefs in the `mlir::runtime` namespace.

Reviewed By: mehdi_amini

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

3 years ago[flang] Handle undeclared names in EQUIVALENCE statements
Peter Steinfeld [Tue, 15 Dec 2020 22:44:22 +0000 (14:44 -0800)]
[flang] Handle undeclared names in EQUIVALENCE statements

Names in EQUIVALENCE statements are only allowed to indicate local
objects as per 19.5.1.4, paragraph 2, item (10).  Thus, a name appearing
in an EQUIVALENCE statement with no corresponding declaration in the
same scope is an implicit declaration of the name.  If that scope
contains an IMPLICIT NONE, it's an error.

I implemented this by adding a state variable to ScopeHandler to
indicate if we're resolving the names in an EQUIVALENCE statement and
then checked this state when resolving names.  I also added a test to
the existing tests for EQUIVALENCE statements.

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

3 years ago[lldb][NFC] Apply performance-faster-string-find (`str.find("X")` -> `str.find('x')`)
Jordan Rupprecht [Wed, 16 Dec 2020 18:53:18 +0000 (10:53 -0800)]
[lldb][NFC] Apply performance-faster-string-find (`str.find("X")` -> `str.find('x')`)

3 years ago[SimplifyCFG] Precommit test for preserving !annotation.
Florian Hahn [Wed, 16 Dec 2020 16:51:14 +0000 (16:51 +0000)]
[SimplifyCFG] Precommit test for preserving !annotation.

3 years ago[Go] Fix bindings/go/llvm/IRBindings.cpp
Fangrui Song [Wed, 16 Dec 2020 18:09:58 +0000 (10:09 -0800)]
[Go] Fix bindings/go/llvm/IRBindings.cpp

3 years ago[mlir] Fix for gpu-async-region pass.
Christian Sigg [Tue, 15 Dec 2020 20:15:28 +0000 (21:15 +0100)]
[mlir] Fix for gpu-async-region pass.

- the !gpu.async.token is the second result of 'gpu.alloc async', not the first.
- async.execute construction takes operand types not yet wrapped in !async.value.
- fix typo

Reviewed By: herhut

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

3 years ago[gn build] Port 6eff12788ee
LLVM GN Syncbot [Wed, 16 Dec 2020 17:38:06 +0000 (17:38 +0000)]
[gn build] Port 6eff12788ee

3 years ago[DDG] Data Dependence Graph - DOT printer - recommit
Bardia Mahjour [Wed, 16 Dec 2020 17:34:38 +0000 (12:34 -0500)]
[DDG] Data Dependence Graph - DOT printer - recommit

This is being recommitted to try and address the MSVC complaint.

This patch implements a DDG printer pass that generates a graph in
the DOT description language, providing a more visually appealing
representation of the DDG. Similar to the CFG DOT printer, this
functionality is provided under an option called -dot-ddg and can
be generated in a less verbose mode under -dot-ddg-only option.

Reviewed By: Meinersbur

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

3 years agoRemove spurious MLIRLLVMConversionsIncGen dependency from LLVM Dialect (NFC)
Mehdi Amini [Wed, 16 Dec 2020 17:31:22 +0000 (17:31 +0000)]
Remove spurious MLIRLLVMConversionsIncGen dependency from LLVM Dialect (NFC)

Reviewed By: ftynse

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

3 years ago[VectorCombine] loosen alignment constraint for load transform
Sanjay Patel [Wed, 16 Dec 2020 17:11:57 +0000 (12:11 -0500)]
[VectorCombine] loosen alignment constraint for load transform

As discussed in D93229, we only need a minimal alignment constraint
when querying whether a hypothetical vector load is safe. We still
pass/use the potentially stronger alignment attribute when checking
costs and creating the new load.

There's already a test that changes with the minimum code change,
so splitting this off as a preliminary commit independent of any
gep/offset enhancements.

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

3 years ago[AArch64InstPrinter] Change printADRPLabel to print the target address in hexadecimal...
Fangrui Song [Wed, 16 Dec 2020 17:20:55 +0000 (09:20 -0800)]
[AArch64InstPrinter] Change printADRPLabel to print the target address in hexadecimal form

Similar to D77853. Change ADRP to print the target address in hex, instead of the raw immediate.
The behavior is similar to GNU objdump but we also include `0x`.

Note: GNU objdump is not consistent whether or not to emit `0x` for different architectures. We try emitting 0x consistently for all targets.

```
GNU objdump:       adrp x16, 10000000
Old llvm-objdump:  adrp x16, #0
New llvm-objdump:  adrp x16, 0x10000000
```

`adrp Xd, 0x...` assembles to a relocation referencing `*ABS*+0x10000` which is not intended. We need to use a linker or use yaml2obj.
The main test is `test/tools/llvm-objdump/ELF/AArch64/pcrel-address.yaml`

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

3 years agoRevert "[PowerPC] Extend folding RLWINM + RLWINM to post-RA."
Esme-Yi [Wed, 16 Dec 2020 17:12:24 +0000 (17:12 +0000)]
Revert "[PowerPC] Extend folding RLWINM + RLWINM to post-RA."

This reverts commit 1c0941e1524f499e3fbde48fc3bdd0e70fc8f2e4.

3 years ago[LoopNest] Handle loop-nest passes in LoopPassManager
Whitney Tsang [Wed, 16 Dec 2020 17:05:44 +0000 (17:05 +0000)]
[LoopNest] Handle loop-nest passes in LoopPassManager

Per http://llvm.org/OpenProjects.html#llvm_loopnest, the goal of this
patch (and other following patches) is to create facilities that allow
implementing loop nest passes that run on top-level loop nests for the
New Pass Manager.

This patch extends the functionality of LoopPassManager to handle
loop-nest passes by specializing the definition of LoopPassManager that
accepts both kinds of passes in addPass.

Only loop passes are executed if L is not a top-level one, and both
kinds of passes are executed if L is top-level. Currently, loop nest
passes should have the following run method:

PreservedAnalyses run(LoopNest &, LoopAnalysisManager &,
LoopStandardAnalysisResults &, LPMUpdater &);

Reviewed By: Whitney, ychen
Differential Revision: https://reviews.llvm.org/D87045

3 years ago[NFC] Use regex for code object version in hip tests
Jon Chesterfield [Wed, 16 Dec 2020 17:00:18 +0000 (17:00 +0000)]
[NFC] Use regex for code object version in hip tests

[NFC] Use regex for code object version in hip tests

Extracted from D93258. Makes tests robust to changes in default
code object version.

Reviewed By: t-tye

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

3 years ago[ELF] --emit-relocs: fix a crash if .rela.dyn is an empty output section
Fangrui Song [Wed, 16 Dec 2020 16:59:38 +0000 (08:59 -0800)]
[ELF] --emit-relocs: fix a crash if .rela.dyn is an empty output section

Fix PR48357: If .rela.dyn appears as an output section description, its type may
be SHT_RELA (due to the empty synthetic .rela.plt) while there is no input
section. The empty .rela.dyn may be retained due to a reference in a linker
script. Don't crash.

Reviewed By: grimar

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

3 years ago[libomptarget][nfc] Replace static const with enum
Jon Chesterfield [Wed, 16 Dec 2020 16:40:21 +0000 (16:40 +0000)]
[libomptarget][nfc] Replace static const with enum

[libomptarget][nfc] Replace static const with enum

Semantically identical. Replaces 0xff... with ~0 to spare counting the f.
Has the advantage that the compiler doesn't need to prove the 4/8 byte
value dead before discarding it, and sidesteps the compilation question
associated with what static means for a single source language.

Reviewed By: jdoerfert

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

3 years ago[CMake] Avoid __FakeVCSRevision.h with no git repository
Jonas Hahnfeld [Sat, 5 Dec 2020 11:52:38 +0000 (12:52 +0100)]
[CMake] Avoid __FakeVCSRevision.h with no git repository

Set the return variable to "" in find_first_existing_vc_file to
say that there is a repository, but no file to depend on. This works
transparently for all other callers that handle undefinedness and
equality to an empty string the same way.

Use the knowledge to avoid depending on __FakeVCSRevision.h if there
is no git repository at all (for example when building a release) as
there is no point in regenerating an empty VCSRevision.h.

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

3 years ago[flang] Fix crash in folding (#48437)
peter klausler [Tue, 15 Dec 2020 18:59:26 +0000 (10:59 -0800)]
[flang] Fix crash in folding (#48437)

Elemental intrinsic function folding was not taking the lower
bounds of constant array arguments into account; these lower bounds
can be distinct from 1 when named constants appear as arguments.

LLVM bugzilla #48437.

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

3 years ago[Doc][SystemZ] Add Linux/SystemZ to Getting Started guide.
Kai Nacke [Wed, 16 Dec 2020 11:01:08 +0000 (06:01 -0500)]
[Doc][SystemZ] Add Linux/SystemZ to Getting Started guide.

The Linux/SystemZ platform is missing in the Getting Started guide
as platform on which LLVM is known to work.

Reviewed by: uweigand

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

3 years ago[InstCombine] Precommit tests for !annotation metadata handling.
Florian Hahn [Wed, 16 Dec 2020 11:30:01 +0000 (11:30 +0000)]
[InstCombine] Precommit tests for !annotation metadata handling.

3 years agoLangRef: Update byval/sret description for required types
Matt Arsenault [Wed, 16 Dec 2020 15:25:07 +0000 (10:25 -0500)]
LangRef: Update byval/sret description for required types

3 years ago[flang] Handle multiple names for same operator
Tim Keith [Wed, 16 Dec 2020 15:06:53 +0000 (07:06 -0800)]
[flang] Handle multiple names for same operator

Some operators have more than one name, e.g. operator(==), operator(.eq).
That was working correctly in generic definitions but they can also
appear in other contexts: USE statements and access statements, for
example.

This changes FindInScope to always look for each of the names for
a symbol. So an operator may be use-associated under one name but
declared private under another name and it will be the same symbol.
This replaces GenericSpecInfo::FindInScope which was only usable in
some cases.

Add a version of FindInScope() that looks in the current scope to
simplify many of the calls.

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

3 years agoNFC: balance a quote in AttrDocs.td
Erik Pilkington [Tue, 15 Dec 2020 22:01:20 +0000 (17:01 -0500)]
NFC: balance a quote in AttrDocs.td

This was confusing my editor.

3 years ago[Sema] Fix a miscompile by retaining array qualifiers when folding VLAs to constant...
Erik Pilkington [Tue, 15 Dec 2020 22:00:20 +0000 (17:00 -0500)]
[Sema] Fix a miscompile by retaining array qualifiers when folding VLAs to constant arrays

rdar://72243125

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

3 years ago[TableGen] Slim down the data structures in xxxGenInstrInfo.inc, step 1
Paul C. Anagnostopoulos [Fri, 11 Dec 2020 21:19:52 +0000 (16:19 -0500)]
[TableGen] Slim down the data structures in xxxGenInstrInfo.inc, step 1

3 years ago[X86] Regenerate bit extraction tests, cleaning up check-prefixes.
Simon Pilgrim [Wed, 16 Dec 2020 14:42:08 +0000 (14:42 +0000)]
[X86] Regenerate bit extraction tests, cleaning up check-prefixes.

As noticed on D92965, we needed to simplify the prefixes to ensure all RUNs were properly covered.

We should never have a target with BMI2 without BMI1, so use that as the 'BMI level' and then check with/without TBM (all TBM targets have at least BMI1).

3 years ago[X86] Rename reduction combiners to make it clearer whats happening. NFCI.
Simon Pilgrim [Wed, 16 Dec 2020 13:31:10 +0000 (13:31 +0000)]
[X86] Rename reduction combiners to make it clearer whats happening. NFCI.

Since these are all working on reduction patterns, actually use that term in the function name to make them easier to search for.

At some point we're likely to start working with the ISD::VECREDUCE_* opcodes directly in the x86 backend, but that is still some way off.

3 years ago[sanitizer-common] Force pickup of llvm-symbolizer from new binaries.
Mitch Phillips [Wed, 16 Dec 2020 14:36:22 +0000 (06:36 -0800)]
[sanitizer-common] Force pickup of llvm-symbolizer from new binaries.

It's possible currently that the sanitizer runtimes when testing grab
the path to the symbolizer through *SAN_SYMBOLIZER_PATH=...

This can be polluted by things like Android's setup script. This patch
forces external_symbolizer_path=$new_build_out_dir/llvm-symbolizer when
%env_tool_options is used.

Reviewed By: vitalybuka

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

3 years ago[XCOFF][AIX] Emit EH information in traceback table
diggerlin [Wed, 16 Dec 2020 14:34:59 +0000 (09:34 -0500)]
[XCOFF][AIX] Emit EH information in traceback table

SUMMARY:

In order for the runtime on AIX to find the compact unwind section(EHInfo table),
we would need to set the following on the traceback table:

The 6th byte's longtbtable field to true to signal there is an Extended TB Table Flag.
The Extended TB Table Flag to be 0x08 to signal there is an exception handling info presents.
Emit the offset between ehinfo TC entry and TOC base after all other optional portions of traceback table.

The patch is authored by Jason Liu.

Reviewers: David Tenty, Digger Lin
Differential Revision: https://reviews.llvm.org/D92766

3 years ago[SLPVectorizer]Migrate getEntryCost to return InstructionCost
Caroline Concatto [Thu, 10 Dec 2020 17:23:46 +0000 (17:23 +0000)]
[SLPVectorizer]Migrate getEntryCost to return InstructionCost

This patch also changes:
  the return type of getGatherCost and
  the signature of the debug function dumpTreeCosts
to use InstructionCost.

This patch is part of a series of patches to use InstructionCost instead of
unsigned/int for the cost model functions.

See this thread for context:
http://lists.llvm.org/pipermail/llvm-dev/2020-November/146408.html

See this patch for the introduction of the type:
https://reviews.llvm.org/D91174

Depends on D93049

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

3 years ago[Statepoints] Extract invoke tests into separate file. NFC.
Denis Antrushin [Tue, 15 Dec 2020 12:14:39 +0000 (19:14 +0700)]
[Statepoints] Extract invoke tests into separate file. NFC.

Extract VReg lowering tests with invokes into separate file
for easier maintenance/modification.
Check MIR after register allocation - at this point all
transformations we're interested in has been applied and verifying
of MIR is simpler than that of assembly.

3 years ago[PATCH] [compiler-rt] [builtins] Fix name of __aarch64_have_lse_atomics on Darwin
Stephan Bergmann [Wed, 16 Dec 2020 11:46:10 +0000 (12:46 +0100)]
[PATCH] [compiler-rt] [builtins] Fix name of __aarch64_have_lse_atomics on Darwin

...where the name of that variable defined in
compiler-rt/lib/builtins/cpu_model.c is decorated with a leading underscore

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

3 years ago[CostModel] Add costs for llvm.experimental.vector.{extract,insert} intrinsics
Bradley Smith [Wed, 9 Dec 2020 11:03:54 +0000 (11:03 +0000)]
[CostModel] Add costs for llvm.experimental.vector.{extract,insert} intrinsics

Adds cost model support for the new llvm.experimental.vector.{extract,insert}
intrinsics, using the existing getExtractSubvectorOverhead and
getInsertSubvectorOverhead functions for shuffles.

Previously this case would throw an assertion.

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

3 years ago[mlir][spirv] Add parsing and printing support for SpecConstantOperation
ergawy [Wed, 16 Dec 2020 13:20:24 +0000 (08:20 -0500)]
[mlir][spirv] Add parsing and printing support for SpecConstantOperation

Adds more support for `SpecConstantOperation` by defining a custom
syntax for the op and implementing its parsing and printing.

Reviewed By: mravishankar, antiagainst

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

3 years ago[CostModel]Migrate getTreeCost() to use InstructionCost
Caroline Concatto [Thu, 10 Dec 2020 13:52:35 +0000 (13:52 +0000)]
[CostModel]Migrate getTreeCost() to use InstructionCost

This patch changes the type of cost variables (for instance: Cost, ExtractCost,
SpillCost) to use InstructionCost.
This patch also changes the type of cost variables to InstructionCost in other
functions that use the result of getTreeCost()
This patch is part of a series of patches to use InstructionCost instead of
unsigned/int for the cost model functions.

See this thread for context:
http://lists.llvm.org/pipermail/llvm-dev/2020-November/146408.html

Depends on D91174

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

3 years ago[CostModel]Replace FixedVectorType by VectorType in costgetIntrinsicInstrCost
Caroline Concatto [Wed, 25 Nov 2020 12:06:27 +0000 (12:06 +0000)]
[CostModel]Replace FixedVectorType by VectorType in costgetIntrinsicInstrCost

This patch replaces FixedVectorType by VectorType in getIntrinsicInstrCost
in BasicTTIImpl.h. It re-arranges the scalable type test earlier return
and add tests for scalable types.

Depends on D91532

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

3 years ago[clang][AArch64][SVE] Avoid going through memory for VLAT <-> VLST casts
Joe Ellis [Wed, 16 Dec 2020 09:01:28 +0000 (09:01 +0000)]
[clang][AArch64][SVE] Avoid going through memory for VLAT <-> VLST casts

This change makes use of the llvm.vector.extract intrinsic to avoid
going through memory when performing bitcasts between vector-length
agnostic types and vector-length specific types.

Depends on D91362

Reviewed By: c-rhodes

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

3 years ago[LLDB] Skip TestGuiBasicDebug.py on Arm and AArch64/Linux
Muhammad Omair Javaid [Wed, 16 Dec 2020 11:09:24 +0000 (16:09 +0500)]
[LLDB] Skip TestGuiBasicDebug.py on Arm and AArch64/Linux

TestGuiBasicDebug.py is intermittenly timing out on LLDB AArch64/Linux
buildbot. Putting SkipIf decorator untill root cuase is identified.

3 years agoRevert "Ensure SplitEdge to return the new block between the two given blocks"
Bangtian Liu [Wed, 16 Dec 2020 11:51:26 +0000 (11:51 +0000)]
Revert "Ensure SplitEdge to return the new block between the two given blocks"

This reverts commit cf638d793c489632bbcf0ee0fbf9d0f8c76e1f48.

3 years ago[X86][SSE] combineReductionToHorizontal - don't rely on widenSubVector to handle...
Simon Pilgrim [Wed, 16 Dec 2020 11:24:19 +0000 (11:24 +0000)]
[X86][SSE] combineReductionToHorizontal - don't rely on widenSubVector to handle illegal vector types.

Thanks to @asbirlea for reporting the bug.

3 years agoRevert "[LLDB] Remove AArch64/Linux xfail decorator from TestGuiBasicDebug"
Muhammad Omair Javaid [Wed, 16 Dec 2020 11:02:54 +0000 (16:02 +0500)]
Revert "[LLDB] Remove AArch64/Linux xfail decorator from TestGuiBasicDebug"

This reverts commit 3d27a99b2ed24e1951483cf13357ec188ad44bb0.

3 years ago[yaml2obj/obj2yaml] - Make Value/Size fields of Symbol optional.
Georgii Rymar [Wed, 9 Dec 2020 13:46:42 +0000 (16:46 +0300)]
[yaml2obj/obj2yaml] - Make Value/Size fields of Symbol optional.

When a field is optional we can use the `=<none>` syntax in macros.
This patch makes `Value`/`Size` fields of `Symbol` optional
and adds test cases for them.

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

3 years ago[lib/Object] - Make ELFObjectFile::getSymbol() return Expected<>.
Georgii Rymar [Tue, 15 Dec 2020 12:45:15 +0000 (15:45 +0300)]
[lib/Object] - Make ELFObjectFile::getSymbol() return Expected<>.

This was requested in comments for D93209:
https://reviews.llvm.org/D93209#inline-871192

D93209 fixes an issue with `ELFFile<ELFT>::getEntry`,
after what `getSymbol` starts calling `report_fatal_error` for previously
missed invalid cases.

This patch makes it return `Expected<>` and updates callers.
For few of them I had to add new `report_fatal_error` calls. But I see no
way to avoid it currently. The change would affects too many places, e.g:
`getSymbolBinding` and other methods are used from `ELFSymbolRef`
which is used in too many places across LLVM.

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

3 years ago[llvm-readelf/obj] - Handle out-of-order PT_LOADs better.
Georgii Rymar [Fri, 4 Dec 2020 08:54:03 +0000 (11:54 +0300)]
[llvm-readelf/obj] - Handle out-of-order PT_LOADs better.

This is https://bugs.llvm.org/show_bug.cgi?id=45698.

Specification says that
"Loadable segment entries in the program header table appear
in ascending order, sorted on the p_vaddr member."

Our `toMappedAddr()` relies on this condition. This patch
adds a warning when the sorting order of loadable segments is wrong.
In this case we force segments sorting and that allows
`toMappedAddr()` to work as expected.

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

3 years ago[clang][cli] Port DependencyOutput string based options to new option parsing system
Jan Svoboda [Tue, 15 Dec 2020 12:08:04 +0000 (13:08 +0100)]
[clang][cli] Port DependencyOutput string based options to new option parsing system

Depends on D84186

Reviewed By: dexonsmith

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

3 years ago[AMDGPU] Avoid calling copyFastMathFlags in wrong context
Piotr Sobczak [Wed, 16 Dec 2020 09:12:54 +0000 (10:12 +0100)]
[AMDGPU] Avoid calling copyFastMathFlags in wrong context

Calling Instruction::copyFastMathFlags() assumes the caller is
FPMathOperator. Avoid calling the function for instructions
that are not instances of FPMathOperator.

3 years ago[NFC] Pre-commit test for long-double builtins
Qiu Chaofan [Wed, 16 Dec 2020 09:19:54 +0000 (17:19 +0800)]
[NFC] Pre-commit test for long-double builtins

This test reflects clang behavior on long-double type math library
builtins under default or explicit 128-bit long-double options.

3 years ago[clang][cli] Port LangOpts option flags to new option parsing system
Jan Svoboda [Wed, 16 Dec 2020 09:05:09 +0000 (10:05 +0100)]
[clang][cli] Port LangOpts option flags to new option parsing system

Depends on D83892 & D83694 & D93104.

Reviewed By: dexonsmith

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

3 years ago[AMDGPU] Allow no saddr for global addtid insts
Sebastian Neubauer [Tue, 15 Dec 2020 10:15:53 +0000 (11:15 +0100)]
[AMDGPU] Allow no saddr for global addtid insts

I think the global_load/store_dword_addtid instructions support
switching off the scalar address.
Add assembler and disassembler support for this.

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

3 years ago[clang][cli] Port CodeGen option flags to new option parsing system
Jan Svoboda [Fri, 11 Dec 2020 14:41:35 +0000 (15:41 +0100)]
[clang][cli] Port CodeGen option flags to new option parsing system

Depends on D83697.

Reviewed By: dexonsmith

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

3 years ago[mlir] Lookup the latest value with a legal type when remapping values.
Alexander Belyaev [Wed, 16 Dec 2020 07:38:12 +0000 (08:38 +0100)]
[mlir] Lookup the latest value with a legal type when remapping values.

The current condition implies that the target materialization will be
called even if the type is the new operand type is legal, but slightly
different. For example, if there is a bufferization pattern that changes
memref layout, then target materialization for an illegal type
(TensorType) would be called.

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

3 years ago[clang][cli] Prevent double denormalization
Jan Svoboda [Wed, 9 Dec 2020 12:26:39 +0000 (13:26 +0100)]
[clang][cli] Prevent double denormalization

If both flags created through BoolOption are CC1Option and the keypath has a non-default or non-implied value, the denormalizer gets called twice. If the denormalizer has the ability to generate both flags, we can end up generating the same flag twice.

Reviewed By: dexonsmith, Bigcheese

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

3 years ago[clang][cli] Do not marshall only CC1Option flags in BoolOption
Jan Svoboda [Tue, 8 Dec 2020 17:15:21 +0000 (18:15 +0100)]
[clang][cli] Do not marshall only CC1Option flags in BoolOption

We cannot be sure whether a flag is CC1Option inside the definition of `BoolOption`. Take the example below:

```
let Flags = [CC1Option] in {
  defm xxx : BoolOption<...>;
}
```

where TableGen applies `Flags = [CC1Option]` to the `xxx` and `no_xxx` records **after** they have been is fully declared by `BoolOption`.

For the refactored `-f[no-]debug-pass-manager` flags (see the diff), this means `BoolOption` never adds any marshalling info, as it doesn't see either of the flags as `CC1Option`.

For that reason, we should defensively append the marshalling information to both flags inside `BoolOption`. Now the check for `CC1Option` needs to happen later, in the parsing macro, when all TableGen logic has been resolved.

However, for some flags defined through `BoolOption`, we can run into issues:

```
// Options.td
def fenable_xxx : /* ... */;

// Both flags are CC1Option, the first is implied.
defm xxx : BoolOption<"xxx,
  "Opts.Xxx", DefaultsToFalse,
  ChangedBy<PosFlag, [CC1Option], "", [fenable_xxx]>,
  ResetBy<NegFlag, [CC1Option]>>;
```

When parsing `clang -cc1 -fenable-xxx`:
* we run parsing for `PosFlag`:
  * set `Opts.Xxx` to default `false`,
  * discover `PosFlag` is implied by `-fenable-xxx`: set `Opts.Xxx` to `true`,
  * don't see `-fxxx` on command line: do nothing,
* we run parsing for `NegFlag`:
  * set `Opts.Xxx` to default `false`,
  * discover `NegFlag` cannot be implied: do nothing,
  * don't see `-fno-xxx` on command line: do nothing.

Now we ended up with `Opts.Xxx` set to `false` instead of `true`. For this reason, we need to ensure to append the same `ImpliedByAnyOf` instance to both flags.

This means both parsing runs now behave identically (they set the same default value, run the same "implied by" check, and call `makeBooleanOptionNormalizer` that already has information on both flags, so it returns the same value in both calls).

The solution works well, but what might be confusing is this: you have defined a flag **A** that is not `CC1Option`, but can be implied by another flag **B** that is `CC1Option`:
* if **A** is defined manually, it will never get implied, as the code never runs
```
def no_signed_zeros : Flag<["-"], "fno-signed-zeros">, Group<f_Group>, Flags<[]>,
  MarshallingInfoFlag<"LangOpts->NoSignedZero">, ImpliedByAnyOf<[menable_unsafe_fp_math]>;
```
* if **A** is defined by `BoolOption`, it could get implied, as the code is run by its `CC1Option` counterpart:
```
defm signed_zeros : BoolOption<"signed-zeros",
  "LangOpts->NoSignedZero", DefaultsToFalse,
  ChangedBy<NegFlag, [], "Allow optimizations that ignore the sign of floating point zeros",
            [cl_no_signed_zeros, menable_unsafe_fp_math]>,
  ResetBy<PosFlag, [CC1Option]>, "f">, Group<f_Group>;
```

This is a surprising inconsistency.

One solution might be to somehow propagate the final `Flags` of the implied flag in `ImpliedByAnyOf` and check whether it has `CC1Option` in the parsing macro. However, I think it doesn't make sense to spend time thinking about a corner case that won't come up in real code.

An observation: it is unfortunate that the marshalling information is a part of the flag definition. If we represented it in a separate structure, we could avoid the "double parsing" problem by having a single source of truth. This would require a lot of additional work though.

Note: the original patch missed the `CC1Option` check in the parsing macro, making my reasoning here incomplete. Moreover, it contained a change to denormalization that wasn't necessarily related to these changes, so I've extracted that to a follow-up patch: D93094.

Reviewed By: dexonsmith, Bigcheese

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

3 years agoRevert "[Compiler-rt][AArch64] Workaround for .cfi_startproc assembler parser bug."
Raul Tambre [Wed, 16 Dec 2020 08:14:41 +0000 (10:14 +0200)]
Revert "[Compiler-rt][AArch64] Workaround for .cfi_startproc assembler parser bug."

039cb03dd0dcff4daa17a062f7414ac22bf5f2eb (D93378) fixed the assembly separator, so the workaround is no longer necessary.

This reverts commit 3000c19df64f89ff319590f3a6e4d6b93d20983d.

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

3 years ago[builtins] Use %% as the separator for aarch64-*-darwin and ; for powerpc{32,64}
Fangrui Song [Wed, 16 Dec 2020 08:13:22 +0000 (00:13 -0800)]
[builtins] Use %% as the separator for aarch64-*-darwin and ; for powerpc{32,64}

`;` is the default comment marker, which is also used by powerpc*-*-elf target triples.
`@` is the comment marker of powerpc*-*-darwin but the Darwin support has been deleted for PowerPC (D72063).
`%%` is the statement separator used by aarch64-*-darwin (see AArch64MCAsmInfoDarwin, it uses `;` as the comment marker, which is different from most other targets)

Reviewed By: tambre

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

3 years ago[libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests.
Siva Chandra Reddy [Wed, 16 Dec 2020 07:44:44 +0000 (23:44 -0800)]
[libc][NFC] Use ASSERT_FP_EQ to comapre NaN values in tests.

3 years ago[AMDGPU] Print SCRATCH_EN field after the kernel
Stanislav Mekhanoshin [Tue, 15 Dec 2020 23:31:29 +0000 (15:31 -0800)]
[AMDGPU] Print SCRATCH_EN field after the kernel

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

3 years ago[libc][NFC] Rename global `nan` in tests to `aNaN`.
Siva Chandra Reddy [Wed, 16 Dec 2020 06:23:22 +0000 (22:23 -0800)]
[libc][NFC] Rename global `nan` in tests to `aNaN`.

The name `nan` conflicts with the function `nan` defined declared in
math.h.

3 years ago[libc][NFC][Obvious] Remove few unnecessary #include directives in tests.
Siva Chandra Reddy [Wed, 16 Dec 2020 05:40:40 +0000 (21:40 -0800)]
[libc][NFC][Obvious] Remove few unnecessary #include directives in tests.

3 years ago[HIP] unbundle bundled preprocessor output
Yaxun (Sam) Liu [Fri, 4 Dec 2020 22:38:57 +0000 (17:38 -0500)]
[HIP] unbundle bundled preprocessor output

There is a use case that users want to emit preprocessor
output as file and compile the preprocessor output later
with -x hip-cpp-output.

Clang emits bundled preprocessor output when users
compile with -E for combined host/device compilations.
Clang should be able to compile the bundled preprocessor
output with -x hip-cpp-output. Basically clang should
unbundle the bundled preprocessor output and launch
device and host compilation actions.

Currently there is a bug in clang driver causing bundled
preprocessor output not unbundled.

This patch fixes that.

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

3 years ago[LV] Weaken a unnecessarily strong assert [NFC]
Philip Reames [Wed, 16 Dec 2020 03:06:12 +0000 (19:06 -0800)]
[LV] Weaken a unnecessarily strong assert [NFC]

Account for the fact that (in the future) the latch might be a switch not a branch.  The existing code is correct, minus the assert.

3 years ago[JITLink][ORC] Enable creation / linking of raw jitlink::LinkGraphs.
Lang Hames [Wed, 16 Dec 2020 01:18:30 +0000 (12:18 +1100)]
[JITLink][ORC] Enable creation / linking of raw jitlink::LinkGraphs.

Separates link graph creation from linking. This allows raw LinkGraphs to be
created and passed to a link. ObjectLinkingLayer is updated to support emission
of raw LinkGraphs in addition to object buffers.

Raw LinkGraphs can be created by in-memory compilers to bypass object encoding /
decoding (though this prevents caching, as LinkGraphs have do not have an
on-disk representation), and by utility code to add programatically generated
data structures to the JIT target process.

3 years ago[RISCV] Refine vector load/store tablegen pattern, NFC.
Zakk Chen [Wed, 16 Dec 2020 01:27:38 +0000 (17:27 -0800)]
[RISCV] Refine vector load/store tablegen pattern, NFC.

Refine tablegen pattern for vector load/store, and follow
D93012 to separate masked and unmasked definitions for
pseudo load/store instructions.

Reviewed By: craig.topper

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

3 years ago[LV] Extend dead instruction detection to multiple exiting blocks
Philip Reames [Wed, 16 Dec 2020 02:46:32 +0000 (18:46 -0800)]
[LV] Extend dead instruction detection to multiple exiting blocks

Given we haven't yet enabled multiple exiting blocks, this is currently non functional, but it's an obvious extension which cleans up a later patch.

I don't think this is worth review (as it's pretty obvious), if anyone disagrees, feel feel to revert or comment and I will.

3 years ago[ASTMatchers][NFC] Strip prefixes eagerly in dynamic matcher arg traits.
Nathan James [Wed, 16 Dec 2020 01:56:30 +0000 (01:56 +0000)]
[ASTMatchers][NFC] Strip prefixes eagerly in dynamic matcher arg traits.

3 years ago[flang] Implement STORAGE_SIZE(), SIZEOF(), C_SIZEOF()
peter klausler [Tue, 15 Dec 2020 19:06:44 +0000 (11:06 -0800)]
[flang] Implement STORAGE_SIZE(), SIZEOF(), C_SIZEOF()

STORAGE_SIZE() is a standard inquiry intrinsic (size in bits
of an array element of the same type as the argument); SIZEOF()
is a common extension that returns the size in bytes of its
argument; C_SIZEOF() is a renaming of SIZEOF() in module ISO_C_BINDING.

STORAGE_SIZE() and SIZEOF() are implemented via rewrites to
expressions; these expressions will be constant when the necessary
type parameters and bounds are also constant.

Code to calculate the sizes of types (with and without alignment)
was isolated into Evaluate/type.* and /characteristics.*.
Code in Semantics/compute-offsets.* to calculate sizes and alignments
of derived types' scopes was exposed so that it can be called at type
instantiation time (earlier than before) so that these inquiry intrinsics
could be called from specification expressions.

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

3 years ago[Hexagon] Rename test case, NFC
Krzysztof Parzyszek [Wed, 16 Dec 2020 01:05:31 +0000 (19:05 -0600)]
[Hexagon] Rename test case, NFC

3 years ago[Hexagon] Temporarily disable vector realignment for non-HVX vectors
Krzysztof Parzyszek [Wed, 16 Dec 2020 01:03:07 +0000 (19:03 -0600)]
[Hexagon] Temporarily disable vector realignment for non-HVX vectors

3 years ago[Hexagon] Emit enough stores when aligning vector addresses
Krzysztof Parzyszek [Wed, 16 Dec 2020 00:41:49 +0000 (18:41 -0600)]
[Hexagon] Emit enough stores when aligning vector addresses

3 years ago[mac/lld] fix amend mishap from ec88746a059
Nico Weber [Wed, 16 Dec 2020 00:41:00 +0000 (19:41 -0500)]
[mac/lld] fix amend mishap from ec88746a059

3 years ago[lld/mac] fill in current and compatibility version for LC_LOAD_(WEAK_)DYLIB
Nico Weber [Tue, 15 Dec 2020 20:25:15 +0000 (15:25 -0500)]
[lld/mac] fill in current and compatibility version for LC_LOAD_(WEAK_)DYLIB

Not sure if anything actually depends on this, but it makes `otool -L`
output look nicer.

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

3 years ago[flang] Fix false error message for "ptr => func()" array conformance
peter klausler [Tue, 15 Dec 2020 18:54:36 +0000 (10:54 -0800)]
[flang] Fix false error message for "ptr => func()" array conformance

Pointers must have deferred shapes, so CheckConformance must be
extended to allow for them.

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

3 years ago[mac/lld] simplify code using PackedVersion instead of VersionTuple
Nico Weber [Tue, 15 Dec 2020 21:37:37 +0000 (16:37 -0500)]
[mac/lld] simplify code using PackedVersion instead of VersionTuple

PackedVersion already does the correct range checks.

No behavior change.

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

3 years ago[flang] Fix bug with USE of USE of generic
Tim Keith [Wed, 16 Dec 2020 00:11:58 +0000 (16:11 -0800)]
[flang] Fix bug with USE of USE of generic

When merging use associations into a generic, we weren't handling
the case where the name that was use associated was itself a use
association. This is fixed by following that association to its
ultimate symbol (`useUltimate` in `DoAddUse`).

An example of the bug is `m12d` in `resolve17.f90`. `g` is associated
with `gc` in `m12c` which is associated with `gb` in `m12b`. It was that
last association that we weren't correctly following.

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

3 years ago[gn build] Port b9c77542e23
LLVM GN Syncbot [Wed, 16 Dec 2020 00:03:26 +0000 (00:03 +0000)]
[gn build] Port b9c77542e23

3 years agoRevert "[OpenMP] Add initial support for `omp [begin/end] assumes`"
Johannes Doerfert [Wed, 16 Dec 2020 00:02:22 +0000 (18:02 -0600)]
Revert "[OpenMP] Add initial support for `omp [begin/end] assumes`"

There is a build error with gcc-5 [0], investigating now.

[0] https://reviews.llvm.org/D91980#2456526

This reverts commit a5a14cbe7f87e01882ecaa14df5d596cbf38823a.

3 years agoDocument that AlignedCharArrayUnion exists to work around an MSVC bug
Reid Kleckner [Tue, 15 Dec 2020 23:59:21 +0000 (15:59 -0800)]
Document that AlignedCharArrayUnion exists to work around an MSVC bug

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

3 years ago[mlir] Allow SymbolTable to update existing symbols
Tres Popp [Tue, 15 Dec 2020 23:13:05 +0000 (00:13 +0100)]
[mlir] Allow SymbolTable to update existing symbols

Previous behavior would fail if inserting an operation that already
existed. Now SymbolTable::insert can also be used as a way to make a
symbol's name unique even after insertion.

Further TODOs have been left over naming and consistent behavior
considerations.

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

3 years agoEnsure SplitEdge to return the new block between the two given blocks
Bangtian Liu [Tue, 15 Dec 2020 23:28:42 +0000 (23:28 +0000)]
Ensure SplitEdge to return the new block between the two given blocks

This PR implements the function splitBasicBlockBefore to address an
issue
that occurred during SplitEdge(BB, Succ, ...), inside splitBlockBefore.
The issue occurs in SplitEdge when the Succ has a single predecessor
and the edge between the BB and Succ is not critical. This produces
the result ‘BB->Succ->New’. The new function splitBasicBlockBefore
was added to splitBlockBefore to handle the issue and now produces
the correct result ‘BB->New->Succ’.

Below is an example of splitting the block bb1 at its first instruction.

/// Original IR
bb0:
br bb1
bb1:
        %0 = mul i32 1, 2
br bb2
bb2:
/// IR after splitEdge(bb0, bb1) using splitBasicBlock
bb0:
br bb1
bb1:
br bb1.split
bb1.split:
        %0 = mul i32 1, 2
br bb2
bb2:
/// IR after splitEdge(bb0, bb1) using splitBasicBlockBefore
bb0:
br bb1.split
bb1.split
br bb1
bb1:
        %0 = mul i32 1, 2
br bb2
bb2:

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

3 years ago[ClangTidy] NFC: Add more tests for container-size-empty
Stephen Kelly [Mon, 14 Dec 2020 23:09:32 +0000 (23:09 +0000)]
[ClangTidy] NFC: Add more tests for container-size-empty