forked from OSchip/llvm-project
[BasicAA] Only add visited phi blocks temporarily
Visited phi blocks only need to be added for the duration of the recursive alias queries, they should not leak into following code. Once again, while this also improves analysis precision, this is mainly intended to clarify the applicability scope of VisitedPhiBBs.
This commit is contained in:
parent
0ba9843397
commit
1882568fcb
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "llvm/Analysis/BasicAliasAnalysis.h"
|
||||
#include "llvm/ADT/APInt.h"
|
||||
#include "llvm/ADT/ScopeExit.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
|
@ -814,7 +815,7 @@ AliasResult BasicAAResult::alias(const MemoryLocation &LocA,
|
|||
AliasResult Alias = aliasCheck(LocA.Ptr, LocA.Size, LocA.AATags, LocB.Ptr,
|
||||
LocB.Size, LocB.AATags, AAQI);
|
||||
|
||||
VisitedPhiBBs.clear();
|
||||
assert(VisitedPhiBBs.empty());
|
||||
return Alias;
|
||||
}
|
||||
|
||||
|
@ -1654,7 +1655,11 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
|
|||
// In the recursive alias queries below, we may compare values from two
|
||||
// different loop iterations. Keep track of visited phi blocks, which will
|
||||
// be used when determining value equivalence.
|
||||
VisitedPhiBBs.insert(PN->getParent());
|
||||
auto Pair = VisitedPhiBBs.insert(PN->getParent());
|
||||
auto _ = make_scope_exit([&]() {
|
||||
if (Pair.second)
|
||||
VisitedPhiBBs.erase(PN->getParent());
|
||||
});
|
||||
|
||||
AliasResult Alias = aliasCheck(V2, V2Size, V2AAInfo, V1Srcs[0], PNSize,
|
||||
PNAAInfo, AAQI, UnderV2);
|
||||
|
|
|
@ -116,7 +116,7 @@ end:
|
|||
}
|
||||
|
||||
; CHECK-LABEL: phi_and_select
|
||||
; CHECK: MayAlias: i32* %p, i32* %s
|
||||
; CHECK: MustAlias: i32* %p, i32* %s
|
||||
define void @phi_and_select(i1 %c, i1 %c2, i32* %x, i32* %y) {
|
||||
entry:
|
||||
br i1 %c, label %true, label %false
|
||||
|
|
Loading…
Reference in New Issue