forked from OSchip/llvm-project
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. llvm-svn: 114666
This commit is contained in:
parent
d5f4130ffb
commit
3aecb15f0a
|
@ -50,24 +50,22 @@ namespace {
|
||||||
|
|
||||||
// Visit the GlobalVariables.
|
// Visit the GlobalVariables.
|
||||||
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
|
||||||
I != E; ++I)
|
I != E; ++I) {
|
||||||
if (!I->isDeclaration()) {
|
if (I->hasLocalLinkage())
|
||||||
if (I->hasLocalLinkage())
|
I->setVisibility(GlobalValue::HiddenVisibility);
|
||||||
I->setVisibility(GlobalValue::HiddenVisibility);
|
I->setLinkage(GlobalValue::ExternalLinkage);
|
||||||
I->setLinkage(GlobalValue::ExternalLinkage);
|
if (deleteStuff == (bool)Named.count(I) && !I->isDeclaration())
|
||||||
if (deleteStuff == (bool)Named.count(I))
|
I->setInitializer(0);
|
||||||
I->setInitializer(0);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Visit the Functions.
|
// Visit the Functions.
|
||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
||||||
if (!I->isDeclaration()) {
|
if (I->hasLocalLinkage())
|
||||||
if (I->hasLocalLinkage())
|
I->setVisibility(GlobalValue::HiddenVisibility);
|
||||||
I->setVisibility(GlobalValue::HiddenVisibility);
|
I->setLinkage(GlobalValue::ExternalLinkage);
|
||||||
I->setLinkage(GlobalValue::ExternalLinkage);
|
if (deleteStuff == (bool)Named.count(I) && !I->isDeclaration())
|
||||||
if (deleteStuff == (bool)Named.count(I))
|
I->deleteBody();
|
||||||
I->deleteBody();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,18 @@
|
||||||
; CHECK: define void @foo() {
|
; CHECK: define void @foo() {
|
||||||
; CHECK: ret void
|
; CHECK: ret void
|
||||||
; CHECK: }
|
; CHECK: }
|
||||||
|
|
||||||
|
; The linkonce_odr linkage for foo() should be changed to external linkage.
|
||||||
|
; DELETE: declare void @foo()
|
||||||
; DELETE: define void @bar() {
|
; DELETE: define void @bar() {
|
||||||
|
; DELETE: call void @foo()
|
||||||
; DELETE: ret void
|
; DELETE: ret void
|
||||||
; DELETE: }
|
; DELETE: }
|
||||||
|
|
||||||
define void @foo() {
|
define linkonce_odr void @foo() {
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
define void @bar() {
|
define void @bar() {
|
||||||
|
call void @foo()
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue