1 //===-- RegionPrinter.h - Region printer external interface -----*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file defines external functions that can be called to explicitly 10 // instantiate the region printer. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_ANALYSIS_REGIONPRINTER_H 15 #define LLVM_ANALYSIS_REGIONPRINTER_H 16 17 #include "llvm/Analysis/DOTGraphTraitsPass.h" 18 #include "llvm/Analysis/RegionInfo.h" 19 20 namespace llvm { 21 class FunctionPass; 22 class Function; 23 class RegionInfo; 24 25 FunctionPass *createRegionViewerPass(); 26 FunctionPass *createRegionOnlyViewerPass(); 27 FunctionPass *createRegionPrinterPass(); 28 FunctionPass *createRegionOnlyPrinterPass(); 29 30 template <> 31 struct DOTGraphTraits<RegionNode *> : public DefaultDOTGraphTraits { 32 DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {} 33 34 std::string getNodeLabel(RegionNode *Node, RegionNode *Graph); 35 }; 36 37 #ifndef NDEBUG 38 /// Open a viewer to display the GraphViz vizualization of the analysis 39 /// result. 40 /// 41 /// Practical to call in the debugger. 42 /// Includes the instructions in each BasicBlock. 43 /// 44 /// @param RI The analysis to display. 45 void viewRegion(llvm::RegionInfo *RI); 46 47 /// Analyze the regions of a function and open its GraphViz 48 /// visualization in a viewer. 49 /// 50 /// Useful to call in the debugger. 51 /// Includes the instructions in each BasicBlock. 52 /// The result of a new analysis may differ from the RegionInfo the pass 53 /// manager currently holds. 54 /// 55 /// @param F Function to analyze. 56 void viewRegion(const llvm::Function *F); 57 58 /// Open a viewer to display the GraphViz vizualization of the analysis 59 /// result. 60 /// 61 /// Useful to call in the debugger. 62 /// Shows only the BasicBlock names without their instructions. 63 /// 64 /// @param RI The analysis to display. 65 void viewRegionOnly(llvm::RegionInfo *RI); 66 67 /// Analyze the regions of a function and open its GraphViz 68 /// visualization in a viewer. 69 /// 70 /// Useful to call in the debugger. 71 /// Shows only the BasicBlock names without their instructions. 72 /// The result of a new analysis may differ from the RegionInfo the pass 73 /// manager currently holds. 74 /// 75 /// @param F Function to analyze. 76 void viewRegionOnly(const llvm::Function *F); 77 #endif 78 } // End llvm namespace 79 80 #endif 81