From 7809811e4ed3c2462efa327cef0464b9844baea2 Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Tue, 7 Mar 2006 22:00:35 +0000 Subject: [PATCH] Use "llvm.metadata" section for debug globals. Filter out these globals in the asm printer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26599 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter.cpp | 8 ++++++-- lib/CodeGen/MachineDebugInfo.cpp | 3 +++ lib/Target/PowerPC/PPCAsmPrinter.cpp | 2 +- lib/Target/X86/X86AsmPrinter.cpp | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index dfac3c07788..11c6f231b9f 100644 --- a/lib/CodeGen/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter.cpp @@ -131,8 +131,12 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) { /// special global used by LLVM. If so, emit it and return true, otherwise /// do nothing and return false. bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) { - assert(GV->hasInitializer() && GV->hasAppendingLinkage() && - "Not a special LLVM global!"); + // Ignore debug and non-emitted data. + if (GV->getSection() == "llvm.metadata") return true; + + if (!GV->hasAppendingLinkage()) return false; + + assert(GV->hasInitializer() && "Not a special LLVM global!"); if (GV->getName() == "llvm.used") return true; // No need to emit this at all. diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp index ba5bf03b96f..9e76daa4b78 100644 --- a/lib/CodeGen/MachineDebugInfo.cpp +++ b/lib/CodeGen/MachineDebugInfo.cpp @@ -350,6 +350,7 @@ public: GlobalValue::InternalLinkage, CA, "llvm.dbg.array", SR.getModule()); + CAGV->setSection("llvm.metadata"); Constant *CAE = ConstantExpr::getCast(CAGV, EmptyTy); Elements.push_back(CAE); } @@ -1193,6 +1194,7 @@ Constant *DISerializer::getString(const std::string &String) { GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true, GlobalVariable::InternalLinkage, ConstStr, "str", M); + StrGV->setSection("llvm.metadata"); // Convert to generic string pointer. Slot = ConstantExpr::getCast(StrGV, getStrPtrType()); return Slot; @@ -1214,6 +1216,7 @@ GlobalVariable *DISerializer::Serialize(DebugInfoDesc *DD) { // Create the GlobalVariable early to prevent infinite recursion. GlobalVariable *GV = new GlobalVariable(Ty, true, DD->getLinkage(), NULL, DD->getDescString(), M); + GV->setSection("llvm.metadata"); // Insert new GlobalVariable in DescGlobals map. Slot = GV; diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index cc40bbf76a1..2b88a855f5c 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -564,7 +564,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) { if (!I->hasInitializer()) continue; // External global require no code // Check to see if this is a special global used by LLVM, if so, emit it. - if (I->hasAppendingLinkage() && EmitSpecialLLVMGlobal(I)) + if (EmitSpecialLLVMGlobal(I)) continue; std::string name = Mang->getValueName(I); diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index a5e7008bc0b..ad2569d810d 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -92,7 +92,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { if (!I->hasInitializer()) continue; // External global require no code // Check to see if this is a special global used by LLVM, if so, emit it. - if (I->hasAppendingLinkage() && EmitSpecialLLVMGlobal(I)) + if (EmitSpecialLLVMGlobal(I)) continue; std::string name = Mang->getValueName(I);