diff options
| author | Bob Wilson <bob.wilson@apple.com> | 2010-09-23 17:25:06 +0000 |
|---|---|---|
| committer | Bob Wilson <bob.wilson@apple.com> | 2010-09-23 17:25:06 +0000 |
| commit | 3aecb15f0afb9c92ca1f6de33653e75fa1240a6b (patch) | |
| tree | 0c704e738216485f9c4cb7176bd9da9bc4e0614d | |
| parent | d5f4130ffbb42dd1918ba05430523f00f14d8c96 (diff) | |
| download | bcm5719-llvm-3aecb15f0afb9c92ca1f6de33653e75fa1240a6b.tar.gz bcm5719-llvm-3aecb15f0afb9c92ca1f6de33653e75fa1240a6b.zip | |
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
| -rw-r--r-- | llvm/lib/Transforms/IPO/ExtractGV.cpp | 30 | ||||
| -rw-r--r-- | llvm/test/Other/extract.ll | 7 |
2 files changed, 20 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/IPO/ExtractGV.cpp b/llvm/lib/Transforms/IPO/ExtractGV.cpp index bb041697a5c..9d432de9fa7 100644 --- a/llvm/lib/Transforms/IPO/ExtractGV.cpp +++ b/llvm/lib/Transforms/IPO/ExtractGV.cpp @@ -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; } diff --git a/llvm/test/Other/extract.ll b/llvm/test/Other/extract.ll index 46962d094fd..57573ed76f9 100644 --- a/llvm/test/Other/extract.ll +++ b/llvm/test/Other/extract.ll @@ -10,13 +10,18 @@ ; CHECK: define void @foo() { ; CHECK: ret void ; CHECK: } + +; The linkonce_odr linkage for foo() should be changed to external linkage. +; DELETE: declare void @foo() ; DELETE: define void @bar() { +; DELETE: call void @foo() ; DELETE: ret void ; DELETE: } -define void @foo() { +define linkonce_odr void @foo() { ret void } define void @bar() { + call void @foo() ret void } |

