Now that numbered types have their number printed, it's no longer
authorDan Gohman <gohman@apple.com>
Wed, 12 Aug 2009 23:54:22 +0000 (23:54 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 12 Aug 2009 23:54:22 +0000 (23:54 +0000)
interesting to print the number in a comment. Numbered instructions
don't need their number in a comment either.

Also, tidy up newline printing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78865 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/AsmWriter.cpp
test/Integer/a15.ll.out
test/Integer/a17.ll.out
test/Integer/a31.ll.out
test/Integer/a33.ll.out
test/Integer/a63.ll.out
test/Integer/a7.ll.out
test/Integer/a9.ll.out

index c2a121a2b69e68552e77e0289ff49edc78b9928d..c20cf46f92c88ebd520768daade6b09c7da29ac0 100644 (file)
@@ -521,7 +521,8 @@ public:
   /// MDNode map iterators.
   ValueMap::iterator mdnBegin() { return mdnMap.begin(); }
   ValueMap::iterator mdnEnd() { return mdnMap.end(); }
-  unsigned mdnSize() { return mdnMap.size(); }
+  unsigned mdnSize() const { return mdnMap.size(); }
+  bool mdnEmpty() const { return mdnMap.empty(); }
 
   /// This function does the actual initialization.
   inline void initialize();
@@ -1343,6 +1344,7 @@ void AssemblyWriter::printModule(const Module *M) {
     std::string Asm = M->getModuleInlineAsm();
     size_t CurPos = 0;
     size_t NewLine = Asm.find_first_of('\n', CurPos);
+    Out << '\n';
     while (NewLine != std::string::npos) {
       // We found a newline, print the portion of the asm string from the
       // last newline up to this newline.
@@ -1362,6 +1364,7 @@ void AssemblyWriter::printModule(const Module *M) {
   Module::lib_iterator LI = M->lib_begin();
   Module::lib_iterator LE = M->lib_end();
   if (LI != LE) {
+    Out << '\n';
     Out << "deplibs = [ ";
     while (LI != LE) {
       Out << '"' << *LI << '"';
@@ -1369,12 +1372,15 @@ void AssemblyWriter::printModule(const Module *M) {
       if (LI != LE)
         Out << ", ";
     }
-    Out << " ]\n";
+    Out << " ]";
   }
 
   // Loop over the symbol table, emitting all id'd types.
+  if (!M->getTypeSymbolTable().empty() || !NumberedTypes.empty()) Out << '\n';
   printTypeSymbolTable(M->getTypeSymbolTable());
 
+  // Output all globals.
+  if (!M->global_empty()) Out << '\n';
   for (Module::const_global_iterator I = M->global_begin(), E = M->global_end();
        I != E; ++I)
     printGlobal(I);
@@ -1390,6 +1396,7 @@ void AssemblyWriter::printModule(const Module *M) {
     printFunction(I);
 
   // Output named metadata.
+  if (!M->named_metadata_empty()) Out << '\n';
   for (Module::const_named_metadata_iterator I = M->named_metadata_begin(),
          E = M->named_metadata_end(); I != E; ++I) {
     const NamedMDNode *NMD = I;
@@ -1403,6 +1410,7 @@ void AssemblyWriter::printModule(const Module *M) {
   }
 
   // Output metadata.
+  if (!Machine.mdnEmpty()) Out << '\n';
   WriteMDNodes(Out, TypePrinter, Machine);
 }
 
@@ -1521,8 +1529,7 @@ void AssemblyWriter::printTypeSymbolTable(const TypeSymbolTable &ST) {
     // Make sure we print out at least one level of the type structure, so
     // that we do not get %2 = type %2
     TypePrinter.printAtLeastOneLevel(NumberedTypes[i], Out);
-    Out.PadToColumn(50);
-    Out << "; type %" << i << '\n';
+    Out << '\n';
   }
   
   // Print the named types.
@@ -1713,20 +1720,7 @@ void AssemblyWriter::printInfoComment(const Value &V) {
     Out.PadToColumn(50);
     Out << "; <";
     TypePrinter.print(V.getType(), Out);
-    Out << '>';
-
-    if (!V.hasName() && !isa<Instruction>(V)) {
-      int SlotNum;
-      if (const GlobalValue *GV = dyn_cast<GlobalValue>(&V))
-        SlotNum = Machine.getGlobalSlot(GV);
-      else
-        SlotNum = Machine.getLocalSlot(&V);
-      if (SlotNum == -1)
-        Out << ":<badref>";
-      else
-        Out << ':' << SlotNum; // Print out the def slot taken.
-    }
-    Out << " [#uses=" << V.getNumUses() << ']';  // Output # uses
+    Out << "> [#uses=" << V.getNumUses() << ']';  // Output # uses
   }
 }
 
index 74387ccd6d9596b138e469f5951be1fb3fe78298..5195cdf3761f0efb9733068f81798f06b5fbd830 100644 (file)
@@ -1,4 +1,5 @@
 ; ModuleID = '<stdin>'
+
 @b = constant i15 0                               ; <i15*> [#uses=0]
 @c = constant i15 -2                              ; <i15*> [#uses=0]
 @d = constant i15 0                               ; <i15*> [#uses=0]
index 6ded8452f6d7f66a239596084f2dd35188559b81..ba6641289e3160c0b0ca53219528d10044aa15ea 100644 (file)
@@ -1,4 +1,5 @@
 ; ModuleID = '<stdin>'
+
 @b = constant i17 0                               ; <i17*> [#uses=0]
 @c = constant i17 -2                              ; <i17*> [#uses=0]
 @d = constant i17 0                               ; <i17*> [#uses=0]
index c7892ea722573a11c62bf985485fff14c6e796d0..7407a746b5bf77b5068fa1c42ddbdedcd13f96a7 100644 (file)
@@ -1,4 +1,5 @@
 ; ModuleID = '<stdin>'
+
 @b = constant i31 0                               ; <i31*> [#uses=0]
 @c = constant i31 -2                              ; <i31*> [#uses=0]
 @d = constant i31 0                               ; <i31*> [#uses=0]
index 6f723b45e5c47313aa02724bf39c49a1626c97c2..6cd61ee69cdca3bdc2d1c6edfb1f0322ecce7aff 100644 (file)
@@ -1,4 +1,5 @@
 ; ModuleID = '<stdin>'
+
 @b = constant i33 0                               ; <i33*> [#uses=0]
 @c = constant i33 -2                              ; <i33*> [#uses=0]
 @d = constant i33 0                               ; <i33*> [#uses=0]
index 21cef72d80e802e0a30909b143521102f7a3face..18dff5a2964ef406fe854df3161344bb8610a44b 100644 (file)
@@ -1,4 +1,5 @@
 ; ModuleID = '<stdin>'
+
 @b = constant i63 0                               ; <i63*> [#uses=0]
 @c = constant i63 -2                              ; <i63*> [#uses=0]
 @d = constant i63 0                               ; <i63*> [#uses=0]
index 78a114c087de3b0e3501ecaa1d154e91dc482058..250925d795e647a93e2cd5586afeddf163f64a20 100644 (file)
@@ -1,4 +1,5 @@
 ; ModuleID = '<stdin>'
+
 @b = constant i7 0                                ; <i7*> [#uses=0]
 @q = constant i7 63                               ; <i7*> [#uses=0]
 @c = constant i7 -2                               ; <i7*> [#uses=0]
index fd329d48121251e11bba33cd21d8f9e02da03638..6e38062c4a03586c27a798ffa2105cb70e86b58f 100644 (file)
@@ -1,4 +1,5 @@
 ; ModuleID = '<stdin>'
+
 @b = constant i9 0                                ; <i9*> [#uses=0]
 @c = constant i9 -2                               ; <i9*> [#uses=0]
 @d = constant i9 0                                ; <i9*> [#uses=0]