[PATCH] D80552: [PrintSCC] Fix printing a basic-block without a name

Ehud Katz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 29 10:23:43 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGdfc8244c2463: [PrintSCC] Fix printing a basic-block without a name (authored by ekatz).

Changed prior to commit:
  https://reviews.llvm.org/D80552?vs=266646&id=267289#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80552/new/

https://reviews.llvm.org/D80552

Files:
  llvm/test/Other/print-cfg-sccs.ll
  llvm/tools/opt/PrintSCC.cpp


Index: llvm/tools/opt/PrintSCC.cpp
===================================================================
--- llvm/tools/opt/PrintSCC.cpp
+++ llvm/tools/opt/PrintSCC.cpp
@@ -76,9 +76,10 @@
   for (scc_iterator<Function*> SCCI = scc_begin(&F); !SCCI.isAtEnd(); ++SCCI) {
     const std::vector<BasicBlock *> &nextSCC = *SCCI;
     errs() << "\nSCC #" << ++sccNum << " : ";
-    for (std::vector<BasicBlock*>::const_iterator I = nextSCC.begin(),
-           E = nextSCC.end(); I != E; ++I)
-      errs() << (*I)->getName() << ", ";
+    for (BasicBlock *BB : nextSCC) {
+      BB->printAsOperand(errs(), false);
+      errs() << ", ";
+    }
     if (nextSCC.size() == 1 && SCCI.hasCycle())
       errs() << " (Has self-loop).";
   }
Index: llvm/test/Other/print-cfg-sccs.ll
===================================================================
--- /dev/null
+++ llvm/test/Other/print-cfg-sccs.ll
@@ -0,0 +1,27 @@
+; RUN: opt -print-cfg-sccs -disable-output < %s 2>&1 | FileCheck %s
+
+; CHECK: SCCs for Function test in PostOrder:
+; CHECK-NEXT: SCC #1 : %exit,
+; CHECK-NEXT: SCC #2 : %0,
+; CHECK-NEXT: SCC #3 : %3,
+; CHECK-NEXT: SCC #4 : %2, %1,
+; CHECK-NEXT: SCC #5 : %entry,
+define void @test(i1 %cond) {
+entry:
+  br i1 %cond, label %0, label %1
+
+0:
+  br label %exit
+
+1:
+  br label %2
+
+2:
+  br i1 %cond, label %1, label %3
+
+3:
+  br label %exit
+
+exit:
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80552.267289.patch
Type: text/x-patch
Size: 1384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200529/913c8932/attachment-0001.bin>


More information about the llvm-commits mailing list