[llvm] 92ed7e2 - [CodeGen][PM] Use errs() instead of dbgs() in printer passes (#118469)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 22:51:37 PST 2024


Author: Akshat Oke
Date: 2024-12-04T12:21:33+05:30
New Revision: 92ed7e292443de1d89754a59a533ded160d544eb

URL: https://github.com/llvm/llvm-project/commit/92ed7e292443de1d89754a59a533ded160d544eb
DIFF: https://github.com/llvm/llvm-project/commit/92ed7e292443de1d89754a59a533ded160d544eb.diff

LOG: [CodeGen][PM] Use errs() instead of dbgs() in printer passes (#118469)

Printing passes is not exactly a debug activity, it is used in release (and dbgs() is errs() in release)

Added: 
    

Modified: 
    llvm/include/llvm/Passes/MachinePassRegistry.def
    llvm/lib/Passes/PassRegistry.def

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Passes/MachinePassRegistry.def b/llvm/include/llvm/Passes/MachinePassRegistry.def
index 437ec39beb040e..614e36cfbd1a04 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -28,7 +28,7 @@ MODULE_PASS("global-merge", GlobalMergePass(TM, GlobalMergeOptions()))
 MODULE_PASS("jmc-instrumenter", JMCInstrumenterPass())
 MODULE_PASS("lower-emutls", LowerEmuTLSPass())
 MODULE_PASS("pre-isel-intrinsic-lowering", PreISelIntrinsicLoweringPass())
-MODULE_PASS("print<regusage>", PhysicalRegisterUsageInfoPrinterPass(dbgs()))
+MODULE_PASS("print<regusage>", PhysicalRegisterUsageInfoPrinterPass(errs()))
 MODULE_PASS("shadow-stack-gc-lowering", ShadowStackGCLoweringPass())
 MODULE_PASS("global-merge-func", GlobalMergeFuncPass())
 #undef MODULE_PASS
@@ -146,19 +146,19 @@ MACHINE_FUNCTION_PASS("opt-phis", OptimizePHIsPass())
 MACHINE_FUNCTION_PASS("peephole-opt", PeepholeOptimizerPass())
 MACHINE_FUNCTION_PASS("phi-node-elimination", PHIEliminationPass())
 MACHINE_FUNCTION_PASS("print", PrintMIRPass())
-MACHINE_FUNCTION_PASS("print<live-intervals>", LiveIntervalsPrinterPass(dbgs()))
-MACHINE_FUNCTION_PASS("print<live-vars>", LiveVariablesPrinterPass(dbgs()))
+MACHINE_FUNCTION_PASS("print<live-intervals>", LiveIntervalsPrinterPass(errs()))
+MACHINE_FUNCTION_PASS("print<live-vars>", LiveVariablesPrinterPass(errs()))
 MACHINE_FUNCTION_PASS("print<machine-block-freq>",
-                      MachineBlockFrequencyPrinterPass(dbgs()))
+                      MachineBlockFrequencyPrinterPass(errs()))
 MACHINE_FUNCTION_PASS("print<machine-branch-prob>",
-                      MachineBranchProbabilityPrinterPass(dbgs()))
+                      MachineBranchProbabilityPrinterPass(errs()))
 MACHINE_FUNCTION_PASS("print<machine-dom-tree>",
-                      MachineDominatorTreePrinterPass(dbgs()))
-MACHINE_FUNCTION_PASS("print<machine-loops>", MachineLoopPrinterPass(dbgs()))
+                      MachineDominatorTreePrinterPass(errs()))
+MACHINE_FUNCTION_PASS("print<machine-loops>", MachineLoopPrinterPass(errs()))
 MACHINE_FUNCTION_PASS("print<machine-post-dom-tree>",
-                      MachinePostDominatorTreePrinterPass(dbgs()))
-MACHINE_FUNCTION_PASS("print<slot-indexes>", SlotIndexesPrinterPass(dbgs()))
-MACHINE_FUNCTION_PASS("print<virtregmap>", VirtRegMapPrinterPass(dbgs()))
+                      MachinePostDominatorTreePrinterPass(errs()))
+MACHINE_FUNCTION_PASS("print<slot-indexes>", SlotIndexesPrinterPass(errs()))
+MACHINE_FUNCTION_PASS("print<virtregmap>", VirtRegMapPrinterPass(errs()))
 MACHINE_FUNCTION_PASS("reg-usage-collector", RegUsageInfoCollectorPass())
 MACHINE_FUNCTION_PASS("reg-usage-propagation", RegUsageInfoPropagationPass())
 MACHINE_FUNCTION_PASS("require-all-machine-function-properties",

diff  --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 7c3798f6462a46..772ec5fd10e633 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -89,7 +89,7 @@ MODULE_PASS("insert-gcov-profiling", GCOVProfilerPass())
 MODULE_PASS("instrorderfile", InstrOrderFilePass())
 MODULE_PASS("instrprof", InstrProfilingLoweringPass())
 MODULE_PASS("ctx-instr-lower", PGOCtxProfLoweringPass())
-MODULE_PASS("print<ctx-prof-analysis>", CtxProfAnalysisPrinterPass(dbgs()))
+MODULE_PASS("print<ctx-prof-analysis>", CtxProfAnalysisPrinterPass(errs()))
 MODULE_PASS("invalidate<all>", InvalidateAllAnalysesPass())
 MODULE_PASS("iroutliner", IROutlinerPass())
 MODULE_PASS("jmc-instrumenter", JMCInstrumenterPass())
@@ -116,21 +116,21 @@ MODULE_PASS("pgo-instr-gen", PGOInstrumentationGen())
 MODULE_PASS("pgo-instr-use", PGOInstrumentationUse())
 MODULE_PASS("poison-checking", PoisonCheckingPass())
 MODULE_PASS("pre-isel-intrinsic-lowering", PreISelIntrinsicLoweringPass(TM))
-MODULE_PASS("print", PrintModulePass(dbgs()))
-MODULE_PASS("print-callgraph", CallGraphPrinterPass(dbgs()))
-MODULE_PASS("print-callgraph-sccs", CallGraphSCCsPrinterPass(dbgs()))
-MODULE_PASS("print-ir-similarity", IRSimilarityAnalysisPrinterPass(dbgs()))
-MODULE_PASS("print-lcg", LazyCallGraphPrinterPass(dbgs()))
-MODULE_PASS("print-lcg-dot", LazyCallGraphDOTPrinterPass(dbgs()))
+MODULE_PASS("print", PrintModulePass(errs()))
+MODULE_PASS("print-callgraph", CallGraphPrinterPass(errs()))
+MODULE_PASS("print-callgraph-sccs", CallGraphSCCsPrinterPass(errs()))
+MODULE_PASS("print-ir-similarity", IRSimilarityAnalysisPrinterPass(errs()))
+MODULE_PASS("print-lcg", LazyCallGraphPrinterPass(errs()))
+MODULE_PASS("print-lcg-dot", LazyCallGraphDOTPrinterPass(errs()))
 MODULE_PASS("print-must-be-executed-contexts",
-            MustBeExecutedContextPrinterPass(dbgs()))
-MODULE_PASS("print-profile-summary", ProfileSummaryPrinterPass(dbgs()))
-MODULE_PASS("print-stack-safety", StackSafetyGlobalPrinterPass(dbgs()))
-MODULE_PASS("print<dxil-metadata>", DXILMetadataAnalysisPrinterPass(dbgs()))
-MODULE_PASS("print<dxil-resource>", DXILResourcePrinterPass(dbgs()))
-MODULE_PASS("print<inline-advisor>", InlineAdvisorAnalysisPrinterPass(dbgs()))
-MODULE_PASS("print<module-debuginfo>", ModuleDebugInfoPrinterPass(dbgs()))
-MODULE_PASS("print<reg-usage>", PhysicalRegisterUsageInfoPrinterPass(dbgs()))
+            MustBeExecutedContextPrinterPass(errs()))
+MODULE_PASS("print-profile-summary", ProfileSummaryPrinterPass(errs()))
+MODULE_PASS("print-stack-safety", StackSafetyGlobalPrinterPass(errs()))
+MODULE_PASS("print<dxil-metadata>", DXILMetadataAnalysisPrinterPass(errs()))
+MODULE_PASS("print<dxil-resource>", DXILResourcePrinterPass(errs()))
+MODULE_PASS("print<inline-advisor>", InlineAdvisorAnalysisPrinterPass(errs()))
+MODULE_PASS("print<module-debuginfo>", ModuleDebugInfoPrinterPass(errs()))
+MODULE_PASS("print<reg-usage>", PhysicalRegisterUsageInfoPrinterPass(errs()))
 MODULE_PASS("pseudo-probe", SampleProfileProbePass(TM))
 MODULE_PASS("pseudo-probe-update", PseudoProbeUpdatePass())
 MODULE_PASS("recompute-globalsaa", RecomputeGlobalsAAPass())
@@ -225,7 +225,7 @@ MODULE_PASS_WITH_PARAMS(
 MODULE_PASS_WITH_PARAMS(
     "print<structural-hash>", "StructuralHashPrinterPass",
     [](StructuralHashOptions Options) {
-      return StructuralHashPrinterPass(dbgs(), Options);
+      return StructuralHashPrinterPass(errs(), Options);
     },
     parseStructuralHashPrinterPassOptions, "detailed;call-target-ignored")
 
@@ -424,38 +424,38 @@ FUNCTION_PASS("pa-eval", PAEvalPass())
 FUNCTION_PASS("partially-inline-libcalls", PartiallyInlineLibCallsPass())
 FUNCTION_PASS("pgo-memop-opt", PGOMemOPSizeOpt())
 FUNCTION_PASS("place-safepoints", PlaceSafepointsPass())
-FUNCTION_PASS("print", PrintFunctionPass(dbgs()))
+FUNCTION_PASS("print", PrintFunctionPass(errs()))
 // TODO: rename to print<foo> after NPM switch
-FUNCTION_PASS("print-alias-sets", AliasSetsPrinterPass(dbgs()))
-FUNCTION_PASS("print-cfg-sccs", CFGSCCPrinterPass(dbgs()))
-FUNCTION_PASS("print-memderefs", MemDerefPrinterPass(dbgs()))
-FUNCTION_PASS("print-mustexecute", MustExecutePrinterPass(dbgs()))
-FUNCTION_PASS("print-predicateinfo", PredicateInfoPrinterPass(dbgs()))
-FUNCTION_PASS("print<access-info>", LoopAccessInfoPrinterPass(dbgs()))
-FUNCTION_PASS("print<assumptions>", AssumptionPrinterPass(dbgs()))
-FUNCTION_PASS("print<block-freq>", BlockFrequencyPrinterPass(dbgs()))
-FUNCTION_PASS("print<branch-prob>", BranchProbabilityPrinterPass(dbgs()))
-FUNCTION_PASS("print<cost-model>", CostModelPrinterPass(dbgs()))
-FUNCTION_PASS("print<cycles>", CycleInfoPrinterPass(dbgs()))
-FUNCTION_PASS("print<da>", DependenceAnalysisPrinterPass(dbgs()))
-FUNCTION_PASS("print<debug-ata>", DebugAssignmentTrackingPrinterPass(dbgs()))
-FUNCTION_PASS("print<delinearization>", DelinearizationPrinterPass(dbgs()))
-FUNCTION_PASS("print<demanded-bits>", DemandedBitsPrinterPass(dbgs()))
-FUNCTION_PASS("print<domfrontier>", DominanceFrontierPrinterPass(dbgs()))
-FUNCTION_PASS("print<domtree>", DominatorTreePrinterPass(dbgs()))
-FUNCTION_PASS("print<func-properties>", FunctionPropertiesPrinterPass(dbgs()))
-FUNCTION_PASS("print<inline-cost>", InlineCostAnnotationPrinterPass(dbgs()))
+FUNCTION_PASS("print-alias-sets", AliasSetsPrinterPass(errs()))
+FUNCTION_PASS("print-cfg-sccs", CFGSCCPrinterPass(errs()))
+FUNCTION_PASS("print-memderefs", MemDerefPrinterPass(errs()))
+FUNCTION_PASS("print-mustexecute", MustExecutePrinterPass(errs()))
+FUNCTION_PASS("print-predicateinfo", PredicateInfoPrinterPass(errs()))
+FUNCTION_PASS("print<access-info>", LoopAccessInfoPrinterPass(errs()))
+FUNCTION_PASS("print<assumptions>", AssumptionPrinterPass(errs()))
+FUNCTION_PASS("print<block-freq>", BlockFrequencyPrinterPass(errs()))
+FUNCTION_PASS("print<branch-prob>", BranchProbabilityPrinterPass(errs()))
+FUNCTION_PASS("print<cost-model>", CostModelPrinterPass(errs()))
+FUNCTION_PASS("print<cycles>", CycleInfoPrinterPass(errs()))
+FUNCTION_PASS("print<da>", DependenceAnalysisPrinterPass(errs()))
+FUNCTION_PASS("print<debug-ata>", DebugAssignmentTrackingPrinterPass(errs()))
+FUNCTION_PASS("print<delinearization>", DelinearizationPrinterPass(errs()))
+FUNCTION_PASS("print<demanded-bits>", DemandedBitsPrinterPass(errs()))
+FUNCTION_PASS("print<domfrontier>", DominanceFrontierPrinterPass(errs()))
+FUNCTION_PASS("print<domtree>", DominatorTreePrinterPass(errs()))
+FUNCTION_PASS("print<func-properties>", FunctionPropertiesPrinterPass(errs()))
+FUNCTION_PASS("print<inline-cost>", InlineCostAnnotationPrinterPass(errs()))
 FUNCTION_PASS("print<inliner-size-estimator>",
-              InlineSizeEstimatorAnalysisPrinterPass(dbgs()))
-FUNCTION_PASS("print<lazy-value-info>", LazyValueInfoPrinterPass(dbgs()))
-FUNCTION_PASS("print<loops>", LoopPrinterPass(dbgs()))
-FUNCTION_PASS("print<memoryssa-walker>", MemorySSAWalkerPrinterPass(dbgs()))
-FUNCTION_PASS("print<phi-values>", PhiValuesPrinterPass(dbgs()))
-FUNCTION_PASS("print<postdomtree>", PostDominatorTreePrinterPass(dbgs()))
-FUNCTION_PASS("print<regions>", RegionInfoPrinterPass(dbgs()))
-FUNCTION_PASS("print<scalar-evolution>", ScalarEvolutionPrinterPass(dbgs()))
-FUNCTION_PASS("print<stack-safety-local>", StackSafetyPrinterPass(dbgs()))
-FUNCTION_PASS("print<uniformity>", UniformityInfoPrinterPass(dbgs()))
+              InlineSizeEstimatorAnalysisPrinterPass(errs()))
+FUNCTION_PASS("print<lazy-value-info>", LazyValueInfoPrinterPass(errs()))
+FUNCTION_PASS("print<loops>", LoopPrinterPass(errs()))
+FUNCTION_PASS("print<memoryssa-walker>", MemorySSAWalkerPrinterPass(errs()))
+FUNCTION_PASS("print<phi-values>", PhiValuesPrinterPass(errs()))
+FUNCTION_PASS("print<postdomtree>", PostDominatorTreePrinterPass(errs()))
+FUNCTION_PASS("print<regions>", RegionInfoPrinterPass(errs()))
+FUNCTION_PASS("print<scalar-evolution>", ScalarEvolutionPrinterPass(errs()))
+FUNCTION_PASS("print<stack-safety-local>", StackSafetyPrinterPass(errs()))
+FUNCTION_PASS("print<uniformity>", UniformityInfoPrinterPass(errs()))
 FUNCTION_PASS("reassociate", ReassociatePass())
 FUNCTION_PASS("redundant-dbg-inst-elim", RedundantDbgInstEliminationPass())
 FUNCTION_PASS("reg2mem", RegToMemPass())
@@ -562,19 +562,19 @@ FUNCTION_PASS_WITH_PARAMS(
 FUNCTION_PASS_WITH_PARAMS(
     "print<da>", "DependenceAnalysisPrinterPass",
     [](bool NormalizeResults) {
-      return DependenceAnalysisPrinterPass(dbgs(), NormalizeResults);
+      return DependenceAnalysisPrinterPass(errs(), NormalizeResults);
     },
     parseDependenceAnalysisPrinterOptions, "normalized-results")
 FUNCTION_PASS_WITH_PARAMS(
     "print<memoryssa>", "MemorySSAPrinterPass",
     [](bool NoEnsureOptimizedUses) {
-      return MemorySSAPrinterPass(dbgs(), !NoEnsureOptimizedUses);
+      return MemorySSAPrinterPass(errs(), !NoEnsureOptimizedUses);
     },
     parseMemorySSAPrinterPassOptions, "no-ensure-optimized-uses")
 FUNCTION_PASS_WITH_PARAMS(
     "print<stack-lifetime>", "StackLifetimePrinterPass",
     [](StackLifetime::LivenessType Type) {
-      return StackLifetimePrinterPass(dbgs(), Type);
+      return StackLifetimePrinterPass(errs(), Type);
     },
     parseStackLifetimeOptions, "may;must")
 FUNCTION_PASS_WITH_PARAMS(
@@ -664,11 +664,11 @@ LOOP_PASS("loop-simplifycfg", LoopSimplifyCFGPass())
 LOOP_PASS("loop-unroll-full", LoopFullUnrollPass())
 LOOP_PASS("loop-versioning-licm", LoopVersioningLICMPass())
 LOOP_PASS("no-op-loop", NoOpLoopPass())
-LOOP_PASS("print", PrintLoopPass(dbgs()))
-LOOP_PASS("print<ddg>", DDGAnalysisPrinterPass(dbgs()))
-LOOP_PASS("print<iv-users>", IVUsersPrinterPass(dbgs()))
-LOOP_PASS("print<loop-cache-cost>", LoopCachePrinterPass(dbgs()))
-LOOP_PASS("print<loopnest>", LoopNestPrinterPass(dbgs()))
+LOOP_PASS("print", PrintLoopPass(errs()))
+LOOP_PASS("print<ddg>", DDGAnalysisPrinterPass(errs()))
+LOOP_PASS("print<iv-users>", IVUsersPrinterPass(errs()))
+LOOP_PASS("print<loop-cache-cost>", LoopCachePrinterPass(errs()))
+LOOP_PASS("print<loopnest>", LoopNestPrinterPass(errs()))
 #undef LOOP_PASS
 
 #ifndef LOOP_PASS_WITH_PARAMS


        


More information about the llvm-commits mailing list