From 4b334fd2e265125548b9c2f7519ba888a856e9f9 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 15 Jun 2012 11:50:16 -0700 Subject: [PATCH] Fix linkage for programIndex et al. when not debugging. We now use InternalLinkage for the 'programIndex' symbol (and similar) if we're not compiling with debugging symbols. This prevents those symbol names/definitions from polluting the global namespace for the common case. Basically addresses Issue #274. --- builtins.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/builtins.cpp b/builtins.cpp index 714390d7..c2422ead 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -646,8 +646,9 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module, // Use WeakODRLinkage rather than InternalLinkage so that a definition // survives even if it's not used in the module, so that the symbol is // there in the debugger. - sym->storagePtr = new llvm::GlobalVariable(*module, ltype, true, - llvm::GlobalValue::WeakODRLinkage, + llvm::GlobalValue::LinkageTypes linkage = g->generateDebuggingSymbols ? + llvm::GlobalValue::WeakODRLinkage : llvm::GlobalValue::InternalLinkage; + sym->storagePtr = new llvm::GlobalVariable(*module, ltype, true, linkage, linit, name); symbolTable->AddVariable(sym); @@ -704,10 +705,10 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) { llvm::Type *ltype = LLVMTypes::Int32VectorType; llvm::Constant *linit = LLVMInt32Vector(pi); // See comment in lDefineConstantInt() for why WeakODRLinkage is used here - sym->storagePtr = new llvm::GlobalVariable(*module, ltype, true, - llvm::GlobalValue::WeakODRLinkage, - linit, - sym->name.c_str()); + llvm::GlobalValue::LinkageTypes linkage = g->generateDebuggingSymbols ? + llvm::GlobalValue::WeakODRLinkage : llvm::GlobalValue::InternalLinkage; + sym->storagePtr = new llvm::GlobalVariable(*module, ltype, true, linkage, + linit, sym->name.c_str()); symbolTable->AddVariable(sym); if (m->diBuilder != NULL) {