[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 22:13:49 PDT 2017


uabelho updated this revision to Diff 98400.
uabelho added a comment.

Updated a comment according to review comments.


https://reviews.llvm.org/D32999

Files:
  lib/CodeGen/UnreachableBlockElim.cpp


Index: lib/CodeGen/UnreachableBlockElim.cpp
===================================================================
--- lib/CodeGen/UnreachableBlockElim.cpp
+++ lib/CodeGen/UnreachableBlockElim.cpp
@@ -206,11 +206,12 @@
         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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32999.98400.patch
Type: text/x-patch
Size: 1026 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170510/4b9ae6a8/attachment.bin>


More information about the llvm-commits mailing list