summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegisterClassInfo.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-02-24 18:34:20 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-02-24 18:34:20 +0000
commit27bc818eaf73efe169f95c4dd8f564fd051dd824 (patch)
tree3c0e0108789cba61e6d8fe9bfcf72a26df53b027 /lib/CodeGen/RegisterClassInfo.cpp
parent3161039cf3318a1634af04e1da2038e9dc1f4b3a (diff)
downloadllvm-27bc818eaf73efe169f95c4dd8f564fd051dd824.tar.gz
llvm-27bc818eaf73efe169f95c4dd8f564fd051dd824.tar.bz2
llvm-27bc818eaf73efe169f95c4dd8f564fd051dd824.tar.xz
Add a -stress-regalloc=<N> option.
This will limit all register classes to N registers in order to stress test register allocation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegisterClassInfo.cpp')
-rw-r--r--lib/CodeGen/RegisterClassInfo.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/CodeGen/RegisterClassInfo.cpp b/lib/CodeGen/RegisterClassInfo.cpp
index 786d279c2b..2fde16c4a2 100644
--- a/lib/CodeGen/RegisterClassInfo.cpp
+++ b/lib/CodeGen/RegisterClassInfo.cpp
@@ -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 @@ void RegisterClassInfo::compute(const TargetRegisterClass *RC) const {
// 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)