1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

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 4d3876ada0
commit 6b52b88467

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;