aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/tools/opt/NewPMDriver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/opt/NewPMDriver.cpp')
-rw-r--r--contrib/llvm/tools/opt/NewPMDriver.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/contrib/llvm/tools/opt/NewPMDriver.cpp b/contrib/llvm/tools/opt/NewPMDriver.cpp
index 3030d65743af..f7b2f18d09d9 100644
--- a/contrib/llvm/tools/opt/NewPMDriver.cpp
+++ b/contrib/llvm/tools/opt/NewPMDriver.cpp
@@ -15,7 +15,9 @@
#include "NewPMDriver.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CGSCCPassManager.h"
+#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRPrintingPasses.h"
@@ -36,6 +38,15 @@ static cl::opt<bool>
DebugPM("debug-pass-manager", cl::Hidden,
cl::desc("Print pass management debugging information"));
+// This flag specifies a textual description of the alias analysis pipeline to
+// use when querying for aliasing information. It only works in concert with
+// the "passes" flag above.
+static cl::opt<std::string>
+ AAPipeline("aa-pipeline",
+ cl::desc("A textual description of the alias analysis "
+ "pipeline for handling managed aliasing queries"),
+ cl::Hidden);
+
bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
TargetMachine *TM, tool_output_file *Out,
StringRef PassPipeline, OutputKind OK,
@@ -44,22 +55,28 @@ bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
bool ShouldPreserveBitcodeUseListOrder) {
PassBuilder PB(TM);
+ // Specially handle the alias analysis manager so that we can register
+ // a custom pipeline of AA passes with it.
+ AAManager AA;
+ if (!PB.parseAAPipeline(AA, AAPipeline)) {
+ errs() << Arg0 << ": unable to parse AA pipeline description.\n";
+ return false;
+ }
+
+ LoopAnalysisManager LAM(DebugPM);
FunctionAnalysisManager FAM(DebugPM);
CGSCCAnalysisManager CGAM(DebugPM);
ModuleAnalysisManager MAM(DebugPM);
+ // Register the AA manager first so that our version is the one used.
+ FAM.registerPass([&] { return std::move(AA); });
+
// Register all the basic analyses with the managers.
PB.registerModuleAnalyses(MAM);
PB.registerCGSCCAnalyses(CGAM);
PB.registerFunctionAnalyses(FAM);
-
- // Cross register the analysis managers through their proxies.
- MAM.registerPass(FunctionAnalysisManagerModuleProxy(FAM));
- MAM.registerPass(CGSCCAnalysisManagerModuleProxy(CGAM));
- CGAM.registerPass(FunctionAnalysisManagerCGSCCProxy(FAM));
- CGAM.registerPass(ModuleAnalysisManagerCGSCCProxy(MAM));
- FAM.registerPass(CGSCCAnalysisManagerFunctionProxy(CGAM));
- FAM.registerPass(ModuleAnalysisManagerFunctionProxy(MAM));
+ PB.registerLoopAnalyses(LAM);
+ PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
ModulePassManager MPM(DebugPM);
if (VK > VK_NoVerifier)
@@ -92,7 +109,7 @@ bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
cl::PrintOptionValues();
// Now that we have all of the passes ready, run them.
- MPM.run(M, &MAM);
+ MPM.run(M, MAM);
// Declare success.
if (OK != OK_NoOutput)