89 lines · plain
1;; Test mixed D0/D2 and D5 COMDATs. Reduced from:2;;3;; // a.cc4;; template <typename T>5;; struct A final { virtual ~A() {} };6;; extern "C" void aa() { A<int> a; }7;; // b.cc8;; template <typename T>9;; struct A final { virtual ~A() {} };10;; template struct A<int>;11;; extern "C" void bb(Aptr a) { delete a; }12;;13;; clang -c -fpic -O0 -flto=thin a.cc && ld.lld -shared a.o b.o14;;15;; The file matches lld/test/ELF/lto/ctor-dtor-alias2.ll16 17; RUN: rm -rf %t && split-file %s %t && cd %t18 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.bc21; RUN: opt -module-summary b.ll -o b.bc22; 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-temps24; RUN: llvm-dis < out.2.1.promote.bc | FileCheck %s25 26;; Although D0/D2 in b.bc is non-prevailing, keep D1/D2 as definitions, otherwise27;; the output may have an undefined and unsatisfied D1.28; CHECK: @_ZN1AIiED1Ev = weak_odr unnamed_addr alias void (ptr), ptr @_ZN1AIiED2Ev29; 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 {31 32;--- a.ll33target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"34target triple = "x86_64-unknown-linux-gnu"35 36$_ZN1AIiED2Ev = comdat any37 38$_ZN1AIiED0Ev = comdat any39 40define void @aa() {41entry:42 %a = alloca ptr, align 843 call void @_ZN1AIiED2Ev(ptr noundef nonnull %a)44 ret void45}46 47define linkonce_odr void @_ZN1AIiED2Ev(ptr noundef nonnull %this) unnamed_addr comdat {48 ret void49}50 51define linkonce_odr void @_ZN1AIiED0Ev(ptr noundef nonnull %this) unnamed_addr comdat {52entry:53 call void @_ZN1AIiED2Ev(ptr noundef nonnull %this)54 call void @_ZdlPv(ptr noundef %this)55 ret void56}57 58declare void @_ZdlPv(ptr noundef)59 60;--- b.ll61target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"62target triple = "x86_64-unknown-linux-gnu"63 64$_ZN1AIiED5Ev = comdat any65 66$_ZTV1AIiE = comdat any67 68@_ZN1AIiED1Ev = weak_odr unnamed_addr alias void (ptr), ptr @_ZN1AIiED2Ev69 70define weak_odr void @_ZN1AIiED2Ev(ptr noundef nonnull %this) unnamed_addr comdat($_ZN1AIiED5Ev) {71 ret void72}73 74define weak_odr void @_ZN1AIiED0Ev(ptr noundef nonnull %this) unnamed_addr comdat($_ZN1AIiED5Ev) {75entry:76 call void @_ZN1AIiED1Ev(ptr noundef nonnull %this)77 call void @_ZdlPv(ptr noundef %this)78 ret void79}80 81declare void @_ZdlPv(ptr noundef)82 83define void @bb(ptr noundef %a) {84entry:85 call void @_ZN1AIiED1Ev(ptr noundef nonnull %a)86 call void @_ZdlPv(ptr noundef %a)87 ret void88}89