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

12090 Commits

Author SHA1 Message Date
Craig Disselkoen
1cbae6c6e8 C API: functions to get mask of a ShuffleVector
This commit fixes a regression (from LLVM 10 to LLVM 11 RC3) in the LLVM
C API.

Previously, commit 1ee6ec2bf removed the mask operand from the
ShuffleVector instruction, storing the mask data separately in the
instruction instead; this reduced the number of operands of
ShuffleVector from 3 to 2. AFAICT, this change unintentionally caused
a regression in the LLVM C API. Specifically, it is no longer possible
to get the mask of a ShuffleVector instruction through the C API. This
patch introduces new functions which together allow a C API user to get
the mask of a ShuffleVector instruction, restoring the functionality
which was previously available through LLVMGetOperand().

This patch also adds tests for this change to the llvm-c-test
executable, which involved adding support for InsertElement,
ExtractElement, and ShuffleVector itself (as well as constant vectors)
to echo.cpp. Previously, vector operations weren't tested at all in
echo.ll.

I also fixed some typos in comments and help-text nearby these changes,
which I happened to spot while developing this patch. Since the typo
fixes are technically unrelated other than being in the same files, I'm
happy to take them out if you'd rather they not be included in the patch.

Differential Revision: https://reviews.llvm.org/D88190
2020-09-25 16:01:05 -07:00
Andrew Litteken
841f42ea48 Revert "[IRSim] Adding basic implementation of llvm-sim."
This reverts commit 15645d044bcfe2a0f63156048b302f997a717688.
2020-09-25 16:18:48 -05:00
Andrew Litteken
7c7bb877bb [IRSim] Adding basic implementation of llvm-sim.
This is a similarity visualization tool that accepts a Module and
passes it to the IRSimilarityIdentifier.  The resulting SimilarityGroups
are output in a JSON file.

Tests are found in test/tools/llvm-sim and check for the file not found,
a bad module, and that the JSON is created correctly.

Reviewers: paquette, jroelofs

Differential Revision: https://reviews.llvm.org/D86974
2020-09-25 15:12:34 -05:00
Jinsong Ji
bd991f7d1b [llvm-exegesis] Add whitespace between words in error message 2020-09-24 18:20:57 +00:00
Alexey Lapshin
0d7df5ad90 Fix a builtbot failure after 3ed04f93e30121867a813a220452b97aebeb1730. 2020-09-24 15:09:57 +03:00
Alexey Lapshin
5fe04015c0 [llvm-objcopy][NFC] refactor error handling. part 1.
Remove usages of special error reporting functions(error(),
reportError()). This patch is extracted from D87987.
Errors are reported as Expected<>/Error returning values.
This part is for MachO subfolder of llvm-objcopy.

Testing: check-all.

Reviewed By: jhenderson, alexshap

Differential Revision: https://reviews.llvm.org/D88113
2020-09-24 14:37:30 +03:00
Georgii Rymar
1bf4e4317a [llvm-readelf/obj] - Stop printing wrong addresses for arm32 unwind info for non-relocatable objects.
This is the first patch for https://bugs.llvm.org/show_bug.cgi?id=47581.

Currently -u does not compute function addresses correctly and
dumps broken addresses for non-relocatable objects.

ARM spec says:
"An index table entry consists of 2 words.
The first word contains a prel31 offset (see Relocations) to the start of a function, with bit 31 clear."
...
"The relocated 31 bits form a place-relative signed offset to the referenced entity.
For brevity, this document will refer to the results of these relocations as "prel31 offsets"."

(https://developer.arm.com/documentation/ihi0038/c/?lang=en#index-table-entries)
(https://developer.arm.com/documentation/ihi0038/c/?lang=en#relocations)

Currently we use an address of the SHT_ARM_EXIDX section instead of an address of an entry
in computations. As a result we compute an offset that is not really "place-relative",
but section relative, what is wrong.

The patch fixes this issue.

Differential revision: https://reviews.llvm.org/D88076
2020-09-24 13:21:00 +03:00
Georgii Rymar
ac2d05c135 [llvm-readobj] - Fix a warning.
In a post review comments for D88097 it was mentioned that code
triggers bunch of warnings of the form:

llvm/tools/llvm-readobj/ELFDumper.cpp:5299:28: warning: loop variable 'Note' is always a copy because
the range of type 'iterator_range<llvm::object::ELFFile<llvm::object::ELFType<llvm::support::big, true> >::Elf_Note_Iterator>'
(aka 'iterator_range<Elf_Note_Iterator_Impl<ELFType<(llvm::support::endianness)0U, true> > >') does not return a reference [-Wrange-loop-analysis]
      for (const Elf_Note &Note : this->Obj.notes(P, Err))

It happens because Elf_Note is always copied here:

Elf_Note_Impl<ELFT> operator*() const {
  assert(Nhdr && "dereferenced ELF note end iterator");
  return Elf_Note_Impl<ELFT>(*Nhdr);
}

This patch fixes the issue by removing a reference.
2020-09-24 13:18:01 +03:00
Alexander Shaposhnikov
9f25cd59a2 [llvm-objcopy][MachO] Fix --add-section
This diff fixes --add-section functionality and simplifies the tests organization.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D87497
2020-09-24 01:51:10 -07:00
Xing GUO
0719e72f68 [DWARFYAML] Make the ExtLen field of extended opcodes optional.
This patch makes the 'ExtLen' field of extended opcodes optional. We
don't need to manually calculate it in the future.

Reviewed By: jhenderson, MaskRay

Differential Revision: https://reviews.llvm.org/D88136
2020-09-24 14:13:26 +08:00
Arthur Eubanks
c8fa2dffa7 Revert "[NewPM] Add callbacks to PassBuilder to run before/after parsing a pass"
This reverts commit 111aa4e36614d9a056cf5040d4d7bbfddeb9ebb2.
2020-09-23 18:43:13 -07:00
Arthur Eubanks
ad0cedf725 [NewPM] Add callbacks to PassBuilder to run before/after parsing a pass
This is in preparation for supporting -debugify-each, which adds a debug
info pass before and after each pass.

Switch VerifyEach to use this.

Reviewed By: ychen

Differential Revision: https://reviews.llvm.org/D88107
2020-09-23 15:25:40 -07:00
Georgii Rymar
7fc78c44a1 [llvm-readelf/obj] - Fix extended section symbol indices printed in warnings for MIPS GOT/PLT entries.
Recent refactoring introduced a symbol index argument for `getFullSymbolName` method,
which is only used for reporting error messages about invalid extended symbol indexes.

There are few issues in the implementation and we don't report correct symbol indices
when dumping MIPS GOT/PLT entries currently.

This patch adds test cases and fixes the issue.

Differential revision: https://reviews.llvm.org/D88089
2020-09-23 13:42:56 +03:00
Georgii Rymar
ac5be6fe16 [llvm-readelf/obj] - Print section symbol names properly when dumping relocations.
Currently `--relocations` ignores section symbol names and always prints
section names for them. This is inconsistent with GNU readelf and with `--symbols`.

We have a code in `getFullSymbolName` (which is used for `--symbols`) which can be
reused for `getRelocationTarget` (used for `--relocations`).
With that the issue described is fixed and code becomes a bit shorter.
Also with this change we start to print more relocations (in situations when we just
showed warnings instead before) and also start to report more diagnostic warnings
(see reloc-zero-name-or-value.test).

Differential revision: https://reviews.llvm.org/D87613
2020-09-23 13:25:39 +03:00
Georgii Rymar
3d8119e026 [llvm-readelf/obj] - Cleanup the code. NFCI.
This:
1) Replaces pointers with references in many places.
2) Adds few TODOs about fixing possible unhandled errors (in ARMEHABIPrinter.h).
3) Replaces `auto`s with actual types.
4) Removes excessive arguments.
5) Adds `const ELFFile<ELFT> &Obj;` member to `ELFDumper` to simplify the code.

Differential revision: https://reviews.llvm.org/D88097
2020-09-23 12:58:22 +03:00
Georgii Rymar
b5638caa39 [llvm-readobj/elf] - Stop reporting invalid extended indexes in warnings for unnamed section symbols.
We have an issue with `getFullSymbolName`: it assumes that the symbol passed is
always in the `.symtab`, what is wrong. We might calculate and report a wrong index currently.
I've added a test case revealing that.

This patch adds the "symbol index" argument to `getFullSymbolName` signature,
what fixes the issue.

Differential revision: https://reviews.llvm.org/D87899
2020-09-22 11:55:15 +03:00
Arthur Eubanks
a6e667da4b [NewPM] Support -disable-simplify-libcall/-disable-builtin in NPM opt
Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D87932
2020-09-21 16:38:37 -07:00
Georgii Rymar
9a3425f583 [llvm-readobj/libObject] - Get rid of FirstSym argument. NFCI.
We use `FirstSym` argument in `getExtendedSymbolTableIndex` to calculate
a symbol index:

```
&Sym - &FirstSym
```

Instead, we could pass the symbol index directly.
This is what this patch does, it allows to simplify another llvm-readobj API.

Differential revision: https://reviews.llvm.org/D88016
2020-09-21 16:07:50 +03:00
Georgii Rymar
3caa549f90 [llvm-readelf/obj] - Stop printing invalid names for unnamed section symbols.
We have an issue with `ELFDumper<ELFT>::getSymbolSectionName`:
1) It is used deeply for both LLVM/GNU styles and might return LLVM-style only
   values to describe symbols: "Undefined", "Processor Specific", "Absolute", etc.

2) `getSymbolSectionName` is used by `getFullSymbolName` and these special values
   might appear instead of symbol names in many places.
   This occurs for unnamed section symbols currently.

This patch extracts the LLVM specific logic to `LLVMStyle<ELFT>::printSymbolSection`,
which seems to be the only place where we want to print the special values mentioned.
It also adds a meaningful new warning that is reported when we are unable to get
a section index for a section symbol.

Differential revision: https://reviews.llvm.org/D87764
2020-09-21 13:05:46 +03:00
wlei
e56a524153 [llvm-profdata]Fix llvm-profdata crash on compact binary profile
llvm-profdata `show` and `overlap` will crash in `getFuncName` on compact binary profile. This change fixed this by switching to use `getName`.

 `getFuncName` is misused in llvm-profdata. As showed below, `GUIDToFuncNameMap` is only supported in compilation mode, there is no initialization in llvm-profdata. Compact profile whose MD5 is true would try to query `GUIDToFuncNameMap` then caused the crash. So fix this by switching to `getName`

Reviewed By: MaskRay, wmi, wenlei, weihe, hoy

Differential Revision: https://reviews.llvm.org/D87740
2020-09-20 16:58:34 -07:00
Rainer Orth
4d957ca492 [tools][remarks-shlib] Don't build libRemarks.so without PIC
A build on `sparcv9-sun-solaris2.11` with `-DLLVM_ENABLE_PIC=Off` failed
linking `libRemarks.so`:

  [27/2297] Linking CXX shared library lib/libRemarks.so.12git
  FAILED: lib/libRemarks.so.12git
  [...]
  ld: fatal: relocation error: R_SPARC_H44: file lib/libLLVMRemarks.a(Remark.cpp.o): symbol _ZTVN4llvm18raw_string_ostreamE: invalid shared object relocation type: ABS44 code model unsupported
  [...]

On Solaris/sparcv9 as on many other targets you cannot link non-PIC objects
into a shared object.

The following patch avoids this by not building the library with PIC.  It
allowed the build to complete and `ninja check-all` showed no errors.

Differential Revision: https://reviews.llvm.org/D85626
2020-09-20 12:40:21 +02:00
Alexander Shaposhnikov
8837f43bbb [llvm-objcopy][MachO] Clean up the interface of Object
Remove the method addLoadCommand which was used only in a single place.
NFC.

Test plan: make check-all
2020-09-18 18:23:27 -07:00
Alexander Shaposhnikov
a6c5914f99 [llvm-objcopy][MachO] Add llvm-bitcode-strip driver
This diff adds llvm-bitcode-strip driver to llvm-objcopy.
In the future this will enable us to build a replacement for the tool bitcode_strip.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D87212
2020-09-18 18:13:05 -07:00
Alexander Shaposhnikov
01222be640 [llvm-install-name-tool] Validate -id value early
The code which validates the value of -id is moved into the function parseInstallNameToolOptions.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D87855
2020-09-18 17:50:08 -07:00
Vedant Kumar
ea70c5e0ce [llvm-cov] Allow commas in filenames passed to -object flag
Currently, -object takes a comma separated list of objects as an
argument, which prevents it working with path names that contain a
comma. Drop comma-separated support, which requires to set pass the
-object flag multiple times to set multiple objects.

Patch by Andrew Gallagher!

Differential Revision: https://reviews.llvm.org/D87003
2020-09-18 13:46:29 -07:00
Georgii Rymar
393d75e8ca [obj2yaml] - Don't emit EM_NONE.
When ELF header's `e_machine == 0`, we emit:

```
Machine: EM_NONE
```

We can avoid doing this, because yaml2obj sets the
`e_machine` field to `EM_NONE` by default.

Differential revision: https://reviews.llvm.org/D87829
2020-09-17 15:58:44 +03:00
Fangrui Song
1bd4869627 [llvm-cov gcov] Add --demangled-names (-m)
gcov 4.9 introduced the option.
2020-09-16 23:18:50 -07:00
Rahman Lavaee
e3e9dd3c7b [obj2yaml] - Match ".stack_size" with the original section name, and not the uniquified name.
Without this patch, obj2yaml decodes the content of only one ".stack_size" section. Other sections are dumped with their full contents.

Reviewed By: grimar, MaskRay

Differential Revision: https://reviews.llvm.org/D87727
2020-09-16 14:17:29 -07:00
Rahman Lavaee
c08157a6ed Revert "[obj2yaml] - Match ".stack_size" with the original section name, and not the uniquified name."
This reverts commit 14e55f82980cf1342d4d3eea4885a5375e829496.
2020-09-16 11:42:37 -07:00
Rahman Lavaee
848731407e [obj2yaml] - Match ".stack_size" with the original section name, and not the uniquified name.
Without this patch, obj2yaml decodes the content of only one ".stack_size" section. Other sections are dumped with their full contents.

Reviewed By: grimar, MaskRay

Differential Revision: https://reviews.llvm.org/D87727
2020-09-16 11:33:20 -07:00
Fangrui Song
2e45ee1e4c [llvm-nm] Use aggregate initialization instead of memset zero 2020-09-16 10:27:12 -07:00
Arthur Eubanks
825221f2e5 [NPM] Translate alias analysis into require<> as well
'require<globals-aa>' is needed to make globals-aa work in NPM, since
globals-aa is a module analysis but function passes cannot run module
analyses on demand.
So don't skip translating alias analyses to 'require<>'.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D87743
2020-09-16 08:54:09 -07:00
Xing GUO
db83a6f653 [obj2yaml] Add support for dumping the .debug_addr(v5) section.
This patch adds support for dumping the .debug_addr(v5) section to
obj2yaml.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D87601
2020-09-16 14:48:03 +08:00
Martin Storsjö
2b119dcf7e [llvm-rc] Lowercase the option definitions. NFC.
This matches how such options are most commonly defined in other tools.

This was pointed out in an earlier review a few months ago, that
the llvm-rc td entries felt shouty.

The INCLUDE option is renamed to includepath, to avoid clashing with
the tablegen include directive.
2020-09-16 09:34:26 +03:00
Martin Storsjö
7b4e9362ee [llvm-rc] Update a comment. NFC.
Fix a typo and mention one missing step.
2020-09-16 09:34:26 +03:00
Martin Storsjö
50a529e27d [llvm-rc] Allow omitting components from VERSIONINFO versions
MS rc.exe doesn't require specifying all 4 components.

Differential Revision: https://reviews.llvm.org/D87570
2020-09-16 09:34:26 +03:00
Arthur Eubanks
6ec58c2371 [Bugpoint][NewPM] Pin bugpoint to legacy PM
Bugpoint has lots of assumptions and hacks around the legacy PM, put off migrating it to NPM until later.
Fixes tests under BugPoint under NPM.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D87655
2020-09-15 11:29:10 -07:00
Georgii Rymar
2d1a45eca4 [llvm-readobj/elf] - Don't crash when the size of s dynamic symbol table, inferred from the hash table, is broken.
Currently we might derive the dynamic symbol table size from the DT_HASH hash table (using its `nchain` field).
It is possible to crash dumpers with a broken relocation that refers to a symbol with an index
that is too large. To trigger it, the inferred size of the dynamic symbol table should go past the end of the object.

This patch adds a size validation + warning.

Differential revision: https://reviews.llvm.org/D86923
2020-09-15 17:44:16 +03:00
Georgii Rymar
276064cb00 [llvm-readobj/elf] - Simplify and refine the implementation which dumps .stack_sizes
Our implementation of stack sizes section dumping heavily uses `ELFObjectFile<ELFT>`,
while the rest of the code uses `ELFFile<ELFT>`.

That APIs are very different. `ELFObjectFile<ELFT>` is very generic
and has `SectionRef`, `RelocationRef`, `SymbolRef` and other generic concepts.
The `ELFFile<ELFT>` class works directly with `Elf_Shdr`, `Elf_Rel[a]`, `Elf_Sym` etc,
what is probably much cleaner for ELF dumper.

Also, `ELFObjectFile<ELFT>` API does not always provide a way to check
for possible errors. E.g. the implementation of `symbol_end()` does not verify the `sh_size`:

```
template <class ELFT>
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_end() const {
  const Elf_Shdr *SymTab = DotSymtabSec;
  if (!SymTab)
    return symbol_begin();
  DataRefImpl Sym = toDRI(SymTab, SymTab->sh_size / sizeof(Elf_Sym));
  return basic_symbol_iterator(SymbolRef(Sym, this));
}
```
There are many other examples which makes me thing we might win from
switching to `ELFFile<ELFT>` API, where we heavily validate an input data already.

This patch is the first step in this direction. I've converted the large portion of the code
to use `ELFFile<ELFT>`.

Differential revision: https://reviews.llvm.org/D87362
2020-09-15 11:57:00 +03:00
Georgii Rymar
dfa9fe5b23 [lib/Object] - Refine interface of ELFFile<ELFT>. NFCI.
`ELFFile<ELFT>` has many methods that take pointers,
though they assume that arguments are never null and
hence could take references instead.

This patch performs such clean-up.

Differential revision: https://reviews.llvm.org/D87385
2020-09-15 11:38:31 +03:00
Martin Storsjö
132d94ce5c [llvm-readobj] [ARMWinEH] Print ARM64 packed unwind info
In addition to printing the individual fields, synthesize and
print the corresponding prolog for the unwind info (in reverse
order, to match how it's printed for non-packed unwind info).

Differential Revision: https://reviews.llvm.org/D87370
2020-09-15 08:50:02 +03:00
Georgii Rymar
f5bde848bb [llvm-readobj/elf] - Don't use unwrapOrError when reporting errors about SHT_DYNAMIC sections.
This changes messages reported to stop using dynamic section names (use `describe()` instead).
This allows to avoid `unwrapOrError` and improves diagnostics.

Differential revision: https://reviews.llvm.org/D87503
2020-09-14 14:55:16 +03:00
Georgii Rymar
a6a5b19211 [llvm-readobj] - Cleanup implementation LLVMStyle<ELFT>::printAddrsig().
It has following issues:
1) `getStaticSymbolName` returns `std::string`, but the code
   assigns a result to `Expected<std::string>`.
2) The code uses `unwrapOrError` and never tests the error reported.

This patch fixes these issues.

Differential revision: https://reviews.llvm.org/D87507
2020-09-14 14:52:06 +03:00
Georgii Rymar
ee3b1b7614 [llvm-readelf/obj] - Refine and generalize the code that is used to dump notes.
There is some code that can be shared between GNU/LLVM styles.
Also, this fixes 2 inconsistencies related to dumping unknown note types:
1) For GNU style we printed "Unknown note type: (0x00000003)" in some cases, and
   "Unknown note type (0x00000003)" (no colon) in other cases.
   GNU readelf always prints `:`. This patch removes the related code
   duplication and does the same.
2) For LLVM style in some cases we printed "Unknown note type (0x00000003)",
   but sometimes just "Unknown (0x00000003)". The latter is the right form, which
   is consistent with other unknowns that are printed in LLVM style.

Rebased on top of D87453.

Differential revision: https://reviews.llvm.org/D87454
2020-09-14 14:31:50 +03:00
Fangrui Song
c8bd947872 [llvm-cov gcov] Refactor counting and reporting
The current organization of FileInfo and its referenced utility functions of
(GCOVFile, GCOVFunction, GCOVBlock) is messy. Some members of FileInfo are just
copied from GCOVFile. FileInfo::print (.gcov output and --intermediate output)
is interleaved with branch statistics and computation of line execution counts.
--intermediate has to do redundant .gcov output to gather branch statistics.

This patch deletes lots of code and introduces a clearer work flow:

```
fn collectFunction
  for each block b
    for each line lineNum
      let line be LineInfo of the file on lineNum
      line.exists = 1
      increment function's lines & linesExec if necessary
      increment line.count
      line.blocks.push_back(&b)

fn collectSourceLine
  compute cycle counts
  count = incoming_counts + cycle_counts
  if line.exists
    ++summary->lines
    if line.count
      ++summary->linesExec

fn collectSource
  for each line
    call collectSourceLine

fn main
  for each function
    call collectFunction
    print function summary
  for each source file
    call collectSource
    print file summary
    annotate the source file with line execution counts
  if -i
    print intermediate file
```

The output order of functions and files now follows the original order in
.gcno files.
2020-09-13 23:00:59 -07:00
Fangrui Song
0637c5d6a0 [llvm-cov gcov] Add -r (--relative-only) && -s (--source-prefix)
gcov 4.7 introduced the two options.
https://sourceware.org/pipermail/gcc-patches/2011-November/328782.html

-r only dumps files with relative paths or absolute paths with the prefix
specified by -s. The two options are useful filtering out system header files.
2020-09-13 14:54:20 -07:00
Mateusz Mikuła
8e6bb7d616 [MinGW] Use lib prefix for libraries
In MinGW world, UNIX like lib prefix is preferred for the libraries.
This patch adjusts CMake files to do that.

Differential Revision: https://reviews.llvm.org/D87517
2020-09-12 22:01:29 +03:00
Xing GUO
c2de775a93 [obj2yaml] Add support for dumping the .debug_ranges section.
This patch adds support for dumping the .debug_ranges section to
elf2yaml.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D87429
2020-09-11 08:47:01 +08:00
Martin Storsjö
00b9701362 [llvm-readobj] [ARMWinEH] Print set_fp/add_fp differently in epilogues
This matches how e.g. stp/ldp and other opcodes are printed differently
for epilogues.

Also add a missing --strict-whitespace in an existing test that
was added explicitly for testing vertical alignment, and change to
using temp files for the generated object files.

Differential Revision: https://reviews.llvm.org/D87363
2020-09-10 11:26:43 +03:00
Alexander Shaposhnikov
85362afc67 [llvm-install-name-tool] Add -V flag
This diff adds -V alias for --version to make llvm-install-name-tool
consistent with other tools (llvm-objcopy, llvm-strip, etc).

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D87264
2020-09-09 17:11:08 -07:00