[llvm-commits] [gcc-plugin] r81341 - /gcc-plugin/trunk/llvm-convert.cpp

Duncan Sands baldrick at free.fr
Wed Sep 9 06:42:48 PDT 2009


Author: baldrick
Date: Wed Sep  9 08:42:48 2009
New Revision: 81341

URL: http://llvm.org/viewvc/llvm-project?rev=81341&view=rev
Log:
Try harder to have basic blocks use the same names
as in the GCC tree dumps.  Hopefully all cases are
now covered.

Modified:
    gcc-plugin/trunk/llvm-convert.cpp

Modified: gcc-plugin/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-convert.cpp?rev=81341&r1=81340&r2=81341&view=diff

==============================================================================
--- gcc-plugin/trunk/llvm-convert.cpp (original)
+++ gcc-plugin/trunk/llvm-convert.cpp Wed Sep  9 08:42:48 2009
@@ -767,20 +767,31 @@
     return I->second;
 
   // Otherwise, create a new LLVM basic block.
-  BasicBlock *BB = BasicBlocks[bb] = BasicBlock::Create(Context);
+  BasicBlock *BB = BasicBlock::Create(Context);
 
   // If BB contains labels, name the LLVM basic block after the first one.
-  gimple stmt = first_stmt (bb);
-  if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
-    if (tree name = DECL_NAME(gimple_label_label(stmt))) {
+  gimple stmt = first_stmt(bb);
+  if (stmt && gimple_code(stmt) == GIMPLE_LABEL) {
+    tree label = gimple_label_label(stmt);
+    if (tree name = DECL_NAME(label)) {
+      // If the label has a name then use it.
       BB->setName(IDENTIFIER_POINTER(name));
-      return BB;
+    } else if (LABEL_DECL_UID(label) != -1) {
+      // If the label has a UID then use it.
+      Twine UID(LABEL_DECL_UID(label));
+      BB->setName("<L" + UID + ">");
+    } else {
+      // Otherwise use the generic UID.
+      Twine UID(DECL_UID(label));
+      BB->setName("<D." + UID + ">");
     }
+  } else {
+    // When there is no label, use the same naming scheme as the GCC tree dumps.
+    Twine Index(bb->index);
+    BB->setName("<bb " + Index + ">");
+  }
 
-  // Use the same basic block naming scheme as the GCC tree dumps.
-  Twine Name(bb->index);
-  BB->setName("<bb " + Name + ">");
-  return BB;
+  return BasicBlocks[bb] = BB;
 }
 
 /// getLabelDeclBlock - Lazily get and create a basic block for the specified





More information about the llvm-commits mailing list