Only invoke mustDefineSymbol() once in DtoLinkage.

This is, of course, a microoptimization, but more importantly
makes stepping through the code easier.
This commit is contained in:
David Nadlinger
2012-10-07 00:03:10 +02:00
parent c9e2fc34d1
commit da17b7c6b6

View File

@@ -246,13 +246,19 @@ LLValue* DtoDelegateEquals(TOK op, LLValue* lhs, LLValue* rhs)
LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
{
const bool mustDefine = mustDefineSymbol(sym);
// global variable
if (VarDeclaration* vd = sym->isVarDeclaration())
{
if (mustDefineSymbol(vd))
Logger::println("Variable %savailable externally: %s", (vd->availableExternally ? "" : "not "), vd->toChars());
if (mustDefine)
{
IF_LOG Logger::println("Variable %savailable externally: %s",
(vd->availableExternally ? "" : "not "), vd->toChars());
}
// generated by inlining semantics run
if (vd->availableExternally && mustDefineSymbol(sym))
if (vd->availableExternally && mustDefine)
return llvm::GlobalValue::AvailableExternallyLinkage;
// template
if (needsTemplateLinkage(sym))
@@ -264,8 +270,12 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
// function
else if (FuncDeclaration* fdecl = sym->isFuncDeclaration())
{
if (mustDefineSymbol(fdecl))
Logger::println("Function %savailable externally: %s", (fdecl->availableExternally ? "" : "not "), fdecl->toChars());
if (mustDefine)
{
IF_LOG Logger::println("Function %savailable externally: %s",
(fdecl->availableExternally ? "" : "not "), fdecl->toChars());
}
assert(fdecl->type->ty == Tfunction);
TypeFunction* ft = static_cast<TypeFunction*>(fdecl->type);
@@ -273,7 +283,7 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
if (fdecl->llvmInternal == LLVMintrinsic)
return llvm::GlobalValue::ExternalLinkage;
// generated by inlining semantics run
if (fdecl->availableExternally && mustDefineSymbol(sym))
if (fdecl->availableExternally && mustDefine)
return llvm::GlobalValue::AvailableExternallyLinkage;
// array operations are always template linkage
if (fdecl->isArrayOp == 1)
@@ -297,10 +307,13 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
// class
else if (ClassDeclaration* cd = sym->isClassDeclaration())
{
if (mustDefineSymbol(cd))
Logger::println("Class %savailable externally: %s", (cd->availableExternally ? "" : "not "), vd->toChars());
if (mustDefine)
{
IF_LOG Logger::println("Class %savailable externally: %s",
(cd->availableExternally ? "" : "not "), vd->toChars());
}
// generated by inlining semantics run
if (cd->availableExternally && mustDefineSymbol(sym))
if (cd->availableExternally && mustDefine)
return llvm::GlobalValue::AvailableExternallyLinkage;
// template
if (needsTemplateLinkage(cd))
@@ -318,7 +331,7 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
// interface methods (where __require/__ensure are emitted to the module
// where the interface is declared, but an actual interface implementation
// can be in a completely different place).
bool skipNestedCheck = !mustDefineSymbol(sym);
bool skipNestedCheck = !mustDefine;
if (!skipNestedCheck)
if (FuncDeclaration* fd = sym->isFuncDeclaration())
skipNestedCheck = (fd->naked != 0) ||