Go to the documentation of this file.
31 #define DEBUG_TYPE "objc-arc-ptr-state"
40 return OS <<
"S_None";
42 return OS <<
"S_Retain";
44 return OS <<
"S_CanRelease";
48 return OS <<
"S_MovableRelease";
50 return OS <<
"S_Stop";
182 bool NestingDetected =
false;
185 dbgs() <<
" Found nested releases (i.e. a release pair)\n");
186 NestingDetected =
true;
200 return NestingDetected;
257 auto SetSeqAndInsertReverseInsertPt = [&](
Sequence NewSeq){
264 if (isa<InvokeInst>(Inst)) {
265 const auto IP =
BB->getFirstInsertionPt();
266 InsertAfter =
IP ==
BB->end() ? std::prev(
BB->end()) :
IP;
267 if (isa<CatchSwitchInst>(InsertAfter))
276 if (InsertAfter !=
BB->end())
284 if (
auto *CB = dyn_cast<CallBase>(Inst))
292 if (
CanUse(Inst, Ptr, PA, Class)) {
295 SetSeqAndInsertReverseInsertPt(
S_Use);
300 SetSeqAndInsertReverseInsertPt(
S_Stop);
305 if (
CanUse(Inst, Ptr, PA, Class)) {
307 <<
"; " << *Ptr <<
"\n");
325 bool NestingDetected =
false;
338 NestingDetected =
true;
346 return NestingDetected;
361 if (OldSeq ==
S_Retain || ReleaseMetadata !=
nullptr)
422 if (!
CanUse(Inst, Ptr, PA, Class))
ARCInstKind GetBasicARCInstKind(const Value *V)
Determine which objc runtime call instruction class V belongs to.
raw_ostream & operator<<(raw_ostream &OS, const ARCInstKind Class)
bool CanUse(const Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, ARCInstKind Class)
Test whether the given instruction can "use" the given pointer's object in a way that requires the re...
This is an optimization pass for GlobalISel generic memory operations.
bool hasAttachedCallOpBundle(const CallBase *CB)
InstListType::iterator iterator
Instruction iterators...
void SetReleaseMetadata(MDNode *NewValue)
unsigned get(ARCMDKindID ID)
static Sequence MergeSeqs(Sequence A, Sequence B, bool TopDown)
bool Partial
True if we've seen an opportunity for partial RR elimination, such as pushing calls into a CFG triang...
unsigned char Seq
The current position in the sequence.
bool HasReverseInsertPts() const
bool MatchWithRelease(ARCMDKindCache &Cache, Instruction *Release)
Return true if this set of retains can be paired with the given release.
This is similar to BasicAliasAnalysis, and it uses many of the same techniques, except it uses specia...
void SetTailCallRelease(const bool NewValue)
void InsertCall(Instruction *I)
LLVM Basic Block Representation.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void SetKnownPositiveRefCount()
Unidirectional information about either a retain-decrement-use-release sequence or release-use-decrem...
@ RetainRV
objc_retainAutoreleasedReturnValue
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void ResetSequenceProgress(Sequence NewSeq)
bool KnownSafe
After an objc_retain, the reference count of the referenced object is known to be positive.
BasicBlock::iterator skipDebugIntrinsics(BasicBlock::iterator It)
Advance It while it points to a debug instruction and return the result.
void InsertReverseInsertPt(Instruction *I)
This class implements an extremely fast bulk output stream that can only output to a stream.
@ IntrinsicUser
llvm.objc.clang.arc.use
void ClearSequenceProgress()
@ S_Retain
objc_retain(x).
SmallPtrSet< Instruction *, 2 > ReverseInsertPts
The set of optimal insert positions for moving calls in the opposite sequence.
void HandlePotentialUse(Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, ARCInstKind Class)
bool IsTrackingImpreciseReleases() const
@ S_Stop
code motion is stopped.
bool HandlePotentialAlterRefCount(Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, ARCInstKind Class)
void SetCFGHazardAfflicted(const bool NewValue)
void Merge(const PtrState &Other, bool TopDown)
bool IsTailCallRelease
True of the objc_release calls are all marked with the "tail" keyword.
void HandlePotentialUse(BasicBlock *BB, Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, ARCInstKind Class)
@ S_MovableRelease
objc_release(x), !clang.imprecise_release.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
void SetSeq(Sequence NewSeq)
static const Instruction * getreturnRVOperand(const Instruction &Inst, ARCInstKind Class)
If Inst is a ReturnRV and its operand is a call or invoke, return the operand.
bool CFGHazardAfflicted
If this is true, we cannot perform code motion but can still remove retain/release pairs.
A cache of MDKinds used by various ARC optimizations.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MDNode * ReleaseMetadata
If the Calls are objc_release calls and they all have a clang.imprecise_release tag,...
self_iterator getIterator()
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
SmallPtrSet< Instruction *, 2 > Calls
For a top-down sequence, the set of objc_retains or objc_retainBlocks.
bool KnownPositiveRefCount
True if the reference count is known to be incremented.
void ClearReverseInsertPts()
RRInfo RRI
Unidirectional information about the current sequence.
bool MatchWithRetain()
Return true if this set of releases can be paired with a release.
bool contains(const Instruction *I) const
See if an instruction is a bundled retainRV/claimRV call.
bool InitBottomUp(ARCMDKindCache &Cache, Instruction *I)
(Re-)Initialize this bottom up pointer returning true if we detected a pointer with nested releases.
void ClearKnownPositiveRefCount()
void SetKnownSafe(const bool NewValue)
bool CanDecrementRefCount(ARCInstKind Kind)
Returns false if conservatively we can prove that any instruction mapped to this kind can not decreme...
bool HandlePotentialAlterRefCount(Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA, ARCInstKind Class, const BundledRetainClaimRVs &BundledRVs)
@ S_CanRelease
foo(x) – x could possibly see a ref count decrement.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
This class summarizes several per-pointer runtime properties which are propagated through the flow gr...
LLVM Value Representation.
bool HasKnownPositiveRefCount() const
bool Merge(const RRInfo &Other)
Conservatively merge the two RRInfo.
Optional< std::vector< StOtherPiece > > Other
bool InitTopDown(ARCInstKind Kind, Instruction *I)
(Re-)Initialize this bottom up pointer returning true if we detected a pointer with nested releases.