56 lines · plain
1; Test of comdat handling with mixed thinlto and regular lto compilation.2 3; This module is compiled with ThinLTO4; RUN: opt -module-summary -o %t1.o %s5; Input module compiled for regular LTO6; RUN: opt -o %t2.o %p/Inputs/comdat-mixed-lto.ll7 8; The copy of C from this module is prevailing. The copy of C from the9; regular LTO module is not prevailing, and will be dropped to10; available_externally.11; RUN: llvm-lto2 run -r=%t1.o,C,pl -r=%t2.o,C,l -r=%t1.o,testglobfunc,lxp -r=%t2.o,testglobfunc,lx -o %t3 %t1.o %t2.o -save-temps12 13; The Input module (regular LTO) is %t3.0. Check to make sure that we removed14; __cxx_global_var_init and testglobfunc from comdat. Also check to ensure15; that testglobfunc was dropped to available_externally. Otherwise we would16; have linker multiply defined errors as it is no longer in a comdat and17; would clash with the copy from this module.18; RUN: llvm-dis %t3.0.0.preopt.bc -o - | FileCheck %s19 20; CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init, ptr @C }]21; CHECK: @C = available_externally dso_local global %"class.Test::ptr" zeroinitializer, align 422; CHECK-NOT: declare23; CHECK: declare dso_local void @__cxx_global_var_init() section ".text.startup"24; CHECK-NOT: declare25 26; Check the behavior with the prevailing testglobfunc in %t2.o.27; RUN: llvm-lto2 run -r=%t1.o,C,pl -r=%t2.o,C,l -r=%t1.o,testglobfunc,lx -r=%t2.o,testglobfunc,plx -o %t4 %t1.o %t2.o -save-temps28; RUN: llvm-dis %t4.0.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK229 30; CHECK2: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init, ptr @C }]31; CHECK2: @C = available_externally dso_local global %"class.Test::ptr" zeroinitializer, align 432; CHECK2: declare dso_local void @__cxx_global_var_init() section ".text.startup"33; CHECK2: define available_externally dso_local void @testglobfunc() section ".text.startup" {34 35; ModuleID = 'comdat-mixed-lto.o'36source_filename = "comdat-mixed-lto.cpp"37target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"38target triple = "x86_64-unknown-linux-gnu"39 40%"class.Test::ptr" = type { i32 }41 42$C = comdat any43 44@C = linkonce_odr global %"class.Test::ptr" zeroinitializer, comdat, align 445@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__cxx_global_var_init, i8* bitcast (%"class.Test::ptr"* @C to i8*) }]46define void @testglobfunc() #1 section ".text.startup" comdat($C) {47entry:48 ret void49}50 51; Function Attrs: noinline uwtable52define internal void @__cxx_global_var_init() #1 section ".text.startup" comdat($C) {53entry:54 ret void55}56