1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[opaque pointer types] Pass function types to InvokeInst creation.

This cleans up all InvokeInst creation in LLVM to explicitly pass a
function type rather than deriving it from the pointer's element-type.

Differential Revision: https://reviews.llvm.org/D57171

llvm-svn: 352910
This commit is contained in:
James Y Knight 2019-02-01 20:43:34 +00:00
parent 31a2057127
commit bfd7e4cc65
7 changed files with 16 additions and 13 deletions

View File

@ -4211,7 +4211,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
} }
} }
I = InvokeInst::Create(Callee, NormalBB, UnwindBB, Ops, OperandBundles); I = InvokeInst::Create(FTy, Callee, NormalBB, UnwindBB, Ops,
OperandBundles);
OperandBundles.clear(); OperandBundles.clear();
InstructionList.push_back(I); InstructionList.push_back(I);
cast<InvokeInst>(I)->setCallingConv( cast<InvokeInst>(I)->setCallingConv(

View File

@ -83,7 +83,7 @@ static CallInst *createCallHelper(Function *Callee, ArrayRef<Value *> Ops,
return CI; return CI;
} }
static InvokeInst *createInvokeHelper(Value *Invokee, BasicBlock *NormalDest, static InvokeInst *createInvokeHelper(Function *Invokee, BasicBlock *NormalDest,
BasicBlock *UnwindDest, BasicBlock *UnwindDest,
ArrayRef<Value *> Ops, ArrayRef<Value *> Ops,
IRBuilderBase *Builder, IRBuilderBase *Builder,

View File

@ -711,9 +711,9 @@ InvokeInst *InvokeInst::Create(InvokeInst *II, ArrayRef<OperandBundleDef> OpB,
Instruction *InsertPt) { Instruction *InsertPt) {
std::vector<Value *> Args(II->arg_begin(), II->arg_end()); std::vector<Value *> Args(II->arg_begin(), II->arg_end());
auto *NewII = InvokeInst::Create(II->getCalledValue(), II->getNormalDest(), auto *NewII = InvokeInst::Create(II->getFunctionType(), II->getCalledValue(),
II->getUnwindDest(), Args, OpB, II->getNormalDest(), II->getUnwindDest(),
II->getName(), InsertPt); Args, OpB, II->getName(), InsertPt);
NewII->setCallingConv(II->getCallingConv()); NewII->setCallingConv(II->getCallingConv());
NewII->SubclassOptionalData = II->SubclassOptionalData; NewII->SubclassOptionalData = II->SubclassOptionalData;
NewII->setAttributes(II->getAttributes()); NewII->setAttributes(II->getAttributes());

View File

@ -936,7 +936,7 @@ void DevirtModule::applyICallBranchFunnel(VTableSlotInfo &SlotInfo,
NewCS = IRB.CreateCall(NewFT, IRB.CreateBitCast(JT, NewFTPtr), Args); NewCS = IRB.CreateCall(NewFT, IRB.CreateBitCast(JT, NewFTPtr), Args);
else else
NewCS = IRB.CreateInvoke( NewCS = IRB.CreateInvoke(
IRB.CreateBitCast(JT, NewFTPtr), NewFT, IRB.CreateBitCast(JT, NewFTPtr),
cast<InvokeInst>(CS.getInstruction())->getNormalDest(), cast<InvokeInst>(CS.getInstruction())->getNormalDest(),
cast<InvokeInst>(CS.getInstruction())->getUnwindDest(), Args); cast<InvokeInst>(CS.getInstruction())->getUnwindDest(), Args);
NewCS.setCallingConv(CS.getCallingConv()); NewCS.setCallingConv(CS.getCallingConv());

View File

@ -1724,8 +1724,8 @@ void DFSanVisitor::visitCallSite(CallSite CS) {
CallSite NewCS; CallSite NewCS;
if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) { if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) {
NewCS = IRB.CreateInvoke(Func, II->getNormalDest(), II->getUnwindDest(), NewCS = IRB.CreateInvoke(NewFT, Func, II->getNormalDest(),
Args); II->getUnwindDest(), Args);
} else { } else {
NewCS = IRB.CreateCall(NewFT, Func, Args); NewCS = IRB.CreateCall(NewFT, Func, Args);
} }

View File

@ -1980,8 +1980,9 @@ BasicBlock *llvm::changeToInvokeAndSplitBasicBlock(CallInst *CI,
// can potentially be avoided with a cleverer API design that we do not have // can potentially be avoided with a cleverer API design that we do not have
// as of this time. // as of this time.
InvokeInst *II = InvokeInst::Create(CI->getCalledValue(), Split, UnwindEdge, InvokeInst *II =
InvokeArgs, OpBundles, CI->getName(), BB); InvokeInst::Create(CI->getFunctionType(), CI->getCalledValue(), Split,
UnwindEdge, InvokeArgs, OpBundles, CI->getName(), BB);
II->setDebugLoc(CI->getDebugLoc()); II->setDebugLoc(CI->getDebugLoc());
II->setCallingConv(CI->getCallingConv()); II->setCallingConv(CI->getCallingConv());
II->setAttributes(CI->getAttributes()); II->setAttributes(CI->getAttributes());

View File

@ -565,14 +565,15 @@ TEST(InstructionsTest, AlterCallBundles) {
TEST(InstructionsTest, AlterInvokeBundles) { TEST(InstructionsTest, AlterInvokeBundles) {
LLVMContext C; LLVMContext C;
Type *Int32Ty = Type::getInt32Ty(C); Type *Int32Ty = Type::getInt32Ty(C);
Type *FnTy = FunctionType::get(Int32Ty, Int32Ty, /*isVarArg=*/false); FunctionType *FnTy = FunctionType::get(Int32Ty, Int32Ty, /*isVarArg=*/false);
Value *Callee = Constant::getNullValue(FnTy->getPointerTo()); Value *Callee = Constant::getNullValue(FnTy->getPointerTo());
Value *Args[] = {ConstantInt::get(Int32Ty, 42)}; Value *Args[] = {ConstantInt::get(Int32Ty, 42)};
std::unique_ptr<BasicBlock> NormalDest(BasicBlock::Create(C)); std::unique_ptr<BasicBlock> NormalDest(BasicBlock::Create(C));
std::unique_ptr<BasicBlock> UnwindDest(BasicBlock::Create(C)); std::unique_ptr<BasicBlock> UnwindDest(BasicBlock::Create(C));
OperandBundleDef OldBundle("before", UndefValue::get(Int32Ty)); OperandBundleDef OldBundle("before", UndefValue::get(Int32Ty));
std::unique_ptr<InvokeInst> Invoke(InvokeInst::Create( std::unique_ptr<InvokeInst> Invoke(
Callee, NormalDest.get(), UnwindDest.get(), Args, OldBundle, "result")); InvokeInst::Create(FnTy, Callee, NormalDest.get(), UnwindDest.get(), Args,
OldBundle, "result"));
AttrBuilder AB; AttrBuilder AB;
AB.addAttribute(Attribute::Cold); AB.addAttribute(Attribute::Cold);
Invoke->setAttributes( Invoke->setAttributes(