forked from OSchip/llvm-project
Improve the handling of available_externally and llvm.global_ctors.
llvm-svn: 132775
This commit is contained in:
parent
eeb50c8fd2
commit
b77c00fb60
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue