40 explicit SimpleCaptureTracker(
bool ReturnCaptures)
41 : ReturnCaptures(ReturnCaptures), Captured(
false) {}
46 if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
66 : OrderedBB(IC), BeforeHere(I), DT(DT),
67 ReturnCaptures(ReturnCaptures), IncludeI(IncludeI), Captured(
false) {}
89 if (isa<InvokeInst>(BeforeHere) || isa<PHINode>(
I) || I == BeforeHere)
91 if (!OrderedBB->dominates(BeforeHere, I))
112 if (BeforeHere != I && DT->
dominates(BeforeHere, I) &&
122 if (BeforeHere == I && !IncludeI)
125 if (isSafeToPrune(I))
132 if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
161 bool ReturnCaptures,
bool StoreCaptures) {
162 assert(!isa<GlobalValue>(V) &&
163 "It doesn't make sense to ask whether a global is captured.");
171 SimpleCaptureTracker SCT(ReturnCaptures);
190 assert(!isa<GlobalValue>(V) &&
191 "It doesn't make sense to ask whether a global is captured.");
192 bool UseNewOBB = OBB ==
nullptr;
202 CapturesBefore CB(ReturnCaptures, I, DT, IncludeI, OBB);
220 auto AddUses = [&](
const Value *V) {
222 for (
const Use &U : V->
uses()) {
227 if (!Visited.
insert(&U).second)
231 Worklist.push_back(&U);
236 while (!Worklist.empty()) {
237 const Use *U = Worklist.pop_back_val();
243 case Instruction::Invoke: {
263 if (
auto *
MI = dyn_cast<MemIntrinsic>(I))
264 if (
MI->isVolatile())
286 if (cast<LoadInst>(I)->isVolatile())
290 case Instruction::VAArg:
300 case Instruction::AtomicRMW: {
306 auto *ARMWI = cast<AtomicRMWInst>(
I);
307 if (ARMWI->getValOperand() == V || ARMWI->isVolatile())
312 case Instruction::AtomicCmpXchg: {
318 auto *ACXI = cast<AtomicCmpXchgInst>(
I);
319 if (ACXI->getCompareOperand() == V || ACXI->getNewValOperand() == V ||
325 case Instruction::BitCast:
326 case Instruction::GetElementPtr:
327 case Instruction::PHI:
329 case Instruction::AddrSpaceCast:
333 case Instruction::ICmp: {
338 dyn_cast<ConstantPointerNull>(I->
getOperand(1)))
339 if (CPN->getType()->getAddressSpace() == 0)
345 unsigned OtherIndex = (I->
getOperand(0) == V) ? 1 : 0;
347 if (LI && isa<GlobalVariable>(LI->getPointerOperand()))
iterator_range< use_iterator > uses()
virtual void tooManyUses()=0
tooManyUses - The depth of traversal has breached a limit.
This callback is used in conjunction with PointerMayBeCaptured.
Compute iterated dominance frontiers using a linear time algorithm.
virtual bool shouldExplore(const Use *U)
shouldExplore - This is the use of a value derived from the pointer.
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
An instruction for reading from memory.
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
virtual ~CaptureTracker()
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
A Use represents the edge between a Value definition and its users.
virtual bool captured(const Use *U)=0
captured - Information about the pointer was captured by the user of use U.
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
IterTy data_operands_end() const
Type * getType() const
All values are typed, get the type of this value.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Value * getOperand(unsigned i) const
Interval::succ_iterator succ_end(Interval *I)
bool isVoidTy() const
Return true if this is 'void'.
const BasicBlock & getEntryBlock() const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM Basic Block Representation.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isPointerTy() const
True if this is an instance of PointerType.
bool isPotentiallyReachable(const Instruction *From, const Instruction *To, const DominatorTree *DT=nullptr, const LoopInfo *LI=nullptr)
Determine whether instruction 'To' is reachable from 'From', returning true if uncertain.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures, bool StoreCaptures)
PointerMayBeCaptured - Return true if this pointer value may be captured by the enclosing function (w...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
A constant pointer value that points to null.
IterTy data_operands_begin() const
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
bool isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(ImmutableCallSite CS)
const Function * getParent() const
Return the enclosing method, or null if none.
bool doesNotThrow() const
Determine if the call cannot unwind.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, bool StoreCaptures, const Instruction *I, const DominatorTree *DT, bool IncludeI=false, OrderedBasicBlock *OBB=nullptr)
PointerMayBeCapturedBefore - Return true if this pointer value may be captured by the enclosing funct...
static int const Threshold
TODO: Write a new FunctionPass AliasAnalysis so that it can keep a cache.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
LLVM Value Representation.
static bool isVolatile(Instruction *Inst)
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
bool isPotentiallyReachableFromMany(SmallVectorImpl< BasicBlock *> &Worklist, BasicBlock *StopBB, const DominatorTree *DT=nullptr, const LoopInfo *LI=nullptr)
Determine whether there is at least one path from a block in 'Worklist' to 'StopBB', returning true if uncertain.
const BasicBlock * getParent() const