1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01: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();
InstructionList.push_back(I);
cast<InvokeInst>(I)->setCallingConv(

View File

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

View File

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

View File

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

View File

@ -1724,8 +1724,8 @@ void DFSanVisitor::visitCallSite(CallSite CS) {
CallSite NewCS;
if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) {
NewCS = IRB.CreateInvoke(Func, II->getNormalDest(), II->getUnwindDest(),
Args);
NewCS = IRB.CreateInvoke(NewFT, Func, II->getNormalDest(),
II->getUnwindDest(), Args);
} else {
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
// as of this time.
InvokeInst *II = InvokeInst::Create(CI->getCalledValue(), Split, UnwindEdge,
InvokeArgs, OpBundles, CI->getName(), BB);
InvokeInst *II =
InvokeInst::Create(CI->getFunctionType(), CI->getCalledValue(), Split,
UnwindEdge, InvokeArgs, OpBundles, CI->getName(), BB);
II->setDebugLoc(CI->getDebugLoc());
II->setCallingConv(CI->getCallingConv());
II->setAttributes(CI->getAttributes());

View File

@ -565,14 +565,15 @@ TEST(InstructionsTest, AlterCallBundles) {
TEST(InstructionsTest, AlterInvokeBundles) {
LLVMContext 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 *Args[] = {ConstantInt::get(Int32Ty, 42)};
std::unique_ptr<BasicBlock> NormalDest(BasicBlock::Create(C));
std::unique_ptr<BasicBlock> UnwindDest(BasicBlock::Create(C));
OperandBundleDef OldBundle("before", UndefValue::get(Int32Ty));
std::unique_ptr<InvokeInst> Invoke(InvokeInst::Create(
Callee, NormalDest.get(), UnwindDest.get(), Args, OldBundle, "result"));
std::unique_ptr<InvokeInst> Invoke(
InvokeInst::Create(FnTy, Callee, NormalDest.get(), UnwindDest.get(), Args,
OldBundle, "result"));
AttrBuilder AB;
AB.addAttribute(Attribute::Cold);
Invoke->setAttributes(