xref: /llvm-project/llvm/test/Instrumentation/InstrProfiling/debug-info-correlate.ll (revision db7a1ed9a22fadacfa651e88d0f75f365d44af9a)
1; RUN: opt < %s -passes=instrprof -debug-info-correlate -S > %t.ll
2; RUN: FileCheck < %t.ll --implicit-check-not "{{__llvm_prf_data|__llvm_prf_names}}" %s
3; RUN: %llc_dwarf -O0 -filetype=obj < %t.ll | llvm-dwarfdump - | FileCheck --implicit-check-not "{{DW_TAG|NULL}}" %s --check-prefix CHECK-DWARF
4
5; REQUIRES: target={{.*-linux.*}}, object-emission
6
7@__profn_foo = private constant [3 x i8] c"foo"
8; CHECK:      @__profc_foo =
9; CHECK-SAME: !dbg ![[EXPR:[0-9]+]]
10
11; CHECK:      ![[EXPR]] = !DIGlobalVariableExpression(var: ![[GLOBAL:[0-9]+]]
12; CHECK:      ![[GLOBAL]] = {{.*}} !DIGlobalVariable(name: "__profc_foo"
13; CHECK-SAME: scope: ![[SCOPE:[0-9]+]]
14; CHECK-SAME: annotations: ![[ANNOTATIONS:[0-9]+]]
15; CHECK:      ![[SCOPE]] = {{.*}} !DISubprogram(name: "foo"
16; CHECK:      ![[ANNOTATIONS]] = !{![[NAME:[0-9]+]], ![[HASH:[0-9]+]], ![[COUNTERS:[0-9]+]]}
17; CHECK:      ![[NAME]] = !{!"Function Name", !"foo"}
18; CHECK:      ![[HASH]] = !{!"CFG Hash", i64 12345678}
19; CHECK:      ![[COUNTERS]] = !{!"Num Counters", i32 2}
20
21define void @_Z3foov() !dbg !12 {
22  call void @llvm.instrprof.increment(ptr @__profn_foo, i64 12345678, i32 2, i32 0)
23  ret void
24}
25
26declare void @llvm.instrprof.increment(ptr, i64, i32, i32)
27
28!llvm.dbg.cu = !{!0}
29!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8, !9, !10}
30!llvm.ident = !{!11}
31
32!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
33!1 = !DIFile(filename: "debug-info-correlate.cpp", directory: "")
34!2 = !{i32 7, !"Dwarf Version", i32 4}
35!3 = !{i32 2, !"Debug Info Version", i32 3}
36!4 = !{i32 1, !"wchar_size", i32 4}
37!5 = !{i32 8, !"branch-target-enforcement", i32 0}
38!6 = !{i32 8, !"sign-return-address", i32 0}
39!7 = !{i32 8, !"sign-return-address-all", i32 0}
40!8 = !{i32 8, !"sign-return-address-with-bkey", i32 0}
41!9 = !{i32 7, !"uwtable", i32 1}
42!10 = !{i32 7, !"frame-pointer", i32 1}
43!11 = !{!"clang version 14.0.0"}
44!12 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !13, file: !13, line: 1, type: !14, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !16)
45!13 = !DIFile(filename: "debug-info-correlate.cpp", directory: "")
46!14 = !DISubroutineType(types: !15)
47!15 = !{null}
48!16 = !{}
49
50; CHECK-DWARF: DW_TAG_compile_unit
51; CHECK-DWARF:   DW_TAG_subprogram
52; CHECK-DWARF:     DW_AT_name	("foo")
53; CHECK-DWARF:     DW_TAG_variable
54; CHECK-DWARF:       DW_AT_name	("__profc_foo")
55; CHECK-DWARF:       DW_AT_type	({{.*}} "Profile Data Type")
56; CHECK-DWARF:       DW_TAG_LLVM_annotation
57; CHECK-DWARF:         DW_AT_name	("Function Name")
58; CHECK-DWARF:         DW_AT_const_value	("foo")
59; CHECK-DWARF:       DW_TAG_LLVM_annotation
60; CHECK-DWARF:         DW_AT_name	("CFG Hash")
61; CHECK-DWARF:         DW_AT_const_value	(12345678)
62; CHECK-DWARF:       DW_TAG_LLVM_annotation
63; CHECK-DWARF:         DW_AT_name	("Num Counters")
64; CHECK-DWARF:         DW_AT_const_value	(2)
65; CHECK-DWARF:       NULL
66; CHECK-DWARF:     NULL
67; CHECK-DWARF:   DW_TAG_unspecified_type
68; CHECK-DWARF:   NULL
69