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.

llvm-svn: 66404
This commit is contained in:
Chris Lattner 2009-03-09 05:52:15 +00:00
parent 6f884e07c5
commit 317293b504
1 changed files with 16 additions and 10 deletions

View File

@ -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;