aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-15 19:04:54 +0000
committerChris Lattner <sabre@nondot.org>2008-02-15 19:04:54 +0000
commitec321b4d64ee02a1b90021c09d9513618787c6e8 (patch)
treefb4d896b2649dd36400c4aff0a713f47dd6d49d2 /lib/Target/PowerPC/PPCAsmPrinter.cpp
parent3502d0dac35531279ca848d2aaaa290f11172d6d (diff)
downloadexternal_llvm-ec321b4d64ee02a1b90021c09d9513618787c6e8.zip
external_llvm-ec321b4d64ee02a1b90021c09d9513618787c6e8.tar.gz
external_llvm-ec321b4d64ee02a1b90021c09d9513618787c6e8.tar.bz2
Handle \n's in value names for more targets. The asm printers
really really really need refactoring :( git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47171 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCAsmPrinter.cpp')
-rw-r--r--lib/Target/PowerPC/PPCAsmPrinter.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 605dc12..acc6570 100644
--- a/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -639,6 +639,15 @@ bool LinuxAsmPrinter::doInitialization(Module &M) {
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 @@ bool LinuxAsmPrinter::doFinalization(Module &M) {
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 @@ bool LinuxAsmPrinter::doFinalization(Module &M) {
}
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 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
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 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
}
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!