Skip to content

Commit 3bfd1f0

Browse files
committed
[AA] Make LI and EphValues option in EarliestEscapeInfo (NFC)
To allow using it in places where these may not be available.
1 parent b6ecdf0 commit 3bfd1f0

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

llvm/include/llvm/Analysis/AliasAnalysis.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class SimpleCaptureInfo final : public CaptureInfo {
172172
/// approximation to a precise "captures before" analysis.
173173
class EarliestEscapeInfo final : public CaptureInfo {
174174
DominatorTree &DT;
175-
const LoopInfo &LI;
175+
const LoopInfo *LI;
176176

177177
/// Map from identified local object to an instruction before which it does
178178
/// not escape, or nullptr if it never escapes. The "earliest" instruction
@@ -184,11 +184,11 @@ class EarliestEscapeInfo final : public CaptureInfo {
184184
/// This is used for cache invalidation purposes.
185185
DenseMap<Instruction *, TinyPtrVector<const Value *>> Inst2Obj;
186186

187-
const SmallPtrSetImpl<const Value *> &EphValues;
187+
const SmallPtrSetImpl<const Value *> *EphValues;
188188

189189
public:
190-
EarliestEscapeInfo(DominatorTree &DT, const LoopInfo &LI,
191-
const SmallPtrSetImpl<const Value *> &EphValues)
190+
EarliestEscapeInfo(DominatorTree &DT, const LoopInfo *LI = nullptr,
191+
const SmallPtrSetImpl<const Value *> *EphValues = nullptr)
192192
: DT(DT), LI(LI), EphValues(EphValues) {}
193193

194194
bool isNotCapturedBeforeOrAt(const Value *Object,

llvm/include/llvm/Analysis/CaptureTracking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace llvm {
8383
Instruction *
8484
FindEarliestCapture(const Value *V, Function &F, bool ReturnCaptures,
8585
bool StoreCaptures, const DominatorTree &DT,
86-
const SmallPtrSetImpl<const Value *> &EphValues,
86+
const SmallPtrSetImpl<const Value *> *EphValues = nullptr,
8787
unsigned MaxUsesToExplore = 0);
8888

8989
/// This callback is used in conjunction with PointerMayBeCaptured. In

llvm/lib/Analysis/BasicAliasAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ bool EarliestEscapeInfo::isNotCapturedBeforeOrAt(const Value *Object,
219219
return true;
220220

221221
return I != Iter.first->second &&
222-
!isPotentiallyReachable(Iter.first->second, I, nullptr, &DT, &LI);
222+
!isPotentiallyReachable(Iter.first->second, I, nullptr, &DT, LI);
223223
}
224224

225225
void EarliestEscapeInfo::removeInstruction(Instruction *I) {

llvm/lib/Analysis/CaptureTracking.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ namespace {
167167
struct EarliestCaptures : public CaptureTracker {
168168

169169
EarliestCaptures(bool ReturnCaptures, Function &F, const DominatorTree &DT,
170-
const SmallPtrSetImpl<const Value *> &EphValues)
170+
const SmallPtrSetImpl<const Value *> *EphValues)
171171
: EphValues(EphValues), DT(DT), ReturnCaptures(ReturnCaptures), F(F) {}
172172

173173
void tooManyUses() override {
@@ -180,7 +180,7 @@ namespace {
180180
if (isa<ReturnInst>(I) && !ReturnCaptures)
181181
return false;
182182

183-
if (EphValues.contains(I))
183+
if (EphValues && EphValues->contains(I))
184184
return false;
185185

186186
if (!EarliestCapture)
@@ -194,7 +194,7 @@ namespace {
194194
return false;
195195
}
196196

197-
const SmallPtrSetImpl<const Value *> &EphValues;
197+
const SmallPtrSetImpl<const Value *> *EphValues;
198198

199199
Instruction *EarliestCapture = nullptr;
200200

@@ -286,8 +286,7 @@ bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
286286
Instruction *
287287
llvm::FindEarliestCapture(const Value *V, Function &F, bool ReturnCaptures,
288288
bool StoreCaptures, const DominatorTree &DT,
289-
290-
const SmallPtrSetImpl<const Value *> &EphValues,
289+
const SmallPtrSetImpl<const Value *> *EphValues,
291290
unsigned MaxUsesToExplore) {
292291
assert(!isa<GlobalValue>(V) &&
293292
"It doesn't make sense to ask whether a global is captured.");

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ struct DSEState {
865865
DSEState(Function &F, AliasAnalysis &AA, MemorySSA &MSSA, DominatorTree &DT,
866866
PostDominatorTree &PDT, AssumptionCache &AC,
867867
const TargetLibraryInfo &TLI, const LoopInfo &LI)
868-
: F(F), AA(AA), EI(DT, LI, EphValues), BatchAA(AA, &EI), MSSA(MSSA),
868+
: F(F), AA(AA), EI(DT, &LI, &EphValues), BatchAA(AA, &EI), MSSA(MSSA),
869869
DT(DT), PDT(PDT), TLI(TLI), DL(F.getParent()->getDataLayout()), LI(LI) {
870870
// Collect blocks with throwing instructions not modeled in MemorySSA and
871871
// alloc-like objects.

0 commit comments

Comments
 (0)