[llvm] r279021 - [LTO] Promote before performing weak resolution

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 17:59:25 PDT 2016


Author: mehdi_amini
Date: Wed Aug 17 19:59:24 2016
New Revision: 279021

URL: http://llvm.org/viewvc/llvm-project?rev=279021&view=rev
Log:
[LTO] Promote before performing weak resolution

Summary:
This was reversed compared to ThinLTOCodeGenerator for some reason,
and lead to an increased code-size on my tests. I figured that the
weak resolution may internalize a linkonce function, which will be
promoted immediately (and renamed), before being internalized again.

Reviewers: tejohnson

Subscribers: pcc, llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D23632

Modified:
    llvm/trunk/lib/LTO/LTOBackend.cpp
    llvm/trunk/test/ThinLTO/X86/internalize.ll

Modified: llvm/trunk/lib/LTO/LTOBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOBackend.cpp?rev=279021&r1=279020&r2=279021&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOBackend.cpp (original)
+++ llvm/trunk/lib/LTO/LTOBackend.cpp Wed Aug 17 19:59:24 2016
@@ -250,10 +250,10 @@ Error lto::thinBackend(Config &Conf, uns
   if (Conf.PreOptModuleHook && !Conf.PreOptModuleHook(Task, Mod))
     return Error();
 
-  thinLTOResolveWeakForLinkerModule(Mod, DefinedGlobals);
-
   renameModuleForThinLTO(Mod, CombinedIndex);
 
+  thinLTOResolveWeakForLinkerModule(Mod, DefinedGlobals);
+
   if (Conf.PostPromoteModuleHook && !Conf.PostPromoteModuleHook(Task, Mod))
     return Error();
 

Modified: llvm/trunk/test/ThinLTO/X86/internalize.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ThinLTO/X86/internalize.ll?rev=279021&r1=279020&r2=279021&view=diff
==============================================================================
--- llvm/trunk/test/ThinLTO/X86/internalize.ll (original)
+++ llvm/trunk/test/ThinLTO/X86/internalize.ll Wed Aug 17 19:59:24 2016
@@ -3,10 +3,19 @@
 ; RUN: llvm-lto -thinlto-action=internalize -thinlto-index %t.index.bc %t1.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=REGULAR
 ; RUN: llvm-lto -thinlto-action=internalize -thinlto-index %t.index.bc %t1.bc -o -  --exported-symbol=foo | llvm-dis -o - | FileCheck %s --check-prefix=INTERNALIZE
 
+; RUN: llvm-lto2 %t1.bc -o %t.o -save-temps \
+; RUN:     -r=%t1.bc,_foo,pxl \
+; RUN:     -r=%t1.bc,_bar,pl \
+; RUN:     -r=%t1.bc,_linkonce_func,pl
+; RUN: llvm-dis < %t.o.1.2.internalize.bc | FileCheck  %s --check-prefix=INTERNALIZE
+
+
 ; REGULAR: define void @foo
 ; REGULAR: define void @bar
+; REGULAR: define linkonce void @linkonce_func()
 ; INTERNALIZE: define void @foo
 ; INTERNALIZE: define internal void @bar
+; INTERNALIZE: define internal void @linkonce_func()
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.11.0"
@@ -15,5 +24,9 @@ define void @foo() {
     ret void
 }
 define void @bar() {
+    call void @linkonce_func()
+	ret void
+}
+define linkonce void @linkonce_func() {
     ret void
 }
\ No newline at end of file




More information about the llvm-commits mailing list