xref: /llvm-project/llvm/test/ThinLTO/X86/ctor-dtor-alias.ll (revision d5d3eb16b7ab72529c83dacb2889811491e48909)
1;; The constructor alias example is reduced from
2;;
3;; template <typename T>
4;; struct A { A() {} virtual ~A() {} };
5;; template struct A<void>;
6;; ptr foo() { return new A<void>; }
7;;
8;; clang -c -fpic -O1 -flto=thin a.cc && cp a.o b.o && ld.lld -shared a.o b.so
9
10; RUN: opt -module-summary %s -o %t1.bc
11; RUN: cp %t1.bc %t2.bc
12; RUN: llvm-lto2 run %t1.bc %t2.bc -r=%t1.bc,_ZTV1A,pl -r=%t1.bc,_ZN1AD0Ev,pl -r=%t1.bc,_ZN1AD1Ev,pl -r=%t1.bc,_ZN1AD2Ev,pl -r=%t1.bc,D1_a,pl -r=%t1.bc,D1_a_a,pl \
13; RUN:    -r=%t2.bc,_ZTV1A,l -r=%t2.bc,_ZN1AD0Ev,l -r=%t2.bc,_ZN1AD1Ev,l -r=%t2.bc,_ZN1AD2Ev,l -r=%t2.bc,D1_a,l -r=%t2.bc,D1_a_a,l -o %t3 --save-temps
14; RUN: llvm-dis < %t3.2.1.promote.bc | FileCheck %s
15
16; CHECK: @_ZTV1A = available_externally dso_local unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1AD1Ev, ptr @_ZN1AD0Ev] }
17; CHECK: @D1_a = weak_odr dso_local unnamed_addr alias void (ptr), ptr @_ZN1AD1Ev
18; CHECK: @_ZN1AD1Ev = weak_odr dso_local unnamed_addr alias void (ptr), ptr @_ZN1AD2Ev
19; CHECK: @D1_a_a = weak_odr dso_local unnamed_addr alias void (ptr), ptr @D1_a
20; CHECK: define weak_odr dso_local void @_ZN1AD2Ev(ptr noundef nonnull %0) unnamed_addr comdat($_ZN1AD5Ev) {
21; CHECK: define available_externally dso_local void @_ZN1AD0Ev(ptr noundef nonnull %0) unnamed_addr {
22
23target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
24target triple = "x86_64-unknown-linux-gnu"
25
26$_ZN1AD5Ev = comdat any
27$_ZTV1A = comdat any
28
29@_ZTV1A = weak_odr unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1AD1Ev, ptr @_ZN1AD0Ev] }, comdat
30
31@D1_a = weak_odr unnamed_addr alias void (ptr), ptr @_ZN1AD1Ev
32@_ZN1AD1Ev = weak_odr unnamed_addr alias void (ptr), ptr @_ZN1AD2Ev
33@D1_a_a = weak_odr unnamed_addr alias void (ptr), ptr @D1_a
34
35define weak_odr void @_ZN1AD2Ev(ptr noundef nonnull %0) unnamed_addr comdat($_ZN1AD5Ev) {
36  ret void
37}
38
39define weak_odr void @_ZN1AD0Ev(ptr noundef nonnull %0) unnamed_addr comdat($_ZN1AD5Ev) {
40  call void @D1_a(ptr noundef nonnull %0)
41  call void @D1_a_a(ptr noundef nonnull %0)
42  call void @_ZN1AD1Ev(ptr noundef nonnull %0)
43  ret void
44}
45