]> granicus.if.org Git - llvm/commitdiff
GlobalISel: Fix invoke lowering creating invalid type registers
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 10 Apr 2019 17:27:55 +0000 (17:27 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 10 Apr 2019 17:27:55 +0000 (17:27 +0000)
Unlike the call handling, this wasn't checking for void results and
creating a register with the invalid LLT

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358110 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/GlobalISel/CallLowering.h
lib/CodeGen/GlobalISel/IRTranslator.cpp

index af40d4b9727a47838d8359ccbc0ba34b0d43377b..426906af34299e40db3ce7278ed62d1406d1144f 100644 (file)
@@ -49,7 +49,10 @@ public:
 
     ArgInfo(unsigned Reg, Type *Ty, ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy{},
             bool IsFixed = true)
-        : Reg(Reg), Ty(Ty), Flags(Flags), IsFixed(IsFixed) {}
+      : Reg(Reg), Ty(Ty), Flags(Flags), IsFixed(IsFixed) {
+      assert((Ty->isVoidTy() == (Reg == 0)) &&
+             "only void types should have no register");
+    }
   };
 
   /// Argument handling is mostly uniform between the four places that
index f60f7845655d60f10099e75703c9462832aeabc3..c33a74d1b9a70258399ac1bf633b013bf4d51a35 100644 (file)
@@ -1252,8 +1252,9 @@ bool IRTranslator::translateInvoke(const User &U,
   MCSymbol *BeginSymbol = Context.createTempSymbol();
   MIRBuilder.buildInstr(TargetOpcode::EH_LABEL).addSym(BeginSymbol);
 
-  unsigned Res =
-        MRI->createGenericVirtualRegister(getLLTForType(*I.getType(), *DL));
+  unsigned Res = 0;
+  if (!I.getType()->isVoidTy())
+    Res = MRI->createGenericVirtualRegister(getLLTForType(*I.getType(), *DL));
   SmallVector<unsigned, 8> Args;
   for (auto &Arg: I.arg_operands())
     Args.push_back(packRegs(*Arg, MIRBuilder));