[llvm-commits] [llvm] r54983 - /llvm/trunk/lib/VMCore/AsmWriter.cpp

Chris Lattner sabre at nondot.org
Mon Aug 18 22:16:28 PDT 2008


Author: lattner
Date: Tue Aug 19 00:16:28 2008
New Revision: 54983

URL: http://llvm.org/viewvc/llvm-project?rev=54983&view=rev
Log:
more cleanup, eliminate getLLVMName when printing out
type names at the top of the file.

Modified:
    llvm/trunk/lib/VMCore/AsmWriter.cpp

Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=54983&r1=54982&r2=54983&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Aug 19 00:16:28 2008
@@ -127,20 +127,17 @@
 /// PrintLLVMName - Turn the specified name into an 'LLVM name', which is either
 /// prefixed with % (if the string only contains simple characters) or is
 /// surrounded with ""'s (if it has special chars in it).  Print it out.
-static void PrintLLVMName(std::ostream &OS, const ValueName *Name,
-                          PrefixType Prefix) {
-  assert(Name && "Cannot get empty name!");
+static void PrintLLVMName(std::ostream &OS, const char *NameStr,
+                          unsigned NameLen, PrefixType Prefix) {
+  assert(NameStr && "Cannot get empty name!");
   switch (Prefix) {
-    default: assert(0 && "Bad prefix!");
-    case GlobalPrefix: OS << '@'; break;
-    case LabelPrefix:  break;
-    case LocalPrefix:  OS << '%'; break;
+  default: assert(0 && "Bad prefix!");
+  case GlobalPrefix: OS << '@'; break;
+  case LabelPrefix:  break;
+  case LocalPrefix:  OS << '%'; break;
   }      
   
   // Scan the name to see if it needs quotes first.
-  const char *NameStr = Name->getKeyData();
-  unsigned NameLen = Name->getKeyLength();
-  
   bool NeedsQuotes = NameStr[0] >= '0' && NameStr[0] <= '9';
   if (!NeedsQuotes) {
     for (unsigned i = 0; i != NameLen; ++i) {
@@ -189,7 +186,7 @@
 /// prefixed with % (if the string only contains simple characters) or is
 /// surrounded with ""'s (if it has special chars in it).  Print it out.
 static void PrintLLVMName(std::ostream &OS, const Value *V) {
-  PrintLLVMName(OS, V->getValueName(),
+  PrintLLVMName(OS, V->getNameStart(), V->getNameLen(),
                 isa<GlobalValue>(V) ? GlobalPrefix : LocalPrefix);
 }
 
@@ -1208,16 +1205,11 @@
     Out << " = ";
   }
 
-  if (!GV->hasInitializer()) {
-    switch (GV->getLinkage()) {
-     case GlobalValue::DLLImportLinkage:    Out << "dllimport "; break;
-     case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break;
-     default: Out << "external "; break;
-    }
-  } else {
-    PrintLinkage(GV->getLinkage(), Out);
-    PrintVisibility(GV->getVisibility(), Out);
-  }
+  if (!GV->hasInitializer() && GV->hasExternalLinkage())
+    Out << "external ";
+  
+  PrintLinkage(GV->getLinkage(), Out);
+  PrintVisibility(GV->getVisibility(), Out);
 
   if (GV->isThreadLocal()) Out << "thread_local ";
   Out << (GV->isConstant() ? "constant " : "global ");
@@ -1280,14 +1272,16 @@
   }
   
   printInfoComment(*GA);
-  Out << "\n";
+  Out << '\n';
 }
 
 void AssemblyWriter::printTypeSymbolTable(const TypeSymbolTable &ST) {
   // Print the types.
   for (TypeSymbolTable::const_iterator TI = ST.begin(), TE = ST.end();
        TI != TE; ++TI) {
-    Out << '\t' << getLLVMName(TI->first) << " = type ";
+    Out << '\t';
+    PrintLLVMName(Out, &TI->first[0], TI->first.size(), LocalPrefix);
+    Out << " = type ";
 
     // Make sure we print out at least one level of the type structure, so
     // that we do not get %FILE = type %FILE
@@ -1416,7 +1410,7 @@
 void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
   if (BB->hasName()) {              // Print out the label if it exists...
     Out << "\n";
-    PrintLLVMName(Out, BB->getValueName(), LabelPrefix);
+    PrintLLVMName(Out, BB->getNameStart(), BB->getNameLen(), LabelPrefix);
     Out << ':';
   } else if (!BB->use_empty()) {      // Don't print block # of no uses...
     Out << "\n; <label>:";





More information about the llvm-commits mailing list