platform/upstream/llvm.git
2 years ago[MLIR] Move `print()` and `dump()` from FlatAffineConstraints to IntegerPolyhedron.
Groverkss [Mon, 27 Dec 2021 13:09:57 +0000 (18:39 +0530)]
[MLIR] Move `print()` and `dump()` from FlatAffineConstraints to IntegerPolyhedron.

This patch moves `FlatAffineConstraints::print` and
`FlatAffineConstraints::dump()` to IntegerPolyhedron.

Reviewed By: arjunp

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

2 years agoFix forward for "signed version of createExpression"
Anton Daubert [Mon, 27 Dec 2021 12:50:02 +0000 (13:50 +0100)]
Fix forward for "signed version of createExpression"

Fix forward for "signed version of createExpression" change in https://github.com/llvm/llvm-project/commit/ec501f15a8b8ace2b283732740d6d65d40d82e09

Reviewed By: bgraur, achieveartificialintelligence

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

2 years ago[NFC] [Coroutines] Add tests to address the problem for converting to musttail
Chuanqi Xu [Mon, 27 Dec 2021 12:24:37 +0000 (20:24 +0800)]
[NFC] [Coroutines] Add tests to address the problem for converting to musttail
call

Add two tests to address the problem for missing oppotunities to convert
calls to musttail call.

2 years ago[X86] Add scheduler classes for zmm vector reg-reg move instructions
Simon Pilgrim [Mon, 27 Dec 2021 12:13:17 +0000 (12:13 +0000)]
[X86] Add scheduler classes for zmm vector reg-reg move instructions

Basic zmm reg-reg moves (with predication) are more port limited than xmm/ymm moves, so we need to add a separate class for them.

We still appear to be missing move-elimination patterns for most of the intel models, which looks to be one of the main diffs for basic codegen analysis between llvm-mca and uops.info

Load/stores are a bit messier and might be better handled as overrides.

2 years ago[CodeGen] Avoid one more pointer element type access
Nikita Popov [Mon, 27 Dec 2021 11:42:42 +0000 (12:42 +0100)]
[CodeGen] Avoid one more pointer element type access

The number of elements is always a SizeTy here.

2 years ago[MCA][X86] Add AVX512 vector move instruction test coverage
Simon Pilgrim [Fri, 24 Dec 2021 22:46:20 +0000 (22:46 +0000)]
[MCA][X86] Add AVX512 vector move instruction test coverage

2 years ago[IndVars] Support opaque pointers in LFTR
Nikita Popov [Mon, 27 Dec 2021 11:31:02 +0000 (12:31 +0100)]
[IndVars] Support opaque pointers in LFTR

Remove the assertion about the pointer element type, only check
that the stride is one. Ultimately, the actual pointer type here
doesn't matter, because SCEVExpander would insert appropriate
casts if necessary.

2 years agoGlobalISel: remove redundant line added in D114198. NFC
Petar Avramovic [Mon, 27 Dec 2021 11:13:41 +0000 (12:13 +0100)]
GlobalISel: remove redundant line added in D114198. NFC

2 years agoRevert "[NFC] [Coroutines] Add a test for icmp use of coro.suspend to prevent musttai...
Chuanqi Xu [Mon, 27 Dec 2021 11:05:22 +0000 (19:05 +0800)]
Revert "[NFC] [Coroutines] Add a test for icmp use of coro.suspend to prevent musttail call converting"

This reverts commit 21aa4d5d5ef947d824c50a22d15fb93d7df0b711.

The test added is not proper. It would be passed all the time since it
is in the ramp function.

2 years ago[CodeGen] Avoid more pointer element type accesses
Nikita Popov [Fri, 24 Dec 2021 13:01:54 +0000 (14:01 +0100)]
[CodeGen] Avoid more pointer element type accesses

2 years ago[LV] Sink BTC creation to actual use (NFC).
Florian Hahn [Mon, 27 Dec 2021 10:25:45 +0000 (11:25 +0100)]
[LV] Sink BTC creation to actual use (NFC).

Suggested separately in D116123.

2 years ago[NFC] [Coroutines] Add a test for icmp use of coro.suspend to prevent musttail call...
Chuanqi Xu [Mon, 27 Dec 2021 09:26:44 +0000 (17:26 +0800)]
[NFC] [Coroutines] Add a test for icmp use of coro.suspend to prevent musttail call converting

Add a test to show the false negative optimization oppotunity to not convert a resume
call to musttail call. It should could be.

2 years ago[MLIR] Add forgotten directory Support to unittests cmake
Arjun P [Mon, 27 Dec 2021 09:07:47 +0000 (14:37 +0530)]
[MLIR] Add forgotten directory Support to unittests cmake

The Support directory was removed from the unittests cmake when the directory
was removed in 204c3b551626a925dfdc3822a6f240bdc8ef5d3a. Subsequent commits
added the directory back but seem to have missed adding it back to the cmake.

This patch also removes MLIRSupportIndentedStream from the list of linked
libraries to avoid an ODR violation (it's already part of MLIRSupport which
is also being linked here). Otherwise ASAN complains:

```
=================================================================
==102592==ERROR: AddressSanitizer: odr-violation (0x7fbdf214eee0):
  [1] size=120 'vtable for mlir::raw_indented_ostream' /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
  [2] size=120 'vtable for mlir::raw_indented_ostream' /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
These globals were registered at these points:
  [1]:
    #0 0x28a71d in __asan_register_globals (/home/arjun/llvm-project/build/tools/mlir/unittests/Support/MLIRSupportTests+0x28a71d)
    #1 0x7fbdf214a61b in asan.module_ctor (/home/arjun/llvm-project/build/lib/libMLIRSupportIndentedOstream.so.14git+0x661b)

  [2]:
    #0 0x28a71d in __asan_register_globals (/home/arjun/llvm-project/build/tools/mlir/unittests/Support/MLIRSupportTests+0x28a71d)
    #1 0x7fbdf2061c4b in asan.module_ctor (/home/arjun/llvm-project/build/lib/libMLIRSupport.so.14git+0x11bc4b)

==102592==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY AddressSanitizer: odr-violation: global 'vtable for mlir::raw_indented_ostream' at /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
==102592==ABORTING
```

This patch also fixes a build issue with `DebugAction::classof` under Windows.

This commit re-lands this patch, which was previously reverted in
2132906836cf0618e76485c67a60305bf1557ffc due to a buildbot failure that
turned out to be because of a flaky test.

Reviewed By: jpienaar

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

2 years ago[OpenCL] Allow optional __generic in __remove_address_space utility
Justas Janickas [Tue, 30 Nov 2021 09:17:09 +0000 (09:17 +0000)]
[OpenCL] Allow optional __generic in __remove_address_space utility

2 years ago[Inline][X86] Avoid inlining if it would create ABI-incompatible calls (PR52660)
Nikita Popov [Wed, 15 Dec 2021 16:04:01 +0000 (17:04 +0100)]
[Inline][X86] Avoid inlining if it would create ABI-incompatible calls (PR52660)

X86 allows inlining functions if the callee target features are a
subset of the caller target features. This ensures that we don't
inline something into a caller that does not support it.

However, this does not account for possible call ABI mismatches as
a result of inlining. If a call passing a vector argument was
originally in a -avx function, calling another -avx function, the
vector is passed in xmm. If we now inline it into a +avx function,
then it will be passed in ymm, even though the callee expects it in xmm.

Fix this by scanning over all calls in the function and checking
whether ABI incompatibility is possible. Calls that only pass scalar
types are excluded, as I believe those always use the same ABI
independent of target features.

Fixes https://github.com/llvm/llvm-project/issues/52660.

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

2 years ago[ELF] Move excludeLibs/redirectSymbols/replaceCommonSymbols adjacent
Fangrui Song [Mon, 27 Dec 2021 08:31:54 +0000 (00:31 -0800)]
[ELF] Move excludeLibs/redirectSymbols/replaceCommonSymbols adjacent

Make post-thinlto-index symbol resolution passes closer.

2 years ago[ELF] Delete unused LazyObjKind
Fangrui Song [Mon, 27 Dec 2021 08:03:53 +0000 (00:03 -0800)]
[ELF] Delete unused LazyObjKind

2 years ago[Target] Use range-based for loops (NFC)
Kazu Hirata [Mon, 27 Dec 2021 07:49:38 +0000 (23:49 -0800)]
[Target] Use range-based for loops (NFC)

2 years ago[ELF] Serialize deleteFallThruJmpInsn to fix concurrency issue
Fangrui Song [Mon, 27 Dec 2021 07:26:13 +0000 (23:26 -0800)]
[ELF] Serialize deleteFallThruJmpInsn to fix concurrency issue

New deleteFallThruJmpInsn calls `make<JumpInstrMod>` which cannot be called
concurrently. Losing parallelism is unfortunate but we can think of a better
approach if parallelism here justifies itself.

2 years ago[ELF] Unify sizeof(InputSection) limits for _WIN32 and others
Fangrui Song [Mon, 27 Dec 2021 07:02:24 +0000 (23:02 -0800)]
[ELF] Unify sizeof(InputSection) limits for _WIN32 and others

Windows sizeof(InputSection) seems to match non-Windows now.

2 years ago[ELF] Optimize basic block section bytesDropped/jumpInstrMods
Fangrui Song [Mon, 27 Dec 2021 06:17:30 +0000 (22:17 -0800)]
[ELF] Optimize basic block section bytesDropped/jumpInstrMods

and make them more space efficient. This decreases sizeof(InputSection) from 176
to 160, and decreases peak memory usage by 0.3% when linking Chrome.

2 years ago[clang][CodeGen] Remove the signed version of createExpression
Shao-Ce SUN [Mon, 27 Dec 2021 06:15:30 +0000 (14:15 +0800)]
[clang][CodeGen] Remove the signed version of createExpression

Fix a TODO. Remove the callers of this signed version and delete.

Reviewed By: CodaFi

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

2 years ago[RISCV] Convert whole register copies as the source defined explicitly.
Hsiangkai Wang [Thu, 16 Dec 2021 10:12:38 +0000 (18:12 +0800)]
[RISCV] Convert whole register copies as the source defined explicitly.

The implicit defines may come from a partial define in an instruction.
It does not mean the defining instruction and the COPY instruction have
the same vl and vtype. When the source comes from the implicit defines,
do not convert the whole register copies to vmv.v.v.

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

2 years ago[libcxx] [Coroutines] Support noop_coroutine for GCC
Chuanqi Xu [Mon, 27 Dec 2021 05:52:42 +0000 (13:52 +0800)]
[libcxx] [Coroutines] Support noop_coroutine for GCC

We didn't support noop_coroutine for GCC in previous conforming patch.
So that GCC couldn't use noop_coroutine() defined in <coroutine>. And
after this patch, GCC should be able to compile the whole <coroutine>
header.

Reviewed By: Quuxplusone

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

2 years ago[ELF] ScriptParser: change std::vector to SmallVector
Fangrui Song [Mon, 27 Dec 2021 04:12:55 +0000 (20:12 -0800)]
[ELF] ScriptParser: change std::vector to SmallVector

2 years ago[ELF] SymbolTable::symbols: don't filter out PlaceholderKind
Fangrui Song [Mon, 27 Dec 2021 02:11:45 +0000 (18:11 -0800)]
[ELF] SymbolTable::symbols: don't filter out PlaceholderKind

Placeholders (-y and redirectSymbols removed versioned symbols) are very rare and
the check just makes symbol table iteration slower. Most iterations filter out
placeholders anyway, so this change just drops the filter behavior.

For "Add symbols to symtabs", we need to ensure that redirectSymbols sets
isUsedInRegularObj to false when making a symbol placeholder, to avoid an
assertion failure in SymbolTableSection<ELFT>::writeTo.

My .text is 2KiB smaller. The speed-up linking chrome is 0.x%.

2 years ago[RISCV] Reduce repetitive codes in flw, fsw
Shao-Ce SUN [Fri, 24 Dec 2021 01:22:28 +0000 (09:22 +0800)]
[RISCV] Reduce repetitive codes in flw, fsw

Trying to improve code reuse in F,D,Zfh *.td files.

Reviewed By: craig.topper

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

2 years ago[ELF] Add Symbol::hasVersionSuffix
Fangrui Song [Mon, 27 Dec 2021 01:25:54 +0000 (17:25 -0800)]
[ELF] Add Symbol::hasVersionSuffix

"Process symbol versions" may take 2+% time.
"Redirect symbols" may take 0.6% time.
This change speeds up the two passes and makes `*sym.getVersionSuffix()
== '@'` in the `undefined reference` diagnostic cleaner.

Linking chrome (no debug info) and another large program is 1.5% faster.

For empty-ver2.s: the behavior now matches GNU ld, though I'd consider the input
invalid and the exact behavior does not matter.

2 years ago[ELF] De-template InputSectionBase::getEnclosingFunction
Fangrui Song [Sun, 26 Dec 2021 23:21:22 +0000 (15:21 -0800)]
[ELF] De-template InputSectionBase::getEnclosingFunction

2 years ago[ELF] Remove unused InputSection::getOffsetInFile
Fangrui Song [Sun, 26 Dec 2021 23:18:56 +0000 (15:18 -0800)]
[ELF] Remove unused InputSection::getOffsetInFile

2 years agoUse static_assert instead of assert (NFC)
Kazu Hirata [Sun, 26 Dec 2021 22:26:44 +0000 (14:26 -0800)]
Use static_assert instead of assert (NFC)

Identified with misc-static-assert.

2 years ago[ELF] LinkerScript/OutputSection: change other std::vector members to SmallVector
Fangrui Song [Sun, 26 Dec 2021 21:53:47 +0000 (13:53 -0800)]
[ELF] LinkerScript/OutputSection: change other std::vector members to SmallVector

11+KiB smaller .text with both libc++ and libstdc++ builds.

2 years ago[clang] Remove redundant calls to c_str() (NFC)
Kazu Hirata [Sun, 26 Dec 2021 21:31:40 +0000 (13:31 -0800)]
[clang] Remove redundant calls to c_str() (NFC)

Identified with readability-redundant-string-cstr.

2 years ago[ELF] Change InputSectionDescription members from vector to SmallVector
Fangrui Song [Sun, 26 Dec 2021 21:06:54 +0000 (13:06 -0800)]
[ELF] Change InputSectionDescription members from vector to SmallVector

This decreases sizeof(lld::elf::InputSectionDescription) from 264 to 232.

2 years ago[LV] Move getStepVector out of ILV (NFC).
Florian Hahn [Sun, 26 Dec 2021 20:17:25 +0000 (21:17 +0100)]
[LV] Move getStepVector out of ILV (NFC).

First step to split up induction handling and move it outside ILV.
Used in D116123 and following.

2 years ago[ELF] Move outSecOff addition from InputSection::writeTo to the caller
Fangrui Song [Sun, 26 Dec 2021 20:11:40 +0000 (12:11 -0800)]
[ELF] Move outSecOff addition from InputSection::writeTo to the caller

Simplify the code a bit and improve consistency with SyntheticSection::writeTo.

2 years agoRemove redundant string initialization (NFC)
Kazu Hirata [Sun, 26 Dec 2021 17:39:26 +0000 (09:39 -0800)]
Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.

2 years agoEnsure newlines at the end of files (NFC)
Kazu Hirata [Sun, 26 Dec 2021 16:51:06 +0000 (08:51 -0800)]
Ensure newlines at the end of files (NFC)

2 years ago[Orc] Remove a redundant declaration (NFC)
Kazu Hirata [Sun, 26 Dec 2021 09:01:38 +0000 (01:01 -0800)]
[Orc] Remove a redundant declaration (NFC)

DebugUtils.h contains an identical declaration with a correct comment,
namely:

  /// Render a LookupKind.
  raw_ostream &operator<<(raw_ostream &OS, const LookupKind &K);

Identified with readability-redundant-declaration.

2 years agoRevert "[MLIR] Add forgotten directory Support to unittests cmake"
Arjun P [Sun, 26 Dec 2021 08:29:23 +0000 (13:59 +0530)]
Revert "[MLIR] Add forgotten directory Support to unittests cmake"

This reverts commit 0c553cc1af2e4c14100df6cf4a6fc91987e778e6.

This caused a buildbot failure (https://lab.llvm.org/buildbot#builders/197/builds/888).

```
******************** TEST 'ScudoStandalone-Unit :: ./ScudoUnitTest-aarch64-Test/ScudoCommonTest.ResidentMemorySize' FAILED ********************
Script:
--
/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/projects/compiler-rt/lib/scudo/standalone/tests/./ScudoUnitTest-aarch64-Test --gtest_filter=ScudoCommonTest.ResidentMemorySize
--
Note: Google Test filter = ScudoCommonTest.ResidentMemorySize
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ScudoCommonTest
[ RUN      ] ScudoCommonTest.ResidentMemorySize
/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/compiler-rt/lib/scudo/standalone/tests/common_test.cpp:49: Failure
Expected: (getResidentMemorySize()) > (OnStart + Size - Threshold), actual: 707358720 vs 943153152
[  FAILED  ] ScudoCommonTest.ResidentMemorySize (21709 ms)
[----------] 1 test from ScudoCommonTest (21709 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (21709 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] ScudoCommonTest.ResidentMemorySize
 1 FAILED TEST
********************
```

2 years ago[ELF] Remove one redundant computeBinding
Fangrui Song [Sun, 26 Dec 2021 07:59:27 +0000 (23:59 -0800)]
[ELF] Remove one redundant computeBinding

This does resolve the redundancy in includeInDynsym().

2 years ago[ELF] reportRangeError: mention symbol name for non-STT_SECTION local symbols like...
Fangrui Song [Sun, 26 Dec 2021 07:46:47 +0000 (23:46 -0800)]
[ELF] reportRangeError: mention symbol name for non-STT_SECTION local symbols like non-global symbols

2 years ago[ELF] sortSymTabSymbols: change vector to SmallVector
Fangrui Song [Sun, 26 Dec 2021 07:16:26 +0000 (23:16 -0800)]
[ELF] sortSymTabSymbols: change vector to SmallVector

This function may take ~1% time. SmallVector<SymbolTableEntry, 0> is smaller (16 bytes
instead of 24) and more efficient.

2 years ago[ELF][test] Make some TLS tests less sensitive to addresses
Fangrui Song [Sun, 26 Dec 2021 06:05:20 +0000 (22:05 -0800)]
[ELF][test] Make some TLS tests less sensitive to addresses

2 years agoFix clang-tidy performance-move-const-arg in DLTI Dialect (NFC)
Mehdi Amini [Sun, 26 Dec 2021 02:13:54 +0000 (02:13 +0000)]
Fix clang-tidy performance-move-const-arg in DLTI Dialect (NFC)

The const loop iterator was inhibiting the std::move().

2 years agoDebugInfo: Don't hash DIE offsets before they're computed
David Blaikie [Sat, 25 Dec 2021 23:59:29 +0000 (15:59 -0800)]
DebugInfo: Don't hash DIE offsets before they're computed

Instead of hashing DIE offsets, hash DIE references the same as they
would be when used outside of a loclist - that is, deep hash the type on
first use, and hash the numbering on subsequent uses.

This does produce different hashes for different type references, where
it did not before (because we were hashing zero all the time - so it
didn't matter what type was referenced, the hash would be identical).

This also allows us to enforce that the DIE offset (& size) is not
queried before it is used (which came up while investigating another bug
recently).

2 years ago[ELF] scanReloc: remove unused start parameter. NFC
Fangrui Song [Sat, 25 Dec 2021 22:34:05 +0000 (14:34 -0800)]
[ELF] scanReloc: remove unused start parameter. NFC

This was once used as a workaround for detecting missing PPC64 TLSGD/TLSLD
relocations produced by ancient IBM XL C/C++.

2 years ago[ELF] De-template handleTlsRelocation. NFC
Fangrui Song [Sat, 25 Dec 2021 22:23:12 +0000 (14:23 -0800)]
[ELF] De-template handleTlsRelocation. NFC

2 years ago[MLIR] Add forgotten directory Support to unittests cmake
Arjun P [Sat, 25 Dec 2021 20:18:19 +0000 (01:48 +0530)]
[MLIR] Add forgotten directory Support to unittests cmake

The Support directory was removed from the unittests cmake when the directory
was removed in 204c3b551626a925dfdc3822a6f240bdc8ef5d3a. Subsequent commits
added the directory back but seem to have missed adding it back to the cmake.

This patch also removes MLIRSupportIndentedStream from the list of linked
libraries to avoid an ODR violation (it's already part of MLIRSupport which
is also being linked here). Otherwise ASAN complains:

```
=================================================================
==102592==ERROR: AddressSanitizer: odr-violation (0x7fbdf214eee0):
  [1] size=120 'vtable for mlir::raw_indented_ostream' /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
  [2] size=120 'vtable for mlir::raw_indented_ostream' /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
These globals were registered at these points:
  [1]:
    #0 0x28a71d in __asan_register_globals (/home/arjun/llvm-project/build/tools/mlir/unittests/Support/MLIRSupportTests+0x28a71d)
    #1 0x7fbdf214a61b in asan.module_ctor (/home/arjun/llvm-project/build/lib/libMLIRSupportIndentedOstream.so.14git+0x661b)

  [2]:
    #0 0x28a71d in __asan_register_globals (/home/arjun/llvm-project/build/tools/mlir/unittests/Support/MLIRSupportTests+0x28a71d)
    #1 0x7fbdf2061c4b in asan.module_ctor (/home/arjun/llvm-project/build/lib/libMLIRSupport.so.14git+0x11bc4b)

==102592==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY AddressSanitizer: odr-violation: global 'vtable for mlir::raw_indented_ostream' at /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
==102592==ABORTING
```

Reviewed By: jpienaar

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

2 years ago[lldb] Add support for UTF-8 unicode formatting
Luís Ferreira [Sat, 25 Dec 2021 19:37:45 +0000 (19:37 +0000)]
[lldb] Add support for UTF-8 unicode formatting

This patch adds missing formatting for UTF-8 unicode.

Cross-referencing https://reviews.llvm.org/D66447

Reviewed By: labath

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

2 years ago[MLIR][FlatAffineConstraints][NFC] Move some static functions to be available to...
Groverkss [Sat, 25 Dec 2021 17:05:57 +0000 (22:35 +0530)]
[MLIR][FlatAffineConstraints][NFC] Move some static functions to be available to Presburger/

This patch moves some static functions from AffineStructures.cpp to
Presburger/Utils.cpp and some to be private members of FlatAffineConstraints
(which will later be moved to IntegerPolyhedron) to allow for a smoother
transition for moving FlatAffineConstraints math functionality to
Presburger/IntegerPolyhedron.

This patch is part of a series of patches for moving math functionality to
Presburger directory.

Reviewed By: arjunp, bondhugula

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

2 years ago[NFC] Method for evaluation of FCmpInst for constant operands
Serge Pavlov [Sun, 19 Sep 2021 17:12:21 +0000 (00:12 +0700)]
[NFC] Method for evaluation of FCmpInst for constant operands

New method `FCmpInst::compare` is added, which evaluates the given
compare predicate for constant operands. Interface is made similar to
`ICmpInst::compare`.

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

2 years ago[StaticAnalyzer] Remove redundant declaration isStdSmartPtr (NFC)
Kazu Hirata [Sat, 25 Dec 2021 08:35:41 +0000 (00:35 -0800)]
[StaticAnalyzer] Remove redundant declaration isStdSmartPtr (NFC)

An identical declaration is present just a couple of lines above the
line being removed in this patch.

Identified with readability-redundant-declaration.

2 years agoRemove redundant return and continue statements (NFC)
Kazu Hirata [Sat, 25 Dec 2021 07:17:53 +0000 (23:17 -0800)]
Remove redundant return and continue statements (NFC)

Identified with readability-redundant-control-flow.

2 years ago[ELF] Move TLS dynamic relocations to postScanRelocations
Fangrui Song [Sat, 25 Dec 2021 06:36:49 +0000 (22:36 -0800)]
[ELF] Move TLS dynamic relocations to postScanRelocations

This temporarily increases sizeof(SymbolUnion), but allows us to mov GOT/PLT/etc
index members outside Symbol in the future.

Then, we can make TLSDESC and TLSGD use different indexes and support mixed
TLSDESC and TLSGD (tested by x86-64-tlsdesc-gd-mixed.s).

Note: needsTlsGd and needsTlsGdToIe may optionally be combined.

Test updates are due to reordered GOT entries.

2 years ago[ELF][test] Add tests for mixed GD-to-IE and IE, mixed TLSDESC and GD
Fangrui Song [Sat, 25 Dec 2021 06:24:15 +0000 (22:24 -0800)]
[ELF][test] Add tests for mixed GD-to-IE and IE, mixed TLSDESC and GD

Note: mixed TLSDESC and GD currently does not work.

2 years agoUse StringRef::contains (NFC)
Kazu Hirata [Sat, 25 Dec 2021 06:05:34 +0000 (22:05 -0800)]
Use StringRef::contains (NFC)

2 years agoUse {DenseSet,SetVector,SmallPtrSet}::contains (NFC)
Kazu Hirata [Sat, 25 Dec 2021 05:43:06 +0000 (21:43 -0800)]
Use {DenseSet,SetVector,SmallPtrSet}::contains (NFC)

2 years agoUse isa instead of dyn_cast (NFC)
Kazu Hirata [Sat, 25 Dec 2021 05:22:27 +0000 (21:22 -0800)]
Use isa instead of dyn_cast (NFC)

2 years agoUse Optional::getValueOr (NFC)
Kazu Hirata [Sat, 25 Dec 2021 04:57:40 +0000 (20:57 -0800)]
Use Optional::getValueOr (NFC)

2 years ago[CodeGen] Fix a memory leak
Kazu Hirata [Sat, 25 Dec 2021 03:51:10 +0000 (19:51 -0800)]
[CodeGen] Fix a memory leak

2 years ago[ELF] Optimize replaceCommonSymbols
Fangrui Song [Sat, 25 Dec 2021 03:01:50 +0000 (19:01 -0800)]
[ELF] Optimize replaceCommonSymbols

This decreases the 0.2% time (no debug info) to nearly no.

2 years ago[ELF] Cache global variable `target` in relocate*
Fangrui Song [Sat, 25 Dec 2021 01:54:12 +0000 (17:54 -0800)]
[ELF] Cache global variable `target` in relocate*

This avoid repeated load of the unique_ptr in hot paths.

2 years ago[ELF] Add ELFFileBase::{elfShdrs,numELFShdrs} to avoid duplicate llvm::object::ELFFil...
Fangrui Song [Sat, 25 Dec 2021 01:10:38 +0000 (17:10 -0800)]
[ELF] Add ELFFileBase::{elfShdrs,numELFShdrs} to avoid duplicate llvm::object::ELFFile::sections()

This mainly avoid `relsOrRelas` cost in `InputSectionBase::relocate`.
`llvm::object::ELFFile::sections()` has redundant and expensive checks.

2 years ago[MLIR][LLVM] Add MemmoveOp to LLVM Dialect
William S. Moses [Fri, 24 Dec 2021 21:51:54 +0000 (16:51 -0500)]
[MLIR][LLVM] Add MemmoveOp to LLVM Dialect

LLVM Dialect in MLIR doesn't have a memmove op. This adds one.

Reviewed By: mehdi_amini

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

2 years ago[CMake] Revert -Wl,-O3
Fangrui Song [Fri, 24 Dec 2021 23:41:56 +0000 (15:41 -0800)]
[CMake] Revert -Wl,-O3

This reverts 8cb7876cb366b5803ca35d92313ea00eadf29b78 and follow-ups.

GNU ld/gold/ld.lld -O has nothing to do with any code related linker optimizations.
It has very small benefit (save 144Ki (.hash, .gnu_hash) with GNU ld, save 0.7%
.debug_str with gold/ld.lld) while it makes gold/ld.lld significantly slower
when linking RelWithDebInfo clang (gold: 16.437 vs 19.488; ld.lld: 1.882 vs 4.881).

2 years ago[mlir] Fully qualify default types used in parser code
Markus Böck [Fri, 24 Dec 2021 21:25:32 +0000 (22:25 +0100)]
[mlir] Fully qualify default types used in parser code

2 years ago[ELF] parseLazy: skip local symbols
Fangrui Song [Fri, 24 Dec 2021 21:16:34 +0000 (13:16 -0800)]
[ELF] parseLazy: skip local symbols

2 years ago[ELF] Optimize --wrap to only check non-local symbols
Fangrui Song [Fri, 24 Dec 2021 20:28:59 +0000 (12:28 -0800)]
[ELF] Optimize --wrap to only check non-local symbols

2 years ago[ELF] Avoid referencing SectionBase::repl after ICF
Fangrui Song [Fri, 24 Dec 2021 20:09:48 +0000 (12:09 -0800)]
[ELF] Avoid referencing SectionBase::repl after ICF

It is fairly easy to forget SectionBase::repl after ICF.
Let ICF rewrite a Defined symbol's `section` field to avoid references to
SectionBase::repl in subsequent passes. This slightly improves the --icf=none
performance due to less indirection (maybe for --icf={safe,all} as well if most
symbols are Defined).

With this change, there is only one reference to `repl` (--gdb-index D89751).
We can undo f4fb5fd7523f8e3c3b3966d43c0a28457b59d1d8 (`Move Repl to SectionBase.`)
but move `repl` to `InputSection` instead.

Reviewed By: ikudrin

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

2 years ago[clang-format] Fix short enums getting wrapped even when denied
Gabriel Smith [Fri, 24 Dec 2021 19:38:55 +0000 (11:38 -0800)]
[clang-format] Fix short enums getting wrapped even when denied

Single-variant enums were still getting placed on a single line
even when AllowShortEnumsOnASingleLine was false. This fixes that
by checking that setting when looking to merge lines.

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

2 years agoRevert "[MLIR][FlatAffineConstraints][NFC] Move some static functions to be available...
Groverkss [Fri, 24 Dec 2021 19:09:27 +0000 (00:39 +0530)]
Revert "[MLIR][FlatAffineConstraints][NFC] Move some static functions to be available to Presburger/"

This reverts commit 6c0eaefaf832745f509841afe4dd8a698671b86e.

2 years ago[MLIR][FlatAffineConstraints][NFC] Move some static functions to be available to...
Groverkss [Fri, 24 Dec 2021 18:41:35 +0000 (00:11 +0530)]
[MLIR][FlatAffineConstraints][NFC] Move some static functions to be available to Presburger/

This patch moves some static functions from AffineStructures.cpp to
Presburger/Utils.cpp and some to be private members of FlatAffineConstraints
(which will later be moved to IntegerPolyhedron) to allow for a smoother
transition for moving FlatAffineConstraints math functionality to
Presburger/IntegerPolyhedron.

This patch is part of a series of patches for moving math functionality to
Presburger directory.

Reviewed By: arjunp, bondhugula

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

2 years ago[Docs] Minor fix in clang user manual
Anastasia Stulova [Fri, 24 Dec 2021 16:21:34 +0000 (16:21 +0000)]
[Docs] Minor fix in clang user manual

2 years ago[DFAJumpThreading] Determinator BB should precede switch-defining BB
Alexey Zhikhartsev [Wed, 15 Dec 2021 17:14:13 +0000 (12:14 -0500)]
[DFAJumpThreading] Determinator BB should precede switch-defining BB

Otherwise, it is possible that the state defined in the determinator
block defines the state for the next iteration of the loop, rather than
for the current one.

Fixes llvm-test-suite's
SingleSource/Regression/C/gcc-c-torture/execute/pr80421.c

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

2 years ago[AMDGPU] Changing S_AND_B32 to V_AND_B32_e64 in the divergent 'trunc' to i1 pattern
alex-t [Thu, 23 Dec 2021 22:01:07 +0000 (01:01 +0300)]
[AMDGPU] Changing S_AND_B32 to V_AND_B32_e64 in the divergent 'trunc' to i1  pattern

In 'trunc' i16/32/64 to i1 pattern the 'and $src, 1' node supply operand to 'setcc'.
The latter is selected to S_CMP_EQ/V_CMP_EQ dependent on the divergence. In case the 'and' is scalar
and 'setcc' is divergent, we need VGPR to SGPR copy to adjust input operand for V_CMP_EQ.
This patch changes the S_AND_B32 to V_AND_B32_e64 in the 'trunc to i1' divergent patterns.

Reviewed By: rampitec

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

2 years agoInstCombine: Gracefully handle more allocas in the wrong address space
Matt Arsenault [Thu, 16 Dec 2021 18:47:57 +0000 (13:47 -0500)]
InstCombine: Gracefully handle more allocas in the wrong address space

Officially this is currently required to always use the datalayout's
alloca address space. This may change in the future, and it's cleaner
to propagate the existing alloca's addrspace anyway.

This is a triple fix. Initially the change in simplifyAllocaArraySize
would drop the address space, but produce output. Fixing this hit an
assertion in the cast combine.

This patch also makes the changes to handle this situation from
a33e12801279a947c74fdee2655b24480941fb39 dead, so eliminate
it. InstCombine should not take it upon itself to introduce
addrspacecasts, and preserve the original address space instead.

2 years ago[X86] Enable v32i16 ISD::ROTL/ROTR lowering on AVX512BW targets
Simon Pilgrim [Thu, 23 Dec 2021 18:53:06 +0000 (18:53 +0000)]
[X86] Enable v32i16 ISD::ROTL/ROTR lowering on AVX512BW targets

2 years ago[Clang][OpenMP] Add the support for atomic compare in parser
Shilei Tian [Fri, 24 Dec 2021 13:16:33 +0000 (08:16 -0500)]
[Clang][OpenMP] Add the support for atomic compare in parser

This patch adds the support for `atomic compare` in parser. The support
in Sema and CodeGen will come soon. For now, it simply eimits an error when it
is encountered.

Reviewed By: ABataev

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

2 years ago[AArch64] Add a tablegen pattern for RADDHN/RADDHN2.
Alexandros Lamprineas [Fri, 24 Dec 2021 11:01:36 +0000 (11:01 +0000)]
[AArch64] Add a tablegen pattern for RADDHN/RADDHN2.

Converts RSHRN/RSHRN2 to RADDHN/RADDHN2 when the shift amount is half
the width of the vector element. The latter has twice the throughput
and half the latency on Arm out-of-order cores. Setting up the zero
register adds no latency.

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

2 years ago[gn build] Port 969a51ff3632
LLVM GN Syncbot [Fri, 24 Dec 2021 11:05:23 +0000 (11:05 +0000)]
[gn build] Port 969a51ff3632

2 years agoRevert "[ASan] Moved optimized callbacks into a separate library."
Krasimir Georgiev [Fri, 24 Dec 2021 11:01:36 +0000 (12:01 +0100)]
Revert "[ASan] Moved optimized callbacks into a separate library."

We need some internal updates for this, shared directly with the author.

This reverts commit 71b3bfde9cd296525bbf5b1619e199074156d12b.

2 years ago[DSE] Fix typo in recent commit
Nikita Popov [Fri, 24 Dec 2021 10:25:25 +0000 (11:25 +0100)]
[DSE] Fix typo in recent commit

This fixes a typo in 81d69e1bda9e4b6a83f29ba1f614e43ab4700972.
Of course we should only skip the particular store if it isn't
removable, not bail out of the whole loop. Add a test to cover
this case.

2 years ago[DSE] Remove unnecessary check in getLocForWrite() (NFC)
Nikita Popov [Fri, 24 Dec 2021 09:45:35 +0000 (10:45 +0100)]
[DSE] Remove unnecessary check in getLocForWrite() (NFC)

MemoryLocation::getForDest() checks this itself, call it directly.

2 years ago[DSE] Rename getLocForWriteEx() to getLocForWrite() (NFC)
Nikita Popov [Fri, 24 Dec 2021 09:42:44 +0000 (10:42 +0100)]
[DSE] Rename getLocForWriteEx() to getLocForWrite() (NFC)

We used to have both getLocForWrite() and getLocForWriteEx(). Now
that we only have a single method, the "ex" suffix no longer makes
sense.

2 years agoReland "[X86][MS-InlineAsm] Use exact conditions to recognize MS global variables"
Phoebe Wang [Fri, 24 Dec 2021 09:12:56 +0000 (17:12 +0800)]
Reland "[X86][MS-InlineAsm] Use exact conditions to recognize MS global variables"

This reverts commit a954558e878ed9e97e99036229e99af8c6b6c881.

Thanks Yuanfang's help. I think I found the root cause of the buildbot
fail.

The failed test has both Memory and Immediate X86Operand. All data of
different operand kinds share the same memory space by a union
definition. So it has chance we get the wrong result if we don't check
the operand kind.

It's probably it happen to be the correct value in my local environment
so that I can't reproduce the fail.

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

2 years ago[DSE] Assert analyzable write in isRemovable() (NFC)
Nikita Popov [Fri, 24 Dec 2021 08:37:25 +0000 (09:37 +0100)]
[DSE] Assert analyzable write in isRemovable() (NFC)

As requested on D116210. The function is not necessarily well-defined
without this precondition.

2 years ago[DSE] Avoid calling isRemovable() on non-analyzable location (NFC)
Nikita Popov [Fri, 24 Dec 2021 09:14:55 +0000 (10:14 +0100)]
[DSE] Avoid calling isRemovable() on non-analyzable location (NFC)

At this point the instruction may either have an analyzable
write or be a terminator. For terminators, isRemovable() is not
necessarily well-defined. Move the check until after we have ensured
that it is not a terminator.

2 years ago[DSE] Call isRemovable() after getLocForWriteEx() (NFCI)
Nikita Popov [Fri, 24 Dec 2021 08:55:44 +0000 (09:55 +0100)]
[DSE] Call isRemovable() after getLocForWriteEx() (NFCI)

The only non-trivial change here is that the isReadClobber()
check for redundant stores is now on the DefLoc, not the
UpperLoc. This is semantically the right location to use, though
in practice it makes no difference (the locations are either the
same, or the def inst does not read).

2 years ago[GlobalISel] Fix -Wunused-function in -DLLVM_ENABLE_ASSERTIONS=off builds after D114198
Fangrui Song [Fri, 24 Dec 2021 08:55:54 +0000 (00:55 -0800)]
[GlobalISel] Fix -Wunused-function in -DLLVM_ENABLE_ASSERTIONS=off builds after D114198

2 years ago[DSE] Simplify isGuaranteedLoopInvariant() (NFC)
Nikita Popov [Fri, 24 Dec 2021 08:39:44 +0000 (09:39 +0100)]
[DSE] Simplify isGuaranteedLoopInvariant() (NFC)

We have Value->stripInBoundsConstantOffsets() which does what we
want here, but the inbounds requirement isn't actually necessary.
We should probably add Value->stripConstantOffsets() as well.

2 years ago[DSE][MemLoc] Handle intrinsics more generically
Nikita Popov [Thu, 23 Dec 2021 08:19:26 +0000 (09:19 +0100)]
[DSE][MemLoc] Handle intrinsics more generically

Remove the special casing for intrinsics in MemoryLocation::getForDest()
and handle them through the general attribute based code. On the DSE
side, this means that isRemovable() now needs to handle more than a
hardcoded list of intrinsics. We consider everything apart from
volatile memory intrinsics and lifetime markers to be removable.

This allows us to perform DSE on intrinsics that DSE has not been
specially taught about, using a matrix store as an example here.

There is an interesting test change for invariant.start, but I
believe that optimization is correct. It only looks a bit odd
because the code is immediate UB anyway.

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

2 years ago[DebugInfo] Remove type-units-maybe-unused-types.ll test
Nikita Popov [Fri, 24 Dec 2021 08:24:45 +0000 (09:24 +0100)]
[DebugInfo] Remove type-units-maybe-unused-types.ll test

78d15a112cbd545fbb6e1aa37c221ef5aeffb3f2 has been reverted, but
the test not deleted, so it is failing now.

2 years ago[Attributor] Directly call areTypesABICompatible() hook
Nikita Popov [Mon, 20 Dec 2021 13:27:58 +0000 (14:27 +0100)]
[Attributor] Directly call areTypesABICompatible() hook

Instead of using the ArgumentPromotion implementation, we now walk
call sites using checkForAllCallSites() and directly call
areTypesABICompatible() using the replacement types. I believe
that resolves the TODO in the code.

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

2 years ago[OpenMP] Avoid creating null pointer lvalue (NFC)
Nikita Popov [Thu, 23 Dec 2021 09:43:47 +0000 (10:43 +0100)]
[OpenMP] Avoid creating null pointer lvalue (NFC)

The reduction initialization code creates a "naturally aligned null
pointer to void lvalue", which I found somewhat odd, even though it
works out in the end because it is not actually used. It doesn't
look like this code actually needs an LValue for anything though,
and we can use an invalid Address to represent this case instead.

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

2 years ago[ELF] Optimize symbol initialization and resolution
Fangrui Song [Fri, 24 Dec 2021 05:54:32 +0000 (21:54 -0800)]
[ELF] Optimize symbol initialization and resolution

Avoid repeated load of global pointer (symtab) / members (sections.size(), firstGlobal) in the hot paths.

And remove some unneeded this->

2 years ago[C++20] [Coroutines] Allow promise_type to not define return_void or return_value
Chuanqi Xu [Fri, 24 Dec 2021 05:33:52 +0000 (13:33 +0800)]
[C++20] [Coroutines] Allow promise_type to not define return_void or return_value

According to [dcl.fct.def.coroutine]p6, the promise_type is allowed to
not define return_void nor return_value:

> If searches for the names return_­void and return_­value in the scope
> of the promise type each find any declarations, the program is
> ill-formed.
> [Note 1: If return_­void is found, flowing off the end of a coroutine is
> equivalent to a co_­return with no operand. Otherwise, flowing off the
> end of a coroutine results in
> undefined behavior ([stmt.return.coroutine]). — end note]

So the program isn't ill-formed if the promise_type doesn't define
return_void nor return_value. It is just a potential UB. So the program
should be allowed to compile.

Reviewed By: urnathan

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

2 years ago[RISCV] Use DAG variable directly instead of DCI.DAG
Jim Lin [Fri, 24 Dec 2021 01:27:04 +0000 (09:27 +0800)]
[RISCV] Use DAG variable directly instead of DCI.DAG

Reviewed By: craig.topper

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

2 years agoRevert "[DWARF] Fix PR51087 Extraneous enum record in DWARF with type units"
David Blaikie [Fri, 24 Dec 2021 04:28:37 +0000 (20:28 -0800)]
Revert "[DWARF] Fix PR51087 Extraneous enum record in DWARF with type units"

Causes invalid debug_gnu_pubnames (& I think non-gnu pubnames too) -
visible as 0 values for the offset in gnu pubnames. More details on the
original review in D115325.

This reverts commit 78d15a112cbd545fbb6e1aa37c221ef5aeffb3f2.
This reverts commit 54586582d3e17c0bba76258d2930486a6dfaaf2a.

2 years ago[C++20] Conform coroutine's comments in clang (NFC-ish)
Chuanqi Xu [Fri, 24 Dec 2021 03:48:15 +0000 (11:48 +0800)]
[C++20] Conform coroutine's comments in clang (NFC-ish)

The comments for coroutine in clang wrote for coroutine-TS. Now
coroutine is merged into standard. Try to conform the comments.