[llvm] ae32ba4 - Set isRequired true for CFGViewer/CFGPrinter passes

Bing1 Yu via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 23:20:46 PDT 2023


Author: Wenju He
Date: 2023-06-07T14:20:27+08:00
New Revision: ae32ba4e015b6fe6a3f359fd5a2fde64fa96276e

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

LOG: Set isRequired true for CFGViewer/CFGPrinter passes

This PR allows function's cfg to be viewed/printed even if the function
has optnone attribute.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D152122

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/CFGPrinter.h
    llvm/test/Other/cfg-printer-filter.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/CFGPrinter.h b/llvm/include/llvm/Analysis/CFGPrinter.h
index eeac11bc7af12..8c4c0c3f182f2 100644
--- a/llvm/include/llvm/Analysis/CFGPrinter.h
+++ b/llvm/include/llvm/Analysis/CFGPrinter.h
@@ -35,21 +35,25 @@ template <class GraphType> struct GraphTraits;
 class CFGViewerPass : public PassInfoMixin<CFGViewerPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+  static bool isRequired() { return true; }
 };
 
 class CFGOnlyViewerPass : public PassInfoMixin<CFGOnlyViewerPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+  static bool isRequired() { return true; }
 };
 
 class CFGPrinterPass : public PassInfoMixin<CFGPrinterPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+  static bool isRequired() { return true; }
 };
 
 class CFGOnlyPrinterPass : public PassInfoMixin<CFGOnlyPrinterPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+  static bool isRequired() { return true; }
 };
 
 class DOTFuncInfo {

diff  --git a/llvm/test/Other/cfg-printer-filter.ll b/llvm/test/Other/cfg-printer-filter.ll
index 4ec6b73dda6a7..2a25c465a2bc1 100644
--- a/llvm/test/Other/cfg-printer-filter.ll
+++ b/llvm/test/Other/cfg-printer-filter.ll
@@ -1,6 +1,8 @@
 ; RUN: rm -f %t.other.dot %t-only.other.dot
 
 ;; Both f and func are dumped because their names contain the pattern 'f' as a substring.
+;; Also checks dot-cfg pass runs on func which has optnone attribute.
+
 ; RUN: opt < %s -passes=dot-cfg -cfg-dot-filename-prefix=%t -cfg-func-name=f 2>/dev/null > /dev/null
 ; RUN: FileCheck %s -input-file=%t.f.dot -check-prefix=F
 ; RUN: FileCheck %s -input-file=%t.func.dot -check-prefix=Func
@@ -23,7 +25,7 @@ exit:                   ; preds = %entry, %if
 }
 
 ; Func: digraph "CFG for 'func' function"
-define void @func(i32) {
+define void @func(i32) optnone noinline {
 entry:
   %check = icmp sgt i32 %0, 0
   br label %exit


        


More information about the llvm-commits mailing list