diff --git a/llvm/lib/CodeGen/RegisterClassInfo.cpp b/llvm/lib/CodeGen/RegisterClassInfo.cpp --- a/llvm/lib/CodeGen/RegisterClassInfo.cpp +++ b/llvm/lib/CodeGen/RegisterClassInfo.cpp @@ -188,6 +188,8 @@ } assert(RC && "Failed to find register class"); compute(RC); + if (getNumAllocatableRegs(RC) == 0) + return TRI->getRegPressureSetLimit(*MF, Idx); unsigned NReserved = RC->getNumRegs() - getNumAllocatableRegs(RC); return TRI->getRegPressureSetLimit(*MF, Idx) - TRI->getRegClassWeight(RC).RegWeight * NReserved; diff --git a/llvm/test/CodeGen/PowerPC/compute-regpressure.ll b/llvm/test/CodeGen/PowerPC/compute-regpressure.ll --- a/llvm/test/CodeGen/PowerPC/compute-regpressure.ll +++ b/llvm/test/CodeGen/PowerPC/compute-regpressure.ll @@ -1,7 +1,7 @@ ; REQUIRES: asserts ; RUN: llc -debug-only=regalloc < %s 2>&1 |FileCheck %s --check-prefix=DEBUG -; DEBUG-COUNT-3: AllocationOrder(VRSAVERC) = [ ] +; DEBUG-COUNT-1: AllocationOrder(VRSAVERC) = [ ] target triple = "powerpc64le-unknown-linux-gnu"