Allow multiple declarations to share the same mangled name/LLVM global.

This is necessary to enable aliasing compiler-generated
symbols with pragma(mangle, …).

Note that globals for internal use are still directly
created.
This commit is contained in:
David Nadlinger
2013-06-16 00:12:02 +02:00
parent 0305d3bce2
commit acd508945a
9 changed files with 63 additions and 34 deletions

View File

@@ -17,6 +17,7 @@
#include "root.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "ir/irtype.h"
@@ -121,8 +122,8 @@ llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char*
}
LLPointerType* t = g->getType();
return new LLGlobalVariable(*target, t->getElementType(), g->isConstant(),
g->getLinkage(), NULL, g->getName());
return getOrCreateGlobal(Loc(), *target, t->getElementType(), g->isConstant(),
g->getLinkage(), NULL, g->getName());
}
//////////////////////////////////////////////////////////////////////////////////////////////////