diff --git a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h --- a/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h +++ b/llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h @@ -28,7 +28,6 @@ #include "llvm/Analysis/ObjCARCInstKind.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/ValueTracking.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constants.h" #include "llvm/IR/InstIterator.h" #include "llvm/IR/LLVMContext.h" @@ -191,13 +190,12 @@ /// Helper for GetARCInstKind. Determines what kind of construct CS /// is. -inline ARCInstKind GetCallSiteClass(ImmutableCallSite CS) { - for (ImmutableCallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); - I != E; ++I) +inline ARCInstKind GetCallSiteClass(const CallBase &CB) { + for (auto I = CB.arg_begin(), E = CB.arg_end(); I != E; ++I) if (IsPotentialRetainableObjPtr(*I)) - return CS.onlyReadsMemory() ? ARCInstKind::User : ARCInstKind::CallOrUser; + return CB.onlyReadsMemory() ? ARCInstKind::User : ARCInstKind::CallOrUser; - return CS.onlyReadsMemory() ? ARCInstKind::None : ARCInstKind::Call; + return CB.onlyReadsMemory() ? ARCInstKind::None : ARCInstKind::Call; } /// Return true if this value refers to a distinct and identifiable diff --git a/llvm/lib/Analysis/ObjCARCInstKind.cpp b/llvm/lib/Analysis/ObjCARCInstKind.cpp --- a/llvm/lib/Analysis/ObjCARCInstKind.cpp +++ b/llvm/lib/Analysis/ObjCARCInstKind.cpp @@ -234,11 +234,11 @@ } // Otherwise, be conservative. - return GetCallSiteClass(CI); + return GetCallSiteClass(*CI); } case Instruction::Invoke: // Otherwise, be conservative. - return GetCallSiteClass(cast(I)); + return GetCallSiteClass(cast(*I)); case Instruction::BitCast: case Instruction::GetElementPtr: case Instruction::Select: diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCAPElim.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCAPElim.cpp --- a/llvm/lib/Transforms/ObjCARC/ObjCARCAPElim.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCAPElim.cpp @@ -41,7 +41,7 @@ void getAnalysisUsage(AnalysisUsage &AU) const override; bool runOnModule(Module &M) override; - static bool MayAutorelease(ImmutableCallSite CS, unsigned Depth = 0); + static bool MayAutorelease(const CallBase &CB, unsigned Depth = 0); static bool OptimizeBB(BasicBlock *BB); public: @@ -68,18 +68,17 @@ /// Interprocedurally determine if calls made by the given call site can /// possibly produce autoreleases. -bool ObjCARCAPElim::MayAutorelease(ImmutableCallSite CS, unsigned Depth) { - if (const Function *Callee = CS.getCalledFunction()) { +bool ObjCARCAPElim::MayAutorelease(const CallBase &CB, unsigned Depth) { + if (const Function *Callee = CB.getCalledFunction()) { if (!Callee->hasExactDefinition()) return true; for (const BasicBlock &BB : *Callee) { for (const Instruction &I : BB) - if (ImmutableCallSite JCS = ImmutableCallSite(&I)) + if (const CallBase *JCB = dyn_cast(&I)) // This recursion depth limit is arbitrary. It's just great // enough to cover known interesting testcases. - if (Depth < 3 && - !JCS.onlyReadsMemory() && - MayAutorelease(JCS, Depth + 1)) + if (Depth < 3 && !JCB->onlyReadsMemory() && + MayAutorelease(*JCB, Depth + 1)) return true; } return false; @@ -115,7 +114,7 @@ Push = nullptr; break; case ARCInstKind::CallOrUser: - if (MayAutorelease(ImmutableCallSite(Inst))) + if (MayAutorelease(cast(*Inst))) Push = nullptr; break; default: diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp --- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -43,7 +43,6 @@ #include "llvm/Analysis/ObjCARCInstKind.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CFG.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" @@ -610,8 +609,7 @@ ObjCARCOpt::OptimizeRetainRVCall(Function &F, Instruction *RetainRV) { // Check for the argument being from an immediately preceding call or invoke. const Value *Arg = GetArgRCIdentityRoot(RetainRV); - ImmutableCallSite CS(Arg); - if (const Instruction *Call = CS.getInstruction()) { + if (const Instruction *Call = dyn_cast(Arg)) { if (Call->getParent() == RetainRV->getParent()) { BasicBlock::const_iterator I(Call); ++I; diff --git a/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp b/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp --- a/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp @@ -25,7 +25,6 @@ #include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/IR/CFG.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Function.h" #include "llvm/IR/Module.h" @@ -286,8 +285,7 @@ // what they are doing and don't add any more. for (auto &I : *BB) { if (isa(&I) || isa(&I)) { - ImmutableCallSite CS(&I); - if (const Function *F = CS.getCalledFunction()) { + if (const Function *F = cast(I).getCalledFunction()) { if (F->getIntrinsicID() == Intrinsic::prefetch) return MadeChange; if (TTI->isLoweredToCall(F)) diff --git a/llvm/lib/Transforms/Scalar/SpeculateAroundPHIs.cpp b/llvm/lib/Transforms/Scalar/SpeculateAroundPHIs.cpp --- a/llvm/lib/Transforms/Scalar/SpeculateAroundPHIs.cpp +++ b/llvm/lib/Transforms/Scalar/SpeculateAroundPHIs.cpp @@ -14,7 +14,6 @@ #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/BasicBlock.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" @@ -68,8 +67,8 @@ return false; } - if (auto CS = ImmutableCallSite(UI)) { - if (CS.isConvergent() || CS.cannotDuplicate()) { + if (const auto *CS = dyn_cast(UI)) { + if (CS->isConvergent() || CS->cannotDuplicate()) { LLVM_DEBUG(dbgs() << " Unsafe: convergent " "callsite cannot de duplicated: " << *UI << '\n'); return false;