[llvm-commits] [llvm] r66404 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Chris Lattner
sabre at nondot.org
Sun Mar 8 22:52:15 PDT 2009
Author: lattner
Date: Mon Mar 9 00:52:15 2009
New Revision: 66404
URL: http://llvm.org/viewvc/llvm-project?rev=66404&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=66404&r1=66403&r2=66404&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Mar 9 00:52:15 2009
@@ -418,18 +418,24 @@
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;
More information about the llvm-commits
mailing list