forked from OSchip/llvm-project
[MachineBlockPlacement] Clean up data structures a bit.
No functionality change intended. llvm-svn: 300059
This commit is contained in:
parent
592dbea779
commit
d71461c209
|
@ -50,7 +50,6 @@
|
||||||
#include "llvm/Target/TargetLowering.h"
|
#include "llvm/Target/TargetLowering.h"
|
||||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <forward_list>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
@ -459,7 +458,7 @@ class MachineBlockPlacement : public MachineFunctionPass {
|
||||||
/// Get the best pair of non-conflicting edges.
|
/// Get the best pair of non-conflicting edges.
|
||||||
static std::pair<WeightedEdge, WeightedEdge> getBestNonConflictingEdges(
|
static std::pair<WeightedEdge, WeightedEdge> getBestNonConflictingEdges(
|
||||||
const MachineBasicBlock *BB,
|
const MachineBasicBlock *BB,
|
||||||
SmallVector<SmallVector<WeightedEdge, 8>, 2> &Edges);
|
MutableArrayRef<SmallVector<WeightedEdge, 8>> Edges);
|
||||||
/// Returns true if a block can tail duplicate into all unplaced
|
/// Returns true if a block can tail duplicate into all unplaced
|
||||||
/// predecessors. Filters based on loop.
|
/// predecessors. Filters based on loop.
|
||||||
bool canTailDuplicateUnplacedPreds(
|
bool canTailDuplicateUnplacedPreds(
|
||||||
|
@ -882,8 +881,8 @@ std::pair<MachineBlockPlacement::WeightedEdge,
|
||||||
MachineBlockPlacement::WeightedEdge>
|
MachineBlockPlacement::WeightedEdge>
|
||||||
MachineBlockPlacement::getBestNonConflictingEdges(
|
MachineBlockPlacement::getBestNonConflictingEdges(
|
||||||
const MachineBasicBlock *BB,
|
const MachineBasicBlock *BB,
|
||||||
SmallVector<SmallVector<MachineBlockPlacement::WeightedEdge, 8>, 2>
|
MutableArrayRef<SmallVector<MachineBlockPlacement::WeightedEdge, 8>>
|
||||||
&Edges) {
|
Edges) {
|
||||||
// Sort the edges, and then for each successor, find the best incoming
|
// Sort the edges, and then for each successor, find the best incoming
|
||||||
// predecessor. If the best incoming predecessors aren't the same,
|
// predecessor. If the best incoming predecessors aren't the same,
|
||||||
// then that is clearly the best layout. If there is a conflict, one of the
|
// then that is clearly the best layout. If there is a conflict, one of the
|
||||||
|
@ -941,7 +940,7 @@ MachineBlockPlacement::getBestTrellisSuccessor(
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
// Collect the edge frequencies of all edges that form the trellis.
|
// Collect the edge frequencies of all edges that form the trellis.
|
||||||
SmallVector<SmallVector<WeightedEdge, 8>, 2> Edges(2);
|
SmallVector<WeightedEdge, 8> Edges[2];
|
||||||
int SuccIndex = 0;
|
int SuccIndex = 0;
|
||||||
for (auto Succ : ViableSuccs) {
|
for (auto Succ : ViableSuccs) {
|
||||||
for (MachineBasicBlock *SuccPred : Succ->predecessors()) {
|
for (MachineBasicBlock *SuccPred : Succ->predecessors()) {
|
||||||
|
@ -1085,23 +1084,20 @@ bool MachineBlockPlacement::canTailDuplicateUnplacedPreds(
|
||||||
/// We believe that 2 and 3 are common enough to justify the small margin in 1.
|
/// We believe that 2 and 3 are common enough to justify the small margin in 1.
|
||||||
void MachineBlockPlacement::precomputeTriangleChains() {
|
void MachineBlockPlacement::precomputeTriangleChains() {
|
||||||
struct TriangleChain {
|
struct TriangleChain {
|
||||||
unsigned Count;
|
std::vector<MachineBasicBlock *> Edges;
|
||||||
std::forward_list<MachineBasicBlock*> Edges;
|
TriangleChain(MachineBasicBlock *src, MachineBasicBlock *dst)
|
||||||
TriangleChain(MachineBasicBlock* src, MachineBasicBlock *dst) {
|
: Edges({src, dst}) {}
|
||||||
Edges.push_front(src);
|
|
||||||
Edges.push_front(dst);
|
|
||||||
Count = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void append(MachineBasicBlock *dst) {
|
void append(MachineBasicBlock *dst) {
|
||||||
assert(!Edges.empty() && Edges.front()->isSuccessor(dst) &&
|
assert(getKey()->isSuccessor(dst) &&
|
||||||
"Attempting to append a block that is not a successor.");
|
"Attempting to append a block that is not a successor.");
|
||||||
Edges.push_front(dst);
|
Edges.push_back(dst);
|
||||||
++Count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineBasicBlock *getKey() {
|
unsigned count() const { return Edges.size() - 1; }
|
||||||
return Edges.front();
|
|
||||||
|
MachineBasicBlock *getKey() const {
|
||||||
|
return Edges.back();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1174,11 +1170,11 @@ void MachineBlockPlacement::precomputeTriangleChains() {
|
||||||
// Benchmarking has shown that due to branch correlation duplicating 2 or
|
// Benchmarking has shown that due to branch correlation duplicating 2 or
|
||||||
// more triangles is profitable, despite the calculations assuming
|
// more triangles is profitable, despite the calculations assuming
|
||||||
// independence.
|
// independence.
|
||||||
if (Chain.Count < TriangleChainCount)
|
if (Chain.count() < TriangleChainCount)
|
||||||
continue;
|
continue;
|
||||||
MachineBasicBlock *dst = Chain.Edges.front();
|
MachineBasicBlock *dst = Chain.Edges.back();
|
||||||
Chain.Edges.pop_front();
|
Chain.Edges.pop_back();
|
||||||
for (MachineBasicBlock *src : Chain.Edges) {
|
for (MachineBasicBlock *src : reverse(Chain.Edges)) {
|
||||||
DEBUG(dbgs() << "Marking edge: " << getBlockName(src) << "->" <<
|
DEBUG(dbgs() << "Marking edge: " << getBlockName(src) << "->" <<
|
||||||
getBlockName(dst) << " as pre-computed based on triangles.\n");
|
getBlockName(dst) << " as pre-computed based on triangles.\n");
|
||||||
ComputedEdges[src] = { dst, true };
|
ComputedEdges[src] = { dst, true };
|
||||||
|
|
Loading…
Reference in New Issue