aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2009-01-15 20:18:42 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2009-01-15 20:18:42 +0000
commitbb46f52027416598a662dc1c58f48d9d56b1a65b (patch)
treeebdd7fc62b19bc9bdb7cc03563fd817d3943f17e
parentf193ff05909c2de373032f773e76804474b1ef4e (diff)
Add the private linkage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62279 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--docs/LangRef.html17
-rw-r--r--include/llvm/GlobalValue.h5
-rw-r--r--include/llvm/Module.h2
-rw-r--r--include/llvm/Support/Mangler.h3
-rw-r--r--lib/Analysis/IPA/Andersens.cpp2
-rw-r--r--lib/Analysis/IPA/CallGraph.cpp2
-rw-r--r--lib/Analysis/IPA/GlobalsModRef.cpp6
-rw-r--r--lib/Archive/Archive.cpp4
-rw-r--r--lib/AsmParser/LLLexer.cpp1
-rw-r--r--lib/AsmParser/LLParser.cpp7
-rw-r--r--lib/AsmParser/LLToken.h2
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp1
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp1
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp4
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfWriter.cpp3
-rw-r--r--lib/CodeGen/ELFWriter.cpp5
-rw-r--r--lib/CodeGen/MachOWriter.cpp5
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp2
-rw-r--r--lib/ExecutionEngine/ExecutionEngine.cpp4
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp2
-rw-r--r--lib/Linker/LinkArchives.cpp4
-rw-r--r--lib/Linker/LinkModules.cpp40
-rw-r--r--lib/Target/ARM/ARMISelLowering.cpp2
-rw-r--r--lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp10
-rw-r--r--lib/Target/Alpha/AlphaISelLowering.cpp2
-rw-r--r--lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp1
-rw-r--r--lib/Target/CBackend/CBackend.cpp6
-rw-r--r--lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp7
-rw-r--r--lib/Target/CppBackend/CPPBackend.cpp2
-rw-r--r--lib/Target/DarwinTargetAsmInfo.cpp2
-rw-r--r--lib/Target/ELFTargetAsmInfo.cpp2
-rw-r--r--lib/Target/IA64/IA64AsmPrinter.cpp5
-rw-r--r--lib/Target/MSIL/MSILWriter.cpp6
-rw-r--r--lib/Target/Mips/MipsAsmPrinter.cpp15
-rw-r--r--lib/Target/Mips/MipsISelLowering.cpp4
-rw-r--r--lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp10
-rw-r--r--lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp14
-rw-r--r--lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp12
-rw-r--r--lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp1
-rw-r--r--lib/Target/X86/X86Subtarget.cpp4
-rw-r--r--lib/Target/XCore/XCoreAsmPrinter.cpp14
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp2
-rw-r--r--lib/Transforms/IPO/ConstantMerge.cpp4
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp4
-rw-r--r--lib/Transforms/IPO/ExtractGV.cpp3
-rw-r--r--lib/Transforms/IPO/GlobalDCE.cpp4
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp12
-rw-r--r--lib/Transforms/IPO/IPConstantPropagation.cpp2
-rw-r--r--lib/Transforms/IPO/Inliner.cpp4
-rw-r--r--lib/Transforms/IPO/Internalize.cpp6
-rw-r--r--lib/Transforms/IPO/MergeFunctions.cpp4
-rw-r--r--lib/Transforms/IPO/StripSymbols.cpp12
-rw-r--r--lib/Transforms/IPO/StructRetPromotion.cpp2
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp10
-rw-r--r--lib/Transforms/Utils/BasicInliner.cpp2
-rw-r--r--lib/Transforms/Utils/InlineCost.cpp2
-rw-r--r--lib/VMCore/AsmWriter.cpp1
-rw-r--r--lib/VMCore/Mangler.cpp12
-rw-r--r--lib/VMCore/Module.cpp11
-rw-r--r--lib/VMCore/Verifier.cpp4
-rw-r--r--test/Assembler/private.ll9
-rw-r--r--test/CodeGen/ARM/private.ll22
-rw-r--r--test/CodeGen/Alpha/private.ll21
-rw-r--r--test/CodeGen/CellSPU/private.ll22
-rw-r--r--test/CodeGen/IA64/private.ll21
-rw-r--r--test/CodeGen/Mips/private.ll21
-rw-r--r--test/CodeGen/PowerPC/private.ll21
-rw-r--r--test/CodeGen/SPARC/private.ll21
-rw-r--r--test/CodeGen/X86/private.ll20
-rw-r--r--test/CodeGen/XCore/private.ll21
-rw-r--r--tools/bugpoint/ExtractFunction.cpp2
-rw-r--r--tools/llvm-nm/llvm-nm.cpp3
72 files changed, 401 insertions, 145 deletions
diff --git a/docs/LangRef.html b/docs/LangRef.html
index e097c2a84c..5eef225326 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -480,13 +480,20 @@ All Global Variables and Functions have one of the following types of linkage:
<dl>
- <dt><tt><b><a name="linkage_internal">internal</a></b></tt>: </dt>
+ <dt><tt><b><a name="linkage_private">private</a></b></tt>: </dt>
- <dd>Global values with internal linkage are only directly accessible by
+ <dd>Global values with private linkage are only directly accessible by
objects in the current module. In particular, linking code into a module with
- an internal global value may cause the internal to be renamed as necessary to
- avoid collisions. Because the symbol is internal to the module, all
- references can be updated. This corresponds to the notion of the
+ an private global value may cause the private to be renamed as necessary to
+ avoid collisions. Because the symbol is private to the module, all
+ references can be updated. This doesn't show up in any symbol table in the
+ object file.
+ </dd>
+
+ <dt><tt><b><a name="linkage_internal">internal</a></b></tt>: </dt>
+
+ <dd> Similar to private, but the value show as a local symbol (STB_LOCAL in
+ the case of ELF) in the object file. This corresponds to the notion of the
'<tt>static</tt>' keyword in C.
</dd>
diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h
index b0e58d4451..8fb5580d0d 100644
--- a/include/llvm/GlobalValue.h
+++ b/include/llvm/GlobalValue.h
@@ -35,6 +35,7 @@ public:
WeakLinkage, ///< Keep one copy of named function when linking (weak)
AppendingLinkage, ///< Special purpose, only applies to global arrays
InternalLinkage, ///< Rename collisions when linking (static functions)
+ PrivateLinkage, ///< Like Internal, but omit from symbol table
DLLImportLinkage, ///< Function to be imported from DLL
DLLExportLinkage, ///< Function to be accessible from DLL
ExternalWeakLinkage,///< ExternalWeak linkage description
@@ -104,6 +105,10 @@ public:
bool hasCommonLinkage() const { return Linkage == CommonLinkage; }
bool hasAppendingLinkage() const { return Linkage == AppendingLinkage; }
bool hasInternalLinkage() const { return Linkage == InternalLinkage; }
+ bool hasPrivateLinkage() const { return Linkage == PrivateLinkage; }
+ bool hasLocalLinkage() const {
+ return Linkage == InternalLinkage || Linkage == PrivateLinkage;
+ }
bool hasDLLImportLinkage() const { return Linkage == DLLImportLinkage; }
bool hasDLLExportLinkage() const { return Linkage == DLLExportLinkage; }
bool hasExternalWeakLinkage() const { return Linkage == ExternalWeakLinkage; }
diff --git a/include/llvm/Module.h b/include/llvm/Module.h
index af687c84c3..b0db50a379 100644
--- a/include/llvm/Module.h
+++ b/include/llvm/Module.h
@@ -188,7 +188,7 @@ public:
/// getOrInsertFunction - Look up the specified function in the module symbol
/// table. Four possibilities:
/// 1. If it does not exist, add a prototype for the function and return it.
- /// 2. If it exists, and has internal linkage, the existing function is
+ /// 2. If it exists, and has a local linkage, the existing function is
/// renamed and a new one is inserted.
/// 3. Otherwise, if the existing function has the correct prototype, return
/// the existing function.
diff --git a/include/llvm/Support/Mangler.h b/include/llvm/Support/Mangler.h
index 771c09ee0e..7820b85095 100644
--- a/include/llvm/Support/Mangler.h
+++ b/include/llvm/Support/Mangler.h
@@ -29,6 +29,7 @@ class Mangler {
/// symbol is marked as not needing this prefix.
const char *Prefix;
+ const char *PrivatePrefix;
/// UseQuotes - If this is set, the target accepts global names in quotes,
/// e.g. "foo bar" is a legal name. This syntax is used instead of escaping
/// the space character. By default, this is false.
@@ -58,7 +59,7 @@ public:
// Mangler ctor - if a prefix is specified, it will be prepended onto all
// symbols.
- Mangler(Module &M, const char *Prefix = "");
+ Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "");
/// setUseQuotes - If UseQuotes is set to true, this target accepts quoted
/// strings for assembler labels.
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->isDec