Merge with rev [1221]

This commit is contained in:
Tomas Lindquist Olsen
2009-04-17 01:19:03 +02:00

View File

@@ -305,6 +305,11 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
assert(0 && "not global/function");
}
// The following breaks for nested naked functions, so check for that.
bool skipNestedCheck = false;
if (FuncDeclaration* fd = sym->isFuncDeclaration())
skipNestedCheck = (fd->naked != 0);
// Any symbol nested in a function can't be referenced directly from
// outside that function, so we can give such symbols internal linkage.
// This holds even if nested indirectly, such as member functions of
@@ -318,10 +323,11 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
// ---
// if instances get emitted in multiple object files because they'd use
// different instances of 'i'.
for (Dsymbol* parent = sym->parent; parent ; parent = parent->parent) {
if (parent->isFuncDeclaration())
return llvm::GlobalValue::InternalLinkage;
}
if (!skipNestedCheck)
for (Dsymbol* parent = sym->parent; parent ; parent = parent->parent) {
if (parent->isFuncDeclaration())
return llvm::GlobalValue::InternalLinkage;
}
// default to external linkage
return llvm::GlobalValue::ExternalLinkage;