[llvm] [StandardInstrumentation] Annotate loops with the function name (PR #90756)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 11:20:04 PDT 2024


https://github.com/annamthomas created https://github.com/llvm/llvm-project/pull/90756

When analyzing pass debug output it is helpful to have the function name along with the loop name.

>From f6f069087cd904e2d24b645ed576e21c8d037b77 Mon Sep 17 00:00:00 2001
From: Anna Thomas <anna at azul.com>
Date: Wed, 1 May 2024 14:17:10 -0400
Subject: [PATCH] [StandardInstrumentation] Annotate loops with the function
 name

When analyzing pass debug output it is helpful to have the function name
along with the loop name.
---
 llvm/lib/Passes/StandardInstrumentations.cpp                  | 3 ++-
 llvm/test/Transforms/LoopPredication/invalidate-analyses.ll   | 4 ++--
 .../nontrivial-unswitch-markloopasdeleted.ll                  | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index 63490c83e85f05..990ace8b04f87b 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -245,7 +245,8 @@ std::string getIRName(Any IR) {
     return C->getName();
 
   if (const auto *L = unwrapIR<Loop>(IR))
-    return L->getName().str();
+    return "Loop: [ " + L->getName().str() + " ] In Function: [ " +
+           L->getHeader()->getParent()->getName().str() + " ]";
 
   if (const auto *MF = unwrapIR<MachineFunction>(IR))
     return MF->getName().str();
diff --git a/llvm/test/Transforms/LoopPredication/invalidate-analyses.ll b/llvm/test/Transforms/LoopPredication/invalidate-analyses.ll
index 7afacd564939b5..b3eb345e1ba6cd 100644
--- a/llvm/test/Transforms/LoopPredication/invalidate-analyses.ll
+++ b/llvm/test/Transforms/LoopPredication/invalidate-analyses.ll
@@ -5,10 +5,10 @@
 ;       please update this test some other analysis that isn't preserved.
 
 ; CHECK: Running analysis: LazyValueAnalysis on drop_a_wc_and_leave_early
-; CHECK: Running pass: LoopPredicationPass on loop
+; CHECK: Running pass: LoopPredicationPass on Loop: [ loop ] In Function: [ drop_a_wc_and_leave_early ] 
 ; CHECK: Invalidating analysis: LazyValueAnalysis on drop_a_wc_and_leave_early
 ; CHECK: Running analysis: LazyValueAnalysis on drop_a_wc_and_leave
-; CHECK: Running pass: LoopPredicationPass on loop
+; CHECK: Running pass: LoopPredicationPass on Loop: [ loop ] In Function: [ drop_a_wc_and_leave ] 
 ; CHECK: Invalidating analysis: LazyValueAnalysis on drop_a_wc_and_leave
 
 
diff --git a/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll b/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
index c8e1291b9cd55c..e47b76f58833b3 100644
--- a/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
+++ b/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
@@ -17,9 +17,9 @@
 ; SimpleLoopUnswitch not marking the Loop as removed, so we missed clearing
 ; the analysis caches.
 ;
-; CHECK: Running pass: SimpleLoopUnswitchPass on loop_begin
+; CHECK: Running pass: SimpleLoopUnswitchPass on Loop: [ loop_begin ] In Function: [ test6 ]
 ; CHECK-NEXT: Running analysis: OuterAnalysisManagerProxy
-; CHECK-NEXT: Clearing all analysis results for: loop_a_inner
+; CHECK-NEXT: Clearing all analysis results for: Loop [ loop_a_inner ] In Function: [ test6 ]
 
 
 ; When running loop-distribute the second time we can see that loop_a_inner



More information about the llvm-commits mailing list