[llvm] [AA] Move Target Specific AA before BasicAA (PR #125965)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 29 11:35:07 PDT 2025


================
@@ -748,28 +748,49 @@ bool AAResultsWrapperPass::runOnFunction(Function &F) {
   AAR.reset(
       new AAResults(getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F)));
 
+  // Add any target-specific alias analyses that should be run early.
+  auto *ExtWrapperPass = getAnalysisIfAvailable<ExternalAAWrapperPass>();
+  if (ExtWrapperPass && ExtWrapperPass->runEarly() && ExtWrapperPass->CB) {
+    LLVM_DEBUG(dbgs() << "AAResults register Early ExternalAA: "
+                      << ExtWrapperPass->getPassName() << "\n");
+    ExtWrapperPass->CB(*this, F, *AAR);
+  }
+
   // BasicAA is always available for function analyses. Also, we add it first
   // so that it can trump TBAA results when it proves MustAlias.
   // FIXME: TBAA should have an explicit mode to support this and then we
   // should reconsider the ordering here.
-  if (!DisableBasicAA)
+  if (!DisableBasicAA) {
+    LLVM_DEBUG(dbgs() << "AAResults register BasicAA\n");
----------------
Chengjunp wrote:

Yeah. I do not find a good way to test the change in Legacy pass manager, so I have these debug outputs. These outputs are also helpful when I'm making the change for NVPTX AA. Do you have any suggestions for doing the test?

https://github.com/llvm/llvm-project/pull/125965


More information about the llvm-commits mailing list