[llvm] b90d2d6 - [ThinLTO][test] Test prevailing non-exported non-ODR linkonce/odr can be internalized

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 28 09:56:05 PDT 2023


Author: Fangrui Song
Date: 2023-08-28T09:56:00-07:00
New Revision: b90d2d6680b623ebeb4a3afa38003a6e261ee642

URL: https://github.com/llvm/llvm-project/commit/b90d2d6680b623ebeb4a3afa38003a6e261ee642
DIFF: https://github.com/llvm/llvm-project/commit/b90d2d6680b623ebeb4a3afa38003a6e261ee642.diff

LOG: [ThinLTO][test] Test prevailing non-exported non-ODR linkonce/odr can be internalized

To improve the tests added by D151965. Discovered when writing D158949.

Added: 
    

Modified: 
    llvm/test/ThinLTO/X86/weak_resolution.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/ThinLTO/X86/weak_resolution.ll b/llvm/test/ThinLTO/X86/weak_resolution.ll
index 1bca0c7059dda6..15db40a65fcb84 100644
--- a/llvm/test/ThinLTO/X86/weak_resolution.ll
+++ b/llvm/test/ThinLTO/X86/weak_resolution.ll
@@ -13,7 +13,7 @@
 ; RUN: llvm-lto -thinlto-action=internalize %t.bc -thinlto-index=%t3.bc -exported-symbol=_linkoncefunc -o - | llvm-dis -o - | FileCheck %s --check-prefix=MOD1-INT
 ; RUN: llvm-lto -thinlto-action=promote %t2.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=MOD2
 ; When exported, we always preserve a linkonce
-; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - --exported-symbol=_linkonceodrfuncInSingleModule | llvm-dis -o - | FileCheck %s --check-prefix=EXPORTED
+; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - --exported-symbol=_linkonceodrfuncInSingleModule --exported-symbol=_weakfuncInSingleModule | llvm-dis -o - | FileCheck %s --check-prefix=EXPORTED
 
 ;; Now try this with the new LTO API
 ; RUN: llvm-lto2 run %t.bc %t2.bc -o %t3.out -save-temps \
@@ -21,6 +21,7 @@
 ; RUN:   -r %t.bc,_linkoncealias,pl \
 ; RUN:   -r %t.bc,_linkonceodrvarInSingleModule,pl \
 ; RUN:   -r %t.bc,_weakodrvarInSingleModule,pl \
+; RUN:   -r %t.bc,_weakvarInSingleModule,pl \
 ; RUN:   -r %t.bc,_linkonceodrfuncwithalias,pl \
 ; RUN:   -r %t.bc,_linkoncefuncwithalias,pl \
 ; RUN:   -r %t.bc,_linkonceodrfunc,pl \
@@ -28,6 +29,7 @@
 ; RUN:   -r %t.bc,_weakodrfunc,pl \
 ; RUN:   -r %t.bc,_weakfunc,pl \
 ; RUN:   -r %t.bc,_linkonceodrfuncInSingleModule,pl \
+; RUN:   -r %t.bc,_weakfuncInSingleModule,pl \
 ; RUN:   -r %t2.bc,_linkonceodrfuncwithalias,l \
 ; RUN:   -r %t2.bc,_linkoncefuncwithalias,l \
 ; RUN:   -r %t2.bc,_linkonceodrfunc,l \
@@ -55,8 +57,10 @@ target triple = "x86_64-apple-macosx10.11.0"
 ;; of whether they are const or *unnamed_addr.
 ; MOD1-INT: @linkonceodrvarInSingleModule = internal global
 ; MOD1-INT: @weakodrvarInSingleModule = internal global
+; MOD1-INT: @weakvarInSingleModule = internal global
 @linkonceodrvarInSingleModule = linkonce_odr dso_local global ptr null, align 8
 @weakodrvarInSingleModule = weak_odr dso_local global ptr null, align 8
+ at weakvarInSingleModule = weak dso_local global ptr null, align 8
 
 ;; Function with an alias are resolved to weak_odr in prevailing module, but
 ;; not optimized in non-prevailing module (illegal to have an
@@ -115,3 +119,11 @@ define linkonce_odr void @linkonceodrfuncInSingleModule() #0 {
 entry:
   ret void
 }
+
+; MOD1: define weak void @weakfuncInSingleModule()
+; MOD1-INT: define internal void @weakfuncInSingleModule()
+; EXPORTED: define weak void @weakfuncInSingleModule()
+define weak void @weakfuncInSingleModule() {
+entry:
+  ret void
+}


        


More information about the llvm-commits mailing list