diff options
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 1 | ||||
-rw-r--r-- | lib/VMCore/Mangler.cpp | 12 | ||||
-rw-r--r-- | lib/VMCore/Module.cpp | 11 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 4 |
4 files changed, 17 insertions, 11 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index bdc50b6..b59ec08 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1149,6 +1149,7 @@ void AssemblyWriter::printModule(const Module *M) { static void PrintLinkage(GlobalValue::LinkageTypes LT, raw_ostream &Out) { switch (LT) { + case GlobalValue::PrivateLinkage: Out << "private "; break; case GlobalValue::InternalLinkage: Out << "internal "; break; case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break; case GlobalValue::WeakLinkage: Out << "weak "; break; diff --git a/lib/VMCore/Mangler.cpp b/lib/VMCore/Mangler.cpp index 1488494..36cfbf7 100644 --- a/lib/VMCore/Mangler.cpp +++ b/lib/VMCore/Mangler.cpp @@ -147,14 +147,20 @@ std::string Mangler::getValueName(const GlobalValue *GV, const char * Suffix) { Name = "__unnamed_" + utostr(TypeUniqueID) + "_" + utostr(GlobalID++); } else { Name = makeNameProper(GV->getName() + Suffix, Prefix); + std::string prefix; + if (GV->hasPrivateLinkage()) + prefix = PrivatePrefix; + else + prefix = ""; + Name = prefix + Name; } return Name; } -Mangler::Mangler(Module &M, const char *prefix) - : Prefix(prefix), UseQuotes(false), PreserveAsmNames(false), - Count(0), TypeCounter(0) { +Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix) + : Prefix(prefix), PrivatePrefix (privatePrefix), UseQuotes(false), + PreserveAsmNames(false), Count(0), TypeCounter(0) { std::fill(AcceptableChars, array_endof(AcceptableChars), 0); // Letters and numbers are acceptable. diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index d5b48c0..ef94796 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -153,7 +153,7 @@ Constant *Module::getOrInsertFunction(const std::string &Name, } // Okay, the function exists. Does it have externally visible linkage? - if (F->hasInternalLinkage()) { + if (F->hasLocalLinkage()) { // Clear the function's name. F->setName(""); // Retry, now there won't be a conflict. @@ -238,14 +238,14 @@ Function *Module::getFunction(const char *Name) const { /// symbol table. If it does not exist, return null. The type argument /// should be the underlying type of the global, i.e., it should not have /// the top-level PointerType, which represents the address of the global. -/// If AllowInternal is set to true, this function will return types that -/// have InternalLinkage. By default, these types are not returned. +/// If AllowLocal is set to true, this function will return types that +/// have an local. By default, these types are not returned. /// GlobalVariable *Module::getGlobalVariable(const std::string &Name, - bool AllowInternal) const { + bool AllowLocal) const { if (Value *V = ValSymTab->lookup(Name)) { GlobalVariable *Result = dyn_cast<GlobalVariable>(V); - if (Result && (AllowInternal || !Result->hasInternalLinkage())) + if (Result && (AllowLocal || !Result->hasLocalLinkage())) return Result; } return 0; @@ -376,4 +376,3 @@ void Module::removeLibrary(const std::string& Lib) { return; } } - diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 4744103..790a994 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -350,7 +350,7 @@ void Verifier::visitGlobalValue(GlobalValue &GV) { GV.hasExternalWeakLinkage() || GV.hasGhostLinkage() || (isa<GlobalAlias>(GV) && - (GV.hasInternalLinkage() || GV.hasWeakLinkage())), + (GV.hasLocalLinkage() || GV.hasWeakLinkage())), "Global is external, but doesn't have external or dllimport or weak linkage!", &GV); @@ -384,7 +384,7 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) { void Verifier::visitGlobalAlias(GlobalAlias &GA) { Assert1(!GA.getName().empty(), "Alias name cannot be empty!", &GA); - Assert1(GA.hasExternalLinkage() || GA.hasInternalLinkage() || + Assert1(GA.hasExternalLinkage() || GA.hasLocalLinkage() || GA.hasWeakLinkage(), "Alias should have external or external weak linkage!", &GA); Assert1(GA.getAliasee(), |