mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
GlobalOpt: Don't swap private for internal linkage
There were transforms whose *intent* was to downgrade the linkage of external objects to have internal linkage. However, it fired on things with private linkage as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212104 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
553b2c9435
commit
f44809c898
@ -1908,7 +1908,7 @@ bool GlobalOpt::OptimizeFunctions(Module &M) {
|
||||
for (Module::iterator FI = M.begin(), E = M.end(); FI != E; ) {
|
||||
Function *F = FI++;
|
||||
// Functions without names cannot be referenced outside this module.
|
||||
if (!F->hasName() && !F->isDeclaration())
|
||||
if (!F->hasName() && !F->isDeclaration() && !F->hasLocalLinkage())
|
||||
F->setLinkage(GlobalValue::InternalLinkage);
|
||||
F->removeDeadConstantUsers();
|
||||
if (F->isDefTriviallyDead()) {
|
||||
@ -1953,7 +1953,7 @@ bool GlobalOpt::OptimizeGlobalVars(Module &M) {
|
||||
GVI != E; ) {
|
||||
GlobalVariable *GV = GVI++;
|
||||
// Global variables without names cannot be referenced outside this module.
|
||||
if (!GV->hasName() && !GV->isDeclaration())
|
||||
if (!GV->hasName() && !GV->isDeclaration() && !GV->hasLocalLinkage())
|
||||
GV->setLinkage(GlobalValue::InternalLinkage);
|
||||
// Simplify the initializer.
|
||||
if (GV->hasInitializer())
|
||||
@ -2858,7 +2858,7 @@ bool GlobalOpt::OptimizeGlobalAliases(Module &M) {
|
||||
I != E;) {
|
||||
Module::alias_iterator J = I++;
|
||||
// Aliases without names cannot be referenced outside this module.
|
||||
if (!J->hasName() && !J->isDeclaration())
|
||||
if (!J->hasName() && !J->isDeclaration() && !J->hasLocalLinkage())
|
||||
J->setLinkage(GlobalValue::InternalLinkage);
|
||||
// If the aliasee may change at link time, nothing can be done - bail out.
|
||||
if (J->mayBeOverridden())
|
||||
|
@ -1,13 +1,23 @@
|
||||
; RUN: opt < %s -globalopt -S | FileCheck %s
|
||||
|
||||
global i32 0
|
||||
; CHECK: @0 = internal global i32 0
|
||||
define i32* @1() {
|
||||
; CHECK-DAG: @0 = internal global i32 0
|
||||
|
||||
private global i32 0
|
||||
; CHECK-DAG: @1 = private global i32 0
|
||||
|
||||
define i32* @2() {
|
||||
ret i32* @0
|
||||
}
|
||||
; CHECK: define internal fastcc i32* @1()
|
||||
; CHECK-DAG: define internal fastcc i32* @2()
|
||||
|
||||
define i32* @f() {
|
||||
entry:
|
||||
call i32* @1()
|
||||
call i32* @2()
|
||||
ret i32* %0
|
||||
}
|
||||
|
||||
define i32* @g() {
|
||||
entry:
|
||||
ret i32* @1
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user