projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix a pair of use after free. Should bring the bots back.
[oota-llvm.git]
/
lib
/
CodeGen
/
RegAllocGreedy.cpp
diff --git
a/lib/CodeGen/RegAllocGreedy.cpp
b/lib/CodeGen/RegAllocGreedy.cpp
index 7a120e8802fec12a5e2ec15e822c4cb703955482..a3a8760c54e4b7a0b48cd718e759b290d2ca0685 100644
(file)
--- a/
lib/CodeGen/RegAllocGreedy.cpp
+++ b/
lib/CodeGen/RegAllocGreedy.cpp
@@
-12,7
+12,6
@@
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
-#define DEBUG_TYPE "regalloc"
#include "llvm/CodeGen/Passes.h"
#include "AllocationOrder.h"
#include "InterferenceCache.h"
#include "llvm/CodeGen/Passes.h"
#include "AllocationOrder.h"
#include "InterferenceCache.h"
@@
-45,10
+44,13
@@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Target/TargetSubtargetInfo.h"
#include <queue>
using namespace llvm;
#include <queue>
using namespace llvm;
+#define DEBUG_TYPE "regalloc"
+
STATISTIC(NumGlobalSplits, "Number of split global live ranges");
STATISTIC(NumLocalSplits, "Number of split local live ranges");
STATISTIC(NumEvicted, "Number of interferences evicted");
STATISTIC(NumGlobalSplits, "Number of split global live ranges");
STATISTIC(NumLocalSplits, "Number of split local live ranges");
STATISTIC(NumEvicted, "Number of interferences evicted");
@@
-74,10
+76,16
@@
static cl::opt<unsigned> LastChanceRecoloringMaxInterference(
cl::init(8));
static cl::opt<bool>
cl::init(8));
static cl::opt<bool>
-ExhaustiveSearch("
f
exhaustive-register-search", cl::NotHidden,
+ExhaustiveSearch("exhaustive-register-search", cl::NotHidden,
cl::desc("Exhaustive Search for registers bypassing the depth "
"and interference cutoffs of last chance recoloring"));
cl::desc("Exhaustive Search for registers bypassing the depth "
"and interference cutoffs of last chance recoloring"));
+static cl::opt<bool> EnableLocalReassignment(
+ "enable-local-reassign", cl::Hidden,
+ cl::desc("Local reassignment can yield better allocation decisions, but "
+ "may be compile time intensive"),
+ cl::init(false));
+
// FIXME: Find a good default for this flag and remove the flag.
static cl::opt<unsigned>
CSRFirstTimeCost("regalloc-csr-first-time-cost",
// FIXME: Find a good default for this flag and remove the flag.
static cl::opt<unsigned>
CSRFirstTimeCost("regalloc-csr-first-time-cost",
@@
-284,6
+292,10
@@
class RAGreedy : public MachineFunctionPass,
/// Callee-save register cost, calculated once per machine function.
BlockFrequency CSRCost;
/// Callee-save register cost, calculated once per machine function.
BlockFrequency CSRCost;
+ /// Run or not the local reassignment heuristic. This information is
+ /// obtained from the TargetSubtargetInfo.
+ bool EnableLocalReassign;
+
public:
RAGreedy();
public:
RAGreedy();
@@
-474,7
+486,7
@@
void RAGreedy::LRE_DidCloneVirtReg(unsigned New, unsigned Old) {
}
void RAGreedy::releaseMemory() {
}
void RAGreedy::releaseMemory() {
- SpillerInstance.reset(
0
);
+ SpillerInstance.reset();
ExtraRegInfo.clear();
GlobalCand.clear();
}
ExtraRegInfo.clear();
GlobalCand.clear();
}
@@
-541,7
+553,7
@@
LiveInterval *RAGreedy::dequeue() { return dequeue(Queue); }
LiveInterval *RAGreedy::dequeue(PQueue &CurQueue) {
if (CurQueue.empty())
LiveInterval *RAGreedy::dequeue(PQueue &CurQueue) {
if (CurQueue.empty())
- return
0
;
+ return
nullptr
;
LiveInterval *LI = &LIS->getInterval(~CurQueue.top().second);
CurQueue.pop();
return LI;
LiveInterval *LI = &LIS->getInterval(~CurQueue.top().second);
CurQueue.pop();
return LI;
@@
-730,7
+742,7
@@
bool RAGreedy::canEvictInterference(LiveInterval &VirtReg, unsigned PhysReg,
// Evicting another local live range in this case could lead to suboptimal
// coloring.
if (!MaxCost.isMax() && IsLocal && LIS->intervalIsInOneMBB(*Intf) &&
// Evicting another local live range in this case could lead to suboptimal
// coloring.
if (!MaxCost.isMax() && IsLocal && LIS->intervalIsInOneMBB(*Intf) &&
-
!canReassign(*Intf, PhysReg
)) {
+
(!EnableLocalReassign || !canReassign(*Intf, PhysReg)
)) {
return false;
}
}
return false;
}
}
@@
-2307,9
+2319,14
@@
bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {
<< "********** Function: " << mf.getName() << '\n');
MF = &mf;
<< "********** Function: " << mf.getName() << '\n');
MF = &mf;
- TRI = MF->getTarget().getRegisterInfo();
- TII = MF->getTarget().getInstrInfo();
+ const TargetMachine &TM = MF->getTarget();
+ TRI = TM.getSubtargetImpl()->getRegisterInfo();
+ TII = TM.getSubtargetImpl()->getInstrInfo();
RCI.runOnMachineFunction(mf);
RCI.runOnMachineFunction(mf);
+
+ EnableLocalReassign = EnableLocalReassignment ||
+ TM.getSubtargetImpl()->enableRALocalReassignment(TM.getOptLevel());
+
if (VerifyEnabled)
MF->verify(this, "Before greedy register allocator");
if (VerifyEnabled)
MF->verify(this, "Before greedy register allocator");