341 Commits

Author SHA1 Message Date
Jeremy Morse
40bdfd39e3
[llvm-reduce][DebugInfo] Support reducing non-instruction debug-info (#78995)
LLVM will shortly be able to represent variable locations without
encoding information into intrinsics -- they'll be stored as DPValue
objects instead. We'll still need to be able to llvm-reduce these
variable location assignments just like we can with intrinsics today,
thus, here's an llvm-reduce pass that enumerates and reduces the DPValue
objects.

The test for this is paradoxically written with dbg.value intrinsics:
this is because we're changing all the core parts of LLVM to support
this first, with the textual IR format coming last. Until that arrives,
testing the llvm-reduce'ing of DPValues needs the added test using
intrinsics. We should be able to drop the variable assignment using
%alsoloaded using this method. As with the other llvm-reduce tests, I've
got one set of check lines for making the reduction happen as desired,
and the other set to check the final output.
2024-01-23 14:30:56 +00:00
Matt Arsenault
b2c7cac3ad llvm-reduce: Handle disjoint flag 2023-12-13 11:13:09 +07:00
Matt Arsenault
82d750239e llvm-reduce: Handle nneg flag 2023-12-13 11:13:09 +07:00
Kazu Hirata
586ecdf205
[llvm] Use StringRef::{starts,ends}_with (NFC) (#74956)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-11 21:01:36 -08:00
Kazu Hirata
7ca94a841c [llvm-reduce] Remove unnecessary includes (NFC)
Identified with clangd.
2023-12-05 23:38:46 -08:00
Nikita Popov
ea668144d9
[CodeGen] Split off PseudoSourceValueManager into separate header (NFC) (#73327)
Most users of PseudoSourceValue.h only need PseudoSourceValue, not the
PseudoSourceValueManager. However, this header pulls in some very
expensive dependencies like ValueMap.h, which is only used for the
manager.

Split off the manager into a separate header and include it only where
used.
2023-12-04 10:17:59 +01:00
Kazu Hirata
92c2529ccd [llvm] Stop including vector (NFC)
Identified with clangd.
2023-12-03 22:32:21 -08:00
Kazu Hirata
bc265bd663 [llvm-reduce] Stop including llvm/ADT/SetVector.h (NFC)
Identified with clangd.
2023-11-30 23:52:26 -08:00
Youngsuk Kim
a51196ec6e [llvm-reduce] Remove unreachable branch (NFC)
Remove stale branch which is unreachable with opaque pointers.
2023-11-30 10:30:48 -06:00
Nikita Popov
03f05a4e72 [IR] Don't include GenericDomTreeConstruction.h in header (NFC)
The whole point of the GenericDomTree.h vs
GenericDomTreeConstruction.h distinction is that the latter only
needs to be included in the source file and not the header.
2023-11-22 09:06:36 +01:00
Youngsuk Kim
57dd23bc0a [llvm] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
2023-11-14 10:43:00 -06:00
Youngsuk Kim
eed067e9fb [llvm] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
2023-11-13 14:33:41 -06:00
Kazu Hirata
fcb160eabc [llvm] Stop including llvm/ADT/DenseMap.h (NFC)
Identified with clangd.
2023-11-11 22:46:28 -08:00
Kazu Hirata
01702c3f7f [llvm] Stop including llvm/ADT/SmallSet.h (NFC)
Identified with clangd.
2023-11-11 12:32:15 -08:00
Kazu Hirata
1564c225ef [llvm] Stop including llvm/ADT/SmallString.h (NFC)
Identified with clangd.
2023-11-11 12:32:13 -08:00
Matt Arsenault
748f861bea
llvm-reduce: Handle cloning for MachineJumpTableInfo (#69086) 2023-10-31 21:51:50 +09:00
Kazu Hirata
9c5a5a421d [llvm] Stop including llvm/ADT/iterator_range.h (NFC)
Identified with misc-include-cleaner.
2023-10-22 15:41:18 -07:00
Alex Richardson
a8f8613dec Introduce and use codegen::createTargetMachineForTriple()
This creates a TargetMachine with the default options (from the command
line flags). This allows us to share a bit more code between tools.

Differential Revision: https://reviews.llvm.org/D141057
2023-10-04 13:45:16 -07:00
Arthur Eubanks
0a1aa6cda2
[NFC][CodeGen] Change CodeGenOpt::Level/CodeGenFileType into enum classes (#66295)
This will make it easy for callers to see issues with and fix up calls
to createTargetMachine after a future change to the params of
TargetMachine.

This matches other nearby enums.

For downstream users, this should be a fairly straightforward
replacement,
e.g. s/CodeGenOpt::Aggressive/CodeGenOptLevel::Aggressive
or s/CGFT_/CodeGenFileType::
2023-09-14 14:10:14 -07:00
Fangrui Song
111fcb0df0 [llvm] Fix duplicate word typos. NFC
Those fixes were taken from https://reviews.llvm.org/D137338
2023-09-01 18:25:16 -07:00
Matt Arsenault
f862d62350 llvm-reduce: Fix invalid reduction from breaking phi operands
Fix "PHI node has multiple entries for the same basic block with
different incoming values!" when running operands-to-args.

https://reviews.llvm.org/D158422
2023-08-23 18:54:48 -04:00
Jay Foad
2dcf051259 [CodeGen] Store call frame size in MachineBasicBlock
Record the call frame size on entry to each basic block. This is usually
zero except when a basic block has been split in the middle of a call
sequence.

This simplifies PEI::replaceFrameIndices which previously had to visit
basic blocks in a specific order and had special handling for
unreachable blocks. More importantly it paves the way for an equally
simple implementation of a backwards version of replaceFrameIndices,
which is required to fully convert PrologEpilogInserter to backwards
register scavenging, which is preferred because it does not rely on
accurate kill flags.

Differential Revision: https://reviews.llvm.org/D156113
2023-07-27 10:32:00 +01:00
Ivan Kosarev
e9df4c9892 [ADT] Support iterating size-based integer ranges.
It seems the ranges start with 0 in most cases.

Reviewed By: dblaikie, gchatelet

Differential Revision: https://reviews.llvm.org/D156135
2023-07-26 16:28:41 +01:00
Fangrui Song
1b162fabe8 [Support] Change SetVector's default template parameter to SmallVector<*, 0>
Similar to D156016 for MapVector.

This brings back commit fae7b98c221b5b28797f7b56b656b6b819d99f27 with a
fix to llvm/unittests/Support/ThreadPool.cpp's `_WIN32` code path.
2023-07-25 13:13:35 -07:00
Simon Pilgrim
3d83912c0c Revert rGfae7b98c221b5b28797f7b56b656b6b819d99f27 "[Support] Change SetVector's default template parameter to SmallVector<*, 0>"
This is failing on Windows MSVC builds:
llvm\unittests\Support\ThreadPool.cpp(380): error C2440: 'return': cannot convert from 'Vector' to 'std::vector<llvm::BitVector,std::allocator<llvm::BitVector>>'
        with
        [
            Vector=llvm::SmallVector<llvm::BitVector,0>
        ]
2023-07-25 10:22:08 +01:00
Fangrui Song
fae7b98c22 [Support] Change SetVector's default template parameter to SmallVector<*, 0>
Similar to D156016 for MapVector.
2023-07-25 00:39:17 -07:00
Nikita Popov
35bdcb03d9 [llvm] Remove uses of isOpaqueOrPointeeTypeEquals() (NFC) 2023-07-18 11:41:46 +02:00
Arthur Eubanks
53abf2d56f Revert "[llvm-reduce] Reduce function calling convention"
This reverts commit 702a4d89b413dfcd6619007de1056a48b60f367a.

Can break calling convention restrictions.
2023-07-17 16:10:55 -07:00
Arthur Eubanks
f2ab8f4380 [llvm-reduce] Reduce global value linkage 2023-07-17 15:46:38 -07:00
Arthur Eubanks
702a4d89b4 [llvm-reduce] Reduce function calling convention 2023-07-17 15:17:37 -07:00
Oliver Stannard
aea8db8eb9 Revert "[CodeGen] Store SP adjustment in MachineBasicBlock. NFCI."
This reverts commit 58d1eaa3b6ce4f7285c51f83faff7a3ac374c746.
2023-07-13 14:25:39 +01:00
Jay Foad
58d1eaa3b6 [CodeGen] Store SP adjustment in MachineBasicBlock. NFCI.
Record the SP adjustment on entry to each basic block. This is almost
always zero except on targets like ARM which can split a basic block in
the middle of a call sequence.

This simplifies PEI::replaceFrameIndices which previously had to visit
basic blocks in a specific order and had special handling for
unreachable blocks. More importantly it paves the way for an equally
simple implementation of a backwards version of replaceFrameIndices,
which is required to fully convert PrologEpilogInserter to backwards
register scavenging, which is preferred because it does not rely on
accurate kill flags.

Differential Revision: https://reviews.llvm.org/D154281
2023-07-12 14:29:26 +01:00
Matt Arsenault
363d99db49 llvm-reduce: Fix not preserving uselistorder with bitcode
Fix accidentally passing pointer to bool argument This was supposed to
be writing bitcode with preserved uselistorder, but instead was only
enabling it with LTO module summaries.
2023-06-30 10:26:32 -04:00
Elliot Goodrich
f0fa2d7c29 [llvm] Move AttributeMask to a separate header
Move `AttributeMask` out of `llvm/IR/Attributes.h` to a new file
`llvm/IR/AttributeMask.h`.  After doing this we can remove the
`#include <bitset>` and `#include <set>` directives from `Attributes.h`.
Since there are many headers including `Attributes.h`, but not needing
the definition of `AttributeMask`, this causes unnecessary bloating of
the translation units and slows down compilation.

This commit adds in the include directive for `llvm/IR/AttributeMask.h`
to the handful of source files that need to see the definition.

This reduces the total number of preprocessing tokens across the LLVM
source files in lib from (roughly) 1,917,509,187 to 1,902,982,273 - a
reduction of ~0.76%. This should result in a small improvement in
compilation time.

Differential Revision: https://reviews.llvm.org/D153728
2023-06-27 15:26:17 +01:00
Matt Arsenault
29ce3678c0 llvm-reduce: Fix introducing invalid uses of intrinsics 2023-06-20 12:26:27 -04:00
Arthur Eubanks
7d2b7be28d [llvm-reduce] Only write reduced output after we've saved it
Otherwise we're just rewriting the currently saved module instead of the newly reduced one.

Doesn't affect the final output since we separately write that at the end.
2023-05-15 15:49:22 -07:00
NAKAMURA Takumi
5d71ec6e44 Split out CodeGenTypes from CodeGen for LLT/MVT
This reduces dependencies on `llvm-tblgen` so much.

`CodeGenTypes` depends on `Support` at the moment.
Be careful to append deps on this, since Targets' tablegens
depend on this.

Depends on D149024

Differential Revision: https://reviews.llvm.org/D148769
2023-05-03 00:13:20 +09:00
Shraiysh Vaishay
7021182d6b [nfc][llvm] Replace pointer cast functions in PointerUnion by llvm casting functions.
This patch replaces the uses of PointerUnion.is function by llvm::isa,
PointerUnion.get function by llvm::cast, and PointerUnion.dyn_cast by
llvm::dyn_cast_if_present. This is according to the FIXME in
the definition of the class PointerUnion.

This patch does not remove them as they are being used in other
subprojects.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D148449
2023-04-17 13:40:51 -05:00
NAKAMURA Takumi
7d5d987e93 [CMake] Reorder and reformat deps 2023-04-17 00:32:16 +09:00
wangpc
267708f9d5 [MachineOutliner] Add IsOutlined to MachineFunction
We add a field `IsOutlined` to indicate whether a MachineFunction
is outlined and set it true for outlined functions in MachineOutliner.

Reviewed By: paquette

Differential Revision: https://reviews.llvm.org/D146191
2023-04-10 10:57:29 +08:00
Jay Foad
eac8e25ea5 [CodeGen] Fix type of MachineRegisterInfo::RegAllocHints. NFC.
The first member of the pair should be unsigned instead of Register
because it is the hint type, 0 for simple (target independent) hints and
other values for target dependent hints.

Differential Revision: https://reviews.llvm.org/D146646
2023-03-22 18:41:10 +00:00
Jakub Kuderski
b9db89fbcf [ADT][NFCI] Do not use non-const lvalue-refs with enumerate in llvm/
Replace references to `enumerate` results with either const lvalue
rerences or structured bindings. I did not use structured bindings
everywhere as it wasn't clear to me it would improve readability.

This is in preparation to the switch to `zip` semantics which won't
support non-const lvalue reference to elements:
https://reviews.llvm.org/D144503.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D145987
2023-03-13 20:59:06 -04:00
Florian Mayer
853a46cfb1 Revert "llvm-reduce: Run instruction reduction last"
This reverts commit 463ab1e07a0a15a9aa129639048e29e0f8ec4dc8.
2023-02-14 13:45:39 -08:00
Matt Arsenault
463ab1e07a llvm-reduce: Run instruction reduction last
With the current state of mir support, this is going to generate
a large number of verifier errors. Running the use and def
reductions first helps to mitigate the impact of this.
2023-02-14 04:02:38 -04:00
Archibald Elliott
d768bf994f [NFC][TargetParser] Replace uses of llvm/Support/Host.h
The forwarding header is left in place because of its use in
`polly/lib/External/isl/interface/extract_interface.cc`, but I have
added a GCC warning about the fact it is deprecated, because it is used
in `isl` from where it is included by Polly.
2023-02-10 09:59:46 +00:00
Matt Arsenault
c5fa6b1610 llvm-reduce: Parse file from the opened buffer instead of the file
If this wasn't bitcode this was opening a second MemoryBuffer.
2023-01-27 20:14:36 -04:00
Matt Arsenault
c0a10b2772 llvm-reduce: Use WithColor in another place
Use more consistently capitalized/colorized/punctuated error messages.
2023-01-27 20:14:36 -04:00
Matt Arsenault
4c7f500bd2 llvm-reduce: Use ThreadPool feature to wait for tasks to complete
Don't use the hackier barrier I wrote using the task queue.
2023-01-27 20:14:36 -04:00
Matt Arsenault
abf44b5b1d llvm-reduce: Use consistent type for reducer function 2023-01-27 20:08:44 -04:00
Jay Foad
073401e59c [MC] Define and use MCInstrDesc implicit_uses and implicit_defs. NFC.
The new methods return a range for easier iteration. Use them everywhere
instead of getImplicitUses, getNumImplicitUses, getImplicitDefs and
getNumImplicitDefs. A future patch will remove the old methods.

In some use cases the new methods are less efficient because they always
have to scan the whole uses/defs array to count its length, but that
will be fixed in a future patch by storing the number of implicit
uses/defs explicitly in MCInstrDesc. At that point there will be no need
to 0-terminate the arrays.

Differential Revision: https://reviews.llvm.org/D142215
2023-01-23 14:44:58 +00:00