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

52 Commits

Author SHA1 Message Date
Arnaud A. de Grandmaison
1c6984dc94 [PBQP] Assert conservativelly allocatable nodes are spilled by choice.
llvm-svn: 229302
2015-02-15 10:35:31 +00:00
Arnaud A. de Grandmaison
bfad2ea31a [PBQP] Cautiously update edge costs in the solver
The NodeMetadata are maintained in an incremental way. When an edge between
2 nodes has its cost updated, in the course of graph reduction for example,
the NodeMetadata need first to have the old edge cost removed, then the new
edge cost added. Only once the NodeMetadata have been fully updated, it
becomes safe to consider promoting the nodes to the
ConservativelyAllocatable or OptimallyReducible sets. Previously, this
promotion was occuring right after the removing the old cost, and this was
breaking the assumption that a ConservativelyAllocatable should not be
spilled.

This patch also adds asserts to:
 - enforces the invariant that a node's reduction can not be downgraded,
 - only not provably allocatable or optimally reducible nodes can be spilled.

llvm-svn: 228816
2015-02-11 08:25:36 +00:00
Arnaud A. de Grandmaison
775136711f [PBQP] Provide more information in the debug prints
Based on a patch by Jonas Paulsson

llvm-svn: 228068
2015-02-03 23:40:24 +00:00
Arnaud A. de Grandmaison
352dc10d81 [PBQP] Constify Graph::getEdgeNode1Id and Graph::getEdgeNode2Id
llvm-svn: 228048
2015-02-03 22:02:45 +00:00
Lang Hames
77d387a954 [PBQP] Unique allowed-sets for nodes in the PBQP graph and use pairs of these
sets as keys into a cache of interference matrice values in the Interference
constraint adder.

Creating interference matrices was one of the large remaining time-sinks in
PBQP. Caching them reduces the total compile time (when using PBQP) on the
nightly test suite by ~10%.

llvm-svn: 220688
2014-10-27 17:44:25 +00:00
Lang Hames
fdec95a5a7 [PBQP] Tidy up CostAllocator.h: fix variable case, rename CostPool to ValuePool.
No functional change. This just brings things more in-line with coding
standards, and makes ValuePool's functionality clearer (it's not tied to pooling
costs, and we may want to use it to hold other things in the future).

llvm-svn: 220641
2014-10-26 18:16:27 +00:00
Arnaud A. de Grandmaison
75c3a6de21 [PBQP] Check for out of bound access in DEBUG builds
It is just too easy to use a virtual register intead of a NodeId without a
compiler warning. This does not fix the fundamental problem, i.e. both
have the same underlying types, but increases the likelyhood to detect it.

llvm-svn: 220303
2014-10-21 16:24:21 +00:00
Lang Hames
9df219cc3b [PBQP] Use DenseSet rather than std::set for PBQP's PoolCostAllocator
implementation.

This is good for a ~6% reduction in total compile time on the nightly test suite
when running with -regalloc=pbqp.

llvm-svn: 220183
2014-10-20 04:26:23 +00:00
Lang Hames
7e26130bd2 [PBQP] Move register-allocation specific PBQP code into RegAllocPBQP.h.
Just clean-up - no functional change.

llvm-svn: 220145
2014-10-18 22:23:55 +00:00
Lang Hames
1ac2927c37 [PBQP] Replace PBQPBuilder with composable constraints (PBQPRAConstraint).
This patch removes the PBQPBuilder class and its subclasses and replaces them
with a composable constraints class: PBQPRAConstraint. This allows constraints
that are only required for optimisation (e.g. coalescing, soft pairing) to be
mixed and matched.

This patch also introduces support for target writers to supply custom
constraints for their targets by overriding a TargetSubtargetInfo method:

std::unique_ptr<PBQPRAConstraints> getCustomPBQPConstraints() const;

This patch should have no effect on allocations.

llvm-svn: 219421
2014-10-09 18:20:51 +00:00
Lang Hames
ea94736de4 [PBQP] Update doxygen comment style to match the rest of the file. NFC.
llvm-svn: 218849
2014-10-02 04:21:27 +00:00
Lang Hames
1bd1ce6089 [PBQP] Add support for graph-level metadata to the PBQP graph. This will be used
in the future to attach useful information about the PBQP graph (e.g. the
associated MachineFunction, pointers to regalloc passes) to the graph itself,
making that information accessible to the solver. This should also allow the
PBQPBuilder interface to be simplified.

llvm-svn: 218848
2014-10-02 04:17:36 +00:00
David Blaikie
bf2341c38c Use CostPool::PoolRef typedef some more
Cleanup to 217563 suggested by Lang Hames in post-commit review.

llvm-svn: 217564
2014-09-11 00:08:54 +00:00
David Blaikie
1c410afe1a shared_ptrify ownershp of PoolEntries in PBQP's CostPool
Leveraging both intrusive shared_ptr-ing (std::enable_shared_from_this)
and shared_ptr<T>-owning-U (to allow external users to hold
std::shared_ptr<CostT> while keeping the underlying PoolEntry alive).

The intrusiveness could be removed if we had a weak_set that implicitly
removed items from the set when their underlying data went away.

This /might/ fix an existing memory leak reported by LeakSanitizer in
r217504.

llvm-svn: 217563
2014-09-10 23:54:45 +00:00
Benjamin Kramer
da144ed5a2 Canonicalize header guards into a common format.
Add header guards to files that were missing guards. Remove #endif comments
as they don't seem common in LLVM (we can easily add them back if we decide
they're useful)

Changes made by clang-tidy with minor tweaks.

llvm-svn: 215558
2014-08-13 16:26:38 +00:00
Richard Smith
a8439916a2 Function defined in a header should be inline. Found by modules build.
llvm-svn: 207157
2014-04-24 23:14:32 +00:00
Craig Topper
30281a67fb [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr.
llvm-svn: 206142
2014-04-14 00:51:57 +00:00
Alp Toker
111bd28e59 Fix some doc and comment typos
llvm-svn: 205899
2014-04-09 14:47:27 +00:00
Craig Topper
52173239da [C++11] Replace some comparisons with 'nullptr' with simple boolean checks to reduce verbosity.
llvm-svn: 205829
2014-04-09 04:20:00 +00:00
Lang Hames
5783095348 [PBQP] Move invalid graph nodeId/edgeId methods into base class.
llvm-svn: 205122
2014-03-30 03:47:00 +00:00
David Blaikie
11a640aa93 PBQP: Minor cleanups to r204857
* Use assignment instead of swap (since the original value is being
  destroyed anyway)

* Rename "updateAdjEdgeId" to "setAdjEdgeId"

llvm-svn: 204983
2014-03-27 23:42:21 +00:00
Lang Hames
5077c39f20 Simplify PBQP graph removeAdjEdgeId implementation.
llvm-svn: 204857
2014-03-26 21:21:53 +00:00
Lang Hames
9e2829903c Remove PBQP-cost dimension sanity assertion in PBQP::Graph::addConstructedEdge.
We're already effectively checking sanity for that in PBQP::Graph::addEdge.

llvm-svn: 204844
2014-03-26 19:22:51 +00:00
Lang Hames
82f1d54602 Change the PBQP graph adjacency list structure from std::set to std::vector.
The edge data structure (EdgeEntry) now holds the indices of its entries in the
adjacency lists of the nodes it connects. This trades a little ugliness for
faster insertion/removal, which is now O(1) with a cheap constant factor. All
of this is implementation detail within the PBQP graph, the external API remains
unchanged.

Individual register allocations are likely to change, since the adjacency lists
will now be ordered differently (or rather, will now be unordered). This
shouldn't affect the average quality of allocations however.

llvm-svn: 204841
2014-03-26 18:58:00 +00:00
Lang Hames
bef12cc14d Deleted copy-constructor/copy-assignment broke a buildbot. Removing while I
investigate.

llvm-svn: 204025
2014-03-17 01:51:51 +00:00
Lang Hames
71892ada86 Rename PBQP RegAllocSolver local variables to conform to LLVM coding style.
No functional change.

llvm-svn: 204022
2014-03-17 01:33:21 +00:00
Timur Iskhodzhanov
a48e9af666 Remove unused typedef
llvm-svn: 202808
2014-03-04 09:57:00 +00:00
Patrik Hagglund
766544ffad Fix gcc -Wunused-but-set-variable warning.
llvm-svn: 202800
2014-03-04 08:55:18 +00:00
NAKAMURA Takumi
9a4dff8af3 PBQP/Graph.h: Prune @return in setNodeCosts, possibly copypasto. [-Wdocumentation]
llvm-svn: 202795
2014-03-04 07:27:08 +00:00
NAKAMURA Takumi
8bece16e25 PBQP/Graph.h: s/os/OS/ in @param. [-Wdocumentation]
llvm-svn: 202794
2014-03-04 07:26:55 +00:00
Lang Hames
c78ad508a1 Re-apply r202551, which introduced new PBQP solver.
llvm-svn: 202735
2014-03-03 18:50:05 +00:00
Lang Hames
06b78004a4 Jumped the gun with r202551 and broke some bots that weren't yet C++11ified.
Reverting until the C++11 switch is complete.

llvm-svn: 202554
2014-02-28 22:44:44 +00:00
Lang Hames
e6a310e01a New PBQP solver, and updates to the PBQP graph.
The previous PBQP solver was very robust but consumed a lot of memory,
performed a lot of redundant computation, and contained some unnecessarily tight
coupling that prevented experimentation with novel solution techniques. This new
solver is an attempt to address these shortcomings.

Important/interesting changes:

1) The domain-independent PBQP solver class, HeuristicSolverImpl, is gone.
It is replaced by a register allocation specific solver, PBQP::RegAlloc::Solver
(see RegAllocSolver.h).

The optimal reduction rules and the backpropagation algorithm have been extracted
into stand-alone functions (see ReductionRules.h), which can be used to build
domain specific PBQP solvers. This provides many more opportunities for
domain-specific knowledge to inform the PBQP solvers' decisions. In theory this
should allow us to generate better solutions. In practice, we can at least test
out ideas now.

As a side benefit, I believe the new solver is more readable than the old one.

2) The solver type is now a template parameter of the PBQP graph.

This allows the graph to notify the solver of any modifications made (e.g. by
domain independent rules) without the overhead of a virtual call. It also allows
the solver to supply policy information to the graph (see below).

3) Significantly reduced memory overhead.

Memory management policy is now an explicit property of the PBQP graph (via
the CostAllocator typedef on the graph's solver template argument). Because PBQP
graphs for register allocation tend to contain many redundant instances of
single values (E.g. the value representing an interference constraint between
GPRs), the new RASolver class uses a uniquing scheme. This massively reduces
memory consumption for large register allocation problems. For example, looking
at the largest interference graph in each of the SPEC2006 benchmarks (the
largest graph will always set the memory consumption high-water mark for PBQP),
the average memory reduction for the PBQP costs was 400x. That's times, not
percent. The highest was 1400x. Yikes. So - this is fixed.

"PBQP: No longer feasting upon every last byte of your RAM".

Minor details:

- Fully C++11'd. Never copy-construct another vector/matrix!

- Cute tricks with cost metadata: Metadata that is derived solely from cost
matrices/vectors is attached directly to the cost instances themselves. That way
if you unique the costs you never have to recompute the metadata. 400x less
memory means 400x less cost metadata (re)computation.

Special thanks to Arnaud de Grandmaison, who has been the source of much
encouragement, and of many very useful test cases.

This new solver forms the basis for future work, of which there's plenty to do.
I will be adding TODO notes shortly.

- Lang.

llvm-svn: 202551
2014-02-28 22:25:24 +00:00
Lang Hames
682d6cc95b Dereference the node iterator when dumping the PBQP graph structure in DOT
format.

Thanks to Arnaud A. de Grandmaison for the patch!

llvm-svn: 195316
2013-11-21 06:30:14 +00:00
NAKAMURA Takumi
ba34a4d189 include/llvm/CodeGen/PBQP: Update @param(s) in comments. [-Wdocumentation]
llvm-svn: 194314
2013-11-09 03:54:05 +00:00
NAKAMURA Takumi
dc501161f9 Fix whitespace.
llvm-svn: 194313
2013-11-09 03:53:55 +00:00
Lang Hames
be91a1d947 Re-apply r194300 with fixes for warnings.
llvm-svn: 194311
2013-11-09 03:08:56 +00:00
Nick Lewycky
ebeaea0192 Revert r194300 which broke the build.
llvm-svn: 194308
2013-11-09 02:01:25 +00:00
Lang Hames
e3c935f4ab Rewrite the PBQP graph data structure.
The new graph structure replaces the node and edge linked lists with vectors.
Free lists (well, free vectors) are used for fast insertion/deletion.

The ultimate aim is to make PBQP graphs cheap to clone. The motivation is that
the PBQP solver destructively consumes input graphs while computing a solution,
forcing the graph to be fully reconstructed for each round of PBQP. This
imposes a high cost on large functions, which often require several rounds of
solving/spilling to find a final register allocation. If we can cheaply clone
the PBQP graph and incrementally update it between rounds then hopefully we can
reduce this cost. Further, once we begin pooling matrix/vector values (future
work), we can cache some PBQP solver metadata and share it between cloned
graphs, allowing the PBQP solver to re-use some of the computation done in
earlier rounds.

For now this is just a data structure update. The allocator and solver still
use the graph the same way as before, fully reconstructing it between each
round. I expect no material change from this update, although it may change
the iteration order of the nodes, causing ties in the solver to break in
different directions, and this could perturb the generated allocations
(hopefully in a completely benign way).

Thanks very much to Arnaud Allard de Grandmaison for encouraging me to get back
to work on this, and for a lot of discussion and many useful PBQP test cases.

llvm-svn: 194300
2013-11-09 00:14:07 +00:00
Lang Hames
b0c9552559 Fix PBQP graph iterator typedefs.
llvm-svn: 181973
2013-05-16 02:20:41 +00:00
Jakub Staszak
f1ea1a7f37 Fix include guards so they exactly match file names.
llvm-svn: 172025
2013-01-10 00:45:19 +00:00
Chandler Carruth
ca305491f6 Sort the #include lines for the include/... tree with the script.
AKA: Recompile *ALL* the source code!

This one went much better. No manual edits here. I spot-checked for
silliness and grep-checked for really broken edits and everything seemed
good. It all still compiles. Yell if you see something that looks goofy.

llvm-svn: 169133
2012-12-03 17:02:12 +00:00
Chandler Carruth
a490793037 Use the new script to sort the includes of every file under lib.
Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

llvm-svn: 169131
2012-12-03 16:50:05 +00:00
Lang Hames
c5bf7a5f94 Use ilist rather than std::list for Node and Edge lists in the PBQP graph. This
should fix an issue (described at http://stackoverflow.com/questions/10065384/instantiation-of-a-list-with-an-incomplete-type-in-a-typedef)
that was preventing LLVMCodeGen from building with libc++ in C++11 mode.

llvm-svn: 166484
2012-10-23 17:10:51 +00:00
Lang Hames
bc1651a925 Fix a stub signature. HeuristicReduce should return a bool.
This should fix a -Wdocumentation warning.

llvm-svn: 162458
2012-08-23 19:06:23 +00:00
Dmitri Gribenko
98218ea1ef Fix a bunch of -Wdocumentation warnings.
llvm-svn: 162446
2012-08-23 16:54:08 +00:00
Lang Hames
4c05101031 Matrix simplification in PBQP may push infinite costs onto register options.
The colorability heuristic should count these as denied registers.

No test case - this exposed a bug on an out-of-tree target.

llvm-svn: 153958
2012-04-03 16:27:16 +00:00
Lang Hames
bc5e9b1c25 Add a debug option to dump PBQP graphs during register allocation.
llvm-svn: 153483
2012-03-26 23:07:23 +00:00
Craig Topper
e18a06be4d Convert assert(0) to llvm_unreachable
llvm-svn: 149849
2012-02-05 22:14:15 +00:00
Jay Foad
c146569beb Remove unused STL header includes.
llvm-svn: 130068
2011-04-23 19:53:52 +00:00