mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Add the private linkage.
llvm-svn: 62279
This commit is contained in:
parent
97d45c48c5
commit
0aba6c9435
@ -480,13 +480,20 @@ All Global Variables and Functions have one of the following types of linkage:
|
|||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
|
|
||||||
|
<dt><tt><b><a name="linkage_private">private</a></b></tt>: </dt>
|
||||||
|
|
||||||
|
<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 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>
|
<dt><tt><b><a name="linkage_internal">internal</a></b></tt>: </dt>
|
||||||
|
|
||||||
<dd>Global values with internal linkage are only directly accessible by
|
<dd> Similar to private, but the value show as a local symbol (STB_LOCAL in
|
||||||
objects in the current module. In particular, linking code into a module with
|
the case of ELF) in the object file. This corresponds to the notion of the
|
||||||
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
|
|
||||||
'<tt>static</tt>' keyword in C.
|
'<tt>static</tt>' keyword in C.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ public:
|
|||||||
WeakLinkage, ///< Keep one copy of named function when linking (weak)
|
WeakLinkage, ///< Keep one copy of named function when linking (weak)
|
||||||
AppendingLinkage, ///< Special purpose, only applies to global arrays
|
AppendingLinkage, ///< Special purpose, only applies to global arrays
|
||||||
InternalLinkage, ///< Rename collisions when linking (static functions)
|
InternalLinkage, ///< Rename collisions when linking (static functions)
|
||||||
|
PrivateLinkage, ///< Like Internal, but omit from symbol table
|
||||||
DLLImportLinkage, ///< Function to be imported from DLL
|
DLLImportLinkage, ///< Function to be imported from DLL
|
||||||
DLLExportLinkage, ///< Function to be accessible from DLL
|
DLLExportLinkage, ///< Function to be accessible from DLL
|
||||||
ExternalWeakLinkage,///< ExternalWeak linkage description
|
ExternalWeakLinkage,///< ExternalWeak linkage description
|
||||||
@ -104,6 +105,10 @@ public:
|
|||||||
bool hasCommonLinkage() const { return Linkage == CommonLinkage; }
|
bool hasCommonLinkage() const { return Linkage == CommonLinkage; }
|
||||||
bool hasAppendingLinkage() const { return Linkage == AppendingLinkage; }
|
bool hasAppendingLinkage() const { return Linkage == AppendingLinkage; }
|
||||||
bool hasInternalLinkage() const { return Linkage == InternalLinkage; }
|
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 hasDLLImportLinkage() const { return Linkage == DLLImportLinkage; }
|
||||||
bool hasDLLExportLinkage() const { return Linkage == DLLExportLinkage; }
|
bool hasDLLExportLinkage() const { return Linkage == DLLExportLinkage; }
|
||||||
bool hasExternalWeakLinkage() const { return Linkage == ExternalWeakLinkage; }
|
bool hasExternalWeakLinkage() const { return Linkage == ExternalWeakLinkage; }
|
||||||
|
@ -188,7 +188,7 @@ public:
|
|||||||
/// getOrInsertFunction - Look up the specified function in the module symbol
|
/// getOrInsertFunction - Look up the specified function in the module symbol
|
||||||
/// table. Four possibilities:
|
/// table. Four possibilities:
|
||||||
/// 1. If it does not exist, add a prototype for the function and return it.
|
/// 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.
|
/// renamed and a new one is inserted.
|
||||||
/// 3. Otherwise, if the existing function has the correct prototype, return
|
/// 3. Otherwise, if the existing function has the correct prototype, return
|
||||||
/// the existing function.
|
/// the existing function.
|
||||||
|
@ -29,6 +29,7 @@ class Mangler {
|
|||||||
/// symbol is marked as not needing this prefix.
|
/// symbol is marked as not needing this prefix.
|
||||||
const char *Prefix;
|
const char *Prefix;
|
||||||
|
|
||||||
|
const char *PrivatePrefix;
|
||||||
/// UseQuotes - If this is set, the target accepts global names in quotes,
|
/// 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
|
/// e.g. "foo bar" is a legal name. This syntax is used instead of escaping
|
||||||
/// the space character. By default, this is false.
|
/// 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
|
// Mangler ctor - if a prefix is specified, it will be prepended onto all
|
||||||
// symbols.
|
// 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
|
/// setUseQuotes - If UseQuotes is set to true, this target accepts quoted
|
||||||
/// strings for assembler labels.
|
/// strings for assembler labels.
|
||||||
|
@ -1084,7 +1084,7 @@ void Andersens::CollectConstraints(Module &M) {
|
|||||||
// At some point we should just add constraints for the escaping functions
|
// 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
|
// at solve time, but this slows down solving. For now, we simply mark
|
||||||
// address taken functions as escaping and treat them as external.
|
// address taken functions as escaping and treat them as external.
|
||||||
if (!F->hasInternalLinkage() || AnalyzeUsesOfFunction(F))
|
if (!F->hasLocalLinkage() || AnalyzeUsesOfFunction(F))
|
||||||
AddConstraintsForNonInternalLinkage(F);
|
AddConstraintsForNonInternalLinkage(F);
|
||||||
|
|
||||||
if (!F->isDeclaration()) {
|
if (!F->isDeclaration()) {
|
||||||
|
@ -112,7 +112,7 @@ private:
|
|||||||
CallGraphNode *Node = getOrInsertFunction(F);
|
CallGraphNode *Node = getOrInsertFunction(F);
|
||||||
|
|
||||||
// If this function has external linkage, anything could call it.
|
// If this function has external linkage, anything could call it.
|
||||||
if (!F->hasInternalLinkage()) {
|
if (!F->hasLocalLinkage()) {
|
||||||
ExternalCallingNode->addCalledFunction(CallSite(), Node);
|
ExternalCallingNode->addCalledFunction(CallSite(), Node);
|
||||||
|
|
||||||
// Found the entry point?
|
// Found the entry point?
|
||||||
|
@ -164,7 +164,7 @@ Pass *llvm::createGlobalsModRefPass() { return new GlobalsModRef(); }
|
|||||||
void GlobalsModRef::AnalyzeGlobals(Module &M) {
|
void GlobalsModRef::AnalyzeGlobals(Module &M) {
|
||||||
std::vector<Function*> Readers, Writers;
|
std::vector<Function*> Readers, Writers;
|
||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
||||||
if (I->hasInternalLinkage()) {
|
if (I->hasLocalLinkage()) {
|
||||||
if (!AnalyzeUsesOfPointer(I, Readers, Writers)) {
|
if (!AnalyzeUsesOfPointer(I, Readers, Writers)) {
|
||||||
// Remember that we are tracking this global.
|
// Remember that we are tracking this global.
|
||||||
NonAddressTakenGlobals.insert(I);
|
NonAddressTakenGlobals.insert(I);
|
||||||
@ -175,7 +175,7 @@ void GlobalsModRef::AnalyzeGlobals(Module &M) {
|
|||||||
|
|
||||||
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (I->hasInternalLinkage()) {
|
if (I->hasLocalLinkage()) {
|
||||||
if (!AnalyzeUsesOfPointer(I, Readers, Writers)) {
|
if (!AnalyzeUsesOfPointer(I, Readers, Writers)) {
|
||||||
// Remember that we are tracking this global, and the mod/ref fns
|
// Remember that we are tracking this global, and the mod/ref fns
|
||||||
NonAddressTakenGlobals.insert(I);
|
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
|
// 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.
|
// global we are tracking, return information if we have it.
|
||||||
if (GlobalValue *GV = dyn_cast<GlobalValue>(P->getUnderlyingObject()))
|
if (GlobalValue *GV = dyn_cast<GlobalValue>(P->getUnderlyingObject()))
|
||||||
if (GV->hasInternalLinkage())
|
if (GV->hasLocalLinkage())
|
||||||
if (Function *F = CS.getCalledFunction())
|
if (Function *F = CS.getCalledFunction())
|
||||||
if (NonAddressTakenGlobals.count(GV))
|
if (NonAddressTakenGlobals.count(GV))
|
||||||
if (FunctionRecord *FR = getFunctionInfo(F))
|
if (FunctionRecord *FR = getFunctionInfo(F))
|
||||||
|
@ -188,13 +188,13 @@ Archive::~Archive() {
|
|||||||
static void getSymbols(Module*M, std::vector<std::string>& symbols) {
|
static void getSymbols(Module*M, std::vector<std::string>& symbols) {
|
||||||
// Loop over global variables
|
// Loop over global variables
|
||||||
for (Module::global_iterator GI = M->global_begin(), GE=M->global_end(); GI != GE; ++GI)
|
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())
|
if (!GI->getName().empty())
|
||||||
symbols.push_back(GI->getName());
|
symbols.push_back(GI->getName());
|
||||||
|
|
||||||
// Loop over functions
|
// Loop over functions
|
||||||
for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI)
|
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())
|
if (!FI->getName().empty())
|
||||||
symbols.push_back(FI->getName());
|
symbols.push_back(FI->getName());
|
||||||
|
|
||||||
|
@ -453,6 +453,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
|||||||
KEYWORD(declare); KEYWORD(define);
|
KEYWORD(declare); KEYWORD(define);
|
||||||
KEYWORD(global); KEYWORD(constant);
|
KEYWORD(global); KEYWORD(constant);
|
||||||
|
|
||||||
|
KEYWORD(private);
|
||||||
KEYWORD(internal);
|
KEYWORD(internal);
|
||||||
KEYWORD(linkonce);
|
KEYWORD(linkonce);
|
||||||
KEYWORD(weak);
|
KEYWORD(weak);
|
||||||
|
@ -113,6 +113,7 @@ bool LLParser::ParseTopLevelEntities() {
|
|||||||
// optional leading prefixes, the production is:
|
// optional leading prefixes, the production is:
|
||||||
// GlobalVar ::= OptionalLinkage OptionalVisibility OptionalThreadLocal
|
// GlobalVar ::= OptionalLinkage OptionalVisibility OptionalThreadLocal
|
||||||
// OptionalAddrSpace ('constant'|'global') ...
|
// OptionalAddrSpace ('constant'|'global') ...
|
||||||
|
case lltok::kw_private: // OptionalLinkage
|
||||||
case lltok::kw_internal: // OptionalLinkage
|
case lltok::kw_internal: // OptionalLinkage
|
||||||
case lltok::kw_weak: // OptionalLinkage
|
case lltok::kw_weak: // OptionalLinkage
|
||||||
case lltok::kw_linkonce: // OptionalLinkage
|
case lltok::kw_linkonce: // OptionalLinkage
|
||||||
@ -375,7 +376,8 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
|
|||||||
|
|
||||||
if (Linkage != GlobalValue::ExternalLinkage &&
|
if (Linkage != GlobalValue::ExternalLinkage &&
|
||||||
Linkage != GlobalValue::WeakLinkage &&
|
Linkage != GlobalValue::WeakLinkage &&
|
||||||
Linkage != GlobalValue::InternalLinkage)
|
Linkage != GlobalValue::InternalLinkage &&
|
||||||
|
Linkage != GlobalValue::PrivateLinkage)
|
||||||
return Error(LinkageLoc, "invalid linkage type for alias");
|
return Error(LinkageLoc, "invalid linkage type for alias");
|
||||||
|
|
||||||
Constant *Aliasee;
|
Constant *Aliasee;
|
||||||
@ -738,6 +740,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
|
|||||||
|
|
||||||
/// ParseOptionalLinkage
|
/// ParseOptionalLinkage
|
||||||
/// ::= /*empty*/
|
/// ::= /*empty*/
|
||||||
|
/// ::= 'private'
|
||||||
/// ::= 'internal'
|
/// ::= 'internal'
|
||||||
/// ::= 'weak'
|
/// ::= 'weak'
|
||||||
/// ::= 'linkonce'
|
/// ::= 'linkonce'
|
||||||
@ -751,6 +754,7 @@ bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) {
|
|||||||
HasLinkage = false;
|
HasLinkage = false;
|
||||||
switch (Lex.getKind()) {
|
switch (Lex.getKind()) {
|
||||||
default: Res = GlobalValue::ExternalLinkage; return false;
|
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_internal: Res = GlobalValue::InternalLinkage; break;
|
||||||
case lltok::kw_weak: Res = GlobalValue::WeakLinkage; break;
|
case lltok::kw_weak: Res = GlobalValue::WeakLinkage; break;
|
||||||
case lltok::kw_linkonce: Res = GlobalValue::LinkOnceLinkage; break;
|
case lltok::kw_linkonce: Res = GlobalValue::LinkOnceLinkage; break;
|
||||||
@ -2065,6 +2069,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
|||||||
if (isDefine)
|
if (isDefine)
|
||||||
return Error(LinkageLoc, "invalid linkage for function definition");
|
return Error(LinkageLoc, "invalid linkage for function definition");
|
||||||
break;
|
break;
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
case GlobalValue::LinkOnceLinkage:
|
case GlobalValue::LinkOnceLinkage:
|
||||||
case GlobalValue::WeakLinkage:
|
case GlobalValue::WeakLinkage:
|
||||||
|
@ -36,7 +36,7 @@ namespace lltok {
|
|||||||
kw_declare, kw_define,
|
kw_declare, kw_define,
|
||||||
kw_global, kw_constant,
|
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_dllexport, kw_common, kw_default, kw_hidden, kw_protected,
|
||||||
kw_extern_weak,
|
kw_extern_weak,
|
||||||
kw_external, kw_thread_local,
|
kw_external, kw_thread_local,
|
||||||
|
@ -67,6 +67,7 @@ static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val) {
|
|||||||
case 6: return GlobalValue::DLLExportLinkage;
|
case 6: return GlobalValue::DLLExportLinkage;
|
||||||
case 7: return GlobalValue::ExternalWeakLinkage;
|
case 7: return GlobalValue::ExternalWeakLinkage;
|
||||||
case 8: return GlobalValue::CommonLinkage;
|
case 8: return GlobalValue::CommonLinkage;
|
||||||
|
case 9: return GlobalValue::PrivateLinkage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,6 +284,7 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) {
|
|||||||
case GlobalValue::DLLExportLinkage: return 6;
|
case GlobalValue::DLLExportLinkage: return 6;
|
||||||
case GlobalValue::ExternalWeakLinkage: return 7;
|
case GlobalValue::ExternalWeakLinkage: return 7;
|
||||||
case GlobalValue::CommonLinkage: return 8;
|
case GlobalValue::CommonLinkage: return 8;
|
||||||
|
case GlobalValue::PrivateLinkage: return 9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AsmPrinter::doInitialization(Module &M) {
|
bool AsmPrinter::doInitialization(Module &M) {
|
||||||
Mang = new Mangler(M, TAI->getGlobalPrefix());
|
Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix());
|
||||||
|
|
||||||
GCModuleInfo *MI = getAnalysisToUpdate<GCModuleInfo>();
|
GCModuleInfo *MI = getAnalysisToUpdate<GCModuleInfo>();
|
||||||
assert(MI && "AsmPrinter didn't require GCModuleInfo?");
|
assert(MI && "AsmPrinter didn't require GCModuleInfo?");
|
||||||
@ -199,7 +199,7 @@ bool AsmPrinter::doFinalization(Module &M) {
|
|||||||
O << "\t.globl\t" << Name << '\n';
|
O << "\t.globl\t" << Name << '\n';
|
||||||
else if (I->hasWeakLinkage())
|
else if (I->hasWeakLinkage())
|
||||||
O << TAI->getWeakRefDirective() << Name << '\n';
|
O << TAI->getWeakRefDirective() << Name << '\n';
|
||||||
else if (!I->hasInternalLinkage())
|
else if (!I->hasLocalLinkage())
|
||||||
assert(0 && "Invalid alias linkage");
|
assert(0 && "Invalid alias linkage");
|
||||||
|
|
||||||
printVisibility(Name, I->getVisibility());
|
printVisibility(Name, I->getVisibility());
|
||||||
|
@ -3272,7 +3272,8 @@ private:
|
|||||||
// Externally visible entry into the functions eh frame info.
|
// Externally visible entry into the functions eh frame info.
|
||||||
// If the corresponding function is static, this should not be
|
// If the corresponding function is static, this should not be
|
||||||
// externally visible.
|
// externally visible.
|
||||||
if (linkage != Function::InternalLinkage) {
|
if (linkage != Function::InternalLinkage &&
|
||||||
|
linkage != Function::PrivateLinkage) {
|
||||||
if (const char *GlobalEHDirective = TAI->getGlobalEHDirective())
|
if (const char *GlobalEHDirective = TAI->getGlobalEHDirective())
|
||||||
O << GlobalEHDirective << EHFrameInfo.FnName << "\n";
|
O << GlobalEHDirective << EHFrameInfo.FnName << "\n";
|
||||||
}
|
}
|
||||||
|
@ -174,6 +174,8 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &F) {
|
|||||||
case GlobalValue::WeakLinkage:
|
case GlobalValue::WeakLinkage:
|
||||||
FnSym.SetBind(ELFWriter::ELFSym::STB_WEAK);
|
FnSym.SetBind(ELFWriter::ELFSym::STB_WEAK);
|
||||||
break;
|
break;
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
|
assert (0 && "PrivateLinkage should not be in the symbol table.");
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
FnSym.SetBind(ELFWriter::ELFSym::STB_LOCAL);
|
FnSym.SetBind(ELFWriter::ELFSym::STB_LOCAL);
|
||||||
break;
|
break;
|
||||||
@ -329,7 +331,8 @@ void ELFWriter::EmitGlobal(GlobalVariable *GV) {
|
|||||||
|
|
||||||
// Set the idx of the .bss section
|
// Set the idx of the .bss section
|
||||||
BSSSym.SectionIdx = BSSSection.SectionIdx;
|
BSSSym.SectionIdx = BSSSection.SectionIdx;
|
||||||
SymbolTable.push_back(BSSSym);
|
if (!GV->hasPrivateLinkage())
|
||||||
|
SymbolTable.push_back(BSSSym);
|
||||||
|
|
||||||
// Reserve space in the .bss section for this symbol.
|
// Reserve space in the .bss section for this symbol.
|
||||||
BSSSection.Size += Size;
|
BSSSection.Size += Size;
|
||||||
|
@ -371,7 +371,7 @@ void MachOWriter::AddSymbolToSection(MachOSection *Sec, GlobalVariable *GV) {
|
|||||||
SecDataOut.outbyte(0);
|
SecDataOut.outbyte(0);
|
||||||
}
|
}
|
||||||
// Globals without external linkage apparently do not go in the symbol table.
|
// 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);
|
MachOSym Sym(GV, Mang->getValueName(GV), Sec->Index, TM);
|
||||||
Sym.n_value = Sec->size;
|
Sym.n_value = Sec->size;
|
||||||
SymbolTable.push_back(Sym);
|
SymbolTable.push_back(Sym);
|
||||||
@ -959,6 +959,9 @@ MachOSym::MachOSym(const GlobalValue *gv, std::string name, uint8_t sect,
|
|||||||
GVName = TAI->getGlobalPrefix() + name;
|
GVName = TAI->getGlobalPrefix() + name;
|
||||||
n_type |= GV->hasHiddenVisibility() ? N_PEXT : N_EXT;
|
n_type |= GV->hasHiddenVisibility() ? N_PEXT : N_EXT;
|
||||||
break;
|
break;
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
|
GVName = TAI->getPrivateGlobalPrefix() + name;
|
||||||
|
break;
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
GVName = TAI->getGlobalPrefix() + name;
|
GVName = TAI->getGlobalPrefix() + name;
|
||||||
break;
|
break;
|
||||||
|
@ -4276,7 +4276,7 @@ void SelectionDAGLowering::visitCall(CallInst &I) {
|
|||||||
// Check for well-known libc/libm calls. If the function is internal, it
|
// Check for well-known libc/libm calls. If the function is internal, it
|
||||||
// can't be a library call.
|
// can't be a library call.
|
||||||
unsigned NameLen = F->getNameLen();
|
unsigned NameLen = F->getNameLen();
|
||||||
if (!F->hasInternalLinkage() && NameLen) {
|
if (!F->hasLocalLinkage() && NameLen) {
|
||||||
const char *NameStr = F->getNameStart();
|
const char *NameStr = F->getNameStart();
|
||||||
if (NameStr[0] == 'c' &&
|
if (NameStr[0] == 'c' &&
|
||||||
((NameLen == 8 && !strcmp(NameStr, "copysign")) ||
|
((NameLen == 8 && !strcmp(NameStr, "copysign")) ||
|
||||||
|
@ -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
|
// 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
|
// this is the case, don't execute any of the global ctors, __main will do
|
||||||
// it.
|
// 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
|
// Should be an array of '{ int, void ()* }' structs. The first value is
|
||||||
// the init priority, which we ignore.
|
// the init priority, which we ignore.
|
||||||
@ -893,7 +893,7 @@ void ExecutionEngine::emitGlobals() {
|
|||||||
for (Module::const_global_iterator I = M.global_begin(),
|
for (Module::const_global_iterator I = M.global_begin(),
|
||||||
E = M.global_end(); I != E; ++I) {
|
E = M.global_end(); I != E; ++I) {
|
||||||
const GlobalValue *GV = I;
|
const GlobalValue *GV = I;
|
||||||
if (GV->hasInternalLinkage() || GV->isDeclaration() ||
|
if (GV->hasLocalLinkage() || GV->isDeclaration() ||
|
||||||
GV->hasAppendingLinkage() || !GV->hasName())
|
GV->hasAppendingLinkage() || !GV->hasName())
|
||||||
continue;// Ignore external globals and globals with internal linkage.
|
continue;// Ignore external globals and globals with internal linkage.
|
||||||
|
|
||||||
|
@ -554,7 +554,7 @@ void *JIT::getOrEmitGlobalVariable(const GlobalVariable *GV) {
|
|||||||
addGlobalMapping(GV, Ptr);
|
addGlobalMapping(GV, Ptr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isGVCompilationDisabled() && !GV->hasInternalLinkage()) {
|
if (isGVCompilationDisabled() && !GV->hasLocalLinkage()) {
|
||||||
cerr << "Compilation of non-internal GlobalValue is disabled!\n";
|
cerr << "Compilation of non-internal GlobalValue is disabled!\n";
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
|
|||||||
if (I->hasName()) {
|
if (I->hasName()) {
|
||||||
if (I->isDeclaration())
|
if (I->isDeclaration())
|
||||||
UndefinedSymbols.insert(I->getName());
|
UndefinedSymbols.insert(I->getName());
|
||||||
else if (!I->hasInternalLinkage()) {
|
else if (!I->hasLocalLinkage()) {
|
||||||
assert(!I->hasDLLImportLinkage()
|
assert(!I->hasDLLImportLinkage()
|
||||||
&& "Found dllimported non-external symbol!");
|
&& "Found dllimported non-external symbol!");
|
||||||
DefinedSymbols.insert(I->getName());
|
DefinedSymbols.insert(I->getName());
|
||||||
@ -62,7 +62,7 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
|
|||||||
if (I->hasName()) {
|
if (I->hasName()) {
|
||||||
if (I->isDeclaration())
|
if (I->isDeclaration())
|
||||||
UndefinedSymbols.insert(I->getName());
|
UndefinedSymbols.insert(I->getName());
|
||||||
else if (!I->hasInternalLinkage()) {
|
else if (!I->hasLocalLinkage()) {
|
||||||
assert(!I->hasDLLImportLinkage()
|
assert(!I->hasDLLImportLinkage()
|
||||||
&& "Found dllimported non-external symbol!");
|
&& "Found dllimported non-external symbol!");
|
||||||
DefinedSymbols.insert(I->getName());
|
DefinedSymbols.insert(I->getName());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===- lib/Linker/LinkModules.cpp - Module Linker Implementation ----------===//
|
//===- lib/Linker/LinkModules.cpp - Module Linker Implementation ----------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// 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 there is a conflict, rename the conflict.
|
||||||
if (GlobalValue *ConflictGV = cast_or_null<GlobalValue>(ST.lookup(Name))) {
|
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!");
|
"Not conflicting with a static global, should link instead!");
|
||||||
GV->takeName(ConflictGV);
|
GV->takeName(ConflictGV);
|
||||||
ConflictGV->setName(Name); // This will cause ConflictGV to get renamed
|
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,
|
static bool GetLinkageResult(GlobalValue *Dest, const GlobalValue *Src,
|
||||||
GlobalValue::LinkageTypes <, bool &LinkFromSrc,
|
GlobalValue::LinkageTypes <, bool &LinkFromSrc,
|
||||||
std::string *Err) {
|
std::string *Err) {
|
||||||
assert((!Dest || !Src->hasInternalLinkage()) &&
|
assert((!Dest || !Src->hasLocalLinkage()) &&
|
||||||
"If Src has internal linkage, Dest shouldn't be set!");
|
"If Src has internal linkage, Dest shouldn't be set!");
|
||||||
if (!Dest) {
|
if (!Dest) {
|
||||||
// Linking something to nothing.
|
// 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
|
// Check to see if may have to link the global with the global, alias or
|
||||||
// function.
|
// function.
|
||||||
if (SGV->hasName() && !SGV->hasInternalLinkage())
|
if (SGV->hasName() && !SGV->hasLocalLinkage())
|
||||||
DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SGV->getNameStart(),
|
DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SGV->getNameStart(),
|
||||||
SGV->getNameEnd()));
|
SGV->getNameEnd()));
|
||||||
|
|
||||||
// If we found a global with the same name in the dest module, but it has
|
// 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.
|
// internal linkage, we are really not doing any linkage here.
|
||||||
if (DGV && DGV->hasInternalLinkage())
|
if (DGV && DGV->hasLocalLinkage())
|
||||||
DGV = 0;
|
DGV = 0;
|
||||||
|
|
||||||
// If types don't agree due to opaque types, try to resolve them.
|
// 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
|
// If the LLVM runtime renamed the global, but it is an externally visible
|
||||||
// symbol, DGV must be an existing global with internal linkage. Rename
|
// symbol, DGV must be an existing global with internal linkage. Rename
|
||||||
// it.
|
// it.
|
||||||
if (!NewDGV->hasInternalLinkage() && NewDGV->getName() != SGV->getName())
|
if (!NewDGV->hasLocalLinkage() && NewDGV->getName() != SGV->getName())
|
||||||
ForceRenaming(NewDGV, SGV->getName());
|
ForceRenaming(NewDGV, SGV->getName());
|
||||||
|
|
||||||
// Make sure to remember this mapping.
|
// 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
|
// If the symbol table renamed the global, but it is an externally visible
|
||||||
// symbol, DGV must be an existing global with internal linkage. Rename.
|
// 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());
|
ForceRenaming(NewDGV, SGV->getName());
|
||||||
|
|
||||||
// Inherit const as appropriate.
|
// Inherit const as appropriate.
|
||||||
@ -687,10 +687,12 @@ CalculateAliasLinkage(const GlobalValue *SGV, const GlobalValue *DGV) {
|
|||||||
return GlobalValue::ExternalLinkage;
|
return GlobalValue::ExternalLinkage;
|
||||||
else if (SGV->hasWeakLinkage() || DGV->hasWeakLinkage())
|
else if (SGV->hasWeakLinkage() || DGV->hasWeakLinkage())
|
||||||
return GlobalValue::WeakLinkage;
|
return GlobalValue::WeakLinkage;
|
||||||
else {
|
else if (SGV->hasInternalLinkage() && DGV->hasInternalLinkage())
|
||||||
assert(SGV->hasInternalLinkage() && DGV->hasInternalLinkage() &&
|
|
||||||
"Unexpected linkage type");
|
|
||||||
return GlobalValue::InternalLinkage;
|
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;
|
GlobalValue* DGV = NULL;
|
||||||
|
|
||||||
// Try to find something 'similar' to SGA in destination module.
|
// Try to find something 'similar' to SGA in destination module.
|
||||||
if (!DGV && !SGA->hasInternalLinkage()) {
|
if (!DGV && !SGA->hasLocalLinkage()) {
|
||||||
DGV = Dest->getNamedAlias(SGA->getName());
|
DGV = Dest->getNamedAlias(SGA->getName());
|
||||||
|
|
||||||
// If types don't agree due to opaque types, try to resolve them.
|
// 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());
|
RecursiveResolveTypes(SGA->getType(), DGV->getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DGV && !SGA->hasInternalLinkage()) {
|
if (!DGV && !SGA->hasLocalLinkage()) {
|
||||||
DGV = Dest->getGlobalVariable(SGA->getName());
|
DGV = Dest->getGlobalVariable(SGA->getName());
|
||||||
|
|
||||||
// If types don't agree due to opaque types, try to resolve them.
|
// 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());
|
RecursiveResolveTypes(SGA->getType(), DGV->getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DGV && !SGA->hasInternalLinkage()) {
|
if (!DGV && !SGA->hasLocalLinkage()) {
|
||||||
DGV = Dest->getFunction(SGA->getName());
|
DGV = Dest->getFunction(SGA->getName());
|
||||||
|
|
||||||
// If types don't agree due to opaque types, try to resolve them.
|
// 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.
|
// No linking to be performed on internal stuff.
|
||||||
if (DGV && DGV->hasInternalLinkage())
|
if (DGV && DGV->hasLocalLinkage())
|
||||||
DGV = NULL;
|
DGV = NULL;
|
||||||
|
|
||||||
if (GlobalAlias *DGA = dyn_cast_or_null<GlobalAlias>(DGV)) {
|
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
|
// 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.
|
// symbol, DGA must be an global value with internal linkage. Rename it.
|
||||||
if (NewGA->getName() != SGA->getName() &&
|
if (NewGA->getName() != SGA->getName() &&
|
||||||
!NewGA->hasInternalLinkage())
|
!NewGA->hasLocalLinkage())
|
||||||
ForceRenaming(NewGA, SGA->getName());
|
ForceRenaming(NewGA, SGA->getName());
|
||||||
|
|
||||||
// Remember this mapping so uses in the source module get remapped
|
// 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
|
// Check to see if may have to link the function with the global, alias or
|
||||||
// function.
|
// function.
|
||||||
if (SF->hasName() && !SF->hasInternalLinkage())
|
if (SF->hasName() && !SF->hasLocalLinkage())
|
||||||
DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SF->getNameStart(),
|
DGV = cast_or_null<GlobalValue>(DestSymTab.lookup(SF->getNameStart(),
|
||||||
SF->getNameEnd()));
|
SF->getNameEnd()));
|
||||||
|
|
||||||
// If we found a global with the same name in the dest module, but it has
|
// 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.
|
// internal linkage, we are really not doing any linkage here.
|
||||||
if (DGV && DGV->hasInternalLinkage())
|
if (DGV && DGV->hasLocalLinkage())
|
||||||
DGV = 0;
|
DGV = 0;
|
||||||
|
|
||||||
// If types don't agree due to opaque types, try to resolve them.
|
// 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
|
// If the LLVM runtime renamed the function, but it is an externally
|
||||||
// visible symbol, DF must be an existing function with internal linkage.
|
// visible symbol, DF must be an existing function with internal linkage.
|
||||||
// Rename it.
|
// Rename it.
|
||||||
if (!NewDF->hasInternalLinkage() && NewDF->getName() != SF->getName())
|
if (!NewDF->hasLocalLinkage() && NewDF->getName() != SF->getName())
|
||||||
ForceRenaming(NewDF, SF->getName());
|
ForceRenaming(NewDF, SF->getName());
|
||||||
|
|
||||||
// ... and remember this mapping...
|
// ... and remember this mapping...
|
||||||
@ -982,7 +984,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
|||||||
// If the symbol table renamed the function, but it is an externally
|
// If the symbol table renamed the function, but it is an externally
|
||||||
// visible symbol, DF must be an existing function with internal
|
// visible symbol, DF must be an existing function with internal
|
||||||
// linkage. Rename it.
|
// linkage. Rename it.
|
||||||
if (NewDF->getName() != SF->getName() && !NewDF->hasInternalLinkage())
|
if (NewDF->getName() != SF->getName() && !NewDF->hasLocalLinkage())
|
||||||
ForceRenaming(NewDF, SF->getName());
|
ForceRenaming(NewDF, SF->getName());
|
||||||
|
|
||||||
// Remember this mapping so uses in the source module get remapped
|
// Remember this mapping so uses in the source module get remapped
|
||||||
|
@ -808,7 +808,7 @@ SDValue ARMTargetLowering::LowerGlobalAddressELF(SDValue Op,
|
|||||||
GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
|
GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
|
||||||
Reloc::Model RelocM = getTargetMachine().getRelocationModel();
|
Reloc::Model RelocM = getTargetMachine().getRelocationModel();
|
||||||
if (RelocM == Reloc::PIC_) {
|
if (RelocM == Reloc::PIC_) {
|
||||||
bool UseGOTOFF = GV->hasInternalLinkage() || GV->hasHiddenVisibility();
|
bool UseGOTOFF = GV->hasLocalLinkage() || GV->hasHiddenVisibility();
|
||||||
ARMConstantPoolValue *CPV =
|
ARMConstantPoolValue *CPV =
|
||||||
new ARMConstantPoolValue(GV, ARMCP::CPValue, UseGOTOFF ? "GOTOFF":"GOT");
|
new ARMConstantPoolValue(GV, ARMCP::CPValue, UseGOTOFF ? "GOTOFF":"GOT");
|
||||||
SDValue CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 2);
|
SDValue CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 2);
|
||||||
|
@ -197,6 +197,7 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
const Function *F = MF.getFunction();
|
const Function *F = MF.getFunction();
|
||||||
switch (F->getLinkage()) {
|
switch (F->getLinkage()) {
|
||||||
default: assert(0 && "Unknown linkage type!");
|
default: assert(0 && "Unknown linkage type!");
|
||||||
|
case Function::PrivateLinkage:
|
||||||
case Function::InternalLinkage:
|
case Function::InternalLinkage:
|
||||||
SwitchToTextSection("\t.text", F);
|
SwitchToTextSection("\t.text", F);
|
||||||
break;
|
break;
|
||||||
@ -847,11 +848,11 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GVar->hasInternalLinkage() || GVar->mayBeOverridden()) {
|
if (GVar->hasLocalLinkage() || GVar->mayBeOverridden()) {
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
|
|
||||||
if (isDarwin) {
|
if (isDarwin) {
|
||||||
if (GVar->hasInternalLinkage()) {
|
if (GVar->hasLocalLinkage()) {
|
||||||
O << TAI->getLCOMMDirective() << name << "," << Size
|
O << TAI->getLCOMMDirective() << name << "," << Size
|
||||||
<< ',' << Align;
|
<< ',' << Align;
|
||||||
} else if (GVar->hasCommonLinkage()) {
|
} else if (GVar->hasCommonLinkage()) {
|
||||||
@ -869,7 +870,7 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (TAI->getLCOMMDirective() != NULL) {
|
} else if (TAI->getLCOMMDirective() != NULL) {
|
||||||
if (GVar->hasInternalLinkage()) {
|
if (GVar->hasLocalLinkage()) {
|
||||||
O << TAI->getLCOMMDirective() << name << "," << Size;
|
O << TAI->getLCOMMDirective() << name << "," << Size;
|
||||||
} else {
|
} else {
|
||||||
O << TAI->getCOMMDirective() << name << "," << Size;
|
O << TAI->getCOMMDirective() << name << "," << Size;
|
||||||
@ -878,7 +879,7 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SwitchToSection(TAI->SectionForGlobal(GVar));
|
SwitchToSection(TAI->SectionForGlobal(GVar));
|
||||||
if (GVar->hasInternalLinkage())
|
if (GVar->hasLocalLinkage())
|
||||||
O << "\t.local\t" << name << "\n";
|
O << "\t.local\t" << name << "\n";
|
||||||
O << TAI->getCOMMDirective() << name << "," << Size;
|
O << TAI->getCOMMDirective() << name << "," << Size;
|
||||||
if (TAI->getCOMMDirectiveTakesAlignment())
|
if (TAI->getCOMMDirectiveTakesAlignment())
|
||||||
@ -909,6 +910,7 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
case GlobalValue::ExternalLinkage:
|
case GlobalValue::ExternalLinkage:
|
||||||
O << "\t.globl " << name << "\n";
|
O << "\t.globl " << name << "\n";
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -513,7 +513,7 @@ SDValue AlphaTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) {
|
|||||||
SDValue GA = DAG.getTargetGlobalAddress(GV, MVT::i64, GSDN->getOffset());
|
SDValue GA = DAG.getTargetGlobalAddress(GV, MVT::i64, GSDN->getOffset());
|
||||||
|
|
||||||
// if (!GV->hasWeakLinkage() && !GV->isDeclaration() && !GV->hasLinkOnceLinkage()) {
|
// if (!GV->hasWeakLinkage() && !GV->isDeclaration() && !GV->hasLinkOnceLinkage()) {
|
||||||
if (GV->hasInternalLinkage()) {
|
if (GV->hasLocalLinkage()) {
|
||||||
SDValue Hi = DAG.getNode(AlphaISD::GPRelHi, MVT::i64, GA,
|
SDValue Hi = DAG.getNode(AlphaISD::GPRelHi, MVT::i64, GA,
|
||||||
DAG.getNode(ISD::GLOBAL_OFFSET_TABLE, MVT::i64));
|
DAG.getNode(ISD::GLOBAL_OFFSET_TABLE, MVT::i64));
|
||||||
SDValue Lo = DAG.getNode(AlphaISD::GPRelLo, MVT::i64, GA, Hi);
|
SDValue Lo = DAG.getNode(AlphaISD::GPRelLo, MVT::i64, GA, Hi);
|
||||||
|
@ -169,6 +169,7 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
|
|
||||||
O << "\t.ent " << CurrentFnName << "\n";
|
O << "\t.ent " << CurrentFnName << "\n";
|
||||||
|
|
||||||
|
assert (!F->hasPrivateLinkage() && "add private prefix.");
|
||||||
O << CurrentFnName << ":\n";
|
O << CurrentFnName << ":\n";
|
||||||
|
|
||||||
// Print out code for the function.
|
// Print out code for the function.
|
||||||
|
@ -1910,7 +1910,7 @@ bool CWriter::doInitialization(Module &M) {
|
|||||||
if (getGlobalVariableClass(I))
|
if (getGlobalVariableClass(I))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (I->hasInternalLinkage())
|
if (I->hasLocalLinkage())
|
||||||
Out << "static ";
|
Out << "static ";
|
||||||
else
|
else
|
||||||
Out << "extern ";
|
Out << "extern ";
|
||||||
@ -1946,7 +1946,7 @@ bool CWriter::doInitialization(Module &M) {
|
|||||||
if (getGlobalVariableClass(I))
|
if (getGlobalVariableClass(I))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (I->hasInternalLinkage())
|
if (I->hasLocalLinkage())
|
||||||
Out << "static ";
|
Out << "static ";
|
||||||
else if (I->hasDLLImportLinkage())
|
else if (I->hasDLLImportLinkage())
|
||||||
Out << "__declspec(dllimport) ";
|
Out << "__declspec(dllimport) ";
|
||||||
@ -2190,7 +2190,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
|
|||||||
/// isStructReturn - Should this function actually return a struct by-value?
|
/// isStructReturn - Should this function actually return a struct by-value?
|
||||||
bool isStructReturn = F->hasStructRetAttr();
|
bool isStructReturn = F->hasStructRetAttr();
|
||||||
|
|
||||||
if (F->hasInternalLinkage()) Out << "static ";
|
if (F->hasLocalLinkage()) Out << "static ";
|
||||||
if (F->hasDLLImportLinkage()) Out << "__declspec(dllimport) ";
|
if (F->hasDLLImportLinkage()) Out << "__declspec(dllimport) ";
|
||||||
if (F->hasDLLExportLinkage()) Out << "__declspec(dllexport) ";
|
if (F->hasDLLExportLinkage()) Out << "__declspec(dllexport) ";
|
||||||
switch (F->getCallingConv()) {
|
switch (F->getCallingConv()) {
|
||||||
|
@ -442,6 +442,7 @@ LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF)
|
|||||||
|
|
||||||
switch (F->getLinkage()) {
|
switch (F->getLinkage()) {
|
||||||
default: assert(0 && "Unknown linkage type!");
|
default: assert(0 && "Unknown linkage type!");
|
||||||
|
case Function::PrivateLinkage:
|
||||||
case Function::InternalLinkage: // Symbols default to internal.
|
case Function::InternalLinkage: // Symbols default to internal.
|
||||||
break;
|
break;
|
||||||
case Function::ExternalLinkage:
|
case Function::ExternalLinkage:
|
||||||
@ -536,7 +537,7 @@ void LinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
|
|
||||||
if (C->isNullValue() && /* FIXME: Verify correct */
|
if (C->isNullValue() && /* FIXME: Verify correct */
|
||||||
!GVar->hasSection() &&
|
!GVar->hasSection() &&
|
||||||
(GVar->hasInternalLinkage() || GVar->hasExternalLinkage() ||
|
(GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
|
||||||
GVar->mayBeOverridden())) {
|
GVar->mayBeOverridden())) {
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
|
|
||||||
@ -545,7 +546,7 @@ void LinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
O << "\t.type " << name << ", @object\n";
|
O << "\t.type " << name << ", @object\n";
|
||||||
O << name << ":\n";
|
O << name << ":\n";
|
||||||
O << "\t.zero " << Size << '\n';
|
O << "\t.zero " << Size << '\n';
|
||||||
} else if (GVar->hasInternalLinkage()) {
|
} else if (GVar->hasLocalLinkage()) {
|
||||||
O << TAI->getLCOMMDirective() << name << ',' << Size;
|
O << TAI->getLCOMMDirective() << name << ',' << Size;
|
||||||
} else {
|
} else {
|
||||||
O << ".comm " << name << ',' << Size;
|
O << ".comm " << name << ',' << Size;
|
||||||
@ -573,6 +574,7 @@ void LinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
O << "\t.global " << name << '\n'
|
O << "\t.global " << name << '\n'
|
||||||
<< "\t.type " << name << ", @object\n";
|
<< "\t.type " << name << ", @object\n";
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -617,4 +619,3 @@ FunctionPass *llvm::createSPUAsmPrinterPass(raw_ostream &o,
|
|||||||
SPUTargetMachine &tm) {
|
SPUTargetMachine &tm) {
|
||||||
return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,6 +292,8 @@ namespace {
|
|||||||
switch (LT) {
|
switch (LT) {
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
Out << "GlobalValue::InternalLinkage"; break;
|
Out << "GlobalValue::InternalLinkage"; break;
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
|
Out << "GlobalValue::PrivateLinkage"; break;
|
||||||
case GlobalValue::LinkOnceLinkage:
|
case GlobalValue::LinkOnceLinkage:
|
||||||
Out << "GlobalValue::LinkOnceLinkage "; break;
|
Out << "GlobalValue::LinkOnceLinkage "; break;
|
||||||
case GlobalValue::WeakLinkage:
|
case GlobalValue::WeakLinkage:
|
||||||
|
@ -61,7 +61,7 @@ DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV,
|
|||||||
Mangler *Mang) const {
|
Mangler *Mang) const {
|
||||||
if (GV==0)
|
if (GV==0)
|
||||||
return false;
|
return false;
|
||||||
if (GV->hasInternalLinkage() && !isa<Function>(GV) &&
|
if (GV->hasLocalLinkage() && !isa<Function>(GV) &&
|
||||||
((strlen(getPrivateGlobalPrefix()) != 0 &&
|
((strlen(getPrivateGlobalPrefix()) != 0 &&
|
||||||
Mang->getValueName(GV).substr(0,strlen(getPrivateGlobalPrefix())) ==
|
Mang->getValueName(GV).substr(0,strlen(getPrivateGlobalPrefix())) ==
|
||||||
getPrivateGlobalPrefix()) ||
|
getPrivateGlobalPrefix()) ||
|
||||||
|
@ -44,6 +44,7 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
|||||||
if (const Function *F = dyn_cast<Function>(GV)) {
|
if (const Function *F = dyn_cast<Function>(GV)) {
|
||||||
switch (F->getLinkage()) {
|
switch (F->getLinkage()) {
|
||||||
default: assert(0 && "Unknown linkage type!");
|
default: assert(0 && "Unknown linkage type!");
|
||||||
|
case Function::PrivateLinkage:
|
||||||
case Function::InternalLinkage:
|
case Function::InternalLinkage:
|
||||||
case Function::DLLExportLinkage:
|
case Function::DLLExportLinkage:
|
||||||
case Function::ExternalLinkage:
|
case Function::ExternalLinkage:
|
||||||
@ -184,4 +185,3 @@ std::string ELFTargetAsmInfo::printSectionFlags(unsigned flags) const {
|
|||||||
|
|
||||||
return Flags;
|
return Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,10 +275,10 @@ void IA64AsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
|
|
||||||
if (C->isNullValue() && !GVar->hasSection()) {
|
if (C->isNullValue() && !GVar->hasSection()) {
|
||||||
if (!GVar->isThreadLocal() &&
|
if (!GVar->isThreadLocal() &&
|
||||||
(GVar->hasInternalLinkage() || GVar->mayBeOverridden())) {
|
(GVar->hasLocalLinkage() || GVar->mayBeOverridden())) {
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
|
|
||||||
if (GVar->hasInternalLinkage()) {
|
if (GVar->hasLocalLinkage()) {
|
||||||
O << "\t.lcomm " << name << "#," << Size
|
O << "\t.lcomm " << name << "#," << Size
|
||||||
<< ',' << (1 << Align);
|
<< ',' << (1 << Align);
|
||||||
O << '\n';
|
O << '\n';
|
||||||
@ -307,6 +307,7 @@ void IA64AsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
O << TAI->getGlobalDirective() << name << '\n';
|
O << TAI->getGlobalDirective() << name << '\n';
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
break;
|
break;
|
||||||
case GlobalValue::GhostLinkage:
|
case GlobalValue::GhostLinkage:
|
||||||
cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n";
|
cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n";
|
||||||
|
@ -349,10 +349,10 @@ MSILWriter::ValueType MSILWriter::getValueLocation(const Value* V) {
|
|||||||
return ArgumentVT;
|
return ArgumentVT;
|
||||||
// Function
|
// Function
|
||||||
else if (const Function* F = dyn_cast<Function>(V))
|
else if (const Function* F = dyn_cast<Function>(V))
|
||||||
return F->hasInternalLinkage() ? InternalVT : GlobalVT;
|
return F->hasLocalLinkage() ? InternalVT : GlobalVT;
|
||||||
// Variable
|
// Variable
|
||||||
else if (const GlobalVariable* G = dyn_cast<GlobalVariable>(V))
|
else if (const GlobalVariable* G = dyn_cast<GlobalVariable>(V))
|
||||||
return G->hasInternalLinkage() ? InternalVT : GlobalVT;
|
return G->hasLocalLinkage() ? InternalVT : GlobalVT;
|
||||||
// Constant
|
// Constant
|
||||||
else if (isa<Constant>(V))
|
else if (isa<Constant>(V))
|
||||||
return isa<ConstantExpr>(V) ? ConstExprVT : ConstVT;
|
return isa<ConstantExpr>(V) ? ConstExprVT : ConstVT;
|
||||||
@ -1401,7 +1401,7 @@ void MSILWriter::printStaticInitializerList() {
|
|||||||
void MSILWriter::printFunction(const Function& F) {
|
void MSILWriter::printFunction(const Function& F) {
|
||||||
bool isSigned = F.paramHasAttr(0, Attribute::SExt);
|
bool isSigned = F.paramHasAttr(0, Attribute::SExt);
|
||||||
Out << "\n.method static ";
|
Out << "\n.method static ";
|
||||||
Out << (F.hasInternalLinkage() ? "private " : "public ");
|
Out << (F.hasLocalLinkage() ? "private " : "public ");
|
||||||
if (F.isVarArg()) Out << "vararg ";
|
if (F.isVarArg()) Out << "vararg ";
|
||||||
Out << getTypeName(F.getReturnType(),isSigned) <<
|
Out << getTypeName(F.getReturnType(),isSigned) <<
|
||||||
getConvModopt(F.getCallingConv()) << getValueName(&F) << '\n';
|
getConvModopt(F.getCallingConv()) << getValueName(&F) << '\n';
|
||||||
|
@ -275,9 +275,6 @@ runOnMachineFunction(MachineFunction &MF)
|
|||||||
|
|
||||||
O << "\n\n";
|
O << "\n\n";
|
||||||
|
|
||||||
// What's my mangled name?
|
|
||||||
CurrentFnName = Mang->getValueName(MF.getFunction());
|
|
||||||
|
|
||||||
// Emit the function start directives
|
// Emit the function start directives
|
||||||
emitFunctionStart(MF);
|
emitFunctionStart(MF);
|
||||||
|
|
||||||
@ -384,7 +381,10 @@ printOperand(const MachineInstr *MI, int opNum)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
O << Mang->getValueName(MO.getGlobal());
|
{
|
||||||
|
const GlobalValue *GV = MO.getGlobal();
|
||||||
|
O << Mang->getValueName(GV);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MachineOperand::MO_ExternalSymbol:
|
case MachineOperand::MO_ExternalSymbol:
|
||||||
@ -449,7 +449,7 @@ printFCCOperand(const MachineInstr *MI, int opNum, const char *Modifier)
|
|||||||
bool MipsAsmPrinter::
|
bool MipsAsmPrinter::
|
||||||
doInitialization(Module &M)
|
doInitialization(Module &M)
|
||||||
{
|
{
|
||||||
Mang = new Mangler(M);
|
Mang = new Mangler(M, "", TAI->getPrivateGlobalPrefix());
|
||||||
|
|
||||||
// Tell the assembler which ABI we are using
|
// Tell the assembler which ABI we are using
|
||||||
O << "\t.section .mdebug." << emitCurrentABIString() << '\n';
|
O << "\t.section .mdebug." << emitCurrentABIString() << '\n';
|
||||||
@ -502,10 +502,10 @@ printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
|
|
||||||
if (C->isNullValue() && !GVar->hasSection()) {
|
if (C->isNullValue() && !GVar->hasSection()) {
|
||||||
if (!GVar->isThreadLocal() &&
|
if (!GVar->isThreadLocal() &&
|
||||||
(GVar->hasInternalLinkage() || GVar->mayBeOverridden())) {
|
(GVar->hasLocalLinkage() || GVar->mayBeOverridden())) {
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
|
|
||||||
if (GVar->hasInternalLinkage())
|
if (GVar->hasLocalLinkage())
|
||||||
O << "\t.local\t" << name << '\n';
|
O << "\t.local\t" << name << '\n';
|
||||||
|
|
||||||
O << TAI->getCOMMDirective() << name << ',' << Size;
|
O << TAI->getCOMMDirective() << name << ',' << Size;
|
||||||
@ -531,6 +531,7 @@ printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
// If external or appending, declare as a global symbol
|
// If external or appending, declare as a global symbol
|
||||||
O << TAI->getGlobalDirective() << name << '\n';
|
O << TAI->getGlobalDirective() << name << '\n';
|
||||||
// Fall Through
|
// Fall Through
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
if (CVA && CVA->isCString())
|
if (CVA && CVA->isCString())
|
||||||
printSizeAndType = false;
|
printSizeAndType = false;
|
||||||
|
@ -216,7 +216,7 @@ bool MipsTargetLowering::IsGlobalInSmallSection(GlobalValue *GV)
|
|||||||
|
|
||||||
// if this is a internal constant string, there is a special
|
// if this is a internal constant string, there is a special
|
||||||
// section for it, but not in small data/bss.
|
// section for it, but not in small data/bss.
|
||||||
if (GVA->hasInitializer() && GV->hasInternalLinkage()) {
|
if (GVA->hasInitializer() && GV->hasLocalLinkage()) {
|
||||||
Constant *C = GVA->getInitializer();
|
Constant *C = GVA->getInitializer();
|
||||||
const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
|
const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
|
||||||
if (CVA && CVA->isCString())
|
if (CVA && CVA->isCString())
|
||||||
@ -489,7 +489,7 @@ LowerGlobalAddress(SDValue Op, SelectionDAG &DAG)
|
|||||||
SDValue ResNode = DAG.getLoad(MVT::i32, DAG.getEntryNode(), GA, NULL, 0);
|
SDValue ResNode = DAG.getLoad(MVT::i32, DAG.getEntryNode(), GA, NULL, 0);
|
||||||
// On functions and global targets not internal linked only
|
// On functions and global targets not internal linked only
|
||||||
// a load from got/GP is necessary for PIC to work.
|
// a load from got/GP is necessary for PIC to work.
|
||||||
if (!GV->hasInternalLinkage() || isa<Function>(GV))
|
if (!GV->hasLocalLinkage() || isa<Function>(GV))
|
||||||
return ResNode;
|
return ResNode;
|
||||||
SDValue Lo = DAG.getNode(MipsISD::Lo, MVT::i32, GA);
|
SDValue Lo = DAG.getNode(MipsISD::Lo, MVT::i32, GA);
|
||||||
return DAG.getNode(ISD::ADD, MVT::i32, ResNode, Lo);
|
return DAG.getNode(ISD::ADD, MVT::i32, ResNode, Lo);
|
||||||
|
@ -584,6 +584,7 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
|
|
||||||
switch (F->getLinkage()) {
|
switch (F->getLinkage()) {
|
||||||
default: assert(0 && "Unknown linkage type!");
|
default: assert(0 && "Unknown linkage type!");
|
||||||
|
case Function::PrivateLinkage:
|
||||||
case Function::InternalLinkage: // Symbols default to internal.
|
case Function::InternalLinkage: // Symbols default to internal.
|
||||||
break;
|
break;
|
||||||
case Function::ExternalLinkage:
|
case Function::ExternalLinkage:
|
||||||
@ -686,7 +687,7 @@ void PPCLinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
|
|
||||||
if (C->isNullValue() && /* FIXME: Verify correct */
|
if (C->isNullValue() && /* FIXME: Verify correct */
|
||||||
!GVar->hasSection() &&
|
!GVar->hasSection() &&
|
||||||
(GVar->hasInternalLinkage() || GVar->hasExternalLinkage() ||
|
(GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
|
||||||
GVar->mayBeOverridden())) {
|
GVar->mayBeOverridden())) {
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
|
|
||||||
@ -695,7 +696,7 @@ void PPCLinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
O << "\t.type " << name << ", @object\n";
|
O << "\t.type " << name << ", @object\n";
|
||||||
O << name << ":\n";
|
O << name << ":\n";
|
||||||
O << "\t.zero " << Size << '\n';
|
O << "\t.zero " << Size << '\n';
|
||||||
} else if (GVar->hasInternalLinkage()) {
|
} else if (GVar->hasLocalLinkage()) {
|
||||||
O << TAI->getLCOMMDirective() << name << ',' << Size;
|
O << TAI->getLCOMMDirective() << name << ',' << Size;
|
||||||
} else {
|
} else {
|
||||||
O << ".comm " << name << ',' << Size;
|
O << ".comm " << name << ',' << Size;
|
||||||
@ -723,6 +724,7 @@ void PPCLinuxAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
<< "\t.type " << name << ", @object\n";
|
<< "\t.type " << name << ", @object\n";
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cerr << "Unknown linkage type!";
|
cerr << "Unknown linkage type!";
|
||||||
@ -911,7 +913,7 @@ void PPCDarwinAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
|
|
||||||
if (C->isNullValue() && /* FIXME: Verify correct */
|
if (C->isNullValue() && /* FIXME: Verify correct */
|
||||||
!GVar->hasSection() &&
|
!GVar->hasSection() &&
|
||||||
(GVar->hasInternalLinkage() || GVar->hasExternalLinkage() ||
|
(GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
|
||||||
GVar->mayBeOverridden())) {
|
GVar->mayBeOverridden())) {
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
|
|
||||||
@ -919,7 +921,7 @@ void PPCDarwinAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
O << "\t.globl " << name << '\n';
|
O << "\t.globl " << name << '\n';
|
||||||
O << "\t.zerofill __DATA, __common, " << name << ", "
|
O << "\t.zerofill __DATA, __common, " << name << ", "
|
||||||
<< Size << ", " << Align;
|
<< Size << ", " << Align;
|
||||||
} else if (GVar->hasInternalLinkage()) {
|
} else if (GVar->hasLocalLinkage()) {
|
||||||
O << TAI->getLCOMMDirective() << name << ',' << Size << ',' << Align;
|
O << TAI->getLCOMMDirective() << name << ',' << Size << ',' << Align;
|
||||||
} else if (!GVar->hasCommonLinkage()) {
|
} else if (!GVar->hasCommonLinkage()) {
|
||||||
O << "\t.globl " << name << '\n'
|
O << "\t.globl " << name << '\n'
|
||||||
|
@ -98,8 +98,6 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
static unsigned BBNumber = 0;
|
static unsigned BBNumber = 0;
|
||||||
|
|
||||||
O << "\n\n";
|
O << "\n\n";
|
||||||
// What's my mangled name?
|
|
||||||
CurrentFnName = Mang->getValueName(MF.getFunction());
|
|
||||||
|
|
||||||
// Print out the label for the function.
|
// Print out the label for the function.
|
||||||
const Function *F = MF.getFunction();
|
const Function *F = MF.getFunction();
|
||||||
@ -168,7 +166,10 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
|||||||
printBasicBlockLabel(MO.getMBB());
|
printBasicBlockLabel(MO.getMBB());
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
O << Mang->getValueName(MO.getGlobal());
|
{
|
||||||
|
const GlobalValue *GV = MO.getGlobal();
|
||||||
|
O << Mang->getValueName(GV);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_ExternalSymbol:
|
case MachineOperand::MO_ExternalSymbol:
|
||||||
O << MO.getSymbolName();
|
O << MO.getSymbolName();
|
||||||
@ -218,7 +219,7 @@ void SparcAsmPrinter::printCCOperand(const MachineInstr *MI, int opNum) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SparcAsmPrinter::doInitialization(Module &M) {
|
bool SparcAsmPrinter::doInitialization(Module &M) {
|
||||||
Mang = new Mangler(M);
|
Mang = new Mangler(M, "", TAI->getPrivateGlobalPrefix());
|
||||||
return false; // success
|
return false; // success
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,10 +256,10 @@ void SparcAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
|
|
||||||
if (C->isNullValue() && !GVar->hasSection()) {
|
if (C->isNullValue() && !GVar->hasSection()) {
|
||||||
if (!GVar->isThreadLocal() &&
|
if (!GVar->isThreadLocal() &&
|
||||||
(GVar->hasInternalLinkage() || GVar->mayBeOverridden())) {
|
(GVar->hasLocalLinkage() || GVar->mayBeOverridden())) {
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
|
|
||||||
if (GVar->hasInternalLinkage())
|
if (GVar->hasLocalLinkage())
|
||||||
O << "\t.local " << name << '\n';
|
O << "\t.local " << name << '\n';
|
||||||
|
|
||||||
O << TAI->getCOMMDirective() << name << ',' << Size;
|
O << TAI->getCOMMDirective() << name << ',' << Size;
|
||||||
@ -284,6 +285,7 @@ void SparcAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
// If external or appending, declare as a global symbol
|
// If external or appending, declare as a global symbol
|
||||||
O << TAI->getGlobalDirective() << name << '\n';
|
O << TAI->getGlobalDirective() << name << '\n';
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
break;
|
break;
|
||||||
case GlobalValue::GhostLinkage:
|
case GlobalValue::GhostLinkage:
|
||||||
|
@ -159,6 +159,7 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
|
|||||||
switch (F->getLinkage()) {
|
switch (F->getLinkage()) {
|
||||||
default: assert(0 && "Unknown linkage type!");
|
default: assert(0 && "Unknown linkage type!");
|
||||||
case Function::InternalLinkage: // Symbols default to internal.
|
case Function::InternalLinkage: // Symbols default to internal.
|
||||||
|
case Function::PrivateLinkage:
|
||||||
EmitAlignment(FnAlign, F);
|
EmitAlignment(FnAlign, F);
|
||||||
break;
|
break;
|
||||||
case Function::DLLExportLinkage:
|
case Function::DLLExportLinkage:
|
||||||
@ -188,7 +189,7 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
|
|||||||
else if (Subtarget->isTargetCygMing()) {
|
else if (Subtarget->isTargetCygMing()) {
|
||||||
O << "\t.def\t " << CurrentFnName
|
O << "\t.def\t " << CurrentFnName
|
||||||
<< ";\t.scl\t" <<
|
<< ";\t.scl\t" <<
|
||||||
(F->getLinkage() == Function::InternalLinkage ? COFF::C_STAT : COFF::C_EXT)
|
(F->hasInternalLinkage() ? COFF::C_STAT : COFF::C_EXT)
|
||||||
<< ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
|
<< ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT)
|
||||||
<< ";\t.endef\n";
|
<< ";\t.endef\n";
|
||||||
}
|
}
|
||||||
@ -421,7 +422,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
|||||||
if (shouldPrintPLT(TM, Subtarget)) {
|
if (shouldPrintPLT(TM, Subtarget)) {
|
||||||
// Assemble call via PLT for externally visible symbols
|
// Assemble call via PLT for externally visible symbols
|
||||||
if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() &&
|
if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() &&
|
||||||
!GV->hasInternalLinkage())
|
!GV->hasLocalLinkage())
|
||||||
O << "@PLT";
|
O << "@PLT";
|
||||||
}
|
}
|
||||||
if (Subtarget->isTargetCygMing() && GV->isDeclaration())
|
if (Subtarget->isTargetCygMing() && GV->isDeclaration())
|
||||||
@ -789,11 +790,11 @@ void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!GVar->isThreadLocal() &&
|
if (!GVar->isThreadLocal() &&
|
||||||
(GVar->hasInternalLinkage() || GVar->mayBeOverridden())) {
|
(GVar->hasLocalLinkage() || GVar->mayBeOverridden())) {
|
||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
|
|
||||||
if (TAI->getLCOMMDirective() != NULL) {
|
if (TAI->getLCOMMDirective() != NULL) {
|
||||||
if (GVar->hasInternalLinkage()) {
|
if (GVar->hasLocalLinkage()) {
|
||||||
O << TAI->getLCOMMDirective() << name << ',' << Size;
|
O << TAI->getLCOMMDirective() << name << ',' << Size;
|
||||||
if (Subtarget->isTargetDarwin())
|
if (Subtarget->isTargetDarwin())
|
||||||
O << ',' << Align;
|
O << ',' << Align;
|
||||||
@ -813,7 +814,7 @@ void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!Subtarget->isTargetCygMing()) {
|
if (!Subtarget->isTargetCygMing()) {
|
||||||
if (GVar->hasInternalLinkage())
|
if (GVar->hasLocalLinkage())
|
||||||
O << "\t.local\t" << name << '\n';
|
O << "\t.local\t" << name << '\n';
|
||||||
}
|
}
|
||||||
O << TAI->getCOMMDirective() << name << ',' << Size;
|
O << TAI->getCOMMDirective() << name << ',' << Size;
|
||||||
@ -849,6 +850,7 @@ void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
// If external or appending, declare as a global symbol
|
// If external or appending, declare as a global symbol
|
||||||
O << "\t.globl " << name << '\n';
|
O << "\t.globl " << name << '\n';
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -145,6 +145,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
FnAlign = 1;
|
FnAlign = 1;
|
||||||
switch (F->getLinkage()) {
|
switch (F->getLinkage()) {
|
||||||
default: assert(0 && "Unsupported linkage type!");
|
default: assert(0 && "Unsupported linkage type!");
|
||||||
|
case Function::PrivateLinkage:
|
||||||
case Function::InternalLinkage:
|
case Function::InternalLinkage:
|
||||||
EmitAlignment(FnAlign);
|
EmitAlignment(FnAlign);
|
||||||
break;
|
break;
|
||||||
|
@ -56,7 +56,7 @@ bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV,
|
|||||||
// Extra load is needed for all externally visible.
|
// Extra load is needed for all externally visible.
|
||||||
if (isDirectCall)
|
if (isDirectCall)
|
||||||
return false;
|
return false;
|
||||||
if (GV->hasInternalLinkage() || GV->hasHiddenVisibility())
|
if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
} else if (isTargetCygMing() || isTargetWindows()) {
|
} else if (isTargetCygMing() || isTargetWindows()) {
|
||||||
@ -79,7 +79,7 @@ bool X86Subtarget::GVRequiresRegister(const GlobalValue *GV,
|
|||||||
// returns false.
|
// returns false.
|
||||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||||
return !isDirectCall &&
|
return !isDirectCall &&
|
||||||
(GV->hasInternalLinkage() || GV->hasExternalLinkage());
|
(GV->hasLocalLinkage() || GV->hasExternalLinkage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +198,7 @@ emitGlobal(const GlobalVariable *GV)
|
|||||||
}
|
}
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
|
case GlobalValue::PrivateLinkage:
|
||||||
break;
|
break;
|
||||||
case GlobalValue::GhostLinkage:
|
case GlobalValue::GhostLinkage:
|
||||||
cerr << "Should not have any unmaterialized functions!\n";
|
cerr << "Should not have any unmaterialized functions!\n";
|
||||||
@ -259,6 +260,7 @@ emitFunctionStart(MachineFunction &MF)
|
|||||||
switch (F->getLinkage()) {
|
switch (F->getLinkage()) {
|
||||||
default: assert(0 && "Unknown linkage type!");
|
default: assert(0 && "Unknown linkage type!");
|
||||||
case Function::InternalLinkage: // Symbols default to internal.
|
case Function::InternalLinkage: // Symbols default to internal.
|
||||||
|
case Function::PrivateLinkage:
|
||||||
break;
|
break;
|
||||||
case Function::ExternalLinkage:
|
case Function::ExternalLinkage:
|
||||||
emitGlobalDirective(CurrentFnName);
|
emitGlobalDirective(CurrentFnName);
|
||||||
@ -299,9 +301,6 @@ bool XCoreAsmPrinter::runOnMachineFunction(MachineFunction &MF)
|
|||||||
// Print out jump tables referenced by the function
|
// Print out jump tables referenced by the function
|
||||||
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
|
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
|
||||||
|
|
||||||
// What's my mangled name?
|
|
||||||
CurrentFnName = Mang->getValueName(MF.getFunction());
|
|
||||||
|
|
||||||
// Emit the function start directives
|
// Emit the function start directives
|
||||||
emitFunctionStart(MF);
|
emitFunctionStart(MF);
|
||||||
|
|
||||||
@ -367,9 +366,12 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
|||||||
printBasicBlockLabel(MO.getMBB());
|
printBasicBlockLabel(MO.getMBB());
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
O << Mang->getValueName(MO.getGlobal());
|
{
|
||||||
if (MO.getGlobal()->hasExternalWeakLinkage())
|
const GlobalValue *GV = MO.getGlobal();
|
||||||
ExtWeakSymbols.insert(MO.getGlobal());
|
O << Mang->getValueName(GV);
|
||||||
|
if (GV->hasExternalWeakLinkage())
|
||||||
|
ExtWeakSymbols.insert(GV);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_ExternalSymbol:
|
case MachineOperand::MO_ExternalSymbol:
|
||||||
O << MO.getSymbolName();
|
O << MO.getSymbolName();
|
||||||
|
@ -114,7 +114,7 @@ bool ArgPromotion::PromoteArguments(CallGraphNode *CGN) {
|
|||||||
Function *F = CGN->getFunction();
|
Function *F = CGN->getFunction();
|
||||||
|
|
||||||
// Make sure that it is local to this module.
|
// Make sure that it is local to this module.
|
||||||
if (!F || !F->hasInternalLinkage()) return false;
|
if (!F || !F->hasLocalLinkage()) return false;
|
||||||
|
|
||||||
// First check: see if there are any pointer arguments! If not, quick exit.
|
// First check: see if there are any pointer arguments! If not, quick exit.
|
||||||
SmallVector<std::pair<Argument*, unsigned>, 16> PointerArgs;
|
SmallVector<std::pair<Argument*, unsigned>, 16> PointerArgs;
|
||||||
|
@ -72,7 +72,7 @@ bool ConstantMerge::runOnModule(Module &M) {
|
|||||||
|
|
||||||
// If this GV is dead, remove it.
|
// If this GV is dead, remove it.
|
||||||
GV->removeDeadConstantUsers();
|
GV->removeDeadConstantUsers();
|
||||||
if (GV->use_empty() && GV->hasInternalLinkage()) {
|
if (GV->use_empty() && GV->hasLocalLinkage()) {
|
||||||
GV->eraseFromParent();
|
GV->eraseFromParent();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ bool ConstantMerge::runOnModule(Module &M) {
|
|||||||
|
|
||||||
if (Slot == 0) { // Nope, add it to the map.
|
if (Slot == 0) { // Nope, add it to the map.
|
||||||
Slot = GV;
|
Slot = GV;
|
||||||
} else if (GV->hasInternalLinkage()) { // Yup, this is a duplicate!
|
} else if (GV->hasLocalLinkage()) { // Yup, this is a duplicate!
|
||||||
// Make all uses of the duplicate constant use the canonical version.
|
// Make all uses of the duplicate constant use the canonical version.
|
||||||
Replacements.push_back(std::make_pair(GV, Slot));
|
Replacements.push_back(std::make_pair(GV, Slot));
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ ModulePass *llvm::createDeadArgHackingPass() { return new DAH(); }
|
|||||||
/// llvm.vastart is never called, the varargs list is dead for the function.
|
/// llvm.vastart is never called, the varargs list is dead for the function.
|
||||||
bool DAE::DeleteDeadVarargs(Function &Fn) {
|
bool DAE::DeleteDeadVarargs(Function &Fn) {
|
||||||
assert(Fn.getFunctionType()->isVarArg() && "Function isn't varargs!");
|
assert(Fn.getFunctionType()->isVarArg() && "Function isn't varargs!");
|
||||||
if (Fn.isDeclaration() || !Fn.hasInternalLinkage()) return false;
|
if (Fn.isDeclaration() || !Fn.hasLocalLinkage()) return false;
|
||||||
|
|
||||||
// Ensure that the function is only directly called.
|
// Ensure that the function is only directly called.
|
||||||
for (Value::use_iterator I = Fn.use_begin(), E = Fn.use_end(); I != E; ++I) {
|
for (Value::use_iterator I = Fn.use_begin(), E = Fn.use_end(); I != E; ++I) {
|
||||||
@ -424,7 +424,7 @@ void DAE::SurveyFunction(Function &F) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!F.hasInternalLinkage() && (!ShouldHackArguments() || F.isIntrinsic())) {
|
if (!F.hasLocalLinkage() && (!ShouldHackArguments() || F.isIntrinsic())) {
|
||||||
MarkLive(F);
|
MarkLive(F);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ namespace {
|
|||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (CallInst* callInst = dyn_cast<CallInst>(&*I)) {
|
if (CallInst* callInst = dyn_cast<CallInst>(&*I)) {
|
||||||
Function* Callee = callInst->getCalledFunction();
|
Function* Callee = callInst->getCalledFunction();
|
||||||
if (Callee && Callee->hasInternalLinkage())
|
if (Callee && Callee->hasLocalLinkage())
|
||||||
Callee->setLinkage(GlobalValue::ExternalLinkage);
|
Callee->setLinkage(GlobalValue::ExternalLinkage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,6 +85,7 @@ namespace {
|
|||||||
|
|
||||||
bool isolateGV(Module &M) {
|
bool isolateGV(Module &M) {
|
||||||
// Mark all globals internal
|
// Mark all globals internal
|
||||||
|
// FIXME: what should we do with private linkage?
|
||||||
for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
|
for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
|
||||||
if (!I->isDeclaration()) {
|
if (!I->isDeclaration()) {
|
||||||
I->setLinkage(GlobalValue::InternalLinkage);
|
I->setLinkage(GlobalValue::InternalLinkage);
|
||||||
|
@ -63,7 +63,7 @@ bool GlobalDCE::runOnModule(Module &M) {
|
|||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
||||||
Changed |= RemoveUnusedGlobalValue(*I);
|
Changed |= RemoveUnusedGlobalValue(*I);
|
||||||
// Functions with external linkage are needed if they have a body
|
// Functions with external linkage are needed if they have a body
|
||||||
if ((!I->hasInternalLinkage() && !I->hasLinkOnceLinkage()) &&
|
if ((!I->hasLocalLinkage() && !I->hasLinkOnceLinkage()) &&
|
||||||
!I->isDeclaration())
|
!I->isDeclaration())
|
||||||
GlobalIsNeeded(I);
|
GlobalIsNeeded(I);
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ bool GlobalDCE::runOnModule(Module &M) {
|
|||||||
Changed |= RemoveUnusedGlobalValue(*I);
|
Changed |= RemoveUnusedGlobalValue(*I);
|
||||||
// Externally visible & appending globals are needed, if they have an
|
// Externally visible & appending globals are needed, if they have an
|
||||||
// initializer.
|
// initializer.
|
||||||
if ((!I->hasInternalLinkage() && !I->hasLinkOnceLinkage()) &&
|
if ((!I->hasLocalLinkage() && !I->hasLinkOnceLinkage()) &&
|
||||||
!I->isDeclaration())
|
!I->isDeclaration())
|
||||||
GlobalIsNeeded(I);
|
GlobalIsNeeded(I);
|
||||||
}
|
}
|
||||||
|
@ -464,7 +464,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD) {
|
|||||||
if (!GlobalUsersSafeToSRA(GV))
|
if (!GlobalUsersSafeToSRA(GV))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
assert(GV->hasInternalLinkage() && !GV->isConstant());
|
assert(GV->hasLocalLinkage() && !GV->isConstant());
|
||||||
Constant *Init = GV->getInitializer();
|
Constant *Init = GV->getInitializer();
|
||||||
const Type *Ty = Init->getType();
|
const Type *Ty = Init->getType();
|
||||||
|
|
||||||
@ -1808,12 +1808,12 @@ bool GlobalOpt::OptimizeFunctions(Module &M) {
|
|||||||
for (Module::iterator FI = M.begin(), E = M.end(); FI != E; ) {
|
for (Module::iterator FI = M.begin(), E = M.end(); FI != E; ) {
|
||||||
Function *F = FI++;
|
Function *F = FI++;
|
||||||
F->removeDeadConstantUsers();
|
F->removeDeadConstantUsers();
|
||||||
if (F->use_empty() && (F->hasInternalLinkage() ||
|
if (F->use_empty() && (F->hasLocalLinkage() ||
|
||||||
F->hasLinkOnceLinkage())) {
|
F->hasLinkOnceLinkage())) {
|
||||||
M.getFunctionList().erase(F);
|
M.getFunctionList().erase(F);
|
||||||
Changed = true;
|
Changed = true;
|
||||||
++NumFnDeleted;
|
++NumFnDeleted;
|
||||||
} else if (F->hasInternalLinkage()) {
|
} else if (F->hasLocalLinkage()) {
|
||||||
if (F->getCallingConv() == CallingConv::C && !F->isVarArg() &&
|
if (F->getCallingConv() == CallingConv::C && !F->isVarArg() &&
|
||||||
OnlyCalledDirectly(F)) {
|
OnlyCalledDirectly(F)) {
|
||||||
// If this function has C calling conventions, is not a varargs
|
// If this function has C calling conventions, is not a varargs
|
||||||
@ -1843,7 +1843,7 @@ bool GlobalOpt::OptimizeGlobalVars(Module &M) {
|
|||||||
for (Module::global_iterator GVI = M.global_begin(), E = M.global_end();
|
for (Module::global_iterator GVI = M.global_begin(), E = M.global_end();
|
||||||
GVI != E; ) {
|
GVI != E; ) {
|
||||||
GlobalVariable *GV = GVI++;
|
GlobalVariable *GV = GVI++;
|
||||||
if (!GV->isConstant() && GV->hasInternalLinkage() &&
|
if (!GV->isConstant() && GV->hasLocalLinkage() &&
|
||||||
GV->hasInitializer())
|
GV->hasInitializer())
|
||||||
Changed |= ProcessInternalGlobal(GV, GVI);
|
Changed |= ProcessInternalGlobal(GV, GVI);
|
||||||
}
|
}
|
||||||
@ -1982,7 +1982,7 @@ static Constant *getVal(DenseMap<Value*, Constant*> &ComputedValues,
|
|||||||
/// globals. This should be kept up to date with CommitValueTo.
|
/// globals. This should be kept up to date with CommitValueTo.
|
||||||
static bool isSimpleEnoughPointerToCommit(Constant *C) {
|
static bool isSimpleEnoughPointerToCommit(Constant *C) {
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
|
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
|
||||||
if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
|
if (!GV->hasExternalLinkage() && !GV->hasLocalLinkage())
|
||||||
return false; // do not allow weak/linkonce/dllimport/dllexport linkage.
|
return false; // do not allow weak/linkonce/dllimport/dllexport linkage.
|
||||||
return !GV->isDeclaration(); // reject external globals.
|
return !GV->isDeclaration(); // reject external globals.
|
||||||
}
|
}
|
||||||
@ -1991,7 +1991,7 @@ static bool isSimpleEnoughPointerToCommit(Constant *C) {
|
|||||||
if (CE->getOpcode() == Instruction::GetElementPtr &&
|
if (CE->getOpcode() == Instruction::GetElementPtr &&
|
||||||
isa<GlobalVariable>(CE->getOperand(0))) {
|
isa<GlobalVariable>(CE->getOperand(0))) {
|
||||||
GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
|
GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
|
||||||
if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
|
if (!GV->hasExternalLinkage() && !GV->hasLocalLinkage())
|
||||||
return false; // do not allow weak/linkonce/dllimport/dllexport linkage.
|
return false; // do not allow weak/linkonce/dllimport/dllexport linkage.
|
||||||
return GV->hasInitializer() &&
|
return GV->hasInitializer() &&
|
||||||
ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE);
|
ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE);
|
||||||
|
@ -63,7 +63,7 @@ bool IPCP::runOnModule(Module &M) {
|
|||||||
if (!I->isDeclaration()) {
|
if (!I->isDeclaration()) {
|
||||||
// Delete any klingons.
|
// Delete any klingons.
|
||||||
I->removeDeadConstantUsers();
|
I->removeDeadConstantUsers();
|
||||||
if (I->hasInternalLinkage())
|
if (I->hasLocalLinkage())
|
||||||
LocalChange |= PropagateConstantsIntoArguments(*I);
|
LocalChange |= PropagateConstantsIntoArguments(*I);
|
||||||
Changed |= PropagateConstantReturn(*I);
|
Changed |= PropagateConstantReturn(*I);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
|
|||||||
|
|
||||||
// If we inlined the last possible call site to the function, delete the
|
// If we inlined the last possible call site to the function, delete the
|
||||||
// function body now.
|
// function body now.
|
||||||
if (Callee->use_empty() && Callee->hasInternalLinkage() &&
|
if (Callee->use_empty() && Callee->hasLocalLinkage() &&
|
||||||
!SCCFunctions.count(Callee)) {
|
!SCCFunctions.count(Callee)) {
|
||||||
DOUT << " -> Deleting dead function: " << Callee->getName() << "\n";
|
DOUT << " -> Deleting dead function: " << Callee->getName() << "\n";
|
||||||
CallGraphNode *CalleeNode = CG[Callee];
|
CallGraphNode *CalleeNode = CG[Callee];
|
||||||
@ -240,7 +240,7 @@ bool Inliner::removeDeadFunctions(CallGraph &CG,
|
|||||||
if (DNR && DNR->count(F))
|
if (DNR && DNR->count(F))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
|
if ((F->hasLinkOnceLinkage() || F->hasLocalLinkage()) &&
|
||||||
F->use_empty()) {
|
F->use_empty()) {
|
||||||
|
|
||||||
// Remove any call graph edges from the function to its callees.
|
// Remove any call graph edges from the function to its callees.
|
||||||
|
@ -121,9 +121,10 @@ bool InternalizePass::runOnModule(Module &M) {
|
|||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
// Mark all functions not in the api as internal.
|
// Mark all functions not in the api as internal.
|
||||||
|
// FIXME: maybe use private linkage?
|
||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
||||||
if (!I->isDeclaration() && // Function must be defined here
|
if (!I->isDeclaration() && // Function must be defined here
|
||||||
!I->hasInternalLinkage() && // Can't already have internal linkage
|
!I->hasLocalLinkage() && // Can't already have internal linkage
|
||||||
!ExternalNames.count(I->getName())) {// Not marked to keep external?
|
!ExternalNames.count(I->getName())) {// Not marked to keep external?
|
||||||
I->setLinkage(GlobalValue::InternalLinkage);
|
I->setLinkage(GlobalValue::InternalLinkage);
|
||||||
// Remove a callgraph edge from the external node to this function.
|
// Remove a callgraph edge from the external node to this function.
|
||||||
@ -149,9 +150,10 @@ bool InternalizePass::runOnModule(Module &M) {
|
|||||||
|
|
||||||
// Mark all global variables with initializers that are not in the api as
|
// Mark all global variables with initializers that are not in the api as
|
||||||
// internal as well.
|
// internal as well.
|
||||||
|
// FIXME: maybe use private linkage?
|
||||||
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (!I->isDeclaration() && !I->hasInternalLinkage() &&
|
if (!I->isDeclaration() && !I->hasLocalLinkage() &&
|
||||||
!ExternalNames.count(I->getName())) {
|
!ExternalNames.count(I->getName())) {
|
||||||
I->setLinkage(GlobalValue::InternalLinkage);
|
I->setLinkage(GlobalValue::InternalLinkage);
|
||||||
Changed = true;
|
Changed = true;
|
||||||
|
@ -245,7 +245,7 @@ static bool fold(std::vector<Function *> &FnVec, unsigned i, unsigned j) {
|
|||||||
Function *G = FnVec[j];
|
Function *G = FnVec[j];
|
||||||
|
|
||||||
if (!F->mayBeOverridden()) {
|
if (!F->mayBeOverridden()) {
|
||||||
if (G->hasInternalLinkage()) {
|
if (G->hasLocalLinkage()) {
|
||||||
F->setAlignment(std::max(F->getAlignment(), G->getAlignment()));
|
F->setAlignment(std::max(F->getAlignment(), G->getAlignment()));
|
||||||
G->replaceAllUsesWith(F);
|
G->replaceAllUsesWith(F);
|
||||||
G->eraseFromParent();
|
G->eraseFromParent();
|
||||||
@ -329,7 +329,7 @@ bool MergeFunctions::runOnModule(Module &M) {
|
|||||||
if (F->isDeclaration() || F->isIntrinsic())
|
if (F->isDeclaration() || F->isIntrinsic())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!F->hasInternalLinkage() && !F->hasExternalLinkage() &&
|
if (!F->hasLocalLinkage() && !F->hasExternalLinkage() &&
|
||||||
!F->hasWeakLinkage())
|
!F->hasWeakLinkage())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ static void RemoveDeadConstant(Constant *C) {
|
|||||||
OnlyUsedBy(C->getOperand(i), C))
|
OnlyUsedBy(C->getOperand(i), C))
|
||||||
Operands.insert(C->getOperand(i));
|
Operands.insert(C->getOperand(i));
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
|
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
|
||||||
if (!GV->hasInternalLinkage()) return; // Don't delete non static globals.
|
if (!GV->hasLocalLinkage()) return; // Don't delete non static globals.
|
||||||
GV->eraseFromParent();
|
GV->eraseFromParent();
|
||||||
}
|
}
|
||||||
else if (!isa<Function>(C))
|
else if (!isa<Function>(C))
|
||||||
@ -114,7 +114,7 @@ static void StripSymtab(ValueSymbolTable &ST, bool PreserveDbgInfo) {
|
|||||||
for (ValueSymbolTable::iterator VI = ST.begin(), VE = ST.end(); VI != VE; ) {
|
for (ValueSymbolTable::iterator VI = ST.begin(), VE = ST.end(); VI != VE; ) {
|
||||||
Value *V = VI->getValue();
|
Value *V = VI->getValue();
|
||||||
++VI;
|
++VI;
|
||||||
if (!isa<GlobalValue>(V) || cast<GlobalValue>(V)->hasInternalLinkage()) {
|
if (!isa<GlobalValue>(V) || cast<GlobalValue>(V)->hasLocalLinkage()) {
|
||||||
if (!PreserveDbgInfo || strncmp(V->getNameStart(), "llvm.dbg", 8))
|
if (!PreserveDbgInfo || strncmp(V->getNameStart(), "llvm.dbg", 8))
|
||||||
// Set name to "", removing from symbol table!
|
// Set name to "", removing from symbol table!
|
||||||
V->setName("");
|
V->setName("");
|
||||||
@ -162,13 +162,13 @@ bool StripSymbolNames(Module &M, bool PreserveDbgInfo) {
|
|||||||
|
|
||||||
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (I->hasInternalLinkage() && llvmUsedValues.count(I) == 0)
|
if (I->hasLocalLinkage() && llvmUsedValues.count(I) == 0)
|
||||||
if (!PreserveDbgInfo || strncmp(I->getNameStart(), "llvm.dbg", 8))
|
if (!PreserveDbgInfo || strncmp(I->getNameStart(), "llvm.dbg", 8))
|
||||||
I->setName(""); // Internal symbols can't participate in linkage
|
I->setName(""); // Internal symbols can't participate in linkage
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
||||||
if (I->hasInternalLinkage() && llvmUsedValues.count(I) == 0)
|
if (I->hasLocalLinkage() && llvmUsedValues.count(I) == 0)
|
||||||
if (!PreserveDbgInfo || strncmp(I->getNameStart(), "llvm.dbg", 8))
|
if (!PreserveDbgInfo || strncmp(I->getNameStart(), "llvm.dbg", 8))
|
||||||
I->setName(""); // Internal symbols can't participate in linkage
|
I->setName(""); // Internal symbols can't participate in linkage
|
||||||
StripSymtab(I->getValueSymbolTable(), PreserveDbgInfo);
|
StripSymtab(I->getValueSymbolTable(), PreserveDbgInfo);
|
||||||
@ -268,6 +268,7 @@ bool StripDebugInfo(Module &M) {
|
|||||||
|
|
||||||
// llvm.dbg.compile_units and llvm.dbg.subprograms are marked as linkonce
|
// llvm.dbg.compile_units and llvm.dbg.subprograms are marked as linkonce
|
||||||
// but since we are removing all debug information, make them internal now.
|
// but since we are removing all debug information, make them internal now.
|
||||||
|
// FIXME: Use private linkage maybe?
|
||||||
if (Constant *C = M.getNamedGlobal("llvm.dbg.compile_units"))
|
if (Constant *C = M.getNamedGlobal("llvm.dbg.compile_units"))
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
|
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
|
||||||
GV->setLinkage(GlobalValue::InternalLinkage);
|
GV->setLinkage(GlobalValue::InternalLinkage);
|
||||||
@ -299,7 +300,7 @@ bool StripDebugInfo(Module &M) {
|
|||||||
Constant *C = DeadConstants.back();
|
Constant *C = DeadConstants.back();
|
||||||
DeadConstants.pop_back();
|
DeadConstants.pop_back();
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
|
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
|
||||||
if (GV->hasInternalLinkage())
|
if (GV->hasLocalLinkage())
|
||||||
RemoveDeadConstant(GV);
|
RemoveDeadConstant(GV);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -329,4 +330,3 @@ bool StripSymbols::runOnModule(Module &M) {
|
|||||||
bool StripNonDebugSymbols::runOnModule(Module &M) {
|
bool StripNonDebugSymbols::runOnModule(Module &M) {
|
||||||
return StripSymbolNames(M, true);
|
return StripSymbolNames(M, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ bool SRETPromotion::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
|
|||||||
bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
|
bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
|
||||||
Function *F = CGN->getFunction();
|
Function *F = CGN->getFunction();
|
||||||
|
|
||||||
if (!F || F->isDeclaration() || !F->hasInternalLinkage())
|
if (!F || F->isDeclaration() || !F->hasLocalLinkage())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Make sure that function returns struct.
|
// Make sure that function returns struct.
|
||||||
|
@ -203,7 +203,7 @@ public:
|
|||||||
/// and out of the specified function (which cannot have its address taken),
|
/// and out of the specified function (which cannot have its address taken),
|
||||||
/// this method must be called.
|
/// this method must be called.
|
||||||
void AddTrackedFunction(Function *F) {
|
void AddTrackedFunction(Function *F) {
|
||||||
assert(F->hasInternalLinkage() && "Can only track internal functions!");
|
assert(F->hasLocalLinkage() && "Can only track internal functions!");
|
||||||
// Add an entry, F -> undef.
|
// Add an entry, F -> undef.
|
||||||
if (const StructType *STy = dyn_cast<StructType>(F->getReturnType())) {
|
if (const StructType *STy = dyn_cast<StructType>(F->getReturnType())) {
|
||||||
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
|
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
|
||||||
@ -609,7 +609,7 @@ void SCCPSolver::visitReturnInst(ReturnInst &I) {
|
|||||||
|
|
||||||
Function *F = I.getParent()->getParent();
|
Function *F = I.getParent()->getParent();
|
||||||
// If we are tracking the return value of this function, merge it in.
|
// If we are tracking the return value of this function, merge it in.
|
||||||
if (!F->hasInternalLinkage())
|
if (!F->hasLocalLinkage())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!TrackedRetVals.empty() && I.getNumOperands() == 1) {
|
if (!TrackedRetVals.empty() && I.getNumOperands() == 1) {
|
||||||
@ -1170,7 +1170,7 @@ void SCCPSolver::visitCallSite(CallSite CS) {
|
|||||||
// The common case is that we aren't tracking the callee, either because we
|
// The common case is that we aren't tracking the callee, either because we
|
||||||
// are not doing interprocedural analysis or the callee is indirect, or is
|
// are not doing interprocedural analysis or the callee is indirect, or is
|
||||||
// external. Handle these cases first.
|
// external. Handle these cases first.
|
||||||
if (F == 0 || !F->hasInternalLinkage()) {
|
if (F == 0 || !F->hasLocalLinkage()) {
|
||||||
CallOverdefined:
|
CallOverdefined:
|
||||||
// Void return and not tracking callee, just bail.
|
// Void return and not tracking callee, just bail.
|
||||||
if (I->getType() == Type::VoidTy) return;
|
if (I->getType() == Type::VoidTy) return;
|
||||||
@ -1656,7 +1656,7 @@ bool IPSCCP::runOnModule(Module &M) {
|
|||||||
// taken or that are external as overdefined.
|
// taken or that are external as overdefined.
|
||||||
//
|
//
|
||||||
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
|
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
|
||||||
if (!F->hasInternalLinkage() || AddressIsTaken(F)) {
|
if (!F->hasLocalLinkage() || AddressIsTaken(F)) {
|
||||||
if (!F->isDeclaration())
|
if (!F->isDeclaration())
|
||||||
Solver.MarkBlockExecutable(F->begin());
|
Solver.MarkBlockExecutable(F->begin());
|
||||||
for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end();
|
for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end();
|
||||||
@ -1671,7 +1671,7 @@ bool IPSCCP::runOnModule(Module &M) {
|
|||||||
// their addresses taken, we can propagate constants through them.
|
// their addresses taken, we can propagate constants through them.
|
||||||
for (Module::global_iterator G = M.global_begin(), E = M.global_end();
|
for (Module::global_iterator G = M.global_begin(), E = M.global_end();
|
||||||
G != E; ++G)
|
G != E; ++G)
|
||||||
if (!G->isConstant() && G->hasInternalLinkage() && !AddressIsTaken(G))
|
if (!G->isConstant() && G->hasLocalLinkage() && !AddressIsTaken(G))
|
||||||
Solver.TrackValueOfGlobalVariable(G);
|
Solver.TrackValueOfGlobalVariable(G);
|
||||||
|
|
||||||
// Solve for constants.
|
// Solve for constants.
|
||||||
|
@ -130,7 +130,7 @@ void BasicInlinerImpl::inlineFunctions() {
|
|||||||
|
|
||||||
// Inline
|
// Inline
|
||||||
if (InlineFunction(CS, NULL, TD)) {
|
if (InlineFunction(CS, NULL, TD)) {
|
||||||
if (Callee->use_empty() && Callee->hasInternalLinkage())
|
if (Callee->use_empty() && Callee->hasLocalLinkage())
|
||||||
DeadFunctions.insert(Callee);
|
DeadFunctions.insert(Callee);
|
||||||
Changed = true;
|
Changed = true;
|
||||||
CallSites.erase(CallSites.begin() + index);
|
CallSites.erase(CallSites.begin() + index);
|
||||||
|
@ -199,7 +199,7 @@ InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
|
|||||||
// If there is only one call of the function, and it has internal linkage,
|
// If there is only one call of the function, and it has internal linkage,
|
||||||
// make it almost guaranteed to be inlined.
|
// make it almost guaranteed to be inlined.
|
||||||
//
|
//
|
||||||
if (Callee->hasInternalLinkage() && Callee->hasOneUse())
|
if (Callee->hasLocalLinkage() && Callee->hasOneUse())
|
||||||
InlineCost -= 15000;
|
InlineCost -= 15000;
|
||||||
|
|
||||||
// If this function uses the coldcc calling convention, prefer not to inline
|
// If this function uses the coldcc calling convention, prefer not to inline
|
||||||
|
@ -1149,6 +1149,7 @@ void AssemblyWriter::printModule(const Module *M) {
|
|||||||
|
|
||||||
static void PrintLinkage(GlobalValue::LinkageTypes LT, raw_ostream &Out) {
|
static void PrintLinkage(GlobalValue::LinkageTypes LT, raw_ostream &Out) {
|
||||||
switch (LT) {
|
switch (LT) {
|
||||||
|
case GlobalValue::PrivateLinkage: Out << "private "; break;
|
||||||
case GlobalValue::InternalLinkage: Out << "internal "; break;
|
case GlobalValue::InternalLinkage: Out << "internal "; break;
|
||||||
case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break;
|
case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break;
|
||||||
case GlobalValue::WeakLinkage: Out << "weak "; break;
|
case GlobalValue::WeakLinkage: Out << "weak "; break;
|
||||||
|
@ -147,14 +147,20 @@ std::string Mangler::getValueName(const GlobalValue *GV, const char * Suffix) {
|
|||||||
Name = "__unnamed_" + utostr(TypeUniqueID) + "_" + utostr(GlobalID++);
|
Name = "__unnamed_" + utostr(TypeUniqueID) + "_" + utostr(GlobalID++);
|
||||||
} else {
|
} else {
|
||||||
Name = makeNameProper(GV->getName() + Suffix, Prefix);
|
Name = makeNameProper(GV->getName() + Suffix, Prefix);
|
||||||
|
std::string prefix;
|
||||||
|
if (GV->hasPrivateLinkage())
|
||||||
|
prefix = PrivatePrefix;
|
||||||
|
else
|
||||||
|
prefix = "";
|
||||||
|
Name = prefix + Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mangler::Mangler(Module &M, const char *prefix)
|
Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix)
|
||||||
: Prefix(prefix), UseQuotes(false), PreserveAsmNames(false),
|
: Prefix(prefix), PrivatePrefix (privatePrefix), UseQuotes(false),
|
||||||
Count(0), TypeCounter(0) {
|
PreserveAsmNames(false), Count(0), TypeCounter(0) {
|
||||||
std::fill(AcceptableChars, array_endof(AcceptableChars), 0);
|
std::fill(AcceptableChars, array_endof(AcceptableChars), 0);
|
||||||
|
|
||||||
// Letters and numbers are acceptable.
|
// Letters and numbers are acceptable.
|
||||||
|
@ -153,7 +153,7 @@ Constant *Module::getOrInsertFunction(const std::string &Name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Okay, the function exists. Does it have externally visible linkage?
|
// Okay, the function exists. Does it have externally visible linkage?
|
||||||
if (F->hasInternalLinkage()) {
|
if (F->hasLocalLinkage()) {
|
||||||
// Clear the function's name.
|
// Clear the function's name.
|
||||||
F->setName("");
|
F->setName("");
|
||||||
// Retry, now there won't be a conflict.
|
// 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
|
/// 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
|
/// 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.
|
/// the top-level PointerType, which represents the address of the global.
|
||||||
/// If AllowInternal is set to true, this function will return types that
|
/// If AllowLocal is set to true, this function will return types that
|
||||||
/// have InternalLinkage. By default, these types are not returned.
|
/// have an local. By default, these types are not returned.
|
||||||
///
|
///
|
||||||
GlobalVariable *Module::getGlobalVariable(const std::string &Name,
|
GlobalVariable *Module::getGlobalVariable(const std::string &Name,
|
||||||
bool AllowInternal) const {
|
bool AllowLocal) const {
|
||||||
if (Value *V = ValSymTab->lookup(Name)) {
|
if (Value *V = ValSymTab->lookup(Name)) {
|
||||||
GlobalVariable *Result = dyn_cast<GlobalVariable>(V);
|
GlobalVariable *Result = dyn_cast<GlobalVariable>(V);
|
||||||
if (Result && (AllowInternal || !Result->hasInternalLinkage()))
|
if (Result && (AllowLocal || !Result->hasLocalLinkage()))
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -376,4 +376,3 @@ void Module::removeLibrary(const std::string& Lib) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ void Verifier::visitGlobalValue(GlobalValue &GV) {
|
|||||||
GV.hasExternalWeakLinkage() ||
|
GV.hasExternalWeakLinkage() ||
|
||||||
GV.hasGhostLinkage() ||
|
GV.hasGhostLinkage() ||
|
||||||
(isa<GlobalAlias>(GV) &&
|
(isa<GlobalAlias>(GV) &&
|
||||||
(GV.hasInternalLinkage() || GV.hasWeakLinkage())),
|
(GV.hasLocalLinkage() || GV.hasWeakLinkage())),
|
||||||
"Global is external, but doesn't have external or dllimport or weak linkage!",
|
"Global is external, but doesn't have external or dllimport or weak linkage!",
|
||||||
&GV);
|
&GV);
|
||||||
|
|
||||||
@ -384,7 +384,7 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) {
|
|||||||
void Verifier::visitGlobalAlias(GlobalAlias &GA) {
|
void Verifier::visitGlobalAlias(GlobalAlias &GA) {
|
||||||
Assert1(!GA.getName().empty(),
|
Assert1(!GA.getName().empty(),
|
||||||
"Alias name cannot be empty!", &GA);
|
"Alias name cannot be empty!", &GA);
|
||||||
Assert1(GA.hasExternalLinkage() || GA.hasInternalLinkage() ||
|
Assert1(GA.hasExternalLinkage() || GA.hasLocalLinkage() ||
|
||||||
GA.hasWeakLinkage(),
|
GA.hasWeakLinkage(),
|
||||||
"Alias should have external or external weak linkage!", &GA);
|
"Alias should have external or external weak linkage!", &GA);
|
||||||
Assert1(GA.getAliasee(),
|
Assert1(GA.getAliasee(),
|
||||||
|
9
test/Assembler/private.ll
Normal file
9
test/Assembler/private.ll
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
; Test to make sure that the 'private' tag is not lost!
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s | llvm-dis | grep private
|
||||||
|
|
||||||
|
declare void @foo()
|
||||||
|
|
||||||
|
define private void @foo() {
|
||||||
|
ret void
|
||||||
|
}
|
22
test/CodeGen/ARM/private.ll
Normal file
22
test/CodeGen/ARM/private.ll
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
; Test to make sure that the 'private' is used correctly.
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s | llc -mtriple=arm-linux-gnueabi > %t
|
||||||
|
; RUN: grep .Lfoo: %t
|
||||||
|
; RUN: egrep bl.*\.Lfoo %t
|
||||||
|
; RUN: grep .Lbaz: %t
|
||||||
|
; RUN: grep long.*\.Lbaz %t
|
||||||
|
|
||||||
|
declare void @foo()
|
||||||
|
|
||||||
|
define private void @foo() {
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
@baz = private global i32 4;
|
||||||
|
|
||||||
|
define i32 @bar() {
|
||||||
|
call void @foo()
|
||||||
|
%1 = load i32* @baz, align 4
|
||||||
|
ret i32 %1
|
||||||
|
}
|
||||||
|
|
21
test/CodeGen/Alpha/private.ll
Normal file
21
test/CodeGen/Alpha/private.ll
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
; Test to make sure that the 'private' is used correctly.
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s | llc > %t
|
||||||
|
; RUN: grep .Lfoo: %t
|
||||||
|
; RUN: grep call.*\.Lfoo %t
|
||||||
|
; RUN: grep .Lbaz: %t
|
||||||
|
; RUN: grep movl.*\.Lbaz %t
|
||||||
|
|
||||||
|
declare void @foo()
|
||||||
|
|
||||||
|
define private void @foo() {
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
@baz = private global i32 4;
|
||||||
|
|
||||||
|
define i32 @bar() {
|
||||||
|
call void @foo()
|
||||||
|
%1 = load i32* @baz, align 4
|
||||||
|
ret i32 %1
|
||||||
|
}
|
22
test/CodeGen/CellSPU/private.ll
Normal file
22
test/CodeGen/CellSPU/private.ll
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
; Test to make sure that the 'private' is used correctly.
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s | llc -march=cellspu > %t
|
||||||
|
; RUN: grep .Lfoo: %t
|
||||||
|
; RUN: grep brsl.*\.Lfoo %t
|
||||||
|
; RUN: grep .Lbaz: %t
|
||||||
|
; RUN: grep ila.*\.Lbaz %t
|
||||||
|
|
||||||
|
|
||||||
|
declare void @foo()
|
||||||
|
|
||||||
|
define private void @foo() {
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
@baz = private global i32 4;
|
||||||
|
|
||||||
|
define i32 @bar() {
|
||||||
|
call void @foo()
|
||||||
|
%1 = load i32* @baz, align 4
|
||||||
|
ret i32 %1
|
||||||
|
}
|
21
test/CodeGen/IA64/private.ll
Normal file
21
test/CodeGen/IA64/private.ll
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
; Test to make sure that the 'private' is used correctly.
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s | llc -march=ia64 > %t
|
||||||
|
; RUN: grep .foo: %t
|
||||||
|
; RUN: grep br.call.sptk.*\.foo %t
|
||||||
|
; RUN: grep .baz: %t
|
||||||
|
; RUN: grep ltoff.*\.baz %t
|
||||||
|
|
||||||
|
declare void @foo()
|
||||||
|
|
||||||
|
define private void @foo() {
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
@baz = private global i32 4;
|
||||||
|
|
||||||
|
define i32 @bar() {
|
||||||
|
call void @foo()
|
||||||
|
%1 = load i32* @baz, align 4
|
||||||
|
ret i32 %1
|
||||||
|
}
|
21
test/CodeGen/Mips/private.ll
Normal file
21
test/CodeGen/Mips/private.ll
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
; Test to make sure that the 'private' is used correctly.
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s | llc -march=mips > %t
|
||||||
|
; RUN: grep \\\$foo: %t
|
||||||
|
; RUN: grep call.*\\\$foo %t
|
||||||
|
; RUN: grep \\\$baz: %t
|
||||||
|
; RUN: grep lw.*\\\$baz %t
|
||||||
|
|
||||||
|
declare void @foo()
|
||||||
|
|
||||||
|
define private void @foo() {
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
@baz = private global i32 4;
|
||||||
|
|
||||||
|
define i32 @bar() {
|
||||||
|
call void @foo()
|
||||||
|
%1 = load i32* @baz, align 4
|
||||||
|
ret i32 %1
|
||||||
|
}
|
21
test/CodeGen/PowerPC/private.ll
Normal file
21
test/CodeGen/PowerPC/private.ll
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
; Test to make sure that the 'private' is used correctly.
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s | llc -mtriple=powerpc-unknown-linux-gnu > %t
|
||||||
|
; RUN: grep .Lfoo: %t
|
||||||
|
; RUN: grep bl.*\.Lfoo %t
|
||||||
|
; RUN: grep .Lbaz: %t
|
||||||
|
; RUN: grep lis.*\.Lbaz %t
|
||||||
|
|
||||||
|
declare void @foo()
|
||||||
|
|
||||||
|
define private void @foo() {
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
@baz = private global i32 4;
|
||||||
|
|
||||||
|
define i32 @bar() {
|
||||||
|
call void @foo()
|
||||||
|
%1 = load i32* @baz, align 4
|
||||||
|
ret i32 %1
|
||||||
|
}
|
21
test/CodeGen/SPARC/private.ll
Normal file
21
test/CodeGen/SPARC/private.ll
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
; Test to make sure that the 'private' is used correctly.
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s | llc -march=sparc > %t
|
||||||
|
; RUN: grep .foo: %t
|
||||||
|
; RUN: grep call.*\.foo %t
|
||||||
|
; RUN: grep .baz: %t
|
||||||
|
; RUN: grep ld.*\.baz %t
|
||||||
|
|
||||||
|
declare void @foo()
|
||||||
|
|
||||||
|
define private void @foo() {
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
@baz = private global i32 4;
|
||||||
|
|
||||||
|
define i32 @bar() {
|
||||||
|
call void @foo()
|
||||||
|
%1 = load i32* @baz, align 4
|
||||||
|
ret i32 %1
|
||||||
|
}
|
20
test/CodeGen/X86/private.ll
Normal file
20
test/CodeGen/X86/private.ll
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
; Test to make sure that the 'private' is used correctly.
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s | llc -mtriple=x86_64-pc-linux | grep .Lfoo:
|
||||||
|
; RUN: llvm-as < %s | llc -mtriple=x86_64-pc-linux | grep call.*\.Lfoo
|
||||||
|
; RUN: llvm-as < %s | llc -mtriple=x86_64-pc-linux | grep .Lbaz:
|
||||||
|
; RUN: llvm-as < %s | llc -mtriple=x86_64-pc-linux | grep movl.*\.Lbaz
|
||||||
|
|
||||||
|
declare void @foo()
|
||||||
|
|
||||||
|
define private void @foo() {
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
@baz = private global i32 4;
|
||||||
|
|
||||||
|
define i32 @bar() {
|
||||||
|
call void @foo()
|
||||||
|
%1 = load i32* @baz, align 4
|
||||||
|
ret i32 %1
|
||||||
|
}
|
21
test/CodeGen/XCore/private.ll
Normal file
21
test/CodeGen/XCore/private.ll
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
; Test to make sure that the 'private' is used correctly.
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s | llc -march=xcore > %t
|
||||||
|
; RUN: grep .Lfoo: %t
|
||||||
|
; RUN: grep bl.*\.Lfoo %t
|
||||||
|
; RUN: grep .Lbaz: %t
|
||||||
|
; RUN: grep ldw.*\.Lbaz %t
|
||||||
|
|
||||||
|
declare void @foo()
|
||||||
|
|
||||||
|
define private void @foo() {
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
@baz = private global i32 4;
|
||||||
|
|
||||||
|
define i32 @bar() {
|
||||||
|
call void @foo()
|
||||||
|
%1 = load i32* @baz, align 4
|
||||||
|
ret i32 %1
|
||||||
|
}
|
@ -199,7 +199,7 @@ static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) {
|
|||||||
/// prune appropriate entries out of M1s list.
|
/// prune appropriate entries out of M1s list.
|
||||||
static void SplitStaticCtorDtor(const char *GlobalName, Module *M1, Module *M2){
|
static void SplitStaticCtorDtor(const char *GlobalName, Module *M1, Module *M2){
|
||||||
GlobalVariable *GV = M1->getNamedGlobal(GlobalName);
|
GlobalVariable *GV = M1->getNamedGlobal(GlobalName);
|
||||||
if (!GV || GV->isDeclaration() || GV->hasInternalLinkage() ||
|
if (!GV || GV->isDeclaration() || GV->hasLocalLinkage() ||
|
||||||
!GV->use_empty()) return;
|
!GV->use_empty()) return;
|
||||||
|
|
||||||
std::vector<std::pair<Function*, int> > M1Tors, M2Tors;
|
std::vector<std::pair<Function*, int> > M1Tors, M2Tors;
|
||||||
|
@ -68,6 +68,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char TypeCharForSymbol(GlobalValue &GV) {
|
static char TypeCharForSymbol(GlobalValue &GV) {
|
||||||
|
/* FIXME: what to do with private linkage? */
|
||||||
if (GV.isDeclaration()) return 'U';
|
if (GV.isDeclaration()) return 'U';
|
||||||
if (GV.hasLinkOnceLinkage()) return 'C';
|
if (GV.hasLinkOnceLinkage()) return 'C';
|
||||||
if (GV.hasCommonLinkage()) return 'C';
|
if (GV.hasCommonLinkage()) return 'C';
|
||||||
@ -91,7 +92,7 @@ static void DumpSymbolNameForGlobalValue(GlobalValue &GV) {
|
|||||||
return;
|
return;
|
||||||
if ((TypeChar == 'U') && DefinedOnly)
|
if ((TypeChar == 'U') && DefinedOnly)
|
||||||
return;
|
return;
|
||||||
if (GV.hasInternalLinkage () && ExternalOnly)
|
if (GV.hasLocalLinkage () && ExternalOnly)
|
||||||
return;
|
return;
|
||||||
if (OutputFormat == posix) {
|
if (OutputFormat == posix) {
|
||||||
std::cout << GV.getName () << " " << TypeCharForSymbol (GV) << " "
|
std::cout << GV.getName () << " " << TypeCharForSymbol (GV) << " "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user