1; REQUIRES: x86_64-linux 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 -stop-after=pseudo-probe-inserter -o - | FileCheck %s --check-prefix=CHECK-MIR 5; RUN: llc %t -function-sections -filetype=asm -o %t1 6; RUN: FileCheck %s < %t1 --check-prefix=CHECK-ASM 7; RUN: llc %t -function-sections -filetype=obj -o %t2 8; RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefix=CHECK-OBJ 9; RUN: llvm-mc %t1 -filetype=obj -o %t3 10; RUN: llvm-objdump --section-headers %t3 | FileCheck %s --check-prefix=CHECK-OBJ 11 12;; Check the generation of pseudoprobe intrinsic call. 13 14@a = dso_local global i32 0, align 4 15 16define void @foo(i32 %x) !dbg !3 { 17bb0: 18 %cmp = icmp eq i32 %x, 0 19; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0, i64 -1), !dbg ![[#FAKELINE:]] 20; CHECK-MIR: PSEUDO_PROBE [[#GUID:]], 1, 0, 0 21; CHECK-ASM: .pseudoprobe [[#GUID:]] 1 0 0 22 br i1 %cmp, label %bb1, label %bb2 23 24bb1: 25; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 2, i32 0, i64 -1), !dbg ![[#FAKELINE]] 26; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 3, 0, 0 27; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 4, 0, 0 28; CHECK-ASM: .pseudoprobe [[#GUID]] 3 0 0 29; CHECK-ASM: .pseudoprobe [[#GUID]] 4 0 0 30 store i32 6, ptr @a, align 4 31 br label %bb3 32 33bb2: 34; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 3, i32 0, i64 -1), !dbg ![[#FAKELINE]] 35; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 2, 0, 0 36; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 4, 0, 0 37; CHECK-ASM: .pseudoprobe [[#GUID]] 2 0 0 38; CHECK-ASM: .pseudoprobe [[#GUID]] 4 0 0 39 store i32 8, ptr @a, align 4 40 br label %bb3 41 42bb3: 43; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 4, i32 0, i64 -1), !dbg ![[#REALLINE:]] 44 ret void, !dbg !12 45} 46 47declare void @bar(i32 %x) 48 49define internal void @foo2(ptr %f) !dbg !4 { 50entry: 51; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID2:]], i64 1, i32 0, i64 -1) 52; CHECK-MIR: PSEUDO_PROBE [[#GUID2:]], 1, 0, 0 53; CHECK-ASM: .pseudoprobe [[#GUID2:]] 1 0 0 54; Check pseudo_probe metadata attached to the indirect call instruction. 55; CHECK-IL: call void %f(i32 1), !dbg ![[#PROBE0:]] 56; CHECK-MIR: PSEUDO_PROBE [[#GUID2]], 2, 1, 0 57; CHECK-ASM: .pseudoprobe [[#GUID2]] 2 1 0 58 call void %f(i32 1), !dbg !13 59; Check pseudo_probe metadata attached to the direct call instruction. 60; CHECK-IL: call void @bar(i32 1), !dbg ![[#PROBE1:]] 61; CHECK-MIR: PSEUDO_PROBE [[#GUID2]], 3, 2, 0 62; CHECK-ASM: .pseudoprobe [[#GUID2]] 3 2 0 63 call void @bar(i32 1) 64 ret void 65} 66 67; CHECK-IL: Function Attrs: inaccessiblememonly nocallback nofree nosync nounwind willreturn 68; CHECK-IL-NEXT: declare void @llvm.pseudoprobe(i64, i64, i32, i64) 69 70; CHECK-IL: ![[#FOO:]] = distinct !DISubprogram(name: "foo" 71; CHECK-IL: ![[#FAKELINE]] = !DILocation(line: 0, scope: ![[#FOO]]) 72; CHECK-IL: ![[#REALLINE]] = !DILocation(line: 2, scope: ![[#FOO]]) 73; CHECK-IL: ![[#PROBE0]] = !DILocation(line: 2, column: 20, scope: ![[#SCOPE0:]]) 74;; A discriminator of 67108887 which is 0x7200017 in hexdecimal, stands for a direct call probe 75;; with an index of 2. 76; CHECK-IL: ![[#SCOPE0]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 119537687) 77; CHECK-IL: ![[#PROBE1]] = !DILocation(line: 0, scope: ![[#SCOPE1:]]) 78;; A discriminator of 186646559 which is 0xb20001f in hexdecimal, stands for a direct call probe 79;; with an index of 3. 80; CHECK-IL: ![[#SCOPE1]] = !DILexicalBlockFile(scope: ![[#]], file: ![[#]], discriminator: 186646559) 81 82; Check the generation of .pseudo_probe_desc section 83; CHECK-ASM: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo,comdat 84; CHECK-ASM-NEXT: .quad [[#GUID]] 85; CHECK-ASM-NEXT: .quad [[#HASH:]] 86; CHECK-ASM-NEXT: .byte 3 87; CHECK-ASM-NEXT: .ascii "foo" 88; CHECK-ASM-NEXT: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo2,comdat 89; CHECK-ASM-NEXT: .quad [[#GUID2]] 90; CHECK-ASM-NEXT: .quad [[#HASH2:]] 91; CHECK-ASM-NEXT: .byte 4 92; CHECK-ASM-NEXT: .ascii "foo2" 93 94; CHECK-OBJ-COUNT-2: .pseudo_probe_desc 95; CHECK-OBJ-COUNT-2: .pseudo_probe 96 97!llvm.dbg.cu = !{!0} 98!llvm.module.flags = !{!9, !10} 99 100!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1) 101!1 = !DIFile(filename: "test.c", directory: "") 102!2 = !{} 103!3 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, unit: !0, retainedNodes: !2) 104!4 = distinct !DISubprogram(name: "foo2", scope: !1, file: !1, line: 2, type: !5, unit: !0, retainedNodes: !2) 105!5 = !DISubroutineType(types: !6) 106!6 = !{!7} 107!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 108!9 = !{i32 2, !"Dwarf Version", i32 4} 109!10 = !{i32 2, !"Debug Info Version", i32 3} 110!11 = !{!"clang version 3.9.0"} 111!12 = !DILocation(line: 2, scope: !3) 112!13 = !DILocation(line: 2, column: 20, scope: !4) 113