[llvm] r302622 - [UnreachableBlockElim] Check return value of constrainRegClass().
Mikael Holmen via llvm-commits
llvm-commits at lists.llvm.org
Tue May 9 23:33:44 PDT 2017
Author: uabelho
Date: Wed May 10 01:33:43 2017
New Revision: 302622
URL: http://llvm.org/viewvc/llvm-project?rev=302622&view=rev
Log:
[UnreachableBlockElim] Check return value of constrainRegClass().
Summary:
MachineRegisterInfo::constrainRegClass() can fail if two register classes
don't have a common subclass or if the register class doesn't contain
enough registers. Check the return value before trying to remove Phi nodes,
and if we can't constrain, we output a COPY instead of simply replacing
registers.
Reviewers: kparzysz, david2050, wmi
Reviewed By: kparzysz
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D32999
Modified:
llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp
Modified: llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp?rev=302622&r1=302621&r2=302622&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp (original)
+++ llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp Wed May 10 01:33:43 2017
@@ -206,11 +206,12 @@ bool UnreachableMachineBlockElim::runOnM
if (InputReg != OutputReg) {
MachineRegisterInfo &MRI = F.getRegInfo();
unsigned InputSub = Input.getSubReg();
- if (InputSub == 0) {
- MRI.constrainRegClass(InputReg, MRI.getRegClass(OutputReg));
+ if (InputSub == 0 &&
+ MRI.constrainRegClass(InputReg, MRI.getRegClass(OutputReg))) {
MRI.replaceRegWith(OutputReg, InputReg);
} else {
- // The input register to the PHI has a subregister:
+ // The input register to the PHI has a subregister or it can't be
+ // constrained to the proper register class:
// insert a COPY instead of simply replacing the output
// with the input.
const TargetInstrInfo *TII = F.getSubtarget().getInstrInfo();
More information about the llvm-commits
mailing list