summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorJames Y Knight <jyknight@google.com>2019-02-01 20:43:34 +0000
committerJames Y Knight <jyknight@google.com>2019-02-01 20:43:34 +0000
commitd9e85a0861b7e9320c34547a2ad7f49c504a9381 (patch)
treebafc31ff522534fb10e65ddc519943a7be7abc28 /llvm
parent7976eb58382b25d0e17490b9d77fb06cb000c95b (diff)
downloadbcm5719-llvm-d9e85a0861b7e9320c34547a2ad7f49c504a9381.tar.gz
bcm5719-llvm-d9e85a0861b7e9320c34547a2ad7f49c504a9381.zip
[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
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp3
-rw-r--r--llvm/lib/IR/IRBuilder.cpp2
-rw-r--r--llvm/lib/IR/Instructions.cpp6
-rw-r--r--llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp4
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp5
-rw-r--r--llvm/unittests/IR/InstructionsTest.cpp7
7 files changed, 16 insertions, 13 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 0b93a61dc40..433a481efb0 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -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(
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index 2c13bb505a9..a7290cb8c0f 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -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,
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 452ccff49d2..b9e6cd653ea 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -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());
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index a48d21e5366..cb884d189d8 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -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());
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index 9e609c387e4..383e6603762 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -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);
}
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index b63f15bff4a..a05a7a23457 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -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());
diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp
index 1f82d4b632c..56a55e1f9e0 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -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(
OpenPOWER on IntegriCloud