/// 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];
}
/// 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;
Result += *I;
}
- if (NeedPrefix) {
- if (Prefix)
- Result = Prefix + Result;
- if (PrivatePrefix)
- Result = PrivatePrefix + Result;
- }
+ if (NeedPrefix)
+ Result = ThePrefix + Result;
return Result;
}
// 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) {
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;
}
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.
; 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