Fix llvm-extract so that it changes the linkage of all GlobalValues to

"external" even when doing lazy bitcode loading.  This was broken because
a function that is not materialized fails the !isDeclaration() test.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114666 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bob Wilson
2010-09-23 17:25:06 +00:00
parent 32d2c5de64
commit edf017487f
2 changed files with 20 additions and 17 deletions
+14 -16
View File
@@ -50,24 +50,22 @@ namespace {
// Visit the GlobalVariables.
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I)
if (!I->isDeclaration()) {
if (I->hasLocalLinkage())
I->setVisibility(GlobalValue::HiddenVisibility);
I->setLinkage(GlobalValue::ExternalLinkage);
if (deleteStuff == (bool)Named.count(I))
I->setInitializer(0);
}
I != E; ++I) {
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 (!I->isDeclaration()) {
if (I->hasLocalLinkage())
I->setVisibility(GlobalValue::HiddenVisibility);
I->setLinkage(GlobalValue::ExternalLinkage);
if (deleteStuff == (bool)Named.count(I))
I->deleteBody();
}
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
if (I->hasLocalLinkage())
I->setVisibility(GlobalValue::HiddenVisibility);
I->setLinkage(GlobalValue::ExternalLinkage);
if (deleteStuff == (bool)Named.count(I) && !I->isDeclaration())
I->deleteBody();
}
return true;
}