[PATCH] D32999: [UnreachableBlockElim] Check return value of constrainRegClass().
Mikael Holmén via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 9 06:05:34 PDT 2017
uabelho created this revision.
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.
https://reviews.llvm.org/D32999
Files:
lib/CodeGen/UnreachableBlockElim.cpp
Index: lib/CodeGen/UnreachableBlockElim.cpp
===================================================================
--- lib/CodeGen/UnreachableBlockElim.cpp
+++ lib/CodeGen/UnreachableBlockElim.cpp
@@ -206,8 +206,8 @@
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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32999.98273.patch
Type: text/x-patch
Size: 711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170509/9efb17ae/attachment.bin>
More information about the llvm-commits
mailing list