mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-06 20:32:19 +00: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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66404 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
319e63234a
commit
f231c07228
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user