aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Mangler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore/Mangler.cpp')
-rw-r--r--lib/VMCore/Mangler.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/VMCore/Mangler.cpp b/lib/VMCore/Mangler.cpp
index cec41df..10a29db 100644
--- a/lib/VMCore/Mangler.cpp
+++ b/lib/VMCore/Mangler.cpp
@@ -116,12 +116,19 @@ std::string Mangler::makeNameProper(const std::string &X,
return Result;
}
-std::string Mangler::getValueName(const GlobalValue *GV, const char *Suffix) {
+/// getMangledName - Returns the mangled name of V, an LLVM Value,
+/// in the current module. If 'Suffix' is specified, the name ends with the
+/// specified suffix. If 'ForcePrivate' is specified, the label is specified
+/// to have a private label prefix.
+///
+std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix,
+ bool ForcePrivate) {
assert((!isa<Function>(GV) || !cast<Function>(GV)->isIntrinsic()) &&
"Intrinsic functions cannot be mangled by Mangler");
if (GV->hasName())
- return makeNameProper(GV->getName() + Suffix, GV->hasPrivateLinkage());
+ return makeNameProper(GV->getName() + Suffix,
+ GV->hasPrivateLinkage() | ForcePrivate);
// Get the ID for the global, assigning a new one if we haven't got one
// already.
@@ -129,7 +136,8 @@ std::string Mangler::getValueName(const GlobalValue *GV, const char *Suffix) {
if (ID == 0) ID = NextAnonGlobalID++;
// Must mangle the global into a unique ID.
- return "__unnamed_" + utostr(ID) + Suffix;
+ return makeNameProper("__unnamed_" + utostr(ID) + Suffix,
+ GV->hasPrivateLinkage() | ForcePrivate);
}
Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix)