20 Commits

Author SHA1 Message Date
Simon Pilgrim
624b9697fa [MachineOutliner] Add missing initializers for OutlinedFunction. NFCI.
Appeases MSVC/cppcheck.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366014 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-14 11:10:04 +00:00
Chandler Carruth
6b547686c5 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 08:50:56 +00:00
Jessica Paquette
8bd5d3d025 [MachineOutliner][NFC] Candidates don't need to be shared_ptrs anymore
More refactoring.

After the changes to the pruning logic, and removing CandidateList, there's
no reason for Candiates to be shared_ptrs (or pointers at all).

std::shared_ptr<Candidate> -> Candidate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348427 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-05 23:24:22 +00:00
Jessica Paquette
d5178b04bc [MachineOutliner][NFC] Simplify and unify pruning/outlining logic
Since we're now performing outlining per OutlinedFunction rather than per
Candidate, we can simply outline each candidate as it shows up.

Instead of having a pruning phase, instead, we'll outline entire functions.
Then we'll update the UnsignedVec we mapped to reflect the deletion. If any
candidate is in a space that's marked dirty, then we'll drop it.

This lets us remove the pruning logic entirely, and greatly simplifies the
code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348420 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-05 22:27:38 +00:00
Jessica Paquette
a5d8d4c7c9 [MachineOutliner] Outline functions by order of benefit
Mostly NFC, only change is the order of outlined function names.

Loop over the outlined functions instead of walking the candidate list.

This is a bit easier to understand. It's far more natural to create a function,
then replace all of its occurrences with calls than the other way around.

The functions outlined after this do not change, but their names will be
decided by their benefit. E.g, OUTLINED_FUNCTION_0 will now always be the
most beneficial function, rather than the first one seen.

This makes it easier to enforce an ordering on the outlined functions. So,
this also adds a test to make sure that the ordering works as expected.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348414 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-05 21:36:04 +00:00
Jessica Paquette
96d084fd30 [MachineOutliner][NFC] Use getOccurrenceCount() in getNotOutlinedCost()
Some more gardening.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348392 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-05 18:17:40 +00:00
Jessica Paquette
b70f93c28c [MachineOutliner][NFC] Make getters in MachineOutliner.h const
Just some refactoring. A few of the getters in OutlinedFunction weren't const.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348391 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-05 18:12:52 +00:00
Jessica Paquette
f18b476bf7 [MachineOutliner][NFC] Don't create outlined sequence from integer mapping
Some gardening/refactoring.

It's cleaner to copy the instructions into the MachineFunction using the first
candidate instead of going to the mapper.

Also, by doing this we can remove the Seq member from OutlinedFunction entirely.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348390 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-05 17:57:33 +00:00
Jessica Paquette
522fd7bbaa [MachineOutliner][NFC] Don't compute liveness if X16/X17/NZCV are unused
Using the MBB flags, we can tell if X16/X17/NZCV are unused in a block,
and also not live out.

If this holds for all MBBs, then we can avoid checking for liveness on
that candidate. Furthermore, if it holds for an individual candidate's
MBB, then we can avoid checking for liveness on that candidate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346901 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-14 22:23:38 +00:00
Jessica Paquette
cdd4dd393b [MachineOutliner][NFC] Use MBB flags to avoid call checks in getOutliningInfo
We already determine a bunch of information about an MBB in
getMachineOutlinerMBBFlags. We can reuse that information to avoid calculating
things that must be false/true.

The first thing we can easily check is if an outlined sequence could ever
contain calls. There's no reason to walk over the outlined range, checking for
calls, if we already know that there are no calls in the block containing the
sequence.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346809 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-13 23:01:34 +00:00
Jessica Paquette
fc6b6a704e [MachineOutliner] Don't store outlined function numberings on OutlinedFunction
NFC-ish. This doesn't change the behaviour of the outliner, but does make sure
that you won't end up with say

OUTLINED_FUNCTION_2:
...
ret

OUTLINED_FUNCTION_248:
...
ret

as the only outlined functions in your module. Those should really be

OUTLINED_FUNCTION_0:
...
ret

OUTLINED_FUNCTION_1:
...
ret

If we produce outlined functions, they probably should have sequential numbers
attached to them. This makes it a bit easier+stable to write outliner tests.

The point of this is to move towards a bit more stability in outlined function
names. By doing this, we at least don't rely on the traversal order of the
suffix tree. Instead, we rely on the order of the candidate list, which is
*far* more consistent. The candidate list is ordered by the end indices of
candidates, so we're more likely to get a stable ordering. This is still
susceptible to changes in the cost model though (like, if we suddenly find new
candidates, for example).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346340 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-07 18:36:43 +00:00
Jessica Paquette
54b04a891a [MachineOutliner][AArch64] Add support for saving LR to a register
This teaches the outliner to save LR to a register rather than the stack when
possible. This allows us to avoid bumping the stack in outlined functions in
some cases. By doing this, in a later patch, we can teach the outliner to do
something like this:

f1:
  ...
  bl OUTLINED_FUNCTION
  ...

f2:
  ...
  move LR's contents to a register
  bl OUTLINED_FUNCTION
  move the register's contents back

instead of falling back to saving LR in both cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338278 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-30 17:45:28 +00:00
Jessica Paquette
4ec15997d0 [MachineOutliner] Exit getOutliningCandidateInfo when we erase all candidates
There was a missing check for if a candidate list was entirely deleted. This
adds that check.

This fixes an asan failure caused by running test/CodeGen/AArch64/addsub_ext.ll
with the MachineOutliner enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338148 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-27 18:21:57 +00:00
Jessica Paquette
742c37184c [MachineOutliner][NFC] Move target frame info into OutlinedFunction
Just some gardening here.

Similar to how we moved call information into Candidates, this moves outlined
frame information into OutlinedFunction. This allows us to remove
TargetCostInfo entirely.

Anywhere where we returned a TargetCostInfo struct, we now return an
OutlinedFunction. This establishes OutlinedFunctions as more of a general
repeated sequence, and Candidates as occurrences of those repeated sequences.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337848 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-24 20:13:10 +00:00
Jessica Paquette
264d8038e8 [MachineOutliner][NFC] Make Candidates own their call information
Before this, TCI contained all the call information for each Candidate.

This moves that information onto the Candidates. As a result, each Candidate
can now supply how it ought to be called. Thus, Candidates will be able to,
say, call the same function in cheaper ways when possible. This also removes
that information from TCI, since it's no longer used there.

A follow-up patch for the AArch64 outliner will demonstrate this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337840 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-24 17:42:11 +00:00
Jessica Paquette
f381561a76 [MachineOutliner][NFC] Sink some candidate logic into OutlinedFunction
Just some simple gardening to improve clarity.

Before, we had something along the lines of

1) Create a std::vector of Candidates
2) Create an OutlinedFunction
3) Create a std::vector of pointers to Candidates
4) Copy those over to the OutlinedFunction and the Candidate list

Now, OutlinedFunctions create the Candidate pointers. They're still copied
over to the main list of Candidates, but it makes it a bit clearer what's
going on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337838 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-24 17:36:13 +00:00
Yvan Roux
4af4a557bf [MachineOutliner] Assert that Liveness tracking is accurate (NFC)
The checking is done deeper inside MachineBasicBlock, but this will
hopefully help to find issues when porting the machine outliner to a
target where Liveness tracking is broken (like ARM).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336481 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-07 08:02:19 +00:00
Jessica Paquette
43d4585d61 [MachineOutliner] Don't outline sequences where x16/x17/nzcv are live across
It isn't safe to outline sequences of instructions where x16/x17/nzcv live
across the sequence.

This teaches the outliner to check whether or not a specific canidate has
x16/x17/nzcv live across it and discard the candidate in the case that that is
true.

https://bugs.llvm.org/show_bug.cgi?id=37573
https://reviews.llvm.org/D47655

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335758 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 17:43:27 +00:00
Benjamin Kramer
c011f6948e Fix namespaces. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334890 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-16 13:37:52 +00:00
Jessica Paquette
65c5ddb6f8 [MachineOutliner] NFC - Move intermediate data structures to MachineOutliner.h
This is setting up to fix bug 37573 cleanly.

This moves data structures that are technically both used in some way by the
target and the general-purpose outlining algorithm into MachineOutliner.h. In
particular, the `Candidate` class is of importance.

Before, the outliner passed the locations of `Candidates` to the target, which
would then make some decisions about the prospective outlined function. This
change allows us to just pass `Candidates` along to the target. This will allow
the target to discard `Candidates` that would be considered unsafe before cost
calculation. Thus, we will be able to remove the unsafe candidates described in
the bug without resorting to torching the entire prospective function.

Also, as a side-effect, it makes the outliner a bit cleaner.

https://bugs.llvm.org/show_bug.cgi?id=37573

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333952 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-04 21:14:16 +00:00