[PATCH] D28076: [PM] Add support for building a default AA pipeline to the PassBuilder.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 23 12:48:58 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL290449: [PM] Add support for building a default AA pipeline to the PassBuilder. (authored by chandlerc).

Changed prior to commit:
  https://reviews.llvm.org/D28076?vs=82399&id=82417#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28076

Files:
  llvm/trunk/include/llvm/Passes/PassBuilder.h
  llvm/trunk/lib/Passes/PassBuilder.cpp
  llvm/trunk/test/Other/new-pass-manager.ll


Index: llvm/trunk/include/llvm/Passes/PassBuilder.h
===================================================================
--- llvm/trunk/include/llvm/Passes/PassBuilder.h
+++ llvm/trunk/include/llvm/Passes/PassBuilder.h
@@ -224,6 +224,10 @@
   ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level,
                                             bool DebugLogging = false);
 
+  /// Build the default `AAManager` with the default alias analysis pipeline
+  /// registered.
+  AAManager buildDefaultAAPipeline();
+
   /// \brief Parse a textual pass pipeline description into a \c ModulePassManager.
   ///
   /// The format of the textual pass pipeline description looks something like:
Index: llvm/trunk/test/Other/new-pass-manager.ll
===================================================================
--- llvm/trunk/test/Other/new-pass-manager.ll
+++ llvm/trunk/test/Other/new-pass-manager.ll
@@ -312,6 +312,17 @@
 ; CHECK-AA: Finished llvm::Module pass manager run
 
 ; RUN: opt -disable-output -disable-verify -debug-pass-manager %s 2>&1 \
+; RUN:     -passes='require<aa>' -aa-pipeline='default' \
+; RUN:     | FileCheck %s --check-prefix=CHECK-AA-DEFAULT
+; CHECK-AA-DEFAULT: Starting llvm::Module pass manager run
+; CHECK-AA-DEFAULT: Running pass: RequireAnalysisPass
+; CHECK-AA-DEFAULT: Running analysis: AAManager
+; CHECK-AA-DEFAULT: Running analysis: BasicAA
+; CHECK-AA-DEFAULT: Running analysis: ScopedNoAliasAA
+; CHECK-AA-DEFAULT: Running analysis: TypeBasedAA
+; CHECK-AA-DEFAULT: Finished llvm::Module pass manager run
+
+; RUN: opt -disable-output -disable-verify -debug-pass-manager %s 2>&1 \
 ; RUN:     -passes='require<memdep>' \
 ; RUN:     | FileCheck %s --check-prefix=CHECK-MEMDEP
 ; CHECK-MEMDEP: Starting llvm::Module pass manager run
Index: llvm/trunk/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/trunk/lib/Passes/PassBuilder.cpp
+++ llvm/trunk/lib/Passes/PassBuilder.cpp
@@ -544,6 +544,33 @@
   return MPM;
 }
 
+AAManager PassBuilder::buildDefaultAAPipeline() {
+  AAManager AA;
+
+  // The order in which these are registered determines their priority when
+  // being queried.
+
+  // First we register the basic alias analysis that provides the majority of
+  // per-function local AA logic. This is a stateless, on-demand local set of
+  // AA techniques.
+  AA.registerFunctionAnalysis<BasicAA>();
+
+  // Next we query fast, specialized alias analyses that wrap IR-embedded
+  // information about aliasing.
+  AA.registerFunctionAnalysis<ScopedNoAliasAA>();
+  AA.registerFunctionAnalysis<TypeBasedAA>();
+
+  // Add support for querying global aliasing information when available.
+  // Because this is a module analysis this will use any cached analysis state
+  // available but isn't enough to cause it to be available.
+  // FIXME: Enable once the invalidation logic supports this.
+#if 0
+  AA.registerModuleAnalysis<GlobalsAA>();
+#endif
+
+  return AA;
+}
+
 static Optional<int> parseRepeatPassName(StringRef Name) {
   if (!Name.consume_front("repeat<") || !Name.consume_back(">"))
     return None;
@@ -1084,6 +1111,13 @@
 }
 
 bool PassBuilder::parseAAPipeline(AAManager &AA, StringRef PipelineText) {
+  // If the pipeline just consists of the word 'default' just replace the AA
+  // manager with our default one.
+  if (PipelineText == "default") {
+    AA = buildDefaultAAPipeline();
+    return true;
+  }
+
   while (!PipelineText.empty()) {
     StringRef Name;
     std::tie(Name, PipelineText) = PipelineText.split(',');


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28076.82417.patch
Type: text/x-patch
Size: 3551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161223/d8cfc9a1/attachment.bin>


More information about the llvm-commits mailing list