1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

12216 Commits

Author SHA1 Message Date
Georgii Rymar
04b897752e Recommit: [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt.
This is recommit for D90903 with fixes for BB:
1) Used std::move<> when returning Expected<> (http://lab.llvm.org:8011/#/builders/112/builds/913)
2) Fixed the name of temporarily file in the file-headers.test (http://lab.llvm.org:8011/#/builders/36/builds/1269)
   (a local old temporarily file was used before)

For creating `ELFObjectFile` instances we have the factory method
`ELFObjectFile<ELFT>::create(MemoryBufferRef Object)`.

The problem of this method is that it scans the section header to locate some sections.
When a file is truncated or has broken fields in the ELF header, this approach does
not allow us to create the `ELFObjectFile` and dump the ELF header.

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

This patch suggests a solution - it allows to delay scaning sections in the
`ELFObjectFile<ELFT>::create`. It now allows user code to call an object
initialization (`initContent()`) later. With that it is possible,
for example, for dumpers just to dump the file header and exit.
By default initialization is still performed as before, what helps to keep
the logic of existent callers untouched.

I've experimented with different approaches when worked on this patch.
I think this approach is better than doing initialization of sections (i.e. scan of them)
on demand, because normally users of `ELFObjectFile` API expect to work with a valid object.
In most cases when a section header table can't be read (because of an error), we don't
have to continue to work with object. So we probably don't need to implement a more complex API.

Differential revision: https://reviews.llvm.org/D90903
2020-11-09 12:53:53 +03:00
Georgii Rymar
aaa86f8a5c Revert "[llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt."
This reverts commit ea8a0b8b29eb08d3f0f6ac40942a2d8e98ab57ee.

It broke BBots.
http://lab.llvm.org:8011/#/builders/14/builds/1439
http://lab.llvm.org:8011/#/builders/112/builds/913
2020-11-09 11:50:50 +03:00
Georgii Rymar
0e596f45f4 [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt.
For creating `ELFObjectFile` instances we have the factory method
`ELFObjectFile<ELFT>::create(MemoryBufferRef Object)`.

The problem of this method is that it scans the section header to locate some sections.
When a file is truncated or has broken fields in the ELF header, this approach does
not allow us to create the `ELFObjectFile` and dump the ELF header.

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

This patch suggests a solution - it allows to delay scaning sections in the
`ELFObjectFile<ELFT>::create`. It now allows user code to call an object
initialization (`initContent()`) later. With that it is possible,
for example, for dumpers just to dump the file header and exit.
By default initialization is still performed as before, what helps to keep
the logic of existent callers untouched.

I've experimented with different approaches when worked on this patch.
I think this approach is better than doing initialization of sections (i.e. scan of them)
on demand, because normally users of `ELFObjectFile` API expect to work with a valid object.
In most cases when a section header table can't be read (because of an error), we don't
have to continue to work with object. So we probably don't need to implement a more complex API.

Differential revision: https://reviews.llvm.org/D90903
2020-11-09 11:27:07 +03:00
António Afonso
b3e4704ff5 Fix debug_abbrev emitter to only assign table id once
While generating yamls for my tests I noticed that the new debug_abbrev format (with multiple table support) was incorrectly assigning id's to the table because it was generating one per abbrev entry in the table. For instance, the first table would get id 4 when 5 abbrev entries existed in the table. By itself this is not a problem but the corresponding debug_info sections were still referencing id 0. This was introduced here: https://reviews.llvm.org/D83116.

Maybe a better fix is to actually correctly calculate the table id when emitting debug info? From a quick glance it seems to me the ID is just being calculated as the distance between the first DWARFAbbreviationDeclarationSet and the one the debug info entry points to, which means it's just its index and not the actual table id that was generated when emitting the debug_abbrev tables. With my fix I guess this is fine but on the diff that introduced this Pavel mentioned that he would like to have some sort of unique id between them but not necessarily +1 increasing, but for that to work we need to actually find the table ID, I guess by going directly to Y.DebugAbbrev but to honest I have no idea how to link the DWARFAbbreviationDeclarationSet and the Y.DebugAbbrev, so I just did this simple fix.

I also realized there's barely any tests for MachO so it might useful to invest on that if the tool is being reworked on.

Reviewed By: Higuoxing, jhenderson

Differential Revision: https://reviews.llvm.org/D87179
2020-11-08 18:11:50 -08:00
Alexander Shaposhnikov
2a809716d4 [llvm-objcopy][MachO] Minor refactoring of MachOLayoutBuilder
Move the implementation of getStringTableBuilderKind into
MachOLayoutBuilder.cpp. NFC.

Test plan: make check-all
2020-11-07 20:25:49 -08:00
Cornelius Aschermann
b0a87771b5 [llvm-objcopy][MachO] Fix adding multiple sections
This diff fixes missing fields initialization (Size, VMSize).
Previously this resulted in broken binaries when multiple sections
were added in one tool's invocatation.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D90690
2020-11-07 18:16:06 -08:00
Zequan Wu
f88097c935 [llvm-cov] Fix missing slash in -path-equivalence 2020-11-06 14:54:11 -08:00
Alexander Shaposhnikov
a0b02387ac [llvm-objcopy][MachO] Skip sections with zero offset
Some binaries can contain regular sections with zero offset and zero size.
This diff makes llvm-objcopy's handling of such sections consistent with
cctools's strip (which doesn't modify them),
previously the tool would allocate file space for them.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D90796
2020-11-06 13:29:43 -08:00
Rahman Lavaee
2405269073 [obj2yaml] [yaml2obj] Add yaml support for SHT_LLVM_BB_ADDR_MAP section.
YAML support allows us to better test the feature in the subsequent patches. The implementation is quite similar to the .stack_sizes section.

Reviewed By: jhenderson, grimar

Differential Revision: https://reviews.llvm.org/D88717
2020-11-06 12:44:42 -08:00
Arthur Eubanks
b3f5096b36 Reland [NewPM] Add OptimizationLevel param to registerPipelineStartEPCallback
This allows targets to skip optional optimization passes at -O0.

Reviewed By: ychen

Differential Revision: https://reviews.llvm.org/D90777
2020-11-04 13:11:40 -08:00
Arthur Eubanks
3a6a4e9f83 Revert "[NewPM] Add OptimizationLevel param to registerPipelineStartEPCallback"
This reverts commit 7a83aa0520d24ee5285a9c60b97b57a1db1d65e8.

Causing buildbot failures.
2020-11-04 12:57:32 -08:00
Arthur Eubanks
753c4830f9 [NewPM] Add OptimizationLevel param to registerPipelineStartEPCallback
This allows targets to skip optional optimization passes at -O0.

Reviewed By: ychen

Differential Revision: https://reviews.llvm.org/D90777
2020-11-04 12:53:30 -08:00
Eric Astor
40fb1cd465 [ms] [llvm-ml] Lex MASM strings, including escaping
Allow single-quoted strings and double-quoted character values, as well as doubled-quote escaping.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D89731
2020-11-04 15:28:43 -05:00
Fangrui Song
c248aad5ed [llvm-objcopy] Make --set-section-flags work with --add-section
This matches behavior GNU objcopy and can simplify clang-offload-bundler
(which currently works around the issue by invoking llvm-objcopy twice).

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D90438
2020-11-04 09:39:14 -08:00
Alexander Shaposhnikov
57690ddfcb [llvm-objcopy][MachO] Make isValidMachOCannonicalName static
This diff makes the function isValidMachOCannonicalName static.
NFC.

Test plan: make check-all
2020-11-04 09:37:29 -08:00
Clement Courbet
672cb989aa [llvm-exegesis] Fix rGaf658d920e2b
Add missing header.

```
../../llvm/tools/llvm-exegesis/lib/X86/Target.cpp(606,14): error: use of undeclared identifier '__readeflags'
    Eflags = __readeflags();
```
2020-11-04 13:23:34 +01:00
Clement Courbet
fab7d28218 [llvm-exegesis][X86] Save and restore eflags.
This is needed to benchmark instruction that touch EFLAGS (e.g. STD: set direction flag).

Differential Revision: https://reviews.llvm.org/D90742
2020-11-04 10:44:15 +01:00
Clement Courbet
d7751be085 [llvm-exegesis] Fix unused variable warning. 2020-11-04 10:09:50 +01:00
Clement Courbet
3104bbde01 Re-land "[llvm-exegesis] Save target state before running the benchmark."
The X86 exegesis target is never executed run on non-X86 hosts, disable
X86 instrinsic code on non-X86 targets.

This reverts commit 8cfc872129a99782ab07a19171bf8eace85589ae.
2020-11-04 09:46:55 +01:00
Clement Courbet
932b6b828d Revert "Re-land "[llvm-exegesis] Save target state before running the benchmark."
Still issues on some architectures.

This reverts commit fd13d7ce09af2bcad6976b8f5207874992bdd908.
2020-11-04 08:48:44 +01:00
Clement Courbet
b8e79488b4 Re-land "[llvm-exegesis] Save target state before running the benchmark.
Use `__builtin_ia32_fxsave64` under __GNUC__, (_fxsave64) does not exist in old versions of
gcc (pre-9.1).

This reverts commit e128f9cafca4e72b089fcd1381af5a1ec656d987.
2020-11-04 08:34:33 +01:00
Tim Renouf
83e3834a8d [AMDGPU] Add gfx1033 target
Differential Revision: https://reviews.llvm.org/D90447

Change-Id: If2650fc7f31bbdd49c76e74a9ca8e3734d769761
2020-11-03 16:27:48 +00:00
Tim Renouf
2a63696860 [AMDGPU] Add gfx90c target
This differentiates the Ryzen 4000/4300/4500/4700 series APUs that were
previously included in gfx909.

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

Change-Id: Ia901a7157eb2f73ccd9f25dbacec38427312377d
2020-11-03 16:27:43 +00:00
Georgii Rymar
d2ae6e2eba [llvm-readobj/libObject] - Allow dumping objects that has a broken SHT_SYMTAB_SHNDX section.
Currently it is impossible to create an instance of ELFObjectFile when the
SHT_SYMTAB_SHNDX can't be read. We error out when fail to parse the
SHT_SYMTAB_SHNDX section in the factory method.

This change delays reading of the SHT_SYMTAB_SHNDX section entries,
with it llvm-readobj is now able to work with such inputs.

Differential revision: https://reviews.llvm.org/D89379
2020-11-03 11:30:28 +03:00
Fangrui Song
f727ae92f5 [MC] Make MCStreamer aware of AsmParser's StartTokLoc
A SMLoc allows MCStreamer to report location-aware diagnostics, which
were previously done by adding SMLoc to various methods (e.g. emit*) in an ad-hoc way.

Since the file:line is most important, the column is less important and
the start token location suffices in many cases, this patch reverts
b7e7131af2dd7bdb03fa42a3bc1b4bc72ab95ce1

```
// old
symbol-binding-changed.s:6:8: error: local changed binding to STB_GLOBAL
.globl local
       ^
// new
symbol-binding-changed.s:6:1: error: local changed binding to STB_GLOBAL
.globl local
^
```

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D90511
2020-11-02 12:32:07 -08:00
Fangrui Song
6fba8f1f14 [Debugify] Port -debugify-each to NewPM
Preemptively switch 2 tests to the new PM

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D90365
2020-11-02 08:16:43 -08:00
Clement Courbet
230b955ed6 Revert "[llvm-exegesis] Save target state before running the benchmark."
_fxsave64 is not available on some buildbots.

This reverts commit 274de447fe9621082a523a7227157aeb84702a7d.
2020-11-02 15:11:45 +01:00
Clement Courbet
0a181c6ec2 [llvm-exegesis] Save target state before running the benchmark.
Some benchmarked instructions might set target state. Preserve this
state. See PR26418.

Differential Revision: https://reviews.llvm.org/D90592
2020-11-02 15:02:54 +01:00
Clement Courbet
c19cc98e95 [llvm-exegesis] Print signal name when the snippet crashed.
Differential Revision: https://reviews.llvm.org/D90453
2020-11-02 10:41:17 +01:00
Arthur Eubanks
3102160c9b [NFC] Clean up PassBuilder
Make DebugLogging a member variable so that users of PassBuilder don't
need to pass it around so much.

Move call to TargetMachine::registerPassBuilderCallbacks() within
PassBuilder so users don't need to remember to call it.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D90437
2020-10-30 10:03:59 -07:00
Georgii Rymar
76c7f0ba36 [yaml2obj] - Make Section::Link field to be Optional<>.
`Link` is not an optional field currently.
Because of this it is not convenient to write macros.

This makes it optional and fixes corresponding test cases.

Differential revision: https://reviews.llvm.org/D90390
2020-10-30 16:18:53 +03:00
Michael Liao
1162fdc839 Fix shared build. 2020-10-30 00:46:23 -04:00
Fangrui Song
2b0a4f95fd [MC] Add SMLoc to MCStreamer::emitSymbolAttribute and report changed binding warnings/errors for ELF 2020-10-29 19:43:11 -07:00
Arthur Eubanks
58177673f4 [NFC] Fix typo function -> module 2020-10-29 16:10:56 -07:00
Paul-Antoine Arras
50e9735691 [llvm-libtool-darwin] Add support for LLVM bitcode files
This diff adds support for LLVM bitcode objects to llvm-libtool-darwin.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D88722
2020-10-29 12:00:44 -07:00
Georgii Rymar
74b8b0d6b8 [llvm-readobj/elf] - Fix a crash when dumping a dynamic relocation that refer to a symbol past the EOF.
There is a possible scenario when we crash when dumping dynamic relocations.
For that we should have no section headers (to take the number of synamic symbols from)
and a dynamic relocation that refers to a symbol with an index that is too large to be in a file.

The patch fixes it.

Differential revision: https://reviews.llvm.org/D90214
2020-10-29 15:38:47 +03:00
Clement Courbet
0cedf9a2e2 [llvm-exegesis] Do not try to assign random registers twice.
Doing a random assignment assigns both tested (forward) and back-to-back
(backward) instructions.

When none of the tested instruction and back-to-back instruction have
implicit aliasing, we're currently trying to do a random register
asignment twice.

Fix this (see PR26418).

Differential Revision: https://reviews.llvm.org/D90380
2020-10-29 13:27:35 +01:00
Fangrui Song
23241c90df [Debugify] Move global namespace functions into llvm::
Also move exportDebugifyStats from tools/opt to Debugify.cpp
2020-10-28 19:11:41 -07:00
Keith Smiley
6bbd9a4106 [llvm-install-name-tool] Quote passed rpath args in error messages
This diff refactors error reporting to make it more clear
what arguments were passed to llvm-install-name-tool.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D90080
2020-10-28 15:22:33 -07:00
Craig Disselkoen
fe85e24882 C API: support scalable vectors
This adds support for scalable vector types in the C API and in
llvm-c-test, and also adds a test to ensure that llvm-c-test can properly
roundtrip operations involving scalable vectors.

While creating this diff, I discovered that the C API cannot properly roundtrip
_constant expressions_ involving shufflevector / scalable vectors, but that
seems to be a separate enough issue that I plan to address it in a future diff
(unless reviewers feel it should be addressed here).

Differential Revision: https://reviews.llvm.org/D89816
2020-10-28 18:19:34 -04:00
Fangrui Song
1d50041fbd [llvm-mc] Drop unneeded dependency on CodeGen
Spot by Craig Topper.
2020-10-28 10:53:15 -07:00
Florian Hahn
b3730ed205 [llvm-reduce] Add reduction for aliases.
This patch adds a new reduction pass that tries to remove aliases.
It runs early, as most of those likely can be removed up-front in
practice.

This substantially improves llvm-reduce for IR generated by the swift
compiler, which can generate a lot of aliases which lead to lots of
invalid reductions.

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D90260
2020-10-28 13:11:19 +00:00
Georgii Rymar
5ef47e6205 [yaml2obj][obj2yaml] - Teach tools to work with regular archives.
This teaches obj2yaml to dump valid regular (not thin) archives.
This also teaches yaml2obj to recognize archives YAML descriptions,
what allows to craft all different kinds of archives (valid and broken ones).

Differential revision: https://reviews.llvm.org/D89949
2020-10-28 15:27:11 +03:00
Clement Courbet
e24013abee [llvm-exegesis] Do not silently fail on unknown instruction encoding formats.
The addition of TILELOADD instructions with a new encoding format
triggered a hard abort instead of proper error reporting due to the use
of `llvm_unreachable` for actually reachable code.
Properly report an error when the encoding format is unknown.

Differential Revision: https://reviews.llvm.org/D90289
2020-10-28 10:06:00 +01:00
Simon Pilgrim
a330db66de [llvm-readobj] Remove duplicate inner if() condition. NFCI.
This should have been removed when rG445c3fdd2ae8 simplified the conditions.

Reported as "Snippet 5" in https://www.viva64.com/en/b/0771/
2020-10-27 18:36:04 +00:00
Georgii Rymar
4708221cf7 [llvm-readelf] - Implement --section-details option.
--section-details/-t is a GNU readelf option that produce
an output that is an alternative to --sections.

Differential revision: https://reviews.llvm.org/D89304
2020-10-27 13:29:39 +03:00
Zequan Wu
243529579b [llvm-cov] don't include all source files when provided source files are filtered out
When all provided source files are filtered out either due to `--ignore-filename-regex` or not part of binary, don't generate coverage reults for all source files. Because if users want to generate coverage results for all source files, they don't even need to provid selected source files or `--ignore-filename-regex`.

Differential Revision: https://reviews.llvm.org/D89359
2020-10-23 19:32:16 -07:00
David Blaikie
174725a4ae llvm-dwarfdump: Support verbose printing DW_OP_convert to print the CU local offset before the resolved absolute offset 2020-10-23 18:50:15 -07:00
Keith Smiley
63e3d161d6 [llvm-install-name-tool] Add -prepend_rpath option
This diff adds the option -prepend_rpath which inserts an rpath as
the first rpath in the binary.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D89605
2020-10-23 15:01:03 -07:00
Keith Smiley
b059263c5a [llvm-objcopy][NFC] Extract arg parsing logic into a helper function
This diff refactors the code which determines the tool type based on
how llvm-objcopy is invoked (objcopy vs strip vs bitcode-strip vs install-name-tool).
NFC.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D89713
2020-10-22 23:33:33 -07:00