Skip to content

Commit 4c285ab

Browse files
committed
Add test for Legacy PM
1 parent 0b95b09 commit 4c285ab

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

llvm/lib/Analysis/AliasAnalysis.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -750,30 +750,44 @@ bool AAResultsWrapperPass::runOnFunction(Function &F) {
750750

751751
// Add any target-specific alias analyses that should be run early.
752752
auto *ExtWrapperPass = getAnalysisIfAvailable<ExternalAAWrapperPass>();
753-
if (ExtWrapperPass && ExtWrapperPass->runEarly() && ExtWrapperPass->CB)
753+
if (ExtWrapperPass && ExtWrapperPass->runEarly() && ExtWrapperPass->CB) {
754+
LLVM_DEBUG(dbgs() << "AAResults register Early ExternalAA: " << ExtWrapperPass->getPassName() << "\n");
754755
ExtWrapperPass->CB(*this, F, *AAR);
756+
}
755757

756758
// BasicAA is always available for function analyses. Also, we add it first
757759
// so that it can trump TBAA results when it proves MustAlias.
758760
// FIXME: TBAA should have an explicit mode to support this and then we
759761
// should reconsider the ordering here.
760-
if (!DisableBasicAA)
762+
if (!DisableBasicAA) {
763+
LLVM_DEBUG(dbgs() << "AAResults register BasicAA\n");
761764
AAR->addAAResult(getAnalysis<BasicAAWrapperPass>().getResult());
765+
}
762766

763767
// Populate the results with the currently available AAs.
764-
if (auto *WrapperPass = getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>())
768+
if (auto *WrapperPass = getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>()) {
769+
LLVM_DEBUG(dbgs() << "AAResults register ScopedNoAliasAA\n");
765770
AAR->addAAResult(WrapperPass->getResult());
766-
if (auto *WrapperPass = getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
771+
}
772+
if (auto *WrapperPass = getAnalysisIfAvailable<TypeBasedAAWrapperPass>()) {
773+
LLVM_DEBUG(dbgs() << "AAResults register TypeBasedAA\n");
767774
AAR->addAAResult(WrapperPass->getResult());
768-
if (auto *WrapperPass = getAnalysisIfAvailable<GlobalsAAWrapperPass>())
775+
}
776+
if (auto *WrapperPass = getAnalysisIfAvailable<GlobalsAAWrapperPass>()) {
777+
LLVM_DEBUG(dbgs() << "AAResults register GlobalsAA\n");
769778
AAR->addAAResult(WrapperPass->getResult());
770-
if (auto *WrapperPass = getAnalysisIfAvailable<SCEVAAWrapperPass>())
779+
}
780+
if (auto *WrapperPass = getAnalysisIfAvailable<SCEVAAWrapperPass>()) {
781+
LLVM_DEBUG(dbgs() << "AAResults register SCEVAA\n");
771782
AAR->addAAResult(WrapperPass->getResult());
783+
}
772784

773785
// If available, run an external AA providing callback over the results as
774786
// well.
775-
if (ExtWrapperPass && !ExtWrapperPass->runEarly() && ExtWrapperPass->CB)
787+
if (ExtWrapperPass && !ExtWrapperPass->runEarly() && ExtWrapperPass->CB) {
788+
LLVM_DEBUG(dbgs() << "AAResults register Late ExternalAA: " << ExtWrapperPass->getPassName() << "\n");
776789
ExtWrapperPass->CB(*this, F, *AAR);
790+
}
777791

778792
// Analyses don't mutate the IR, so return false.
779793
return false;

llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class NVPTXExternalAAWrapper : public ExternalAAWrapperPass {
9292
P.getAnalysisIfAvailable<NVPTXAAWrapperPass>())
9393
AAR.addAAResult(WrapperPass->getResult());
9494
}) {}
95+
96+
StringRef getPassName() const override { return "NVPTX Address space based Alias Analysis Wrapper"; }
9597
};
9698

9799
ImmutablePass *createNVPTXAAWrapperPass();

llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,7 @@ void NVPTXPassConfig::addIRPasses() {
360360
disablePass(&RemoveLoadsIntoFakeUsesID);
361361

362362
addPass(createNVPTXAAWrapperPass());
363-
addPass(createExternalAAWrapperPass([](Pass &P, Function &, AAResults &AAR) {
364-
if (auto *WrapperPass = P.getAnalysisIfAvailable<NVPTXAAWrapperPass>())
365-
AAR.addAAResult(WrapperPass->getResult());
366-
}));
363+
addPass(createNVPTXExternalAAWrapperPass());
367364

368365
// NVVMReflectPass is added in addEarlyAsPossiblePasses, so hopefully running
369366
// it here does nothing. But since we need it for correctness when lowering

llvm/test/Analysis/NVPTXAA/NVPTXAA_before_BasicAA.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
; REQUIRES: asserts
12
; RUN: opt -aa-pipeline=default -passes='require<aa>' -debug-pass-manager -disable-output -S < %s 2>&1 | FileCheck %s
3+
; RUN: llc --debug-only='aa' -o /dev/null %s 2>&1 | FileCheck %s -check-prefix=LEGACY
24

35
; In default AA pipeline, NVPTXAA should run before BasicAA to reduce compile time for NVPTX backend
46
target triple = "nvptx64-nvidia-cuda"
57

68
; CHECK: Running analysis: NVPTXAA on foo
79
; CHECK-NEXT: Running analysis: BasicAA on foo
10+
11+
; LEGACY: AAResults register Early ExternalAA: NVPTX Address space based Alias Analysis Wrapper
12+
; LEGACY-NEXT: AAResults register BasicAA
813
define void @foo(){
914
entry:
1015
ret void

0 commit comments

Comments
 (0)