Skip to content

Commit

Permalink
[ThinLTO][test] Test prevailing non-exported non-ODR linkonce/odr can…
Browse files Browse the repository at this point in the history
… be internalized

To improve the tests added by D151965. Discovered when writing D158949.
  • Loading branch information
MaskRay committed Aug 28, 2023
1 parent b9b81e3 commit b90d2d6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion llvm/test/ThinLTO/X86/weak_resolution.ll
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@
; 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 \
; RUN: -r %t.bc,_linkonceodralias,pl \
; 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 \
; RUN: -r %t.bc,_linkoncefunc,pl \
; 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 \
Expand Down Expand Up @@ -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
@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
Expand Down Expand Up @@ -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
}

0 comments on commit b90d2d6

Please sign in to comment.