[llvm] r212104 - GlobalOpt: Don't swap private for internal linkage
Rafael Avila de Espindola
rafael.espindola at gmail.com
Tue Jul 1 09:22:14 PDT 2014
Nice catch!
Sent from my iPhone
> On Jul 1, 2014, at 11:26, David Majnemer <david.majnemer at gmail.com> wrote:
>
> Author: majnemer
> Date: Tue Jul 1 10:26:50 2014
> New Revision: 212104
>
> URL: http://llvm.org/viewvc/llvm-project?rev=212104&view=rev
> Log:
> 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.
>
> Modified:
> llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
> llvm/trunk/test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll
>
> Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=212104&r1=212103&r2=212104&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Jul 1 10:26:50 2014
> @@ -1908,7 +1908,7 @@ bool GlobalOpt::OptimizeFunctions(Module
> 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(Modul
> 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(Mo
> 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())
>
> Modified: llvm/trunk/test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll?rev=212104&r1=212103&r2=212104&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll (original)
> +++ llvm/trunk/test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll Tue Jul 1 10:26:50 2014
> @@ -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
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list