1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01: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).

llvm-svn: 25429
This commit is contained in:
Chris Lattner 2006-01-19 00:40:39 +00:00
parent c7a7422412
commit 197d33ce21

View File

@ -125,13 +125,19 @@ bool InternalizePass::runOnModule(Module &M) {
// the list if it's empty.
//
if (I->hasAppendingLinkage() && (I->getName() == "llvm.global_ctors" ||
I->getName() == "llvm.global_dtors"))
I->getName() == "llvm.global_dtors")) {
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);
Changed = true;
++NumGlobals;
DEBUG(std::cerr << "Internalizing gvar " << I->getName() << "\n");
DEBUG(std::cerr << "Internalized gvar " << I->getName() << "\n");
}
return Changed;