Skip to content

Commit 7dc0ba9

Browse files
authored
[LoopInfo][NewPM] Print function name in LoopPrinterPass (#76527)
The legacy pass manager printed the function name when printing loop info (via -analyze option). Like this: Printing analysis 'Natural Loop Information' for function 'func': Loop at depth 1 containing: ... Loop at depth 2 containing: ... Make sure we print such a first line including the function name also when using the new pass manager version of LoopPrinterPass. The format of the string is changed slightly, so now we say: Loop info for function 'func': Loop at depth 1 containing: ... Loop at depth 2 containing: ... This was originally requested in https://discourse.llvm.org/t/need-usage-help-w-new-pass-manager-for-opt-analysis-natural-loop-information/75874/7 and also mentioned in #76762
1 parent 11a702d commit 7dc0ba9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

llvm/lib/Analysis/LoopInfo.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,9 @@ LoopInfo LoopAnalysis::run(Function &F, FunctionAnalysisManager &AM) {
969969

970970
PreservedAnalyses LoopPrinterPass::run(Function &F,
971971
FunctionAnalysisManager &AM) {
972-
AM.getResult<LoopAnalysis>(F).print(OS);
972+
auto &LI = AM.getResult<LoopAnalysis>(F);
973+
OS << "Loop info for function '" << F.getName() << "':\n";
974+
LI.print(OS);
973975
return PreservedAnalyses::all();
974976
}
975977

llvm/test/Analysis/LoopInfo/annotated-parallel-simple.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ for.end:
3333
!7 = distinct !{!7, !9} ; LoopID
3434
!9 = !{!"llvm.loop.parallel_accesses", !6}
3535

36-
37-
; CHECK: Parallel Loop
36+
; CHECK: Loop info for function 'func':
37+
; CHECK: Parallel Loop at depth 1 containing:

0 commit comments

Comments
 (0)