Author: lattner Date: Fri Feb 15 13:04:54 2008 New Revision: 47171 URL: http://llvm.org/viewvc/llvm-project?rev=47171&view=rev Log: Handle \n's in value names for more targets. The asm printers really really really need refactoring :(
Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=47171&r1=47170&r2=47171&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Fri Feb 15 13:04:54 2008 @@ -807,6 +807,15 @@ return Result; } +/// PrintUnmangledNameSafely - Print out the printable characters in the name. +/// Don't print things like \n or \0. +static void PrintUnmangledNameSafely(const Value *V, std::ostream &OS) { + for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen(); + Name != E; ++Name) + if (isprint(*Name)) + OS << *Name; +} + bool ARMAsmPrinter::doFinalization(Module &M) { const TargetData *TD = TM.getTargetData(); @@ -875,7 +884,9 @@ if (TAI->getCOMMDirectiveTakesAlignment()) O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align); } - O << "\t\t" << TAI->getCommentString() << " " << I->getName() << "\n"; + O << "\t\t" << TAI->getCommentString() << " "; + PrintUnmangledNameSafely(I, O); + O << "\n"; continue; } } @@ -961,8 +972,9 @@ } EmitAlignment(Align, I); - O << name << ":\t\t\t\t" << TAI->getCommentString() << " " << I->getName() - << "\n"; + O << name << ":\t\t\t\t" << TAI->getCommentString() << " "; + PrintUnmangledNameSafely(I, O); + O << "\n"; if (TAI->hasDotTypeDotSizeDirective()) O << "\t.size " << name << ", " << Size << "\n"; // If the initializer is a extern weak symbol, remember to emit the weak Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=47171&r1=47170&r2=47171&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Fri Feb 15 13:04:54 2008 @@ -639,6 +639,15 @@ return Result; } +/// PrintUnmangledNameSafely - Print out the printable characters in the name. +/// Don't print things like \n or \0. +static void PrintUnmangledNameSafely(const Value *V, std::ostream &OS) { + for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen(); + Name != E; ++Name) + if (isprint(*Name)) + OS << *Name; +} + bool LinuxAsmPrinter::doFinalization(Module &M) { const TargetData *TD = TM.getTargetData(); @@ -680,7 +689,9 @@ SwitchToDataSection("\t.data", I); O << ".comm " << name << "," << Size; } - O << "\t\t" << TAI->getCommentString() << " '" << I->getName() << "'\n"; + O << "\t\t" << TAI->getCommentString() << " '"; + PrintUnmangledNameSafely(I, O); + O << "'\n"; } else { switch (I->getLinkage()) { case GlobalValue::LinkOnceLinkage: @@ -727,8 +738,9 @@ } EmitAlignment(Align, I); - O << name << ":\t\t\t\t" << TAI->getCommentString() << " '" - << I->getName() << "'\n"; + O << name << ":\t\t\t\t" << TAI->getCommentString() << " '"; + PrintUnmangledNameSafely(I, O); + O << "'\n"; // If the initializer is a extern weak symbol, remember to emit the weak // reference! @@ -942,7 +954,9 @@ if (Subtarget.isDarwin9()) O << "," << Align; } - O << "\t\t" << TAI->getCommentString() << " '" << I->getName() << "'\n"; + O << "\t\t" << TAI->getCommentString() << " '"; + PrintUnmangledNameSafely(I, O); + O << "'\n"; } else { switch (I->getLinkage()) { case GlobalValue::LinkOnceLinkage: @@ -999,8 +1013,9 @@ } EmitAlignment(Align, I); - O << name << ":\t\t\t\t" << TAI->getCommentString() << " '" - << I->getName() << "'\n"; + O << name << ":\t\t\t\t" << TAI->getCommentString() << " '"; + PrintUnmangledNameSafely(I, O); + O << "'\n"; // If the initializer is a extern weak symbol, remember to emit the weak // reference! Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=47171&r1=47170&r2=47171&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Fri Feb 15 13:04:54 2008 @@ -138,9 +138,9 @@ return Result; } -/// PrintUnamedNameSafely - Print out the printable characters in the name. +/// PrintUnmangledNameSafely - Print out the printable characters in the name. /// Don't print things like \n or \0. -static void PrintUnamedNameSafely(const Value *V, std::ostream &OS) { +static void PrintUnmangledNameSafely(const Value *V, std::ostream &OS) { for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen(); Name != E; ++Name) if (isprint(*Name)) @@ -228,7 +228,7 @@ O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align); } O << "\t\t" << TAI->getCommentString() << " "; - PrintUnamedNameSafely(I, O); + PrintUnmangledNameSafely(I, O); O << "\n"; continue; } @@ -331,7 +331,7 @@ EmitAlignment(Align, I); O << name << ":\t\t\t\t" << TAI->getCommentString() << " "; - PrintUnamedNameSafely(I, O); + PrintUnmangledNameSafely(I, O); O << "\n"; if (TAI->hasDotTypeDotSizeDirective()) O << "\t.size\t" << name << ", " << Size << "\n"; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits