Skip to content

[Kaleidoscope] Switch to the new PassManager. #69032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2023
Merged

Conversation

Logikable
Copy link
Contributor

Using the new pass manager is more verbose; let me know if the tutorial doesn't flow well with all the additions.

@alinas alinas requested review from nikic, alinas and aeubanks October 13, 2023 22:19
Copy link
Contributor

@aeubanks aeubanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good with one suggestion

@aeubanks aeubanks merged commit 7b94744 into llvm:main Oct 18, 2023
Logikable added a commit to Logikable/llvm-project that referenced this pull request Oct 18, 2023
aeubanks pushed a commit that referenced this pull request Oct 18, 2023
Broke https://lab.llvm.org/buildbot/#/builders/181/builds/24470.

Could we build the example/tutorial code in the submit checks? This
breakage wasn't caught at submit time.
aemerson added a commit that referenced this pull request Nov 13, 2023
This reverts commit 7b94744.

This breaks the expensive checks bot: https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/26026/

We didn't notice because it was broken for other reasons I think.
@aemerson
Copy link
Contributor

I reverted this because it was breaking the expensive checks bot: https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/26026/

I know it's been a while but it's only just come to our attention as it was probably failing for a different reason as well, and since this is just the examples I'd like to revert to green.

I tried a quick go at fixing it but the only way I could get one to work was to do this:

diff --git a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
index 19ec70efd5e1..81f58d4f023c 100644
--- a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp
@@ -426,8 +426,10 @@ static std::unique_ptr<IRBuilder<>> Builder;
 static std::map<std::string, Value *> NamedValues;
 static std::unique_ptr<KaleidoscopeJIT> TheJIT;
 static std::unique_ptr<FunctionPassManager> TheFPM;
+static std::unique_ptr<LoopAnalysisManager> TheLAM;
 static std::unique_ptr<FunctionAnalysisManager> TheFAM;
 static std::unique_ptr<ModuleAnalysisManager> TheMAM;
+static std::unique_ptr<CGSCCAnalysisManager> TheCGAM;
 static std::unique_ptr<PassInstrumentationCallbacks> ThePIC;
 static std::unique_ptr<StandardInstrumentations> TheSI;
 static std::map<std::string, std::unique_ptr<PrototypeAST>> FunctionProtos;
@@ -575,8 +577,10 @@ static void InitializeModuleAndManagers() {
 
   // Create new pass and analysis managers.
   TheFPM = std::make_unique<FunctionPassManager>();
+  TheLAM = std::make_unique<LoopAnalysisManager>();
   TheFAM = std::make_unique<FunctionAnalysisManager>();
   TheMAM = std::make_unique<ModuleAnalysisManager>();
+  TheCGAM = std::make_unique<CGSCCAnalysisManager>();
   ThePIC = std::make_unique<PassInstrumentationCallbacks>();
   TheSI = std::make_unique<StandardInstrumentations>(*TheContext,
                                                      /*DebugLogging*/ true);
@@ -592,23 +596,11 @@ static void InitializeModuleAndManagers() {
   // Simplify the control flow graph (deleting unreachable blocks, etc).
   TheFPM->addPass(SimplifyCFGPass());
 
+  PassBuilder PB;
   // Register analysis passes used in these transform passes.
-  TheFAM->registerPass([&] { return AAManager(); });
-  TheFAM->registerPass([&] { return AssumptionAnalysis(); });
-  TheFAM->registerPass([&] { return DominatorTreeAnalysis(); });
-  TheFAM->registerPass([&] { return LoopAnalysis(); });
-  TheFAM->registerPass([&] { return MemoryDependenceAnalysis(); });
-  TheFAM->registerPass([&] { return MemorySSAAnalysis(); });
-  TheFAM->registerPass([&] { return OptimizationRemarkEmitterAnalysis(); });
-  TheFAM->registerPass([&] {
-    return OuterAnalysisManagerProxy<ModuleAnalysisManager, Function>(*TheMAM);
-  });
-  TheFAM->registerPass(
-      [&] { return PassInstrumentationAnalysis(ThePIC.get()); });
-  TheFAM->registerPass([&] { return TargetIRAnalysis(); });
-  TheFAM->registerPass([&] { return TargetLibraryAnalysis(); });
-
-  TheMAM->registerPass([&] { return ProfileSummaryAnalysis(); });
+  PB.registerModuleAnalyses(*TheMAM);
+  PB.registerFunctionAnalyses(*TheFAM);
+  PB.crossRegisterProxies(*TheLAM, *TheFAM, *TheCGAM, *TheMAM);
 }
 
 static void HandleDefinition() {

but I'm not sure what the right solution is.

@aeubanks
Copy link
Contributor

grepping getResult() in instcombine perhaps we're missing

  FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); });

aeubanks pushed a commit that referenced this pull request Nov 16, 2023
Rollforward of #69032, which was reverted in
[63d19cf](63d19cf).

New: implemented changes in
#69032 (comment).
Given the PassBuilder is how we expect users to register passes, the
tutorial should reflect that.
sr-tream pushed a commit to sr-tream/llvm-project that referenced this pull request Nov 20, 2023
Rollforward of llvm#69032, which was reverted in
[63d19cf](llvm@63d19cf).

New: implemented changes in
llvm#69032 (comment).
Given the PassBuilder is how we expect users to register passes, the
tutorial should reflect that.
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
This reverts commit 7b94744.

This breaks the expensive checks bot: https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/26026/

We didn't notice because it was broken for other reasons I think.
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
Rollforward of llvm#69032, which was reverted in
[63d19cf](llvm@63d19cf).

New: implemented changes in
llvm#69032 (comment).
Given the PassBuilder is how we expect users to register passes, the
tutorial should reflect that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants