1 ;; Test mixed D0/D2 and D5 COMDATs. Reduced from:
4 ;; template <typename T>
5 ;; struct A final { virtual ~A() {} };
6 ;; extern "C" void aa() { A<int> a; }
8 ;; template <typename T>
9 ;; struct A final { virtual ~A() {} };
10 ;; template struct A<int>;
11 ;; extern "C" void bb(Aptr a) { delete a; }
13 ;; clang -c -fpic -O0 -flto=thin a.cc && ld.lld -shared a.o b.o
15 ;; The file matches lld/test/ELF/lto/ctor-dtor-alias2.ll
17 ; RUN: rm -rf %t && split-file %s %t && cd %t
19 ;; a.bc defines D0 in comdat D0 and D2 in comdat D2. b.bc defines D0/D1/D2 in comdat D5.
20 ; RUN: opt -module-summary a.ll -o a.bc
21 ; RUN: opt -module-summary b.ll -o b.bc
22 ; RUN: llvm-lto2 run a.bc b.bc -r=a.bc,aa,px -r=a.bc,_ZN1AIiED0Ev,px -r=a.bc,_ZN1AIiED2Ev,px -r=a.bc,_ZdlPv, \
23 ; RUN: -r=b.bc,bb,px -r=b.bc,_ZN1AIiED0Ev, -r=b.bc,_ZN1AIiED1Ev,px -r=b.bc,_ZN1AIiED2Ev, -r=b.bc,_ZdlPv, -o out --save-temps
24 ; RUN: llvm-dis < out.2.1.promote.bc | FileCheck %s
26 ;; Although D0/D2 in b.bc is non-prevailing, keep D1/D2 as definitions, otherwise
27 ;; the output may have an undefined and unsatisfied D1.
28 ; CHECK: @_ZN1AIiED1Ev = weak_odr unnamed_addr alias void (ptr), ptr @_ZN1AIiED2Ev
29 ; CHECK: define weak_odr void @_ZN1AIiED2Ev(ptr noundef nonnull %this) unnamed_addr comdat($_ZN1AIiED5Ev) {
30 ; CHECK: define available_externally void @_ZN1AIiED0Ev(ptr noundef nonnull %this) unnamed_addr {
33 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
34 target triple = "x86_64-unknown-linux-gnu"
36 $_ZN1AIiED2Ev = comdat any
38 $_ZN1AIiED0Ev = comdat any
42 %a = alloca ptr, align 8
43 call void @_ZN1AIiED2Ev(ptr noundef nonnull %a)
47 define linkonce_odr void @_ZN1AIiED2Ev(ptr noundef nonnull %this) unnamed_addr comdat {
51 define linkonce_odr void @_ZN1AIiED0Ev(ptr noundef nonnull %this) unnamed_addr comdat {
53 call void @_ZN1AIiED2Ev(ptr noundef nonnull %this)
54 call void @_ZdlPv(ptr noundef %this)
58 declare void @_ZdlPv(ptr noundef)
61 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
62 target triple = "x86_64-unknown-linux-gnu"
64 $_ZN1AIiED5Ev = comdat any
66 $_ZTV1AIiE = comdat any
68 @_ZN1AIiED1Ev = weak_odr unnamed_addr alias void (ptr), ptr @_ZN1AIiED2Ev
70 define weak_odr void @_ZN1AIiED2Ev(ptr noundef nonnull %this) unnamed_addr comdat($_ZN1AIiED5Ev) {
74 define weak_odr void @_ZN1AIiED0Ev(ptr noundef nonnull %this) unnamed_addr comdat($_ZN1AIiED5Ev) {
76 call void @_ZN1AIiED1Ev(ptr noundef nonnull %this)
77 call void @_ZdlPv(ptr noundef %this)
81 declare void @_ZdlPv(ptr noundef)
83 define void @bb(ptr noundef %a) {
85 call void @_ZN1AIiED1Ev(ptr noundef nonnull %a)
86 call void @_ZdlPv(ptr noundef %a)