Don't change the visibility when converting a definition to a declaration.

llvm-svn: 242030
This commit is contained in:
Rafael Espindola 2015-07-13 14:18:22 +00:00
parent ef5aa29e12
commit 237c3a6def
4 changed files with 13 additions and 3 deletions

View File

@ -176,6 +176,7 @@ namespace {
(void) llvm::createStraightLineStrengthReducePass();
(void) llvm::createMemDerefPrinter();
(void) llvm::createFloat2IntPass();
(void) llvm::createEliminateAvailableExternallyPass();
(void)new llvm::IntervalPartition();
(void)new llvm::ScalarEvolution();

View File

@ -67,7 +67,6 @@ bool EliminateAvailableExternally::runOnModule(Module &M) {
}
I->removeDeadConstantUsers();
I->setLinkage(GlobalValue::ExternalLinkage);
I->setVisibility(GlobalValue::DefaultVisibility);
NumVariables++;
}
@ -78,7 +77,6 @@ bool EliminateAvailableExternally::runOnModule(Module &M) {
if (!I->isDeclaration())
// This will set the linkage to external
I->deleteBody();
I->setVisibility(GlobalValue::DefaultVisibility);
I->removeDeadConstantUsers();
NumFunctions++;
}
@ -91,7 +89,6 @@ bool EliminateAvailableExternally::runOnModule(Module &M) {
I->setAliasee(nullptr);
I->removeDeadConstantUsers();
I->setLinkage(GlobalValue::ExternalLinkage);
I->setVisibility(GlobalValue::DefaultVisibility);
NumAliases++;
}

View File

@ -46,6 +46,7 @@ void llvm::initializeIPO(PassRegistry &Registry) {
initializeStripDeadDebugInfoPass(Registry);
initializeStripNonDebugSymbolsPass(Registry);
initializeBarrierNoopPass(Registry);
initializeEliminateAvailableExternallyPass(Registry);
}
void LLVMInitializeIPO(LLVMPassRegistryRef R) {

View File

@ -0,0 +1,11 @@
; RUN: opt -elim-avail-extern -S < %s | FileCheck %s
; CHECK: declare hidden void @f()
define available_externally hidden void @f() {
ret void
}
define void @g() {
call void @f()
ret void
}