summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2014-01-21 21:27:37 +0000
committerAndrew Trick <atrick@apple.com>2014-01-21 21:27:37 +0000
commit10afb02d48116d08e7e9307fe9ad3ada32bece87 (patch)
treefa473015b56cbf73812aac7fdde2695b9e41560b /lib/CodeGen/MachineScheduler.cpp
parentce5f07f33c5ee660709cc7a6bc5101f0e25da757 (diff)
downloadllvm-10afb02d48116d08e7e9307fe9ad3ada32bece87.tar.gz
llvm-10afb02d48116d08e7e9307fe9ad3ada32bece87.tar.bz2
llvm-10afb02d48116d08e7e9307fe9ad3ada32bece87.tar.xz
Fix PR18572 - llc crash during GenericScheduler::initPolicy().
Generalized the heuristic that looks at the (very rough) size of the register file before enabling regpressure tracking. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199766 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineScheduler.cpp')
-rw-r--r--lib/CodeGen/MachineScheduler.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp
index b1dd34bcb7..4812b30526 100644
--- a/lib/CodeGen/MachineScheduler.cpp
+++ b/lib/CodeGen/MachineScheduler.cpp
@@ -2531,10 +2531,16 @@ void GenericScheduler::initPolicy(MachineBasicBlock::iterator Begin,
// Avoid setting up the register pressure tracker for small regions to save
// compile time. As a rough heuristic, only track pressure when the number of
// schedulable instructions exceeds half the integer register file.
- unsigned NIntRegs = Context->RegClassInfo->getNumAllocatableRegs(
- TM.getTargetLowering()->getRegClassFor(MVT::i32));
-
- RegionPolicy.ShouldTrackPressure = NumRegionInstrs > (NIntRegs / 2);
+ RegionPolicy.ShouldTrackPressure = true;
+ unsigned LegalIntVT = MVT::i32;
+ for (; LegalIntVT > (unsigned)MVT::i1; --LegalIntVT) {
+ if (TM.getTargetLowering()->isTypeLegal((MVT::SimpleValueType)LegalIntVT)) {
+ unsigned NIntRegs = Context->RegClassInfo->getNumAllocatableRegs(
+ TM.getTargetLowering()->getRegClassFor(
+ (MVT::SimpleValueType)LegalIntVT));
+ RegionPolicy.ShouldTrackPressure = NumRegionInstrs > (NIntRegs / 2);
+ }
+ }
// For generic targets, we default to bottom-up, because it's simpler and more
// compile-time optimizations have been implemented in that direction.