xref: /llvm-project/llvm/test/Transforms/GCOVProfiling/global-ctor.ll (revision ff375292981d054c7a45c406c31e32413015260d)
1;; For a global constructor, _GLOBAL__sub_I_ only has artificial lines.
2;; Test that we don't instrument those functions.
3; RUN: mkdir -p %t && cd %t
4; RUN: opt -S -passes=insert-gcov-profiling < %s | FileCheck %s
5
6@var = dso_local global i32 0, align 4
7@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_a.cc, ptr null }]
8
9define internal void @__cxx_global_var_init() section ".text.startup" !dbg !7 {
10; CHECK: define internal void @__cxx_global_var_init()
11; CHECK: @__llvm_gcov_ctr
12; CHECK: call i32 @_Z3foov()
13entry:
14  %call = call i32 @_Z3foov(), !dbg !9
15  store i32 %call, ptr @var, align 4, !dbg !9
16  ret void, !dbg !9
17}
18
19declare i32 @_Z3foov()
20
21;; Artificial lines only. Don't instrument.
22define internal void @_GLOBAL__sub_I_a.cc() section ".text.startup" !dbg !10 {
23; CHECK: define internal void @_GLOBAL__sub_I_a.cc()
24; CHECK-NOT: @__llvm_gcov_ctr
25; CHECK: call void @__cxx_global_var_init()
26entry:
27  call void @__cxx_global_var_init(), !dbg !11
28  ret void
29}
30
31!llvm.dbg.cu = !{!0}
32!llvm.module.flags = !{!3, !4}
33
34!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, emissionKind: LineTablesOnly)
35!1 = !DIFile(filename: "a.cc", directory: "/")
36!2 = !{}
37!3 = !{i32 7, !"Dwarf Version", i32 4}
38!4 = !{i32 2, !"Debug Info Version", i32 3}
39!7 = distinct !DISubprogram(name: "__cxx_global_var_init", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !2)
40!8 = !DISubroutineType(types: !2)
41!9 = !DILocation(line: 2, column: 11, scope: !7)
42!10 = distinct !DISubprogram(linkageName: "_GLOBAL__sub_I_a.cc", scope: !1, file: !1, type: !8, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !2)
43!11 = !DILocation(line: 0, scope: !10)
44