summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/ObjCARC
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/ObjCARC')
-rw-r--r--llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h24
-rw-r--r--llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp16
-rw-r--r--llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp10
3 files changed, 29 insertions, 21 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
index c882336b8a2..e1e95cd6a40 100644
--- a/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
+++ b/llvm/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h
@@ -33,7 +33,7 @@
namespace llvm {
-class Constant;
+class Function;
class LLVMContext;
namespace objcarc {
@@ -69,7 +69,7 @@ public:
RetainAutoreleaseRV = nullptr;
}
- Constant *get(ARCRuntimeEntryPointKind kind) {
+ Function *get(ARCRuntimeEntryPointKind kind) {
assert(TheModule != nullptr && "Not initialized.");
switch (kind) {
@@ -105,33 +105,33 @@ private:
Module *TheModule = nullptr;
/// Declaration for ObjC runtime function objc_autoreleaseReturnValue.
- Constant *AutoreleaseRV = nullptr;
+ Function *AutoreleaseRV = nullptr;
/// Declaration for ObjC runtime function objc_release.
- Constant *Release = nullptr;
+ Function *Release = nullptr;
/// Declaration for ObjC runtime function objc_retain.
- Constant *Retain = nullptr;
+ Function *Retain = nullptr;
/// Declaration for ObjC runtime function objc_retainBlock.
- Constant *RetainBlock = nullptr;
+ Function *RetainBlock = nullptr;
/// Declaration for ObjC runtime function objc_autorelease.
- Constant *Autorelease = nullptr;
+ Function *Autorelease = nullptr;
/// Declaration for objc_storeStrong().
- Constant *StoreStrong = nullptr;
+ Function *StoreStrong = nullptr;
/// Declaration for objc_retainAutoreleasedReturnValue().
- Constant *RetainRV = nullptr;
+ Function *RetainRV = nullptr;
/// Declaration for objc_retainAutorelease().
- Constant *RetainAutorelease = nullptr;
+ Function *RetainAutorelease = nullptr;
/// Declaration for objc_retainAutoreleaseReturnValue().
- Constant *RetainAutoreleaseRV = nullptr;
+ Function *RetainAutoreleaseRV = nullptr;
- Constant *getIntrinsicEntryPoint(Constant *&Decl, Intrinsic::ID IntID) {
+ Function *getIntrinsicEntryPoint(Function *&Decl, Intrinsic::ID IntID) {
if (Decl)
return Decl;
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
index d021d39097e..a424f5323b9 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
@@ -313,8 +313,8 @@ findRetainForStoreStrongContraction(Value *New, StoreInst *Store,
/// Create a call instruction with the correct funclet token. Should be used
/// instead of calling CallInst::Create directly.
static CallInst *
-createCallInst(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr,
- Instruction *InsertBefore,
+createCallInst(FunctionType *FTy, Value *Func, ArrayRef<Value *> Args,
+ const Twine &NameStr, Instruction *InsertBefore,
const DenseMap<BasicBlock *, ColorVector> &BlockColors) {
SmallVector<OperandBundleDef, 1> OpBundles;
if (!BlockColors.empty()) {
@@ -325,7 +325,15 @@ createCallInst(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr,
OpBundles.emplace_back("funclet", EHPad);
}
- return CallInst::Create(Func, Args, OpBundles, NameStr, InsertBefore);
+ return CallInst::Create(FTy, Func, Args, OpBundles, NameStr, InsertBefore);
+}
+
+static CallInst *
+createCallInst(FunctionCallee Func, ArrayRef<Value *> Args, const Twine &NameStr,
+ Instruction *InsertBefore,
+ const DenseMap<BasicBlock *, ColorVector> &BlockColors) {
+ return createCallInst(Func.getFunctionType(), Func.getCallee(), Args, NameStr,
+ InsertBefore, BlockColors);
}
/// Attempt to merge an objc_release with a store, load, and objc_retain to form
@@ -408,7 +416,7 @@ void ObjCARCContract::tryToContractReleaseIntoStoreStrong(
Args[0] = new BitCastInst(Args[0], I8XX, "", Store);
if (Args[1]->getType() != I8X)
Args[1] = new BitCastInst(Args[1], I8X, "", Store);
- Constant *Decl = EP.get(ARCRuntimeEntryPointKind::StoreStrong);
+ Function *Decl = EP.get(ARCRuntimeEntryPointKind::StoreStrong);
CallInst *StoreStrong = createCallInst(Decl, Args, "", Store, BlockColors);
StoreStrong->setDoesNotThrow();
StoreStrong->setDebugLoc(Store->getDebugLoc());
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index 1c1243a230c..bfec15ca9c7 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -829,7 +829,7 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) {
// Create the declaration lazily.
LLVMContext &C = Inst->getContext();
- Constant *Decl = EP.get(ARCRuntimeEntryPointKind::Release);
+ Function *Decl = EP.get(ARCRuntimeEntryPointKind::Release);
CallInst *NewCall = CallInst::Create(Decl, Call->getArgOperand(0), "",
Call);
NewCall->setMetadata(MDKindCache.get(ARCMDKindID::ImpreciseRelease),
@@ -1527,7 +1527,7 @@ void ObjCARCOpt::MoveCalls(Value *Arg, RRInfo &RetainsToMove,
for (Instruction *InsertPt : ReleasesToMove.ReverseInsertPts) {
Value *MyArg = ArgTy == ParamTy ? Arg :
new BitCastInst(Arg, ParamTy, "", InsertPt);
- Constant *Decl = EP.get(ARCRuntimeEntryPointKind::Retain);
+ Function *Decl = EP.get(ARCRuntimeEntryPointKind::Retain);
CallInst *Call = CallInst::Create(Decl, MyArg, "", InsertPt);
Call->setDoesNotThrow();
Call->setTailCall();
@@ -1540,7 +1540,7 @@ void ObjCARCOpt::MoveCalls(Value *Arg, RRInfo &RetainsToMove,
for (Instruction *InsertPt : RetainsToMove.ReverseInsertPts) {
Value *MyArg = ArgTy == ParamTy ? Arg :
new BitCastInst(Arg, ParamTy, "", InsertPt);
- Constant *Decl = EP.get(ARCRuntimeEntryPointKind::Release);
+ Function *Decl = EP.get(ARCRuntimeEntryPointKind::Release);
CallInst *Call = CallInst::Create(Decl, MyArg, "", InsertPt);
// Attach a clang.imprecise_release metadata tag, if appropriate.
if (MDNode *M = ReleasesToMove.ReleaseMetadata)
@@ -1876,7 +1876,7 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) {
Changed = true;
// If the load has a builtin retain, insert a plain retain for it.
if (Class == ARCInstKind::LoadWeakRetained) {
- Constant *Decl = EP.get(ARCRuntimeEntryPointKind::Retain);
+ Function *Decl = EP.get(ARCRuntimeEntryPointKind::Retain);
CallInst *CI = CallInst::Create(Decl, EarlierCall, "", Call);
CI->setTailCall();
}
@@ -1905,7 +1905,7 @@ void ObjCARCOpt::OptimizeWeakCalls(Function &F) {
Changed = true;
// If the load has a builtin retain, insert a plain retain for it.
if (Class == ARCInstKind::LoadWeakRetained) {
- Constant *Decl = EP.get(ARCRuntimeEntryPointKind::Retain);
+ Function *Decl = EP.get(ARCRuntimeEntryPointKind::Retain);
CallInst *CI = CallInst::Create(Decl, EarlierCall, "", Call);
CI->setTailCall();
}
OpenPOWER on IntegriCloud