[llvm-commits] [llvm] r151379 - /llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Fri Feb 24 10:34:21 PST 2012
Author: stoklund
Date: Fri Feb 24 12:34:20 2012
New Revision: 151379
URL: http://llvm.org/viewvc/llvm-project?rev=151379&view=rev
Log:
Add a -stress-regalloc=<N> option.
This will limit all register classes to N registers in order to stress
test register allocation.
Modified:
llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp
Modified: llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp?rev=151379&r1=151378&r2=151379&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp Fri Feb 24 12:34:20 2012
@@ -18,12 +18,16 @@
#include "RegisterClassInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Target/TargetMachine.h"
-
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
+cl::opt<unsigned> StressRA("stress-regalloc", cl::Hidden, cl::init(0),
+ cl::value_desc("N"),
+ cl::desc("Limit all regclasses to N registers"));
+
RegisterClassInfo::RegisterClassInfo() : Tag(0), MF(0), TRI(0), CalleeSaved(0)
{}
@@ -99,6 +103,10 @@
// CSR aliases go after the volatile registers, preserve the target's order.
std::copy(CSRAlias.begin(), CSRAlias.end(), &RCI.Order[N]);
+ // Register allocator stress test. Clip register class to N registers.
+ if (StressRA && RCI.NumRegs > StressRA)
+ RCI.NumRegs = StressRA;
+
// Check if RC is a proper sub-class.
if (const TargetRegisterClass *Super = TRI->getLargestLegalSuperClass(RC))
if (Super != RC && getNumAllocatableRegs(Super) > RCI.NumRegs)
More information about the llvm-commits
mailing list