summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorJames Y Knight <jyknight@google.com>2019-02-01 20:44:54 +0000
committerJames Y Knight <jyknight@google.com>2019-02-01 20:44:54 +0000
commit291f791ef1ecba3856b6192e3a81856c15d2e161 (patch)
treee4c02100f7aca4de6f15cbcd3f14da4f88c7dd94 /llvm/lib/Transforms
parent7716075a1729ead67844574fdb34579894122992 (diff)
downloadbcm5719-llvm-291f791ef1ecba3856b6192e3a81856c15d2e161.tar.gz
bcm5719-llvm-291f791ef1ecba3856b6192e3a81856c15d2e161.zip
[opaque pointer types] Pass function type for CallBase::setCalledFunction.
Differential Revision: https://reviews.llvm.org/D57174 llvm-svn: 352914
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp15
-rw-r--r--llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp4
-rw-r--r--llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp4
-rw-r--r--llvm/lib/Transforms/Utils/CallPromotionUtils.cpp5
4 files changed, 14 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 80eb51be84e..b34b3fd1619 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -4214,7 +4214,8 @@ Instruction *InstCombiner::visitCallBase(CallBase &Call) {
// We cannot remove an invoke, because it would change the CFG, just
// change the callee to a null pointer.
cast<InvokeInst>(OldCall)->setCalledFunction(
- Constant::getNullValue(CalleeF->getType()));
+ CalleeF->getFunctionType(),
+ Constant::getNullValue(CalleeF->getType()));
return nullptr;
}
}
@@ -4555,8 +4556,8 @@ Instruction *
InstCombiner::transformCallThroughTrampoline(CallBase &Call,
IntrinsicInst &Tramp) {
Value *Callee = Call.getCalledValue();
- PointerType *PTy = cast<PointerType>(Callee->getType());
- FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
+ Type *CalleeTy = Callee->getType();
+ FunctionType *FTy = Call.getFunctionType();
AttributeList Attrs = Call.getAttributes();
// If the call already has the 'nest' attribute somewhere then give up -
@@ -4565,7 +4566,7 @@ InstCombiner::transformCallThroughTrampoline(CallBase &Call,
return nullptr;
Function *NestF = cast<Function>(Tramp.getArgOperand(1)->stripPointerCasts());
- FunctionType *NestFTy = cast<FunctionType>(NestF->getValueType());
+ FunctionType *NestFTy = NestF->getFunctionType();
AttributeList NestAttrs = NestF->getAttributes();
if (!NestAttrs.isEmpty()) {
@@ -4689,9 +4690,7 @@ InstCombiner::transformCallThroughTrampoline(CallBase &Call,
// Replace the trampoline call with a direct call. Since there is no 'nest'
// parameter, there is no need to adjust the argument list. Let the generic
// code sort out any function type mismatches.
- Constant *NewCallee =
- NestF->getType() == PTy ? NestF :
- ConstantExpr::getBitCast(NestF, PTy);
- Call.setCalledFunction(NewCallee);
+ Constant *NewCallee = ConstantExpr::getBitCast(NestF, CalleeTy);
+ Call.setCalledFunction(FTy, NewCallee);
return &Call;
}
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
index a424f5323b9..6613f6a76d0 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
@@ -139,7 +139,7 @@ bool ObjCARCContract::optimizeRetainCall(Function &F, Instruction *Retain) {
// We do not have to worry about tail calls/does not throw since
// retain/retainRV have the same properties.
- Constant *Decl = EP.get(ARCRuntimeEntryPointKind::RetainRV);
+ Function *Decl = EP.get(ARCRuntimeEntryPointKind::RetainRV);
cast<CallInst>(Retain)->setCalledFunction(Decl);
LLVM_DEBUG(dbgs() << "New: " << *Retain << "\n");
@@ -188,7 +188,7 @@ bool ObjCARCContract::contractAutorelease(
" Retain: "
<< *Retain << "\n");
- Constant *Decl = EP.get(Class == ARCInstKind::AutoreleaseRV
+ Function *Decl = EP.get(Class == ARCInstKind::AutoreleaseRV
? ARCRuntimeEntryPointKind::RetainAutoreleaseRV
: ARCRuntimeEntryPointKind::RetainAutorelease);
Retain->setCalledFunction(Decl);
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index bfec15ca9c7..9572674f758 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -641,7 +641,7 @@ ObjCARCOpt::OptimizeRetainRVCall(Function &F, Instruction *RetainRV) {
"Old = "
<< *RetainRV << "\n");
- Constant *NewDecl = EP.get(ARCRuntimeEntryPointKind::Retain);
+ Function *NewDecl = EP.get(ARCRuntimeEntryPointKind::Retain);
cast<CallInst>(RetainRV)->setCalledFunction(NewDecl);
LLVM_DEBUG(dbgs() << "New = " << *RetainRV << "\n");
@@ -690,7 +690,7 @@ void ObjCARCOpt::OptimizeAutoreleaseRVCall(Function &F,
<< *AutoreleaseRV << "\n");
CallInst *AutoreleaseRVCI = cast<CallInst>(AutoreleaseRV);
- Constant *NewDecl = EP.get(ARCRuntimeEntryPointKind::Autorelease);
+ Function *NewDecl = EP.get(ARCRuntimeEntryPointKind::Autorelease);
AutoreleaseRVCI->setCalledFunction(NewDecl);
AutoreleaseRVCI->setTailCall(false); // Never tail call objc_autorelease.
Class = ARCInstKind::Autorelease;
diff --git a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
index 681c5a7de93..1cb883517e8 100644
--- a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
+++ b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
@@ -366,8 +366,9 @@ Instruction *llvm::promoteCall(CallSite CS, Function *Callee,
CastInst **RetBitCast) {
assert(!CS.getCalledFunction() && "Only indirect call sites can be promoted");
- // Set the called function of the call site to be the given callee.
- CS.setCalledFunction(Callee);
+ // Set the called function of the call site to be the given callee (but don't
+ // change the type).
+ cast<CallBase>(CS.getInstruction())->setCalledOperand(Callee);
// Since the call site will no longer be direct, we must clear metadata that
// is only appropriate for indirect calls. This includes !prof and !callees
OpenPOWER on IntegriCloud