File: comdat-mixed-lto.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (55 lines) | stat: -rw-r--r-- 2,740 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
; Test of comdat handling with mixed thinlto and regular lto compilation.

; This module is compiled with ThinLTO
; RUN: opt -module-summary -o %t1.o %s
; Input module compiled for regular LTO
; RUN: opt -o %t2.o %p/Inputs/comdat-mixed-lto.ll

; The copy of C from this module is prevailing. The copy of C from the
; regular LTO module is not prevailing, and will be dropped to
; available_externally.
; 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-temps

; The Input module (regular LTO) is %t3.0. Check to make sure that we removed
; __cxx_global_var_init and testglobfunc from comdat. Also check to ensure
; that testglobfunc was dropped to available_externally. Otherwise we would
; have linker multiply defined errors as it is no longer in a comdat and
; would clash with the copy from this module.
; RUN: llvm-dis %t3.0.0.preopt.bc -o - | FileCheck %s

; CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init, ptr @C }]
; CHECK: @C = available_externally dso_local global %"class.Test::ptr" zeroinitializer, align 4
; CHECK-NOT: declare
; CHECK: declare dso_local void @__cxx_global_var_init() section ".text.startup"
; CHECK-NOT: declare

; Check the behavior with the prevailing testglobfunc in %t2.o.
; 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-temps
; RUN: llvm-dis %t4.0.0.preopt.bc -o - | FileCheck %s --check-prefix=CHECK2

; CHECK2: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init, ptr @C }]
; CHECK2: @C = available_externally dso_local global %"class.Test::ptr" zeroinitializer, align 4
; CHECK2: declare dso_local void @__cxx_global_var_init() section ".text.startup"
; CHECK2: define available_externally dso_local void @testglobfunc() section ".text.startup" {

; ModuleID = 'comdat-mixed-lto.o'
source_filename = "comdat-mixed-lto.cpp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.Test::ptr" = type { i32 }

$C = comdat any

@C = linkonce_odr global %"class.Test::ptr" zeroinitializer, comdat, align 4
@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*) }]
define void @testglobfunc() #1 section ".text.startup" comdat($C) {
entry:
  ret void
}

; Function Attrs: noinline uwtable
define internal void @__cxx_global_var_init() #1 section ".text.startup" comdat($C) {
entry:
  ret void
}