xref: /llvm-project/lld/test/ELF/lto/ctor-dtor-alias2.ll (revision 12050a3fb7344694cfd7527d4cca0033729bcfc5)
1; REQUIRES: x86
2;; Test mixed D0/D2 and D5 COMDATs. The file matches llvm/test/ThinLTO/X86/ctor-dtor-alias2.ll
3
4; RUN: rm -rf %t && split-file %s %t && cd %t
5
6;; a.bc defines D0 in comdat D0 and D2 in comdat D2. b.bc defines D0/D1/D2 in comdat D5.
7; RUN: opt -module-summary a.ll -o a.bc
8; RUN: opt -module-summary b.ll -o b.bc
9; RUN: ld.lld -shared a.bc b.bc -o out.so
10; RUN: llvm-nm -D out.so
11
12;; Although D0/D2 in b.bc is non-prevailing, keep D1/D2 as definitions, otherwise
13;; the output may have an undefined and unsatisfied D1.
14; CHECK:      W _ZN1AIiED0Ev
15; CHECK-NEXT: W _ZN1AIiED1Ev
16; CHECK-NEXT: W _ZN1AIiED2Ev
17; CHECK-NEXT: U _ZdlPv
18; CHECK-NEXT: T aa
19; CHECK-NEXT: T bb
20
21;--- a.ll
22target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
23target triple = "x86_64-unknown-linux-gnu"
24
25$_ZN1AIiED2Ev = comdat any
26
27$_ZN1AIiED0Ev = comdat any
28
29define void @aa() {
30entry:
31  %a = alloca ptr, align 8
32  call void @_ZN1AIiED2Ev(ptr noundef nonnull %a)
33  ret void
34}
35
36define linkonce_odr void @_ZN1AIiED2Ev(ptr noundef nonnull %this) unnamed_addr comdat {
37  ret void
38}
39
40define linkonce_odr void @_ZN1AIiED0Ev(ptr noundef nonnull %this) unnamed_addr comdat {
41entry:
42  call void @_ZN1AIiED2Ev(ptr noundef nonnull %this)
43  call void @_ZdlPv(ptr noundef %this)
44  ret void
45}
46
47declare void @_ZdlPv(ptr noundef)
48
49;--- b.ll
50target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
51target triple = "x86_64-unknown-linux-gnu"
52
53$_ZN1AIiED5Ev = comdat any
54
55$_ZTV1AIiE = comdat any
56
57@_ZN1AIiED1Ev = weak_odr unnamed_addr alias void (ptr), ptr @_ZN1AIiED2Ev
58
59define weak_odr void @_ZN1AIiED2Ev(ptr noundef nonnull %this) unnamed_addr comdat($_ZN1AIiED5Ev) {
60  ret void
61}
62
63define weak_odr void @_ZN1AIiED0Ev(ptr noundef nonnull %this) unnamed_addr comdat($_ZN1AIiED5Ev) {
64entry:
65  call void @_ZN1AIiED1Ev(ptr noundef nonnull %this)
66  call void @_ZdlPv(ptr noundef %this)
67  ret void
68}
69
70declare void @_ZdlPv(ptr noundef)
71
72define void @bb(ptr noundef %a) {
73entry:
74  call void @_ZN1AIiED1Ev(ptr noundef nonnull %a)
75  call void @_ZdlPv(ptr noundef %a)
76  ret void
77}
78