Teresa Johnson | b247ffb | 2017-06-30 14:03:24 +0000 | [diff] [blame] | 1 | ; Test of comdat handling with mixed thinlto and regular lto compilation. |
| 2 | |
| 3 | ; This module is compiled with ThinLTO |
| 4 | ; RUN: opt -module-summary -o %t1.o %s |
| 5 | ; Input module compiled for regular LTO |
| 6 | ; RUN: opt -o %t2.o %p/Inputs/comdat-mixed-lto.ll |
| 7 | |
| 8 | ; The copy of C from this module is prevailing. The copy of C from the |
| 9 | ; regular LTO module is not prevailing, and will be dropped to |
| 10 | ; available_externally. |
| 11 | ; RUN: llvm-lto2 run -r=%t1.o,C,pl -r=%t2.o,C,l -r=%t2.o,testglobfunc,lxp -r=%t1.o,testglobfunc,lx -o %t3 %t1.o %t2.o -save-temps |
| 12 | |
| 13 | ; The Input module (regular LTO) is %t3.0. Check to make sure that we removed |
| 14 | ; __cxx_global_var_init and testglobfunc from comdat. Also check to ensure |
| 15 | ; that testglobfunc was dropped to available_externally. Otherwise we would |
| 16 | ; have linker multiply defined errors as it is no longer in a comdat and |
| 17 | ; would clash with the copy from this module. |
| 18 | ; RUN: llvm-dis %t3.0.0.preopt.bc -o - | FileCheck %s |
| 19 | ; CHECK: define internal void @__cxx_global_var_init() section ".text.startup" { |
Sean Fertile | 39770ca | 2017-11-04 01:54:20 +0000 | [diff] [blame^] | 20 | ; CHECK: define available_externally void @testglobfunc() section ".text.startup" { |
Teresa Johnson | b247ffb | 2017-06-30 14:03:24 +0000 | [diff] [blame] | 21 | |
| 22 | ; ModuleID = 'comdat-mixed-lto.o' |
| 23 | source_filename = "comdat-mixed-lto.cpp" |
| 24 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 25 | target triple = "x86_64-unknown-linux-gnu" |
| 26 | |
| 27 | %"class.Test::ptr" = type { i32 } |
| 28 | |
| 29 | $C = comdat any |
| 30 | |
| 31 | @C = linkonce_odr global %"class.Test::ptr" zeroinitializer, comdat, align 4 |
| 32 | @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*) }] |
| 33 | define void @testglobfunc() #1 section ".text.startup" comdat($C) { |
| 34 | entry: |
| 35 | ret void |
| 36 | } |
| 37 | |
| 38 | ; Function Attrs: noinline uwtable |
| 39 | define internal void @__cxx_global_var_init() #1 section ".text.startup" comdat($C) { |
| 40 | entry: |
| 41 | ret void |
| 42 | } |