diff options
Diffstat (limited to 'lib')
56 files changed, 179 insertions, 136 deletions
diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index 38b29fed0b..8584d06f7a 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -1084,7 +1084,7 @@ void Andersens::CollectConstraints(Module &M) { // At some point we should just add constraints for the escaping functions // at solve time, but this slows down solving. For now, we simply mark // address taken functions as escaping and treat them as external. - if (!F->hasInternalLinkage() || AnalyzeUsesOfFunction(F)) + if (!F->hasLocalLinkage() || AnalyzeUsesOfFunction(F)) AddConstraintsForNonInternalLinkage(F); if (!F->isDeclaration()) { diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 1dfca607d8..c1082a0028 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -112,7 +112,7 @@ private: CallGraphNode *Node = getOrInsertFunction(F); // If this function has external linkage, anything could call it. - if (!F->hasInternalLinkage()) { + if (!F->hasLocalLinkage()) { ExternalCallingNode->addCalledFunction(CallSite(), Node); // Found the entry point? diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index 99e9d215b0..a795ca675f 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -164,7 +164,7 @@ Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); } void GlobalsModRef::AnalyzeGlobals(Module &M) { std::vector<Function*> Readers, Writers; for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (I->hasInternalLinkage()) { + if (I->hasLocalLinkage()) { if (!AnalyzeUsesOfPointer(I, Readers, Writers)) { // Remember that we are tracking this global. NonAddressTakenGlobals.insert(I); @@ -175,7 +175,7 @@ void GlobalsModRef::AnalyzeGlobals(Module &M) { for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) - if (I->hasInternalLinkage()) { + if (I->hasLocalLinkage()) { if (!AnalyzeUsesOfPointer(I, Readers, Writers)) { // Remember that we are tracking this global, and the mod/ref fns NonAddressTakenGlobals.insert(I); @@ -504,7 +504,7 @@ GlobalsModRef::getModRefInfo(CallSite CS, Value *P, unsigned Size) { // If we are asking for mod/ref info of a direct call with a pointer to a // global we are tracking, return information if we have it. if (GlobalValue *GV = dyn_cast<GlobalValue>(P->getUnderlyingObject())) - if (GV->hasInternalLinkage()) + if (GV->hasLocalLinkage()) if (Function *F = CS.getCalledFunction()) if (NonAddressTakenGlobals.count(GV)) if (FunctionRecord *FR = getFunctionInfo(F)) diff --git a/lib/Archive/Archive.cpp b/lib/Archive/Archive.cpp index 776f4dd367..c6c89d27db 100644 --- a/lib/Archive/Archive.cpp +++ b/lib/Archive/Archive.cpp @@ -188,13 +188,13 @@ Archive::~Archive() { static void getSymbols(Module*M, std::vector<std::string>& symbols) { // Loop over global variables for (Module::global_iterator GI = M->global_begin(), GE=M->global_end(); GI != GE; ++GI) - if (!GI->isDeclaration() && !GI->hasInternalLinkage()) + if (!GI->isDeclaration() && !GI->hasLocalLinkage()) if (!GI->getName().empty()) symbols.push_back(GI->getName()); // Loop over functions for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI) - if (!FI->isDeclaration() && !FI->hasInternalLinkage()) + if (!FI->isDeclaration() && !FI->hasLocalLinkage()) if (!FI->getName().empty()) symbols.push_back(FI->getName()); diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp index 6a3777dedd..fb491d3278 100644 --- a/lib/AsmParser/LLLexer.cpp +++ b/lib/AsmParser/LLLexer.cpp @@ -453,6 +453,7 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(declare); KEYWORD(define); KEYWORD(global); KEYWORD(constant); + KEYWORD(private); KEYWORD(internal); KEYWORD(linkonce); KEYWORD(weak); diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index edfdf15438..401dc39ca5 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -113,6 +113,7 @@ bool LLParser::ParseTopLevelEntities() { // optional leading prefixes, the production is: // GlobalVar ::= OptionalLinkage OptionalVisibility OptionalThreadLocal // OptionalAddrSpace ('constant'|'global') ... + case lltok::kw_private: // OptionalLinkage case lltok::kw_internal: // OptionalLinkage case lltok::kw_weak: // OptionalLinkage case lltok::kw_linkonce: // OptionalLinkage @@ -375,7 +376,8 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc, if (Linkage != GlobalValue::ExternalLinkage && Linkage != GlobalValue::WeakLinkage && - Linkage != GlobalValue::InternalLinkage) + Linkage != GlobalValue::InternalLinkage && + Linkage != GlobalValue::PrivateLinkage) return Error(LinkageLoc, "invalid linkage type for alias"); Constant *Aliasee; @@ -738,6 +740,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) { /// ParseOptionalLinkage /// ::= /*empty*/ +/// ::= 'private' /// ::= 'internal' /// ::= 'weak' /// ::= 'linkonce' @@ -751,6 +754,7 @@ bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) { HasLinkage = false; switch (Lex.getKind()) { default: Res = GlobalValue::ExternalLinkage; return false; + case lltok::kw_private: Res = GlobalValue::PrivateLinkage; break; case lltok::kw_internal: Res = GlobalValue::InternalLinkage; break; case lltok::kw_weak: Res = GlobalValue::WeakLinkage; break; case lltok::kw_linkonce: Res = GlobalValue::LinkOnceLinkage; break; @@ -2065,6 +2069,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { if (isDefine) return Error(LinkageLoc, "invalid linkage for function definition"); break; + case GlobalValue::PrivateLinkage: case GlobalValue::InternalLinkage: case GlobalValue::LinkOnceLinkage: case GlobalValue::WeakLinkage: diff --git a/lib/AsmParser/LLToken.h b/lib/AsmParser/LLToken.h index 75a483fce5..e3bc908b6e 100644 --- a/lib/AsmParser/LLToken.h +++ b/lib/AsmParser/LLToken.h @@ -36,7 +36,7 @@ namespace lltok { kw_declare, kw_define, kw_global, kw_constant, - kw_internal, kw_linkonce, kw_weak, kw_appending, kw_dllimport, + kw_private, kw_internal, kw_linkonce, kw_weak, kw_appending, kw_dllimport, kw_dllexport, kw_common, kw_default, kw_hidden, kw_protected, kw_extern_weak, kw_external, kw_thread_local, diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 2d994d4b13..87700284c4 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -67,6 +67,7 @@ static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val) { case 6: return GlobalValue::DLLExportLinkage; case 7: return GlobalValue::ExternalWeakLinkage; case 8: return GlobalValue::CommonLinkage; + case 9: return GlobalValue::PrivateLinkage; } } diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 81a1a37996..da400a7360 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -284,6 +284,7 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) { case GlobalValue::DLLExportLinkage: return 6; case GlobalValue::ExternalWeakLinkage: return 7; case GlobalValue::CommonLinkage: return 8; + case GlobalValue::PrivateLinkage: return 9; } } diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 6627543a85..5b665a0c22 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -139,7 +139,7 @@ void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { } bool AsmPrinter::doInitialization(Module &M) { - Mang = new Mangler(M, TAI->getGlobalPrefix()); + Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix()); GCModuleInfo *MI = getAnalysisToUpdate<GCModuleInfo>(); assert(MI && "AsmPrinter didn't require GCModuleInfo?"); @@ -199,7 +199,7 @@ bool AsmPrinter::doFinalization(Module &M) { O << "\t.globl\t" << Name << '\n'; else if (I->hasWeakLinkage()) O << TAI->getWeakRefDirective() << Name << '\n'; - else if (!I->hasInternalLinkage()) + else if (!I->hasLocalLinkage()) assert(0 && "Invalid alias linkage"); printVisibility(Name, I->getVisibility()); diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 09d169b6f3..02f27d181a 100644 --- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -3272,7 +3272,8 @@ private: // Externally visible entry into the functions eh frame info. // If the corresponding function is static, this should not be // externally visible. - if (linkage != Function::InternalLinkage) { + if (linkage != Function::InternalLinkage && + linkage != Function::PrivateLinkage) { if (const char *GlobalEHDirective = TAI->getGlobalEHDirective()) O << GlobalEHDirective << EHFrameInfo.FnName << "\n"; } diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index 5d2fca134e..b698178d78 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/lib/CodeGen/ELFWriter.cpp @@ -174,6 +174,8 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &F) { case GlobalValue::WeakLinkage: FnSym.SetBind(ELFWriter::ELFSym::STB_WEAK); break; + case GlobalValue::PrivateLinkage: + assert (0 && "PrivateLinkage should not be in the symbol table."); case GlobalValue::InternalLinkage: FnSym.SetBind(ELFWriter::ELFSym::STB_LOCAL); break; @@ -329,7 +331,8 @@ void ELFWriter::EmitGlobal(GlobalVariable *GV) { // Set the idx of the .bss section BSSSym.SectionIdx = BSSSection.SectionIdx; - SymbolTable.push_back(BSSSym); + if (!GV->hasPrivateLinkage()) + SymbolTable.push_back(BSSSym); // Reserve space in the .bss section for this symbol. BSSSection.Size += Size; diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp index ae1f0d4b04..ef37db8ac9 100644 --- a/lib/CodeGen/MachOWriter.cpp +++ b/lib/CodeGen/MachOWriter.cpp @@ -371,7 +371,7 @@ void MachOWriter::AddSymbolToSection(MachOSection *Sec, GlobalVariable *GV) { SecDataOut.outbyte(0); } // Globals without external linkage apparently do not go in the symbol table. - if (GV->getLinkage() != GlobalValue::InternalLinkage) { + if (!GV->hasLocalLinkage()) { MachOSym Sym(GV, Mang->getValueName(GV), Sec->Index, TM); Sym.n_value = Sec->size; SymbolTable.push_back(Sym); @@ -959,6 +959,9 @@ MachOSym::MachOSym(const GlobalValue *gv, std::string name, uint8_t sect, GVName = TAI->getGlobalPrefix() + name; n_type |= GV->hasHiddenVisibility() ? N_PEXT : N_EXT; break; + case GlobalValue::PrivateLinkage: + GVName = TAI->getPrivateGlobalPrefix() + name; + break; case GlobalValue::InternalLinkage: GVName = TAI->getGlobalPrefix() + name; break; diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index 60a4f61d25..49b7ad80a2 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -4276,7 +4276,7 @@ void SelectionDAGLowering::visitCall(CallInst &I) { // Check for well-known libc/libm calls. If the function is internal, it // can't be a library call. unsigned NameLen = F->getNameLen(); - if (!F->hasInternalLinkage() && NameLen) { + if (!F->hasLocalLinkage() && NameLen) { const char *NameStr = F->getNameStart(); if (NameStr[0] == 'c' && ((NameLen == 8 && !strcmp(NameStr, "copysign")) || diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 9c7592841d..a1fbdd2812 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -249,7 +249,7 @@ void ExecutionEngine::runStaticConstructorsDestructors(Module *module, bool isDt // an old-style (llvmgcc3) static ctor with __main linked in and in use. If // this is the case, don't execute any of the global ctors, __main will do // it. - if (!GV || GV->isDeclaration() || GV->hasInternalLinkage()) return; + if (!GV || GV->isDeclaration() || GV->hasLocalLinkage()) return; // Should be an array of '{ int, void ()* }' structs. The first value is // the init priority, which we ignore. @@ -893,7 +893,7 @@ void ExecutionEngine::emitGlobals() { for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) { const GlobalValue *GV = I; - if (GV->hasInternalLinkage() || GV->isDeclaration() || + if (GV->hasLocalLinkage() || GV->isDeclaration() || GV->hasAppendingLinkage() || !GV->hasName()) continue;// Ignore external globals and globals with internal linkage. diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 1db3662700..dc502c1e8b 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -554,7 +554,7 @@ void *JIT::getOrEmitGlobalVariable(const GlobalVariable *GV) { addGlobalMapping(GV, Ptr); } } else { - if (isGVCompilationDisabled() && !GV->hasInternalLinkage()) { + if (isGVCompilationDisabled() && !GV->hasLocalLinkage()) { cerr << "Compilation of non-internal GlobalValue is disabled!\n"; abort(); } diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp index 6cab77c601..551cc8c390 100644 --- a/lib/Linker/LinkArchives.cpp +++ b/lib/Linker/LinkArchives.cpp @@ -50,7 +50,7 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) { if (I->hasName()) { if (I->isDeclaration()) UndefinedSymbols.insert(I->getName()); - else if (!I->hasInternalLinkage()) { + else if (!I->hasLocalLinkage()) { assert(!I->hasDLLImportLinkage() && "Found dllimported non-external symbol!"); DefinedSymbols.insert(I->getName()); @@ -62,7 +62,7 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) { if (I->hasName()) { if (I->isDeclaration()) UndefinedSymbols.insert(I->getName()); - else if (!I->hasInternalLinkage()) { + else if (!I->hasLocalLinkage()) { assert(!I->hasDLLImportLinkage() && "Found dllimported non-external symbol!"); DefinedSymbols.insert(I->getName()); diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index b8b36ad475..001db21555 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -1,4 +1,4 @@ -//===- lib/Linker/LinkModules.cpp - Module Linker Implementation ----------===// + //===- lib/Linker/LinkModules.cpp - Module Linker Implementation ----------===// // // The LLVM Compiler Infrastructure // @@ -415,7 +415,7 @@ static void ForceRenaming(GlobalValue *GV, const std::string &Name) { // If there is a conflict, rename the conflict. if (GlobalValue *ConflictGV = cast_or_null<GlobalValue>(ST.lookup(Name))) { - assert(ConflictGV->hasInternalLinkage() && + assert(ConflictGV->hasLocalLinkage() && "Not conflicting with a static global, should link instead!"); GV->takeName(ConflictGV); ConflictGV->setName(Name); // This will cause ConflictGV to get renamed @@ -444,7 +444,7 @@ static void CopyGVAttributes(GlobalValue *DestGV, const GlobalValue *SrcGV) { static bool GetLinkageResult(GlobalValue *Dest, const GlobalValue *Src, GlobalValue::LinkageTypes <, bool &LinkFromSrc, std::string *Err) { - assert((!Dest || !Src->hasInternalLinkage()) && + assert((!Dest || !Src->hasLocalLinkage()) && "If Src has internal linkage, Dest shouldn't be set!"); if (!Dest) { // Linking something to nothing. @@ -536,13 +536,13 @@ static bool LinkGlobals(Module *Dest, const Module *Src, // Check to see if may have to link the global with the global, alias or // function. - if (SGV->hasName() && !SGV->hasInternalLinkage()) + if (SGV->hasName() && !SGV->hasLocalLinkage()) DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SGV->getNameStart(), SGV->getNameEnd())); // If we found a global with the same name in the dest module, but it has // internal linkage, we are really not doing any linkage here. - if (DGV && DGV->hasInternalLinkage()) + if (DGV && DGV->hasLocalLinkage()) DGV = 0; // If types don't agree due to opaque types, try to resolve them. @@ -573,7 +573,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src, // If the LLVM runtime renamed the global, but it is an externally visible // symbol, DGV must be an existing global with internal linkage. Rename // it. - if (!NewDGV->hasInternalLinkage() && NewDGV->getName() != SGV->getName()) + if (!NewDGV->hasLocalLinkage() && NewDGV->getName() != SGV->getName()) ForceRenaming(NewDGV, SGV->getName()); // Make sure to remember this mapping. @@ -643,7 +643,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src, // If the symbol table renamed the global, but it is an externally visible // symbol, DGV must be an existing global with internal linkage. Rename. - if (NewDGV->getName() != SGV->getName() && !NewDGV->hasInternalLinkage()) + if (NewDGV->getName() != SGV->getName() && !NewDGV->hasLocalLinkage()) ForceRenaming(NewDGV, SGV->getName()); // Inherit const as appropriate. @@ -687,10 +687,12 @@ CalculateAliasLinkage(const GlobalValue *SGV, const GlobalValue *DGV) { return GlobalValue::ExternalLinkage; else if (SGV->hasWeakLinkage() || DGV->hasWeakLinkage()) return GlobalValue::WeakLinkage; - else { - assert(SGV->hasInternalLinkage() && DGV->hasInternalLinkage() && - "Unexpected linkage type"); + else if (SGV->hasInternalLinkage() && DGV->hasInternalLinkage()) return GlobalValue::InternalLinkage; + else { + assert (SGV->hasPrivateLinkage() && DGV->hasPrivateLinkage() && + "Unexpected linkage type"); + return GlobalValue::PrivateLinkage; } } @@ -715,7 +717,7 @@ static bool LinkAlias(Module *Dest, const Module *Src, GlobalValue* DGV = NULL; // Try to find something 'similar' to SGA in destination module. - if (!DGV && !SGA->hasInternalLinkage()) { + if (!DGV && !SGA->hasLocalLinkage()) { DGV = Dest->getNamedAlias(SGA->getName()); // If types don't agree due to opaque types, try to resolve them. @@ -723,7 +725,7 @@ static bool LinkAlias(Module *Dest, const Module *Src, RecursiveResolveTypes(SGA->getType(), DGV->getType()); } - if (!DGV && !SGA->hasInternalLinkage()) { + if (!DGV && !SGA->hasLocalLinkage()) { DGV = Dest->getGlobalVariable(SGA->getName()); // If types don't agree due to opaque types, try to resolve them. @@ -731,7 +733,7 @@ static bool LinkAlias(Module *Dest, const Module *Src, RecursiveResolveTypes(SGA->getType(), DGV->getType()); } - if (!DGV && !SGA->hasInternalLinkage()) { + if (!DGV && !SGA->hasLocalLinkage()) { DGV = Dest->getFunction(SGA->getName()); // If types don't agree due to opaque types, try to resolve them. @@ -740,7 +742,7 @@ static bool LinkAlias(Module *Dest, const Module *Src, } // No linking to be performed on internal stuff. - if (DGV && DGV->hasInternalLinkage()) + if (DGV && DGV->hasLocalLinkage()) DGV = NULL; if (GlobalAlias *DGA = dyn_cast_or_null<GlobalAlias>(DGV)) { @@ -831,7 +833,7 @@ static bool LinkAlias(Module *Dest, const Module *Src, // If the symbol table renamed the alias, but it is an externally visible // symbol, DGA must be an global value with internal linkage. Rename it. if (NewGA->getName() != SGA->getName() && - !NewGA->hasInternalLinkage()) + !NewGA->hasLocalLinkage()) ForceRenaming(NewGA, SGA->getName()); // Remember this mapping so uses in the source module get remapped @@ -912,13 +914,13 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src, // Check to see if may have to link the function with the global, alias or // function. - if (SF->hasName() && !SF->hasInternalLinkage()) + if (SF->hasName() && !SF->hasLocalLinkage()) DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SF->getNameStart(), SF->getNameEnd())); // If we found a global with the same name in the dest module, but it has // internal linkage, we are really not doing any linkage here. - if (DGV && DGV->hasInternalLinkage()) + if (DGV && DGV->hasLocalLinkage()) DGV = 0; // If types don't agree due to opaque types, try to resolve them. @@ -943,7 +945,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src, // If the LLVM runtime renamed the function, but it is an externally // visible symbol, DF must be an existing function with internal linkage. // Rename it. - if (!NewDF->hasInternalLinkage() && NewDF->getName() != SF->getName()) + if (!NewDF->hasLocalLinkage() && NewDF->getName() != SF->getName()) ForceRenaming(NewD |