From: Matt Arsenault Date: Wed, 10 Apr 2019 17:27:55 +0000 (+0000) Subject: GlobalISel: Fix invoke lowering creating invalid type registers X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc5d59bf21f582a3e72a9e199ff8ea82bc762d61;p=llvm GlobalISel: Fix invoke lowering creating invalid type registers 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 --- diff --git a/include/llvm/CodeGen/GlobalISel/CallLowering.h b/include/llvm/CodeGen/GlobalISel/CallLowering.h index af40d4b9727..426906af342 100644 --- a/include/llvm/CodeGen/GlobalISel/CallLowering.h +++ b/include/llvm/CodeGen/GlobalISel/CallLowering.h @@ -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 diff --git a/lib/CodeGen/GlobalISel/IRTranslator.cpp b/lib/CodeGen/GlobalISel/IRTranslator.cpp index f60f7845655..c33a74d1b9a 100644 --- a/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -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 Args; for (auto &Arg: I.arg_operands()) Args.push_back(packRegs(*Arg, MIRBuilder));