From c65b2388bb0cb4ff533b12d1d13f464a053d03e5 Mon Sep 17 00:00:00 2001 From: Rahul Joshi Date: Wed, 5 Nov 2025 11:28:17 -0800 Subject: [PATCH] [NFC][LLVM] Code cleanup in RegionPrinter - Fix indendation in header file. - Use namespace qualifiers for defining DOTGraphTraits. --- llvm/include/llvm/Analysis/RegionPrinter.h | 104 ++++++++++----------- llvm/lib/Analysis/RegionPrinter.cpp | 11 +-- 2 files changed, 57 insertions(+), 58 deletions(-) diff --git a/llvm/include/llvm/Analysis/RegionPrinter.h b/llvm/include/llvm/Analysis/RegionPrinter.h index 3a1d11d8fd4bc..1d4ba0fd4ebc6 100644 --- a/llvm/include/llvm/Analysis/RegionPrinter.h +++ b/llvm/include/llvm/Analysis/RegionPrinter.h @@ -18,64 +18,64 @@ #include "llvm/Support/DOTGraphTraits.h" namespace llvm { - class FunctionPass; - class Function; - class RegionInfo; - class RegionNode; +class FunctionPass; +class Function; +class RegionInfo; +class RegionNode; - LLVM_ABI FunctionPass *createRegionViewerPass(); - LLVM_ABI FunctionPass *createRegionOnlyViewerPass(); - LLVM_ABI FunctionPass *createRegionPrinterPass(); - LLVM_ABI FunctionPass *createRegionOnlyPrinterPass(); +LLVM_ABI FunctionPass *createRegionViewerPass(); +LLVM_ABI FunctionPass *createRegionOnlyViewerPass(); +LLVM_ABI FunctionPass *createRegionPrinterPass(); +LLVM_ABI FunctionPass *createRegionOnlyPrinterPass(); - template <> - struct DOTGraphTraits : public DefaultDOTGraphTraits { - DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {} +template <> struct DOTGraphTraits : public DefaultDOTGraphTraits { + DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {} - LLVM_ABI std::string getNodeLabel(RegionNode *Node, RegionNode *Graph); - }; + LLVM_ABI std::string getNodeLabel(RegionNode *Node, RegionNode *Graph); +}; #ifndef NDEBUG - /// Open a viewer to display the GraphViz vizualization of the analysis - /// result. - /// - /// Practical to call in the debugger. - /// Includes the instructions in each BasicBlock. - /// - /// @param RI The analysis to display. - void viewRegion(llvm::RegionInfo *RI); +/// Open a viewer to display the GraphViz vizualization of the analysis +/// result. +/// +/// Practical to call in the debugger. +/// Includes the instructions in each BasicBlock. +/// +/// @param RI The analysis to display. +void viewRegion(llvm::RegionInfo *RI); - /// Analyze the regions of a function and open its GraphViz - /// visualization in a viewer. - /// - /// Useful to call in the debugger. - /// Includes the instructions in each BasicBlock. - /// The result of a new analysis may differ from the RegionInfo the pass - /// manager currently holds. - /// - /// @param F Function to analyze. - void viewRegion(const llvm::Function *F); +/// Analyze the regions of a function and open its GraphViz +/// visualization in a viewer. +/// +/// Useful to call in the debugger. +/// Includes the instructions in each BasicBlock. +/// The result of a new analysis may differ from the RegionInfo the pass +/// manager currently holds. +/// +/// @param F Function to analyze. +void viewRegion(const llvm::Function *F); - /// Open a viewer to display the GraphViz vizualization of the analysis - /// result. - /// - /// Useful to call in the debugger. - /// Shows only the BasicBlock names without their instructions. - /// - /// @param RI The analysis to display. - void viewRegionOnly(llvm::RegionInfo *RI); +/// Open a viewer to display the GraphViz vizualization of the analysis +/// result. +/// +/// Useful to call in the debugger. +/// Shows only the BasicBlock names without their instructions. +/// +/// @param RI The analysis to display. +void viewRegionOnly(llvm::RegionInfo *RI); - /// Analyze the regions of a function and open its GraphViz - /// visualization in a viewer. - /// - /// Useful to call in the debugger. - /// Shows only the BasicBlock names without their instructions. - /// The result of a new analysis may differ from the RegionInfo the pass - /// manager currently holds. - /// - /// @param F Function to analyze. - void viewRegionOnly(const llvm::Function *F); -#endif -} // End llvm namespace +/// Analyze the regions of a function and open its GraphViz +/// visualization in a viewer. +/// +/// Useful to call in the debugger. +/// Shows only the BasicBlock names without their instructions. +/// The result of a new analysis may differ from the RegionInfo the pass +/// manager currently holds. +/// +/// @param F Function to analyze. +void viewRegionOnly(const llvm::Function *F); +#endif // NDEBUG -#endif +} // namespace llvm + +#endif // LLVM_ANALYSIS_REGIONPRINTER_H diff --git a/llvm/lib/Analysis/RegionPrinter.cpp b/llvm/lib/Analysis/RegionPrinter.cpp index a83af4ebb430e..39080f51f012e 100644 --- a/llvm/lib/Analysis/RegionPrinter.cpp +++ b/llvm/lib/Analysis/RegionPrinter.cpp @@ -29,10 +29,9 @@ onlySimpleRegions("only-simple-regions", cl::Hidden, cl::init(false)); -namespace llvm { - -std::string DOTGraphTraits::getNodeLabel(RegionNode *Node, - RegionNode *Graph) { +std::string +llvm::DOTGraphTraits::getNodeLabel(RegionNode *Node, + RegionNode *Graph) { if (!Node->isSubRegion()) { BasicBlock *BB = Node->getNodeAs(); @@ -46,7 +45,8 @@ std::string DOTGraphTraits::getNodeLabel(RegionNode *Node, } template <> -struct DOTGraphTraits : public DOTGraphTraits { +struct DOTGraphTraits + : public llvm::DOTGraphTraits { DOTGraphTraits (bool isSimple = false) : DOTGraphTraits(isSimple) {} @@ -125,7 +125,6 @@ struct DOTGraphTraits : public DOTGraphTraits { printRegionCluster(*G->getTopLevelRegion(), GW, 4); } }; -} // end namespace llvm namespace {