mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-04 21:30:49 +00:00
Don't internalize llvm.global[cd]tor unless there are uses of it. This
unbreaks front-ends that don't use __main (like the new CFE). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25429 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8ff318b7fb
commit
ee9e14cb8a
@ -109,7 +109,7 @@ bool InternalizePass::runOnModule(Module &M) {
|
|||||||
// Never internalize the llvm.used symbol. It is used to implement
|
// Never internalize the llvm.used symbol. It is used to implement
|
||||||
// attribute((used)).
|
// attribute((used)).
|
||||||
ExternalNames.insert("llvm.used");
|
ExternalNames.insert("llvm.used");
|
||||||
|
|
||||||
// Never internalize anchors used by the debugger, else the debugger won't
|
// Never internalize anchors used by the debugger, else the debugger won't
|
||||||
// find them.
|
// find them.
|
||||||
ExternalNames.insert("llvm.dbg.translation_units");
|
ExternalNames.insert("llvm.dbg.translation_units");
|
||||||
@ -125,13 +125,19 @@ bool InternalizePass::runOnModule(Module &M) {
|
|||||||
// the list if it's empty.
|
// the list if it's empty.
|
||||||
//
|
//
|
||||||
if (I->hasAppendingLinkage() && (I->getName() == "llvm.global_ctors" ||
|
if (I->hasAppendingLinkage() && (I->getName() == "llvm.global_ctors" ||
|
||||||
I->getName() == "llvm.global_dtors"))
|
I->getName() == "llvm.global_dtors")) {
|
||||||
I->setConstant(true);
|
I->setConstant(true);
|
||||||
|
|
||||||
|
// If the global ctors/dtors list has no uses, do not internalize it, as
|
||||||
|
// there is no __main in this program, so the asmprinter should handle
|
||||||
|
// it.
|
||||||
|
if (I->use_empty()) continue;
|
||||||
|
}
|
||||||
|
|
||||||
I->setLinkage(GlobalValue::InternalLinkage);
|
I->setLinkage(GlobalValue::InternalLinkage);
|
||||||
Changed = true;
|
Changed = true;
|
||||||
++NumGlobals;
|
++NumGlobals;
|
||||||
DEBUG(std::cerr << "Internalizing gvar " << I->getName() << "\n");
|
DEBUG(std::cerr << "Internalized gvar " << I->getName() << "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Changed;
|
return Changed;
|
||||||
|
Loading…
Reference in New Issue
Block a user