Skip to content

Commit fd9722f

Browse files
committed
[AliasSetTracker] Misc cleanup (NFCI)
Summary: Remove two redundant checks, add one in the unit test. Remove an unused method. Fix computation of TotalMayAliasSetSize. llvm-svn: 345911
1 parent d5779da commit fd9722f

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

llvm/include/llvm/Analysis/AliasSetTracker.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,6 @@ class AliasSetTracker {
389389
/// set is returned.
390390
AliasSet &getAliasSetFor(const MemoryLocation &MemLoc);
391391

392-
/// Return true if the specified instruction "may" (or must) alias one of the
393-
/// members in any of the sets.
394-
bool containsUnknown(const Instruction *I) const;
395-
396392
/// Return the underlying alias analysis object used by this tracker.
397393
AliasAnalysis &getAliasAnalysis() const { return AA; }
398394

llvm/lib/Analysis/AliasSetTracker.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ void AliasSetTracker::removeAliasSet(AliasSet *AS) {
114114
if (AliasSet *Fwd = AS->Forward) {
115115
Fwd->dropRef(*this);
116116
AS->Forward = nullptr;
117-
}
118-
119-
if (AS->Alias == AliasSet::SetMayAlias)
120-
TotalMayAliasSetSize -= AS->size();
117+
} else // Update TotalMayAliasSetSize only if not forwarding.
118+
if (AS->Alias == AliasSet::SetMayAlias)
119+
TotalMayAliasSetSize -= AS->size();
121120

122121
AliasSets.erase(AS);
123122
}
@@ -232,8 +231,8 @@ bool AliasSet::aliasesUnknownInst(const Instruction *Inst,
232231
if (AliasAny)
233232
return true;
234233

235-
if (!Inst->mayReadOrWriteMemory())
236-
return false;
234+
assert(Inst->mayReadOrWriteMemory() &&
235+
"Instruction must either read or write memory.");
237236

238237
for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) {
239238
if (auto *UnknownInst = getUnknownInst(i)) {
@@ -311,13 +310,6 @@ AliasSet *AliasSetTracker::mergeAliasSetsForPointer(const Value *Ptr,
311310
return FoundSet;
312311
}
313312

314-
bool AliasSetTracker::containsUnknown(const Instruction *Inst) const {
315-
for (const AliasSet &AS : *this)
316-
if (!AS.Forward && AS.aliasesUnknownInst(Inst, AA))
317-
return true;
318-
return false;
319-
}
320-
321313
AliasSet *AliasSetTracker::findAliasSetForUnknownInst(Instruction *Inst) {
322314
AliasSet *FoundSet = nullptr;
323315
for (iterator I = begin(), E = end(); I != E;) {
@@ -326,7 +318,7 @@ AliasSet *AliasSetTracker::findAliasSetForUnknownInst(Instruction *Inst) {
326318
continue;
327319
if (!FoundSet) // If this is the first alias set ptr can go into.
328320
FoundSet = &*Cur; // Remember it.
329-
else if (!Cur->Forward) // Otherwise, we must merge the sets.
321+
else // Otherwise, we must merge the sets.
330322
FoundSet->mergeSetIn(*Cur, *this); // Merge in contents.
331323
}
332324
return FoundSet;

llvm/unittests/Analysis/AliasSetTrackerTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ TEST(AliasSetTracker, AliasUnknownInst) {
7878
for (auto &Inst : *Test->begin()) {
7979
bool FoundAS = false;
8080
for (AliasSet &AS : AST) {
81+
if (!Inst.mayReadOrWriteMemory())
82+
continue;
8183
if (!AS.aliasesUnknownInst(&Inst, AA))
8284
continue;
8385
ASSERT_NE(FoundAS, true);

0 commit comments

Comments
 (0)