Improve the handling of available_externally and llvm.global_ctors.

llvm-svn: 132775
This commit is contained in:
Rafael Espindola 2011-06-09 14:38:09 +00:00
parent eeb50c8fd2
commit b77c00fb60
1 changed files with 16 additions and 4 deletions

View File

@ -51,20 +51,32 @@ namespace {
// Visit the GlobalVariables.
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
if (deleteStuff == (bool)Named.count(I) && !I->isDeclaration()) {
I->setInitializer(0);
} else {
if (I->hasAvailableExternallyLinkage())
continue;
if (I->getName() == "llvm.global_ctors")
continue;
}
if (I->hasLocalLinkage())
I->setVisibility(GlobalValue::HiddenVisibility);
I->setLinkage(GlobalValue::ExternalLinkage);
if (deleteStuff == (bool)Named.count(I) && !I->isDeclaration())
I->setInitializer(0);
}
// Visit the Functions.
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
if (deleteStuff == (bool)Named.count(I) && !I->isDeclaration()) {
I->deleteBody();
} else {
if (I->hasAvailableExternallyLinkage())
continue;
}
if (I->hasLocalLinkage())
I->setVisibility(GlobalValue::HiddenVisibility);
I->setLinkage(GlobalValue::ExternalLinkage);
if (deleteStuff == (bool)Named.count(I) && !I->isDeclaration())
I->deleteBody();
}
return true;