From: Chris Lattner Date: Mon, 9 Mar 2009 05:52:15 +0000 (+0000) Subject: Make the code generator rip of dead constant expr uses before deciding X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f231c07228deb75b6cd5ae7c9c057bc8303c6998;p=oota-llvm.git Make the code generator rip of dead constant expr uses before deciding whether a global is dead or not. This should fix PR3749 - linker adds spurious use to appending globals. I can't reasonably add a testcase for this, because the bc writer/reader strip dead constant users. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66404 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index fd71ba971e7..dcfa7a5961d 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -418,18 +418,24 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) { const TargetData *TD = TM.getTargetData(); unsigned Align = Log2_32(TD->getPointerPrefAlignment()); - if (GV->getName() == "llvm.global_ctors" && GV->use_empty()) { - SwitchToDataSection(TAI->getStaticCtorsSection()); - EmitAlignment(Align, 0); - EmitXXStructorList(GV->getInitializer()); - return true; + if (GV->getName() == "llvm.global_ctors") { + GV->removeDeadConstantUsers(); + if (GV->use_empty()) { + SwitchToDataSection(TAI->getStaticCtorsSection()); + EmitAlignment(Align, 0); + EmitXXStructorList(GV->getInitializer()); + return true; + } } - if (GV->getName() == "llvm.global_dtors" && GV->use_empty()) { - SwitchToDataSection(TAI->getStaticDtorsSection()); - EmitAlignment(Align, 0); - EmitXXStructorList(GV->getInitializer()); - return true; + if (GV->getName() == "llvm.global_dtors") { + GV->removeDeadConstantUsers(); + if (GV->use_empty()) { + SwitchToDataSection(TAI->getStaticDtorsSection()); + EmitAlignment(Align, 0); + EmitXXStructorList(GV->getInitializer()); + return true; + } } return false;