Commit Graph

408273 Commits

Author SHA1 Message Date
Fangrui Song e9262edf0d [ELF] SymbolTable:🔣 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%.
2021-12-26 18:11:45 -08:00
Shao-Ce SUN 70a98008ea [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
2021-12-27 09:29:35 +08:00
Fangrui Song 7924b3814f [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.
2021-12-26 17:25:54 -08:00
Fangrui Song 469144ffa3 [ELF] De-template InputSectionBase::getEnclosingFunction 2021-12-26 15:21:22 -08:00
Fangrui Song 213896bc5a [ELF] Remove unused InputSection::getOffsetInFile 2021-12-26 15:18:56 -08:00
Kazu Hirata e7774f499b Use static_assert instead of assert (NFC)
Identified with misc-static-assert.
2021-12-26 14:26:44 -08:00
Fangrui Song a1c2ee0147 [ELF] LinkerScript/OutputSection: change other std::vector members to SmallVector
11+KiB smaller .text with both libc++ and libstdc++ builds.
2021-12-26 13:53:47 -08:00
Kazu Hirata 31cfb3f4f6 [clang] Remove redundant calls to c_str() (NFC)
Identified with readability-redundant-string-cstr.
2021-12-26 13:31:40 -08:00
Fangrui Song 10316a6f94 [ELF] Change InputSectionDescription members from vector to SmallVector
This decreases sizeof(lld:🧝:InputSectionDescription) from 264 to 232.
2021-12-26 13:06:54 -08:00
Florian Hahn 511726c64d
[LV] Move getStepVector out of ILV (NFC).
First step to split up induction handling and move it outside ILV.
Used in D116123 and following.
2021-12-26 21:17:26 +01:00
Fangrui Song bf7f3dd74e [ELF] Move outSecOff addition from InputSection::writeTo to the caller
Simplify the code a bit and improve consistency with SyntheticSection::writeTo.
2021-12-26 12:11:41 -08:00
Kazu Hirata 0542d15211 Remove redundant string initialization (NFC)
Identified with readability-redundant-string-init.
2021-12-26 09:39:26 -08:00
Kazu Hirata 7006d34ce7 Ensure newlines at the end of files (NFC) 2021-12-26 08:51:06 -08:00
Kazu Hirata fc15fc57e6 [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.
2021-12-26 01:01:38 -08:00
Arjun P 2132906836 Revert "[MLIR] Add forgotten directory Support to unittests cmake"
This reverts commit 0c553cc1af.

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
********************
```
2021-12-26 13:59:23 +05:30
Fangrui Song aabe901d57 [ELF] Remove one redundant computeBinding
This does resolve the redundancy in includeInDynsym().
2021-12-25 23:59:27 -08:00
Fangrui Song 20b4704da3 [ELF] reportRangeError: mention symbol name for non-STT_SECTION local symbols like non-global symbols 2021-12-25 23:46:47 -08:00
Fangrui Song 2c8ebab32e [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.
2021-12-25 23:16:27 -08:00
Fangrui Song d5e310b154 [ELF][test] Make some TLS tests less sensitive to addresses 2021-12-25 22:05:20 -08:00
Mehdi Amini dabfefa490 Fix clang-tidy performance-move-const-arg in DLTI Dialect (NFC)
The const loop iterator was inhibiting the std::move().
2021-12-26 02:13:54 +00:00
David Blaikie 2bddab25db 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).
2021-12-25 16:09:12 -08:00
Fangrui Song a00f480fe8 [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++.
2021-12-25 14:34:06 -08:00
Fangrui Song dd4f5d4ae5 [ELF] De-template handleTlsRelocation. NFC 2021-12-25 14:23:13 -08:00
Arjun P 0c553cc1af [MLIR] Add forgotten directory Support to unittests cmake
The Support directory was removed from the unittests cmake when the directory
was removed in 204c3b5516. 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
2021-12-26 02:22:00 +05:30
Luís Ferreira 46cdcf0873 [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
2021-12-25 20:19:09 +00:00
Groverkss 5b2e611b73 [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
2021-12-25 22:36:23 +05:30
Serge Pavlov d86e2cc2e3 [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
2021-12-25 17:37:38 +07:00
Kazu Hirata 34558b039b [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.
2021-12-25 00:35:41 -08:00
Kazu Hirata 2d303e6781 Remove redundant return and continue statements (NFC)
Identified with readability-redundant-control-flow.
2021-12-24 23:17:54 -08:00
Fangrui Song 70912420bb [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.
2021-12-24 22:36:49 -08:00
Fangrui Song cde37a7e5a [ELF][test] Add tests for mixed GD-to-IE and IE, mixed TLSDESC and GD
Note: mixed TLSDESC and GD currently does not work.
2021-12-24 22:24:15 -08:00
Kazu Hirata 3cfe375ae4 Use StringRef::contains (NFC) 2021-12-24 22:05:34 -08:00
Kazu Hirata 76f0f1cc5c Use {DenseSet,SetVector,SmallPtrSet}::contains (NFC) 2021-12-24 21:43:06 -08:00
Kazu Hirata 62e48ed10f Use isa instead of dyn_cast (NFC) 2021-12-24 21:22:27 -08:00
Kazu Hirata 9c0a4227a9 Use Optional::getValueOr (NFC) 2021-12-24 20:57:40 -08:00
Kazu Hirata a8cbddc994 [CodeGen] Fix a memory leak 2021-12-24 19:51:10 -08:00
Fangrui Song 40fae4d8fc [ELF] Optimize replaceCommonSymbols
This decreases the 0.2% time (no debug info) to nearly no.
2021-12-24 19:01:51 -08:00
Fangrui Song 745420d3f4 [ELF] Cache global variable `target` in relocate*
This avoid repeated load of the unique_ptr in hot paths.
2021-12-24 17:54:12 -08:00
Fangrui Song b5a0f0f397 [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.
2021-12-24 17:10:38 -08:00
William S. Moses 2709fd1520 [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
2021-12-24 19:48:04 -05:00
Fangrui Song d63016a865 [CMake] Revert -Wl,-O3
This reverts 8cb7876cb3 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).
2021-12-24 15:41:56 -08:00
Markus Böck a9e8b1ee7f [mlir] Fully qualify default types used in parser code 2021-12-24 22:25:50 +01:00
Fangrui Song 5e3403bd22 [ELF] parseLazy: skip local symbols 2021-12-24 13:16:34 -08:00
Fangrui Song e694180033 [ELF] Optimize --wrap to only check non-local symbols 2021-12-24 12:28:59 -08:00
Fangrui Song e1b6b5be46 [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 f4fb5fd752 (`Move Repl to SectionBase.`)
but move `repl` to `InputSection` instead.

Reviewed By: ikudrin

Differential Revision: https://reviews.llvm.org/D116093
2021-12-24 12:09:48 -08:00
Gabriel Smith 8ea64d5585 [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
2021-12-24 11:38:55 -08:00
Groverkss 27a0718ad0 Revert "[MLIR][FlatAffineConstraints][NFC] Move some static functions to be available to Presburger/"
This reverts commit 6c0eaefaf8.
2021-12-25 00:39:27 +05:30
Groverkss 6c0eaefaf8 [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
2021-12-25 00:11:35 +05:30
Anastasia Stulova dc8f9fb196 [Docs] Minor fix in clang user manual 2021-12-24 16:21:56 +00:00
Alexey Zhikhartsev d5dc3964a7 [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
2021-12-24 10:27:03 -05:00