Commit Graph

324698 Commits

Author SHA1 Message Date
Fangrui Song 01c7f4b606 [ELF][PPC] Allow PT_LOAD to have overlapping p_offset ranges
This change affects the non-linker script case (precisely, when the
`SECTIONS` command is not used). It deletes 3 alignments at PT_LOAD
boundaries for the default case: the size of a powerpc64 binary can be
decreased by at most 192kb. The technique can be ported to other
targets.

Let me demonstrate the idea with a maxPageSize=65536 example:

When assigning the address to the first output section of a new PT_LOAD,
if the end p_vaddr of the previous PT_LOAD is 0x10020, we advance to
the next multiple of maxPageSize: 0x20000. The new PT_LOAD will thus
have p_vaddr=0x20000. Because p_offset and p_vaddr are congruent modulo
maxPageSize, p_offset will be 0x20000, leaving a p_offset gap [0x10020,
0x20000) in the output.

Alternatively, if we advance to 0x20020, the new PT_LOAD will have
p_vaddr=0x20020. We can pick either 0x10020 or 0x20020 for p_offset!
Obviously 0x10020 is the choice because it leaves no gap. At runtime,
p_vaddr will be rounded down by pagesize (65536 if
pagesize=maxPageSize). This PT_LOAD will load additional initial
contents from p_offset ranges [0x10000,0x10020), which will also be
loaded by the previous PT_LOAD. This is fine if -z noseparate-code is in
effect or if we are not transiting between executable and non-executable
segments.

ld.bfd -z noseparate-code leverages this technique to keep output small.
This patch implements the technique in lld, which is mostly effective on
targets with large defaultMaxPageSize (AArch64/MIPS/PPC: 65536). The 3
removed alignments can save almost 3*65536 bytes.

Two places that rely on p_vaddr%pagesize = 0 have to be updated.

1) We used to round p_memsz(PT_GNU_RELRO) up to commonPageSize (defaults
  to 4096 on all targets). Now p_vaddr%commonPageSize may be non-zero.
  The updated formula takes account of that factor.
2) Our TP offsets formulae are only correct if p_vaddr%p_align = 0.
  Fix them. See the updated comments in InputSection.cpp for details.

  On targets that we enable the technique (only PPC64 now),
  we can potentially make `p_vaddr(PT_TLS)%p_align(PT_TLS) != 0`
  if `sh_addralign(.tdata) < sh_addralign(.tbss)`

  This exposes many problems in ld.so implementations, especially the
  offsets of dynamic TLS blocks. Known issues:

  FreeBSD 13.0-CURRENT rtld-elf (i386/amd64/powerpc/arm64)
  glibc (HEAD) i386 and x86_64 https://sourceware.org/bugzilla/show_bug.cgi?id=24606
  musl<=1.1.22 on TLS Variant I architectures (aarch64/powerpc64/...)

  So, force p_vaddr%p_align = 0 by rounding dot up to p_align(PT_TLS).

The technique will be enabled (with updated tests) for other targets in
subsequent patches.

Reviewed By: ruiu

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

llvm-svn: 369343
2019-08-20 08:34:25 +00:00
George Rimar ebc8fd3c0c [test/Object] - Move/rewrite 2 more test cases.
This patch makes a change for test/Object tests responsible
for relocations.

* 2 tests were moved to llvm-readobj/llvm-objdump folders:
Object/elf-reloc-no-sym.test -> tools/llvm-readobj/elf-reloc-no-sym.test
Object/objdump-reloc-shared.test -> tools/llvm-objdump/relocations-in-nonreloc.test

* A prerecompiled binary was removed and these tests were refactored.

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

llvm-svn: 369342
2019-08-20 08:23:57 +00:00
Fangrui Song 2682340cdf [MC] Delete an overload of MCExpr::evaluateKnownAbsolute and its associated hack
The hack dated back to 2010 (r121076) and was documented by r122144:

  // FIXME: The use if InSet = Addrs is a hack. Setting InSet causes us
  // absolutize differences across sections and that is what the MachO writer
  // uses Addrs for.

llvm-svn: 369337
2019-08-20 07:42:04 +00:00
Hans Wennborg 9e8b011195 [compiler-rt][crt] Pass -fno-lto in check_cxx_section_exists
Otherwise it doesn't work when building with -DLLVM_ENABLE_LTO=thin

(We hit this in Chromium in
https://bugs.chromium.org/p/chromium/issues/detail?id=966403)

llvm-svn: 369336
2019-08-20 07:41:14 +00:00
Fangrui Song f182617352 [Attributor] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds after r369331
llvm-svn: 369334
2019-08-20 07:21:43 +00:00
Craig Topper 1ada137854 [X86] Add back the -x86-experimental-vector-widening-legalization comand line flag and all associated code, but leave it enabled by default
Google is reporting performance issues with the new default behavior
and have asked for a way to switch back to the old behavior while we
investigate and make fixes.

I've restored all of the code that had since been removed and added
additional checks of the command flag onto code paths that are
not otherwise guarded by a check of getTypeAction.

I've also modified the cost model tables to hopefully get us back
to the previous costs.

Hopefully we won't need to support this for very long since we
have no test coverage of the old behavior so we can very easily
break it.

llvm-svn: 369332
2019-08-20 06:58:00 +00:00
Johannes Doerfert 12cbbab9d9 [Attributor] Create abstract attributes on-demand
Before, we create the set of abstract attributes initially and then
dealt with the fact hat a lookup could fail, e.g., return a nullptr.
This patch will ensure we always return a valid object from a lookup,
allowing us not only to remove the nullptr checks but also to grow the
set of abstract attributes "in-flight" on-demand.

One can now start from those that have the best chance of improving
performance without the need to specify all they might depend on.

While this introduces some boilerplate, the usage of attributes is much
easier and cleaner now.

Reviewers: uenoku, sstefan1

Subscribers: hiraditya, bollu, llvm-commits

Tags: #llvm

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

llvm-svn: 369331
2019-08-20 06:15:50 +00:00
Johannes Doerfert 169af994bc [Attributor][NFC] Cleanup statistics code
llvm-svn: 369330
2019-08-20 06:09:56 +00:00
Johannes Doerfert cfcca1a5b1 [Attributor] Use structured deduction for AADereferenceable
Summary:
This is analogous to D66128 but for AADereferenceable. We have the logic
concentrated in the floating value updateImpl and we use the combiner
helper classes for arguments and return values.

The regressions will go away with "on-demand" attribute creation.
Improvements are already visible in the existing tests.

Reviewers: uenoku, sstefan1

Subscribers: hiraditya, bollu, jfb, llvm-commits

Tags: #llvm

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

llvm-svn: 369329
2019-08-20 06:08:35 +00:00
Johannes Doerfert b9b8791fed [Attributor] Use structured deduction for AANonNull
Summary:
What D66126 did for AAAlign, this patch does for AANonNull. Agian, the
logic becomes more concise and localized. Again, returned poiners are
not annotated properly but that will not be an issue if this lands with
the "on-demand" generation of attributes. First improvements due to the
genericValueTraversal are already visible.

Reviewers: sstefan1, uenoku

Subscribers: hiraditya, bollu, llvm-commits

Tags: #llvm

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

llvm-svn: 369328
2019-08-20 06:02:39 +00:00
Johannes Doerfert 028b2aa56a [Attributor] Fix the "clamp" operator
The clamp operator should not take the known of the given state as the
known is potentially based on assumed information. This also adds TODOs
to guide improvements.

llvm-svn: 369327
2019-08-20 05:57:01 +00:00
Thomas Raoux a08e139d50 [NFC] Test commit, fix some comment spelling.
llvm-svn: 369326
2019-08-20 05:21:27 +00:00
Karl-Johan Karlsson 40da6be2bd [AsmPrinter] Remove const qualifier from EmitBasicBlockStart.
Overriders may want to modify state in it. AMDGPU wants
to, but has to make its members mutable in order to do so.

Besides, EmitBasicBlockEnd is not const, so why should
Start be?

Patch by Bevin Hansson.

Reviewed By: nickdesaulniers

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

llvm-svn: 369325
2019-08-20 05:13:57 +00:00
Fangrui Song ce21c3e12c MCAsmMacro: add `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` to some dump() declarations
llvm-svn: 369324
2019-08-20 04:14:43 +00:00
Artem Dergachev 8cf3dfea54 [CallGraph] Take into accound calls that aren't within any function bodies.
This patch improves Clang call graph analysis by adding in expressions
that are not found in regular function bodies, such as default arguments
or member initializers.

Patch by Joshua Cranmer!

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

llvm-svn: 369321
2019-08-20 02:22:37 +00:00
Artem Dergachev ee92f12fd1 [analyzer] NFC: Rename GRBugReporter to PathSensitiveBugReporter.
The GR prefix is super ancient.

llvm-svn: 369320
2019-08-20 02:15:50 +00:00
Artem Dergachev 48786cf8d3 [analyzer] NFC: Drop support for extra text attached to bug reports.
It was introduced in 2011 but never used since then.

llvm-svn: 369319
2019-08-20 02:15:47 +00:00
Fangrui Song e828ce1b88 [WebAssembly][MC] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds after r369317
llvm-svn: 369318
2019-08-20 02:02:57 +00:00
Sam Clegg ecc5e8084f [WebAssembly][MC] Simplify WasmObjectWriter::recordRelocation. NFC.
WebAssembly doesn't support PC relative relocation or relocation
expressions that can't be reduced to single symbol.

The only support for we have for fixups involving two symbols are when
both symbols are defined and withing the same section.  In this case
evaluateFixup will already have evaluated to the expression before
calling recordRelocation.

llvm-svn: 369317
2019-08-20 00:33:50 +00:00
Richard Trieu 8f9e489a66 Fix typo. "piont" => "point"
Found by Chris Morris (cwmorris).

llvm-svn: 369316
2019-08-20 00:28:21 +00:00
Dinar Temirbulatov 081c57989e [SLP][NFC] Avoid repetitive calls to getSameOpcode()
We can avoid repetitive calls getSameOpcode() for already known tree elements by keeping MainOp and AltOp in TreeEntry.

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

llvm-svn: 369315
2019-08-20 00:22:04 +00:00
Julian Lettner def061e6f0 [TSan] Rename file with libdispatch interceptors
llvm-svn: 369314
2019-08-20 00:04:19 +00:00
Med Ismail Bennani 6815b6ef2a [lldb] Fix typo on the BreakpointLocation header and the lldbtest.py (NFC)
Summary:
This commit fixes some typo I found while exploring LLDB's codebase.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 369313
2019-08-19 23:59:31 +00:00
Louis Dionne 5a14c17221 Provide a meaningful diagnostic when LLVM_PATH doesn't point to a directory
llvm-svn: 369312
2019-08-19 23:51:26 +00:00
Julian Lettner 9f985dd380 [sanitizer_common] Extend test after switch to posix_spawn
llvm-svn: 369311
2019-08-19 23:47:35 +00:00
Hubert Tong 71974b5175 [cmake] Link in LLVMPasses due to dependency by LLVMOrcJIT; NFC
Summary:
rL367756 (f5c40cb) increases the dependency of LLVMOrcJIT on LLVMPasses.
In particular, symbols defined in LLVMPasses that are referenced by the
destructor of `PassBuilder` are now referenced by LLVMOrcJIT through
`Speculation.cpp.o`.

We believe that referencing symbols defined in LLVMPasses in the
destructor of `PassBuilder` is valid, and that adding to the set of such
symbols is legitimate. To support such cases, this patch adds LLVMPasses
to the set of libraries being linked when linking in LLVMOrcJIT causes
such symbols from LLVMPasses to be referenced.

Reviewers: Whitney, anhtuyen, pree-jackie

Reviewed By: pree-jackie

Subscribers: mgorny, llvm-commits

Tags: #llvm

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

llvm-svn: 369310
2019-08-19 23:12:48 +00:00
Joel E. Denny 971a9f7eea [lit] Check for accidental external command calls
This patch extends lit's test suite to check that lit's internal shell
doesn't accidentally execute internal commands as external commands.
It does so by putting fake failing versions of those commands in
`PATH` while the entire lit test suite is running.  Without the fixes
in D65697 but with its tests, this approach catches accidental
external `env` calls.

Reviewed By: probinson

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

llvm-svn: 369309
2019-08-19 22:59:37 +00:00
Anton Afanasyev 3f3a2573c3 [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks
Summary:
Add `Frontend` time trace entry to `HandleTranslationUnit()` function.
Add test to check all codegen blocks are inside frontend blocks.
Also, change `--time-trace-granularity` option a bit to make sure very small
time blocks are outputed to json-file when using `--time-trace-granularity=0`.

This fixes http://llvm.org/pr41969

Reviewers: russell.gallop, lebedev.ri, thakis

Reviewed By: russell.gallop

Subscribers: vsapsai, aras-p, lebedev.ri, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 369308
2019-08-19 22:58:26 +00:00
Saleem Abdulrasool 2e8b57558d Windows: Include "windows" Instead of "Windows"
The actual include directory is lldb/Host/windows not
lldb/Host/Windows which breaks on case sensitive file systems

Patch by Gwen Mittertreiner!

llvm-svn: 369307
2019-08-19 22:45:01 +00:00
Matthias Gehre 5b3275e56f [ORC] fix use-after-free detected by -Wreturn-stack-address
Summary:
llvm/lib/ExecutionEngine/Orc/Layer.cpp:53:12: warning: returning address of local temporary object [-Wreturn-stack-address]

In
```
StringRef IRMaterializationUnit::getName() const {
[...]
     return TSM.withModuleDo(
        [](const Module &M) { return M.getModuleIdentifier(); });
```
`getModuleIdentifier()` returns a `const std::string &`, but the implicit return type
of the lambda is `std::string` by value, and thus the returned `StringRef` refers
to a temporary `std::string`.

Detect by annotating `llvm::StringRef` with `[[gsl::Pointer]]`.

Reviewers: lhames, sgraenitz

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 369306
2019-08-19 21:59:44 +00:00
Johannes Doerfert 8b962f2814 [CaptureTracker] Let subclasses provide dereferenceability information
Summary:
CaptureTracker subclasses might have better dereferenceability
information which allows null pointer checks to be no-capturing.
The first user will be D59922.

Reviewers: sanjoy, hfinkel, aykevl, sstefan1, uenoku, xbolva00

Subscribers: hiraditya, bollu, llvm-commits

Tags: #llvm

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

llvm-svn: 369305
2019-08-19 21:56:38 +00:00
Matthias Gehre 8b0d15e43f Fix use-after-free
Summary:
The warning
```
lldb/source/Core/FormatEntity.cpp:2350:25: warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling]
```
is emitted after annotating `llvm::StringRef` with `[[gsl::Pointer]]`.

The reason is that in
```
 size_t FormatEntity::AutoComplete(CompletionRequest &request) {
  llvm::StringRef str = request.GetCursorArgumentPrefix().str();
```
the function `GetCursorArgumentPrefix()` returns a `StringRef`, and `StringRef::str()` returns
a temporary `std::string`.

Reviewers: jingham, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 369304
2019-08-19 21:39:16 +00:00
Johannes Doerfert de7674ce76 Recommit "[Attributor] Fix: Do not partially resolve returned calls."
This reverts commit b1752f670f.

Fixed the issue with a different commit, reapply this one as it was,
afaik, not broken.

llvm-svn: 369303
2019-08-19 21:35:31 +00:00
Seiya Nuta 12bd490427 Recommit "[llvm-objcopy][MachO] Implement a layout algorithm for executables"
Summary: The layout algorithm for relocatable objects and for executable are somewhat different. This patch implements the latter one based on the algorithm in LLD (MachOFileLayout).

Reviewers: alexshap, rupprecht, jhenderson

Reviewed By: alexshap

Subscribers: jakehehrlich, abrachet, llvm-commits

Tags: #llvm

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

llvm-svn: 369301
2019-08-19 21:12:02 +00:00
Evgeniy Stepanov 55ccd16354 Refactor isPointerOffset (NFC).
Summary:
Simplify the API using Optional<> and address comments in
         https://reviews.llvm.org/D66165

Reviewers: vitalybuka

Subscribers: hiraditya, llvm-commits, ostannard, pcc

Tags: #llvm

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

llvm-svn: 369300
2019-08-19 21:08:04 +00:00
Vyacheslav Zakharin f7229ac7d8 Fixed placement of llvm.global_dtors on Windows.
Differential revision: https://reviews.llvm.org/D66373

llvm-svn: 369299
2019-08-19 21:07:03 +00:00
Seiya Nuta 552bcb854c Recommit "[llvm-objcopy][MachO] Support load commands used in executables/shared libraries"
Summary:
This patch implements copying some load commands that appear in executables/shared libraries such as the indirect symbol table.

I don't add tests intentionally because this patch is incomplete: we need a layout algorithm for executables/shared libraries. I'll submit it as a separate patch with tests.

Reviewers: alexshap, rupprecht, jhenderson, compnerd

Reviewed By: alexshap

Subscribers: abrachet, mgorny, mgrang, MaskRay, mtrent, jakehehrlich, llvm-commits

Tags: #llvm

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

llvm-svn: 369298
2019-08-19 21:05:31 +00:00
Evgeniy Stepanov 50affbe47f MemTag: stack initializer merging.
Summary:
MTE provides instructions to update memory tags and data at the same
time. This change makes use of those to generate more compact code for
stack variable tagging + initialization.

We collect memory store and memset instructions following an alloca or a
lifetime.start call, and replace them with the corresponding MTE
intrinsics. Since the intrinsics work on 16-byte aligned chunks, the
stored values are combined as necessary.

Reviewers: pcc, vitalybuka, ostannard

Subscribers: srhines, javed.absar, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 369297
2019-08-19 20:47:09 +00:00
Alex Langford 3b4ce731fb [lldb-vscode] add `launchCommands` to handle launch specific commands
Summary:
This can help `lldb-vscode` handle launch commands associate with remote platform
attach request have field `attachCommands` to handle attach specific commands
add a corresponding one for launch request
if no launch command is provided, create a new target and launch; otherwise, execute the launch command

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

Patch by Wanyi Ye <kusmour@gmail.com>

llvm-svn: 369296
2019-08-19 20:17:27 +00:00
Benjamin Kramer 928071ae4e [Support] Replace sys::Mutex with their standard equivalents.
Only use a recursive mutex if it can be locked recursively.

llvm-svn: 369295
2019-08-19 19:49:57 +00:00
Johannes Doerfert 056f1b5cc7 Re-apply fixed "[Attributor] Fix: Make sure we set the changed flag"
This reverts commit cedd0d9a6e.

Re-apply the original commit but make sure the variables are initialized
(even if they are not used) so UBSan is not complaining.

llvm-svn: 369294
2019-08-19 19:14:10 +00:00
Raphael Isemann 0f4e9835c9 [lldb] Make TestIOHandlerCompletion more stable and document it
Instead of relying that three tabs show all completions, we should
show all remaining completions which will always stop the mode
where we show completions. Should fix this test on systems that
somehow have more completions that our normal LLDB (as they
would end up being stuck in the mode where we show completions).

llvm-svn: 369293
2019-08-19 19:13:26 +00:00
Sam Clegg 19bf637eb1 [WebAssembly][MC] Allow empty assembly functions
Differential Revision: https://reviews.llvm.org/D66434

llvm-svn: 369292
2019-08-19 19:04:54 +00:00
Alina Sbirlea 1a3fdaf6a6 [MemorySSA] Rename uses when inserting memory uses.
Summary:
When inserting uses from outside the MemorySSA creation, we don't
normally need to rename uses, based on the assumption that there will be
no inserted Phis (if  Def existed that required a Phi, that Phi already
exists). However, when dealing with unreachable blocks, MemorySSA will
optimize away Phis whose incoming blocks are unreachable, and these Phis end
up being re-added when inserting a Use.
There are two potential solutions here:
1. Analyze the inserted Phis and clean them up if they are unneeded
(current method for cleaning up trivial phis does not cover this)
2. Leave the Phi in place and rename uses, the same way as whe inserting
defs.
This patch use approach 2.

Resolves first test in PR42940.

Reviewers: george.burgess.iv

Subscribers: Prazek, sanjoy.google, llvm-commits

Tags: #llvm

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

llvm-svn: 369291
2019-08-19 18:57:40 +00:00
Peter Collingbourne 4340c2cf8f Build symbolizer runtime with C++14.
Should hopefully fix sanitizer-x86_64-linux bot.

llvm-svn: 369290
2019-08-19 18:43:52 +00:00
Julian Lettner e644d5e230 [TSan] Rename file to make it clear that it defines interceptors
Rename file `tsan_libdispatch.cpp -> tsan_libdispatch_interceptors.cpp`
to make it clear that it's main purpose is defining interceptors.

llvm-svn: 369289
2019-08-19 18:41:20 +00:00
Andrea Di Biagio bf989187c3 [X86] Move scheduling tests for CMPXCHG to the corresponding resources-x86_64.s files. NFC
In D66424 it has been requested to move all the new tests added by r369278 into
resources-x86_64.s. That is because only the 8b/16 ops should be tested by
resources-cmpxchg.s. This partially reverts r369278.

llvm-svn: 369288
2019-08-19 18:20:30 +00:00
Craig Topper a0d92c7262 [X86] Teach lowerV4I32Shuffle to only use broadcasts if the mask has more than one undef element. Prioritize shifts over broadcast in lowerV8I16Shuffle.
The motivating case are the changes in vector-reduce-add.ll where
we were doing extra work in the scalar domain instead of shuffling.
There may be some one use check that needs to be looked into there,
but this patch sidesteps the issue by avoiding broadcasts that
aren't really broadcasting.

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

llvm-svn: 369287
2019-08-19 18:15:50 +00:00
Erich Keane a8abe1f828 Fix poorly formatted HTML in the cxx_status.html file caused by adding
1668.

llvm-svn: 369286
2019-08-19 18:14:22 +00:00
David Carlier 949f190810 [Sanitizer] arc4random interception on Mac
Reviewers: yln,vitalybuka

Reviewed By: yln

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

llvm-svn: 369285
2019-08-19 18:12:15 +00:00