1 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
2 ; RUN: llvm-modextract -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=THIN %s
3 ; RUN: llvm-modextract -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=MERGED %s
5 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-pc-windows-msvc19.0.24215"
8 ; Internal comdat leader with type metadata. All comdat members need to live
9 ; in the merged module, and the comdat needs to be renamed.
10 ; MERGED: ${{"?lwt[^ ]+}} = comdat any
13 ; External comdat leader, type metadata on non-leader. All comdat
14 ; members need to live in the merged module, internal members need to
16 ; MERGED: $nlwt = comdat any
19 ; Comdat with two members without type metadata. All comdat members live in
20 ; the ThinLTO module and no renaming needs to take place.
21 ; THIN: $nt = comdat any
24 ; MERGED: @lwt_aliasee = private unnamed_addr global
25 ; MERGED-SAME: comdat(${{"?lwt[^ ]+}})
26 @lwt_aliasee = private unnamed_addr global [1 x i8*] [i8* null], comdat($lwt), !type !0
28 ; MERGED: {{@"?lwt_nl[^ ]+}} = hidden unnamed_addr global
29 ; MERGED-SAME: comdat(${{"?lwt[^ ]+}})
30 ; THIN: {{@"?lwt_nl[^ ]+}} = external hidden
31 @lwt_nl = internal unnamed_addr global i32 0, comdat($lwt)
33 ; MERGED: @nlwt_aliasee = private unnamed_addr global
34 ; MERGED-SAME: comdat($nlwt)
35 @nlwt_aliasee = private unnamed_addr global [1 x i8*] [i8* null], comdat($nlwt), !type !0
37 ; MERGED: @nlwt = unnamed_addr global
39 ; THIN: @nlwt = external
40 @nlwt = unnamed_addr global i32 0, comdat
42 ; THIN: @nt = internal
44 @nt = internal unnamed_addr global [1 x i8*] [i8* null], comdat
46 ; THIN: @nt_nl = internal
47 ; THIN-SAME: comdat($nt)
48 @nt_nl = internal unnamed_addr global i32 0, comdat($nt)
50 ; MERGED: {{@"?lwt[^ ]+}} = hidden unnamed_addr alias
51 ; THIN: {{@"?lwt[^ ]+}} = external hidden
52 @lwt = internal unnamed_addr alias [1 x i8*], [1 x i8*]* @lwt_aliasee
54 ; MERGED: {{@"?nlwt_nl[^ ]+}} = hidden unnamed_addr alias
55 ; THIN: {{@"?nlwt_nl[^ ]+}} = external hidden
56 @nlwt_nl = internal unnamed_addr alias [1 x i8*], [1 x i8*]* @nlwt_aliasee
58 ; The functions below exist just to make sure the globals are used.
59 define i8* @lwt_fun() {
60 %1 = load i32, i32* @lwt_nl
61 %2 = getelementptr inbounds [1 x i8*], [1 x i8*]* @lwt, i32 0, i32 %1
62 %3 = load i8*, i8** %2
66 define i8* @nlwt_fun() {
67 %1 = load i32, i32* @nlwt
68 %2 = getelementptr inbounds [1 x i8*], [1 x i8*]* @nlwt_nl, i32 0, i32 %1
69 %3 = load i8*, i8** %2
73 define i8* @nt_fun() {
74 %1 = load i32, i32* @nt_nl
75 %2 = getelementptr inbounds [1 x i8*], [1 x i8*]* @nt, i32 0, i32 %1
76 %3 = load i8*, i8** %2
80 !0 = !{i64 8, !"?AVA@@"}