1; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile.prof -pass-remarks=sample-profile -S | FileCheck %s 2; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile.prof -pass-remarks=sample-profile -overwrite-existing-weights=1 -S | FileCheck %s -check-prefix=OVW 3 4define dso_local i32 @foo(i32 %x, ptr %f) #0 !dbg !4 !prof !10 { 5entry: 6 %retval = alloca i32, align 4 7 %x.addr = alloca i32, align 4 8 store i32 %x, ptr %x.addr, align 4 9 %0 = load i32, ptr %x.addr, align 4 10 %cmp = icmp eq i32 %0, 0 11 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 1, i32 0, i64 -1) 12 br i1 %cmp, label %if.then, label %if.else, !prof !11 13 14if.then: 15 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 2, i32 0, i64 -1) 16 ; CHECK: call {{.*}}, !dbg ![[#]], !prof ![[#PROF:]] 17 ; OVW: call {{.*}}, !dbg ![[#]], !prof ![[#PROF:]] 18 call void %f(i32 1), !dbg !13, !prof !16 19 store i32 1, ptr %retval, align 4 20 br label %return 21 22if.else: 23 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 2, i32 0, i64 0) 24 ; CHECK: call {{.*}}, !dbg ![[#]], !prof ![[#PROF]] 25 ;; The block should have a 0 weight. Check the profile metadata is dropped. 26 ; OVW-NOT: call {{.*}}, !dbg ![[#]], !prof 27 call void %f(i32 2), !dbg !15, !prof !16 28 store i32 2, ptr %retval, align 4 29 br label %return 30 31return: 32 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 6, i32 0, i64 -1) 33 %1 = load i32, ptr %retval, align 4 34 ret i32 %1 35} 36 37; CHECK: ![[#PROF]] = !{!"VP", i32 0, i64 7, i64 9191153033785521275, i64 5, i64 -1069303473483922844, i64 2} 38; OVW: ![[#PROF]] = !{!"VP", i32 0, i64 7, i64 9191153033785521275, i64 5, i64 -1069303473483922844, i64 2} 39 40declare void @llvm.pseudoprobe(i64, i64, i32, i64) #0 41 42attributes #0 = {"use-sample-profile"} 43 44!llvm.module.flags = !{!0, !1} 45!llvm.pseudo_probe_desc = !{!2} 46 47!0 = !{i32 7, !"Dwarf Version", i32 4} 48!1 = !{i32 2, !"Debug Info Version", i32 3} 49!2 = !{i64 6699318081062747564, i64 563022570642068, !"foo", null} 50!4 = distinct !DISubprogram(name: "foo", scope: !5, file: !5, line: 9, type: !6, scopeLine: 9, spFlags: DISPFlagDefinition, unit: !9) 51!5 = !DIFile(filename: "test.cpp", directory: "test") 52!6 = !DISubroutineType(types: !7) 53!7 = !{!8, !8} 54!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 55!9 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !5, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug) 56!10 = !{!"function_entry_count", i64 14} 57!11 = !{!"branch_weights", i32 100, i32 0} 58;; A discriminator of 186646559 which is 0xB20001F in hexdecimal, stands for an indirect call probe 59;; with an index of 3 and probe factor of 1.0. 60!12 = !DILexicalBlockFile(scope: !4, file: !5, discriminator: 186646559) 61!13 = distinct !DILocation(line: 10, column: 11, scope: !12) 62;; A discriminator of 134217759 which is 0x800001F in hexdecimal, stands for an indirect call probe 63;; with an index of 3 and probe factor of 0. 64!14 = !DILexicalBlockFile(scope: !4, file: !5, discriminator: 134217759) 65!15 = distinct !DILocation(line: 10, column: 11, scope: !14) 66!16 = !{!"VP", i32 0, i64 7, i64 9191153033785521275, i64 5, i64 -1069303473483922844, i64 2} 67