diff options
author | James Y Knight <jyknight@google.com> | 2019-02-01 20:43:25 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2019-02-01 20:43:25 +0000 |
commit | 7976eb58382b25d0e17490b9d77fb06cb000c95b (patch) | |
tree | 286450abb61ef79d2e7356e0d0d80dbbce0a728a /llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | |
parent | c456309f67a9ea44038fb5d8a96c90d9c6965b67 (diff) | |
download | llvm-7976eb58382b25d0e17490b9d77fb06cb000c95b.zip llvm-7976eb58382b25d0e17490b9d77fb06cb000c95b.tar.gz llvm-7976eb58382b25d0e17490b9d77fb06cb000c95b.tar.bz2 |
[opaque pointer types] Pass function types to CallInst creation.
This cleans up all CallInst 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/D57170
llvm-svn: 352909
Diffstat (limited to 'llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp index fc46421..a48d21e 100644 --- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -881,7 +881,7 @@ void DevirtModule::tryICallBranchFunnel( } BasicBlock *BB = BasicBlock::Create(M.getContext(), "", JT, nullptr); - Constant *Intr = + Function *Intr = Intrinsic::getDeclaration(&M, llvm::Intrinsic::icall_branch_funnel, {}); auto *CI = CallInst::Create(Intr, JTArgs, "", BB); @@ -920,9 +920,10 @@ void DevirtModule::applyICallBranchFunnel(VTableSlotInfo &SlotInfo, NewArgs.push_back(Int8PtrTy); for (Type *T : CS.getFunctionType()->params()) NewArgs.push_back(T); - PointerType *NewFT = PointerType::getUnqual( + FunctionType *NewFT = FunctionType::get(CS.getFunctionType()->getReturnType(), NewArgs, - CS.getFunctionType()->isVarArg())); + CS.getFunctionType()->isVarArg()); + PointerType *NewFTPtr = PointerType::getUnqual(NewFT); IRBuilder<> IRB(CS.getInstruction()); std::vector<Value *> Args; @@ -932,10 +933,10 @@ void DevirtModule::applyICallBranchFunnel(VTableSlotInfo &SlotInfo, CallSite NewCS; if (CS.isCall()) - NewCS = IRB.CreateCall(IRB.CreateBitCast(JT, NewFT), Args); + NewCS = IRB.CreateCall(NewFT, IRB.CreateBitCast(JT, NewFTPtr), Args); else NewCS = IRB.CreateInvoke( - IRB.CreateBitCast(JT, NewFT), + IRB.CreateBitCast(JT, NewFTPtr), cast<InvokeInst>(CS.getInstruction())->getNormalDest(), cast<InvokeInst>(CS.getInstruction())->getUnwindDest(), Args); NewCS.setCallingConv(CS.getCallingConv()); |