[llvm-commits] [llvm] r75607 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/VMCore/Mangler.cpp test/CodeGen/PowerPC/private.ll test/CodeGen/X86/private-2.ll
Chris Lattner
sabre at nondot.org
Mon Jul 13 21:50:14 PDT 2009
Author: lattner
Date: Mon Jul 13 23:50:12 2009
New Revision: 75607
URL: http://llvm.org/viewvc/llvm-project?rev=75607&view=rev
Log:
Change the internal interface to makeNameProper to take a bool that
indicates whether the label is private or not, instead of taking
prefix stuff. One effect of this is that symbols will be generated
with *just* the private prefix, instead of both the private prefix
*and* the user-label-prefix, but this doesn't matter as long as it
is consistent. For example we'll now get "Lfoo" instead of "L_foo".
These are just assembler temporary labels anyway, so they never even
make it into the .o file.
Modified:
llvm/trunk/include/llvm/Support/Mangler.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/VMCore/Mangler.cpp
llvm/trunk/test/CodeGen/PowerPC/private.ll
llvm/trunk/test/CodeGen/X86/private-2.ll
Modified: llvm/trunk/include/llvm/Support/Mangler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=75607&r1=75606&r2=75607&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Mangler.h (original)
+++ llvm/trunk/include/llvm/Support/Mangler.h Mon Jul 13 23:50:12 2009
@@ -94,8 +94,8 @@
/// does this for you, so there's no point calling it on the result
/// from getValueName.
///
- std::string makeNameProper(const std::string &x, const char *Prefix = 0,
- const char *PrivatePrefix = 0);
+ std::string makeNameProper(const std::string &x,
+ bool hasPrivateLinkage = false);
};
} // End llvm namespace
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=75607&r1=75606&r2=75607&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Jul 13 23:50:12 2009
@@ -271,8 +271,8 @@
Name = MF->getFunction()->getName();
if (Name.empty())
Name = Mang->getValueName(MF->getFunction());
- Name = Mang->makeNameProper(TAI->getEHGlobalPrefix() +
- Name + ".eh", TAI->getGlobalPrefix());
+
+ Name = Mang->makeNameProper(TAI->getEHGlobalPrefix() + Name + ".eh");
return Name;
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=75607&r1=75606&r2=75607&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Jul 13 23:50:12 2009
@@ -86,8 +86,8 @@
/// specified debug variable.
DIE *&getDieMapSlotFor(GlobalVariable *GV) { return GVToDieMap[GV]; }
- /// getDIEEntrySlotFor - Returns the debug information entry proxy slot for the
- /// specified debug variable.
+ /// getDIEEntrySlotFor - Returns the debug information entry proxy slot for
+ /// the specified debug variable.
DIEEntry *&getDIEEntrySlotFor(GlobalVariable *GV) {
return GVToDIEEntryMap[GV];
}
Modified: llvm/trunk/lib/VMCore/Mangler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=75607&r1=75606&r2=75607&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Mangler.cpp (original)
+++ llvm/trunk/lib/VMCore/Mangler.cpp Mon Jul 13 23:50:12 2009
@@ -31,13 +31,16 @@
/// makeNameProper - We don't want identifier names non-C-identifier characters
/// in them, so mangle them as appropriate.
///
-std::string Mangler::makeNameProper(const std::string &X, const char *Prefix,
- const char *PrivatePrefix) {
- if (X.empty()) return X; // Empty names are uniqued by the caller.
+std::string Mangler::makeNameProper(const std::string &X,
+ bool hasPrivateLinkage) {
+ assert(!X.empty() && "Cannot mangle empty strings");
// If PreserveAsmNames is set, names with asm identifiers are not modified.
if (PreserveAsmNames && X[0] == 1)
return X;
+
+ // Figure out the prefix to use.
+ const char *ThePrefix = hasPrivateLinkage ? PrivatePrefix : Prefix;
if (!UseQuotes) {
std::string Result;
@@ -61,12 +64,8 @@
Result += *I;
}
- if (NeedPrefix) {
- if (Prefix)
- Result = Prefix + Result;
- if (PrivatePrefix)
- Result = PrivatePrefix + Result;
- }
+ if (NeedPrefix)
+ Result = ThePrefix + Result;
return Result;
}
@@ -94,17 +93,12 @@
// In the common case, we don't need quotes. Handle this quickly.
if (!NeedQuotes) {
- if (NeedPrefix) {
- if (Prefix)
- Result = Prefix + X;
- else
- Result = X;
- if (PrivatePrefix)
- Result = PrivatePrefix + Result;
- return Result;
- } else
- return X.substr(1);
+ if (!NeedPrefix)
+ return X.substr(1); // Strip off the \001.
+ return ThePrefix + X;
}
+
+ Result = X.substr(0, I-X.begin());
// Otherwise, construct the string the expensive way.
for (std::string::const_iterator E = X.end(); I != E; ++I) {
@@ -116,14 +110,8 @@
Result += *I;
}
- if (NeedPrefix) {
- if (Prefix)
- Result = Prefix + X;
- else
- Result = X;
- if (PrivatePrefix)
- Result = PrivatePrefix + Result;
- }
+ if (NeedPrefix)
+ Result = ThePrefix + Result;
Result = '"' + Result + '"';
return Result;
}
@@ -132,11 +120,8 @@
assert((!isa<Function>(GV) || !cast<Function>(GV)->isIntrinsic()) &&
"Intrinsic functions cannot be mangled by Mangler");
- if (GV->hasName()) {
- if (GV->hasPrivateLinkage())
- return makeNameProper(GV->getName() + Suffix, Prefix, PrivatePrefix);
- return makeNameProper(GV->getName() + Suffix, Prefix);
- }
+ if (GV->hasName())
+ return makeNameProper(GV->getName() + Suffix, GV->hasPrivateLinkage());
// Get the ID for the global, assigning a new one if we haven't got one
// already.
Modified: llvm/trunk/test/CodeGen/PowerPC/private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/private.ll?rev=75607&r1=75606&r2=75607&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/private.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/private.ll Mon Jul 13 23:50:12 2009
@@ -6,20 +6,20 @@
; RUN: grep .Lbaz: %t
; RUN: grep lis.*\.Lbaz %t
; RUN: llvm-as < %s | llc -mtriple=powerpc-apple-darwin > %t
-; RUN: grep L_foo: %t
-; RUN: grep bl.*\L_foo %t
-; RUN: grep L_baz: %t
-; RUN: grep lis.*\L_baz %t
+; RUN: grep Lfoo: %t
+; RUN: grep bl.*\Lfoo %t
+; RUN: grep Lbaz: %t
+; RUN: grep lis.*\Lbaz %t
-declare void @foo()
+declare void @foo() nounwind
-define private void @foo() {
+define private void @foo() nounwind {
ret void
}
@baz = private global i32 4;
-define i32 @bar() {
+define i32 @bar() nounwind {
call void @foo()
%1 = load i32* @baz, align 4
ret i32 %1
Modified: llvm/trunk/test/CodeGen/X86/private-2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/private-2.ll?rev=75607&r1=75606&r2=75607&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/private-2.ll (original)
+++ llvm/trunk/test/CodeGen/X86/private-2.ll Mon Jul 13 23:50:12 2009
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin10 | grep L__ZZ20
+; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin10 | grep L_ZZ20
; Quote should be outside of private prefix.
; rdar://6855766x
More information about the llvm-commits
mailing list