[Inliner] Loop info in the inliner

Hi,
It seems inliner does not take into account if a call is inside a loop. I’m trying to figure out if loop-info can be made available to the inliner.

When I try to add LoopInfoWrapperPass to Inliner.cpp,

diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index 568707d…cb51ea8 100644
— a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//

#include “llvm/Transforms/IPO/InlinerPass.h”
+#include “llvm/Analysis/LoopInfo.h”
#include “llvm/ADT/SmallPtrSet.h”
#include “llvm/ADT/Statistic.h”
#include “llvm/Analysis/AliasAnalysis.h”
@@ -58,6 +59,7 @@ Inliner::Inliner(char &ID, bool InsertLifetime)
void Inliner::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired();
AU.addRequired();

  • AU.addRequired();
    getAAResultsAnalysisUsage(AU);
    CallGraphSCCPass::getAnalysisUsage(AU);

}

I get llvm_unreachable in `void PMDataManager::addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass)’

Thanks,
-Aditya

FYI - There is currently an architectural issue which prevents the SCC pass manager (which runs the inliner) from relying on Function or Loop analysis passes. This is the primary motivation of the pass manager rewrite that Chandler Carruth has been working on for the last two years. He’s getting relatively close to that project being done, but until then you are going to be effectively blocked on this.

Philip

What Philip said.

Also, it is possible to help with the pass manager work by porting individual passes over. There are a number of commits that serve as good examples here.