1; REQUIRES: x86-registered-target 2; RUN: opt < %s -passes=pseudo-probe -function-sections -S -o %t 3; RUN: FileCheck %s < %t --check-prefix=CHECK-IL 4; RUN: llc %t -pseudo-probe-for-profiling -stop-after=pseudo-probe-inserter -o - | FileCheck %s --check-prefix=CHECK-MIR 5; 6;; Check the generation of pseudoprobe intrinsic call. 7 8define void @foo(i32 %x) !dbg !3 { 9bb0: 10 %cmp = icmp eq i32 %x, 0 11; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0), !dbg ![[#FAKELINE:]] 12; CHECK-MIR: PSEUDO_PROBE [[#GUID:]], 1, 0, 0 13 br i1 %cmp, label %bb1, label %bb2 14 15bb1: 16; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 2, i32 0), !dbg ![[#FAKELINE]] 17; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 3, 0, 0 18; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 4, 0, 0 19 br label %bb3 20 21bb2: 22; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 3, i32 0), !dbg ![[#FAKELINE]] 23; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 2, 0, 0 24; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 4, 0, 0 25 br label %bb3 26 27bb3: 28; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 4, i32 0), !dbg ![[#REALLINE:]] 29 ret void, !dbg !12 30} 31 32declare void @bar(i32 %x) 33 34define internal void @foo2(void (i32)* %f) !dbg !4 { 35entry: 36; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID2:]], i64 1, i32 0) 37; CHECK-MIR: PSEUDO_PROBE [[#GUID2:]], 1, 0, 0 38; Check pseudo_probe metadata attached to the indirect call instruction. 39; CHECK-IL: call void %f(i32 1), !dbg ![[#PROBE0:]] 40; CHECK-MIR: PSEUDO_PROBE [[#GUID2]], 2, 1, 0 41 call void %f(i32 1), !dbg !13 42; Check pseudo_probe metadata attached to the direct call instruction. 43; CHECK-IL: call void @bar(i32 1), !dbg ![[#PROBE1:]] 44; CHECK-MIR: PSEUDO_PROBE [[#GUID2]], 3, 2, 0 45 call void @bar(i32 1) 46 ret void 47} 48 49; CHECK-IL: ![[#FOO:]] = distinct !DISubprogram(name: "foo" 50; CHECK-IL: ![[#FAKELINE]] = !DILocation(line: 0, scope: ![[#FOO]]) 51; CHECK-IL: ![[#REALLINE]] = !DILocation(line: 2, scope: ![[#FOO]]) 52; CHECK-IL: ![[#PROBE0]] = !DILocation(line: 2, column: 20, scope: ![[#SCOPE0:]]) 53;; A discriminator of 67108887 which is 0x4000017 in hexdecimal, stands for a direct call probe 54;; with an index of 2. 55; CHECK-IL: ![[#SCOPE0]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 67108887) 56; CHECK-IL: ![[#PROBE1]] = !DILocation(line: 0, scope: ![[#SCOPE1:]]) 57;; A discriminator of 134217759 which is 0x800001f in hexdecimal, stands for a direct call probe 58;; with an index of 3. 59; CHECK-IL: ![[#SCOPE1]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 134217759) 60 61 62!llvm.dbg.cu = !{!0} 63!llvm.module.flags = !{!9, !10} 64 65!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1) 66!1 = !DIFile(filename: "test.c", directory: "") 67!2 = !{} 68!3 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, unit: !0, retainedNodes: !2) 69!4 = distinct !DISubprogram(name: "foo2", scope: !1, file: !1, line: 2, type: !5, unit: !0, retainedNodes: !2) 70!5 = !DISubroutineType(types: !6) 71!6 = !{!7} 72!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 73!9 = !{i32 2, !"Dwarf Version", i32 4} 74!10 = !{i32 2, !"Debug Info Version", i32 3} 75!11 = !{!"clang version 3.9.0"} 76!12 = !DILocation(line: 2, scope: !3) 77!13 = !DILocation(line: 2, column: 20, scope: !4) 78