1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
Commit Graph

12356 Commits

Author SHA1 Message Date
Bogdan Graur
a7fe711836 Fixes warning 'enumeration value not handled in switch'.
This was introduced in commit: 981a0bd85811fe49379fdbef35528e2c2f3511a3.

Differential Revision: https://reviews.llvm.org/D93944
2020-12-30 06:56:29 -08:00
Haowei Wu
85e960e3f0 [llvm-elfabi] Add flag to preserve timestamp when output is the same
This change adds '--write-if-changed' flag to llvm-elfabi tool. When
enabled, llvm-elfabi will not overwrite the existing file if the
content of the file will not be changed, which preserves the
timestamp.

Differential Revision: https://reviews.llvm.org/D92902
2020-12-29 20:27:06 -08:00
Lang Hames
cf3fe0c756 [ORC] Move Orc RPC code into Shared, rename some RPC types.
Moves all headers from Orc/RPC to Orc/Shared, and from the llvm::orc::rpc
namespace into llvm::orc::shared. Also renames RPCTypeName to
SerializationTypeName and Function to RPCFunction.

In addition to being a more reasonable home for this code, this will make it
easier for the upcoming Orc runtime to re-use the Serialization system for
creating and parsing wrapper-function binary blobs.
2020-12-30 12:48:20 +11:00
Haowei Wu
8395b2b8fd Revert "[llvm-elfabi] Add flag to preserve timestamp when output is the same"
This reverts commit fddb41744958d21635a60622cfb4067122810bcc. which
causes test failures on Mac builders.
2020-12-29 17:26:22 -08:00
Haowei Wu
1e70786482 [llvm-elfabi] Add flag to preserve timestamp when output is the same
This change adds '--write-if-changed' flag to llvm-elfabi tool. When
enabled, llvm-elfabi will not overwrite the existing file if the
content of the file will not be changed, which preserves the
timestamp.

Differential Revision: https://reviews.llvm.org/D92902
2020-12-29 14:43:47 -08:00
Arthur Eubanks
c8d1c701c3 [NewPM][AMDGPU] Port amdgpu-lower-kernel-attributes
And add it to the AMDGPU opt pipeline.

This is a function pass instead of a module pass (like the legacy pass)
because it's getting added to a CGSCCPassManager, and you can't put a
module pass in a CGSCCPassManager.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D93885
2020-12-29 10:26:06 -08:00
Arthur Eubanks
6a52d86d30 [NewPM] Port infer-address-spaces
And add it to the AMDGPU opt pipeline.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D93880
2020-12-28 19:58:12 -08:00
Arthur Eubanks
38df05d15f [AMDGPU][NewPM] Port amdgpu-promote-alloca(-to-vector)
And add to AMDGPU opt pipeline.

Don't pin an opt run to the legacy PM when -enable-new-pm=1 if these
passes (or passes introduced in https://reviews.llvm.org/D93863) are in
the list of passes.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D93875
2020-12-28 17:52:31 -08:00
Kazu Hirata
41179ce945 [llvm-cov] Use is_contained (NFC) 2020-12-27 09:57:25 -08:00
Kazu Hirata
4eb8419cf3 [llvm-cov, llvm-symbolizer] Use llvm::erase_if (NFC) 2020-12-26 12:06:27 -08:00
Kazu Hirata
45712d80ac [llvm-pdbutil] Use llvm::is_contained (NFC) 2020-12-26 12:06:24 -08:00
Kazu Hirata
5dfa98f2df [llvm-objcopy] Use llvm::erase_if (NFC) 2020-12-25 10:13:18 -08:00
Kazu Hirata
df35ddafb7 [llvm-nm, llvm-objdump] Use llvm::is_contained (NFC) 2020-12-25 09:22:37 -08:00
Georgii Rymar
9ce120ed1a [obj2yaml] - Dump the content of a broken hash table properly.
This is similar to D93760.

When something is wrong with the hash table header we dump
its context as a raw data.

Currently we have the calculation overflow issue and it is possible to
bypass the validation we have (and crash).

The patch fixes it.

Differential revision: https://reviews.llvm.org/D93799
2020-12-25 11:51:28 +03:00
Georgii Rymar
625780544e [llvm-readelf/obj] - Improve the warning reported when unable to read the stack size.
It was discussed in D92545 that we might want to improve messages
reported when something is wrong with the stack size section.
This patch does it.

Differential revision: https://reviews.llvm.org/D93802
2020-12-25 11:40:35 +03:00
Georgii Rymar
8638aa3531 [libObject] - Add more ELF types to LLVM_ELF_IMPORT_TYPES_ELFT define (ELFTypes.h).
This allows to get rid of lots for typedefs/usings from many places.

Differential revision: https://reviews.llvm.org/D93801
2020-12-25 11:39:05 +03:00
Kazu Hirata
2fb3d0d5a0 [Target] Use llvm::any_of (NFC) 2020-12-24 19:43:26 -08:00
Georgii Rymar
4ac301d88d [obj2yaml] - Dump the content of a broken GNU hash table properly.
When something is wrong with the GNU hash table header we dump
its context as a raw data.

Currently we have the calculation overflow issue and it is possible to
bypass the validation we have (and crash).

The patch fixes it.

Differential revision: https://reviews.llvm.org/D93760
2020-12-24 11:16:31 +03:00
Georgii Rymar
baa62a1798 [llvm-readobj] - Dump the ELF file type better.
Currently llvm-readelf might print "OS Specific/Processor Specific/<unknown>"
hint when dumping the ELF file type. The patch teaches llvm-readobj to do the same.

This fixes https://bugs.llvm.org/show_bug.cgi?id=40868

I am removing `Object/elf-unknown-type.test` test because it is not in the right place,
it is outdated and very limited.
The `readobj/ELF/file-types.test` checks the functionality much better.

Differential revision: https://reviews.llvm.org/D93689
2020-12-23 11:13:19 +03:00
Arthur O'Dwyer
bf9fb2bea1 Replace T(x) with reinterpret_cast<T>(x) everywhere it means reinterpret_cast. NFC.
Differential Revision: https://reviews.llvm.org/D76572
2020-12-22 19:54:29 -05:00
Tom Stellard
f1a54f61f5 llvm-profgen: Parse command line arguments after initializing targets
I am experimenting with turning backends into loadable modules and in
that scenario, target specific command line arguments won't be available
until after the targets are initialized.

Also, most other tools initialize targets before parsing arguments.

Reviewed By: wlei

Differential Revision: https://reviews.llvm.org/D93348
2020-12-21 15:13:10 -08:00
Georgii Rymar
6ae506ec2d [libObject, llvm-readobj] - Reimplement ELFFile<ELFT>::getEntry.
Currently, `ELFFile<ELFT>::getEntry` does not check an index of
an entry. Because of that the code might read past the end of the symbol
table silently. I've added a test to `llvm-readobj\ELF\relocations.test`
to demonstrate the possible issue. Also, I've added a unit test for
this method.

After this change, `getEntry` stops reporting the section index and
reuses the `getSectionContentsAsArray` method, which already has
all the validation needed. Our related warnings now provide
more and better context sometimes.

Differential revision: https://reviews.llvm.org/D93209
2020-12-18 16:52:27 +03:00
Adhemerval Zanella
f54cbc7c92 [llvm-readobj/elf] - AArch64: Handle AARCH64_VARIANT_PCS for GNUStyle
It mimics the GNU readelf where it prints a [VARIANT_PCS] for symbols
with st_other with STO_AARCH64_VARIANT_PCS.

Reviewed By: grimar, MaskRay

Differential Revision: https://reviews.llvm.org/D93044
2020-12-17 11:09:53 -03:00
dfukalov
b7b67e3e9a [NFC] Reduce include files dependency and AA header cleanup (part 2).
Continuing work started in https://reviews.llvm.org/D92489:

Removed a bunch of includes from "AliasAnalysis.h" and "LoopPassManager.h".

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D92852
2020-12-17 14:04:48 +03:00
Barry Revzin
2fc9f32ca3 Make LLVM build in C++20 mode
Part of the <=> changes in C++20 make certain patterns of writing equality
operators ambiguous with themselves (sorry!).
This patch goes through and adjusts all the comparison operators such that
they should work in both C++17 and C++20 modes. It also makes two other small
C++20-specific changes (adding a constructor to a type that cases to be an
aggregate, and adding casts from u8 literals which no longer have type
const char*).

There were four categories of errors that this review fixes.
Here are canonical examples of them, ordered from most to least common:

// 1) Missing const
namespace missing_const {
    struct A {
    #ifndef FIXED
        bool operator==(A const&);
    #else
        bool operator==(A const&) const;
    #endif
    };

    bool a = A{} == A{}; // error
}

// 2) Type mismatch on CRTP
namespace crtp_mismatch {
    template <typename Derived>
    struct Base {
    #ifndef FIXED
        bool operator==(Derived const&) const;
    #else
        // in one case changed to taking Base const&
        friend bool operator==(Derived const&, Derived const&);
    #endif
    };

    struct D : Base<D> { };

    bool b = D{} == D{}; // error
}

// 3) iterator/const_iterator with only mixed comparison
namespace iter_const_iter {
    template <bool Const>
    struct iterator {
        using const_iterator = iterator<true>;

        iterator();

        template <bool B, std::enable_if_t<(Const && !B), int> = 0>
        iterator(iterator<B> const&);

    #ifndef FIXED
        bool operator==(const_iterator const&) const;
    #else
        friend bool operator==(iterator const&, iterator const&);
    #endif
    };

    bool c = iterator<false>{} == iterator<false>{} // error
          || iterator<false>{} == iterator<true>{}
          || iterator<true>{} == iterator<false>{}
          || iterator<true>{} == iterator<true>{};
}

// 4) Same-type comparison but only have mixed-type operator
namespace ambiguous_choice {
    enum Color { Red };

    struct C {
        C();
        C(Color);
        operator Color() const;
        bool operator==(Color) const;
        friend bool operator==(C, C);
    };

    bool c = C{} == C{}; // error
    bool d = C{} == Red;
}

Differential revision: https://reviews.llvm.org/D78938
2020-12-17 10:44:10 +00:00
Fangrui Song
8b5501e7ef Use basic_string::find(char) instead of basic_string::find(const char *s, size_type pos=0)
Many (StringRef) cannot be detected by clang-tidy performance-faster-string-find.
2020-12-16 23:28:32 -08:00
Hongtao Yu
66121fdf6a [CSSPGO] Consume pseudo-probe-based AutoFDO profile
This change enables pseudo-probe-based sample counts to be consumed by the sample profile loader under the regular `-fprofile-sample-use` switch with minimal adjustments to the existing sample file formats. After the counts are imported, a probe helper, aka, a `PseudoProbeManager` object, is automatically launched to verify the CFG checksum of every function in the current compilation against the corresponding checksum from the profile. Mismatched checksums will cause a function profile to be slipped. A `SampleProfileProber` pass is scheduled before any of the `SampleProfileLoader` instances so that the CFG checksums as well as probe mappings are available during the profile loading time. The `PseudoProbeManager` object is set up right after the profile reading is done. In the future a CFG-based fuzzy matching could be done in `PseudoProbeManager`.

Samples will be applied only to pseudo probe instructions as well as probed callsites once the checksum verification goes through. Those instructions are processed in the same way that regular instructions would be processed in the line-number-based scenario. In other words, a function is processed in a regular way as if it was reduced to just containing pseudo probes (block probes and callsites).

**Adjustment to profile format **

A CFG checksum field is being added to the existing AutoFDO profile formats. So far only the text format and the extended binary format are supported. For the text format, a new line like
```
!CFGChecksum: 12345
```
is added to the end of the body sample lines. For the extended binary profile format, we introduce a metadata section to store the checksum map from function names to their CFG checksums.

Differential Revision: https://reviews.llvm.org/D92347
2020-12-16 15:57:18 -08:00
Georgii Rymar
f7c776770a [yaml2obj/obj2yaml] - Make Value/Size fields of Symbol optional.
When a field is optional we can use the `=<none>` syntax in macros.
This patch makes `Value`/`Size` fields of `Symbol` optional
and adds test cases for them.

Differential revision: https://reviews.llvm.org/D93010
2020-12-16 13:49:57 +03:00
Georgii Rymar
eb12cf3add [lib/Object] - Make ELFObjectFile::getSymbol() return Expected<>.
This was requested in comments for D93209:
https://reviews.llvm.org/D93209#inline-871192

D93209 fixes an issue with `ELFFile<ELFT>::getEntry`,
after what `getSymbol` starts calling `report_fatal_error` for previously
missed invalid cases.

This patch makes it return `Expected<>` and updates callers.
For few of them I had to add new `report_fatal_error` calls. But I see no
way to avoid it currently. The change would affects too many places, e.g:
`getSymbolBinding` and other methods are used from `ELFSymbolRef`
which is used in too many places across LLVM.

Differential revision: https://reviews.llvm.org/D93297
2020-12-16 13:14:23 +03:00
Georgii Rymar
e16531589c [llvm-readelf/obj] - Handle out-of-order PT_LOADs better.
This is https://bugs.llvm.org/show_bug.cgi?id=45698.

Specification says that
"Loadable segment entries in the program header table appear
in ascending order, sorted on the p_vaddr member."

Our `toMappedAddr()` relies on this condition. This patch
adds a warning when the sorting order of loadable segments is wrong.
In this case we force segments sorting and that allows
`toMappedAddr()` to work as expected.

Differential revision: https://reviews.llvm.org/D92641
2020-12-16 12:59:32 +03:00
Amy Huang
eedfec2ca8 [llvm-symbolizer] Add missing include for config.h
The cmake variable LLVM_ENABLE_DIA_SDK was being used here but
was undefined because config.h wasn't included.

Differential Revision: https://reviews.llvm.org/D93309
2020-12-15 09:20:31 -08:00
Georgii Rymar
0f9894fe39 [llvm-readelf] - Don't print OS/Processor specific prefix for known ELF file types.
This is a change suggested in post commit comments for
D93096 (https://reviews.llvm.org/D93096#2451796).

Imagine we want to add a custom OS specific ELF file type.
For that we can update the `ElfObjectFileType` array:

```
static const EnumEntry<unsigned> ElfObjectFileType[] = {
...
  {"Core",         "CORE (Core file)",         ELF::ET_CORE},
  {"MyType",       "MyType (my description)",     0xfe01},
};
```

The current code then might print:
```
OS Specific: (MyType (my description))
```

Though instead we probably would like to see a nicer output, e.g:
```
Type: MyType (my description)
```

To achieve that we can reorder the code slightly.

It is impossible to add a test I think, because we have no custom values in
the `ElfObjectFileType` array in LLVM.

Differential revision: https://reviews.llvm.org/D93217
2020-12-15 10:56:25 +03:00
David Spickett
18038eabcf [llvm-objdump] Use "--" for long options in --help text
Single dash for these options is not recognised.

Changes found by running this on the --help output
and the user guide:
grep -e ' -[a-zA-Z]\{2,\}'

The user guide was updated in https://reviews.llvm.org/D92305
so no change there.

Reviewed By: jhenderson, MaskRay

Differential Revision: https://reviews.llvm.org/D92310
2020-12-14 13:11:29 +00:00
Georgii Rymar
c7112b7126 [llvm-readobj] - For SHT_REL relocations, don't display an addend.
This is https://bugs.llvm.org/show_bug.cgi?id=44257.

In LLVM style we always print `0` as addend when dumping
SHT_REL relocations. It is confusing, this patch stops
printing it as the first comment on the bug page suggests.

Differential revision: https://reviews.llvm.org/D93033
2020-12-14 12:03:00 +03:00
Georgii Rymar
dff27ca0da [llvm-readelf] - Improve ELF type field dumping.
This is related to https://bugs.llvm.org/show_bug.cgi?id=40868.

Currently we don't print `OS Specific`/``Processor Specific`/`<unknown>`
prefixes when dumping the ELF file type. This is not consistent
with GNU readelf. The patch fixes it.

Also, this patch removes the `types.test`, because we already have
`file-types.test`, which tests more cases and this patch revealed that
we have such a duplicate.

Differential revision: https://reviews.llvm.org/D93096
2020-12-14 11:24:08 +03:00
Arthur Eubanks
26e5c18037 [opt][NPM] Pin -lower-amx-type to legacy PM
This is part of the codegen pipeline.
2020-12-13 19:16:20 -08:00
Lang Hames
74ef815f29 Re-apply 8904ee8ac7e with missing header included this time. 2020-12-14 13:39:33 +11:00
Nico Weber
2ecd062c06 Revert "[JITLink] Add JITLinkDylib type, thread through JITLinkMemoryManager APIs."
This reverts commit 8904ee8ac7ebcc50a60de0914abc6862e28b6664.
Didn't `git add` llvm/ExecutionEngine/JITLink/JITLinkDylib.h and hence doesn't
build anywhere.
2020-12-13 21:30:38 -05:00
Lang Hames
c16030181f [JITLink] Add JITLinkDylib type, thread through JITLinkMemoryManager APIs.
JITLinkDylib represents a target dylib for a JITLink link. By representing this
explicitly we can:
  - Enable JITLinkMemoryManagers to manage allocations on a per-dylib basis
    (e.g by maintaining a seperate allocation pool for each JITLinkDylib).
  - Enable new features and diagnostics that require information about the
    target dylib (not implemented in this patch).
2020-12-14 12:29:16 +11:00
Martin Storsjö
102c71a022 [llvm-rc] Handle driveless absolute windows paths when loading external files
When llvm-rc loads an external file, it looks for it relative to
a number of include directories and the current working directory.
If the path is considered absolute, llvm-rc tries to open the
filename as such, and doesn't try to open it relative to other
paths.

On Windows, a path name like "\dir\file" isn't considered absolute
as it lacks the drive name, but by appending it on top of the search
dirs, it's not found.

LLVM's sys::path::append just appends such a path (same with a properly
absolute posix path) after the paths it's supposed to be relative to.

This fix doesn't handle the case if the resource script and the
external file are on a different drive than the current working
directory; to fix that, we'd have to make LLVM's sys::path::append
handle appending fully absolute and partially absolute paths (ones
lacking a drive prefix but containing a root directory), or switch
to C++17's std::filesystem.

Differential Revision: https://reviews.llvm.org/D92558
2020-12-10 14:11:06 +02:00
Alexey Lapshin
8c9a1f9e87 [dsymutil][DWARFLinker][NFC] Make interface of AddressMap more general.
Current interface of AddressMap assumes that relocations exist.
That is correct for not-linked object file but is not correct
for linked executable. This patch changes interface in such way
that AddressMap could be used not only with not-linked object files:

hasValidRelocationAt()

replaced with:

hasLiveMemoryLocation()
hasLiveAddressRange()

Differential Revision: https://reviews.llvm.org/D87723
2020-12-10 14:57:08 +03:00
Sergey Dmitriev
9302af918f [llvm-link][NFC] Minor cleanup
llvm::Linker::linkModules() is a static member, so there is no need
to pass reference to llvm::Linker instance to loadArFile() function.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D92918
2020-12-09 23:16:13 -08:00
Fangrui Song
ead0e3209d Rename -plugin-opt=no-new-pass-manager to -plugin-opt=legacy-pass-manager 2020-12-09 16:43:30 -08:00
Fangrui Song
7f2a5362d1 [LLD][gold] Add -plugin-opt=no-new-pass-manager
-DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=on configured LLD and LLVMgold.so
will use the new pass manager by default. Add an option to
use the legacy pass manager. This will also be used by the Clang driver
when -fno-new-pass-manager (D92915) / -fno-experimental-new-pass-manager is set.

Reviewed By: aeubanks, tejohnson

Differential Revision: https://reviews.llvm.org/D92916
2020-12-09 13:31:03 -08:00
Sam Clegg
cee0963ebc [WebAssembly] Add support for named data sections in wasm binaries
Followup to https://reviews.llvm.org/D91769 which added support
for names globals.

Differential Revision: https://reviews.llvm.org/D92909
2020-12-09 12:57:07 -08:00
Arthur Eubanks
286730195f Reland Pin -loop-reduce to legacy PM
This was accidentally reverted by a later change.

LSR currently only runs in the codegen pass manager.
There are a couple issues with LSR and the NPM.
1) Lots of tests assume that LCSSA isn't run before LSR. This breaks a
bunch of tests' expected output. This is fixable with some time put in.
2) LSR doesn't preserve LCSSA. See
llvm/test/Analysis/MemorySSA/update-remove-deadblocks.ll. LSR's use of
SCEVExpander is the only use of SCEVExpander where the PreserveLCSSA option is
off. Turning it on causes some code sinking out of loops to fail due to
SCEVExpander's inability to handle the newly created trivial PHI nodes in the
broken critical edge (I was looking at
llvm/test/Transforms/LoopStrengthReduce/X86/2011-11-29-postincphi.ll).
I also tried simply just calling formLCSSA() at the end of LSR, but the extra
PHI nodes cause regressions in codegen tests.

We'll delay figuring these issues out until later.

This causes the number of check-llvm failures with -enable-new-pm true
by default to go from 60 to 29.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D92796
2020-12-09 09:57:57 -08:00
Georgii Rymar
c56960224e [llvm-readelf/obj] - Improve diagnostics when printing NT_FILE notes.
This changes the `printNotesHelper` to report warnings on its side when
there are errors when dumping notes.

With that we can provide more content when reporting warnings about broken notes.

Differential revision: https://reviews.llvm.org/D92636
2020-12-09 12:31:46 +03:00
Georgii Rymar
fa15fb5f0a [obj2yaml] - Support dumping objects that have multiple SHT_SYMTAB_SHNDX sections.
It is allowed to have multiple `SHT_SYMTAB_SHNDX` sections, though
we currently don't implement it.

The current implementation assumes that there is a maximum of one SHT_SYMTAB_SHNDX
section and that it is always linked with .symtab section.

This patch drops this limitations.

Differential revision: https://reviews.llvm.org/D92644
2020-12-09 12:14:58 +03:00
Arthur Eubanks
1309eee42f [gold][NPM] Use NPM with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D92869
2020-12-08 15:13:34 -08:00
Anna Thomas
ea0d3b5f95 [ScalarizeMaskedMemIntrin] Add new PM support
This patch adds new PM support for the pass and the pass can be now used
during middle-end transforms. The old pass is remamed to
ScalarizeMaskedMemIntrinLegacyPass.

Reviewed-By: skatkov, aeubanks
Differential Revision: https://reviews.llvm.org/D92743
2020-12-08 17:15:22 -05:00