mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-07 16:54:48 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75607 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1b8f70a0d3
commit
1cda87c3a0
@ -94,8 +94,8 @@ public:
|
|||||||
/// does this for you, so there's no point calling it on the result
|
/// does this for you, so there's no point calling it on the result
|
||||||
/// from getValueName.
|
/// from getValueName.
|
||||||
///
|
///
|
||||||
std::string makeNameProper(const std::string &x, const char *Prefix = 0,
|
std::string makeNameProper(const std::string &x,
|
||||||
const char *PrivatePrefix = 0);
|
bool hasPrivateLinkage = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
@ -271,8 +271,8 @@ AsmPrinter::getCurrentFunctionEHName(const MachineFunction *MF,
|
|||||||
Name = MF->getFunction()->getName();
|
Name = MF->getFunction()->getName();
|
||||||
if (Name.empty())
|
if (Name.empty())
|
||||||
Name = Mang->getValueName(MF->getFunction());
|
Name = Mang->getValueName(MF->getFunction());
|
||||||
Name = Mang->makeNameProper(TAI->getEHGlobalPrefix() +
|
|
||||||
Name + ".eh", TAI->getGlobalPrefix());
|
Name = Mang->makeNameProper(TAI->getEHGlobalPrefix() + Name + ".eh");
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ public:
|
|||||||
/// specified debug variable.
|
/// specified debug variable.
|
||||||
DIE *&getDieMapSlotFor(GlobalVariable *GV) { return GVToDieMap[GV]; }
|
DIE *&getDieMapSlotFor(GlobalVariable *GV) { return GVToDieMap[GV]; }
|
||||||
|
|
||||||
/// getDIEEntrySlotFor - Returns the debug information entry proxy slot for the
|
/// getDIEEntrySlotFor - Returns the debug information entry proxy slot for
|
||||||
/// specified debug variable.
|
/// the specified debug variable.
|
||||||
DIEEntry *&getDIEEntrySlotFor(GlobalVariable *GV) {
|
DIEEntry *&getDIEEntrySlotFor(GlobalVariable *GV) {
|
||||||
return GVToDIEEntryMap[GV];
|
return GVToDIEEntryMap[GV];
|
||||||
}
|
}
|
||||||
|
@ -31,14 +31,17 @@ static std::string MangleLetter(unsigned char C) {
|
|||||||
/// makeNameProper - We don't want identifier names non-C-identifier characters
|
/// makeNameProper - We don't want identifier names non-C-identifier characters
|
||||||
/// in them, so mangle them as appropriate.
|
/// in them, so mangle them as appropriate.
|
||||||
///
|
///
|
||||||
std::string Mangler::makeNameProper(const std::string &X, const char *Prefix,
|
std::string Mangler::makeNameProper(const std::string &X,
|
||||||
const char *PrivatePrefix) {
|
bool hasPrivateLinkage) {
|
||||||
if (X.empty()) return X; // Empty names are uniqued by the caller.
|
assert(!X.empty() && "Cannot mangle empty strings");
|
||||||
|
|
||||||
// If PreserveAsmNames is set, names with asm identifiers are not modified.
|
// If PreserveAsmNames is set, names with asm identifiers are not modified.
|
||||||
if (PreserveAsmNames && X[0] == 1)
|
if (PreserveAsmNames && X[0] == 1)
|
||||||
return X;
|
return X;
|
||||||
|
|
||||||
|
// Figure out the prefix to use.
|
||||||
|
const char *ThePrefix = hasPrivateLinkage ? PrivatePrefix : Prefix;
|
||||||
|
|
||||||
if (!UseQuotes) {
|
if (!UseQuotes) {
|
||||||
std::string Result;
|
std::string Result;
|
||||||
|
|
||||||
@ -61,12 +64,8 @@ std::string Mangler::makeNameProper(const std::string &X, const char *Prefix,
|
|||||||
Result += *I;
|
Result += *I;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NeedPrefix) {
|
if (NeedPrefix)
|
||||||
if (Prefix)
|
Result = ThePrefix + Result;
|
||||||
Result = Prefix + Result;
|
|
||||||
if (PrivatePrefix)
|
|
||||||
Result = PrivatePrefix + Result;
|
|
||||||
}
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,18 +93,13 @@ std::string Mangler::makeNameProper(const std::string &X, const char *Prefix,
|
|||||||
|
|
||||||
// In the common case, we don't need quotes. Handle this quickly.
|
// In the common case, we don't need quotes. Handle this quickly.
|
||||||
if (!NeedQuotes) {
|
if (!NeedQuotes) {
|
||||||
if (NeedPrefix) {
|
if (!NeedPrefix)
|
||||||
if (Prefix)
|
return X.substr(1); // Strip off the \001.
|
||||||
Result = Prefix + X;
|
return ThePrefix + X;
|
||||||
else
|
|
||||||
Result = X;
|
|
||||||
if (PrivatePrefix)
|
|
||||||
Result = PrivatePrefix + Result;
|
|
||||||
return Result;
|
|
||||||
} else
|
|
||||||
return X.substr(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result = X.substr(0, I-X.begin());
|
||||||
|
|
||||||
// Otherwise, construct the string the expensive way.
|
// Otherwise, construct the string the expensive way.
|
||||||
for (std::string::const_iterator E = X.end(); I != E; ++I) {
|
for (std::string::const_iterator E = X.end(); I != E; ++I) {
|
||||||
if (*I == '"')
|
if (*I == '"')
|
||||||
@ -116,14 +110,8 @@ std::string Mangler::makeNameProper(const std::string &X, const char *Prefix,
|
|||||||
Result += *I;
|
Result += *I;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NeedPrefix) {
|
if (NeedPrefix)
|
||||||
if (Prefix)
|
Result = ThePrefix + Result;
|
||||||
Result = Prefix + X;
|
|
||||||
else
|
|
||||||
Result = X;
|
|
||||||
if (PrivatePrefix)
|
|
||||||
Result = PrivatePrefix + Result;
|
|
||||||
}
|
|
||||||
Result = '"' + Result + '"';
|
Result = '"' + Result + '"';
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
@ -132,11 +120,8 @@ std::string Mangler::getValueName(const GlobalValue *GV, const char *Suffix) {
|
|||||||
assert((!isa<Function>(GV) || !cast<Function>(GV)->isIntrinsic()) &&
|
assert((!isa<Function>(GV) || !cast<Function>(GV)->isIntrinsic()) &&
|
||||||
"Intrinsic functions cannot be mangled by Mangler");
|
"Intrinsic functions cannot be mangled by Mangler");
|
||||||
|
|
||||||
if (GV->hasName()) {
|
if (GV->hasName())
|
||||||
if (GV->hasPrivateLinkage())
|
return makeNameProper(GV->getName() + Suffix, GV->hasPrivateLinkage());
|
||||||
return makeNameProper(GV->getName() + Suffix, Prefix, PrivatePrefix);
|
|
||||||
return makeNameProper(GV->getName() + Suffix, Prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the ID for the global, assigning a new one if we haven't got one
|
// Get the ID for the global, assigning a new one if we haven't got one
|
||||||
// already.
|
// already.
|
||||||
|
@ -6,20 +6,20 @@
|
|||||||
; RUN: grep .Lbaz: %t
|
; RUN: grep .Lbaz: %t
|
||||||
; RUN: grep lis.*\.Lbaz %t
|
; RUN: grep lis.*\.Lbaz %t
|
||||||
; RUN: llvm-as < %s | llc -mtriple=powerpc-apple-darwin > %t
|
; RUN: llvm-as < %s | llc -mtriple=powerpc-apple-darwin > %t
|
||||||
; RUN: grep L_foo: %t
|
; RUN: grep Lfoo: %t
|
||||||
; RUN: grep bl.*\L_foo %t
|
; RUN: grep bl.*\Lfoo %t
|
||||||
; RUN: grep L_baz: %t
|
; RUN: grep Lbaz: %t
|
||||||
; RUN: grep lis.*\L_baz %t
|
; RUN: grep lis.*\Lbaz %t
|
||||||
|
|
||||||
declare void @foo()
|
declare void @foo() nounwind
|
||||||
|
|
||||||
define private void @foo() {
|
define private void @foo() nounwind {
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
@baz = private global i32 4;
|
@baz = private global i32 4;
|
||||||
|
|
||||||
define i32 @bar() {
|
define i32 @bar() nounwind {
|
||||||
call void @foo()
|
call void @foo()
|
||||||
%1 = load i32* @baz, align 4
|
%1 = load i32* @baz, align 4
|
||||||
ret i32 %1
|
ret i32 %1
|
||||||
|
@ -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.
|
; Quote should be outside of private prefix.
|
||||||
; rdar://6855766x
|
; rdar://6855766x
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user