| 1 |
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-missing-probe.prof -S | FileCheck %s |
| 2 |
|
| 3 |
; CHECK: br i1 %tobool.not.i, label %if.end.i, label %if.then.i, !dbg ![[#]], !prof ![[#PROF:]] |
| 4 |
|
| 5 |
; CHECK: [[#PROF]] = !{!"branch_weights", i32 918, i32 918} |
| 6 |
; Verify the else branch is not set to a zero count |
| 7 |
; CHECK-NOT: [[#PROF]] = !{!"branch_weights", i32 1698, i32 0} |
| 8 |
|
| 9 |
@x = dso_local global i32 0, align 4, !dbg !0 |
| 10 |
|
| 11 |
; Function Attrs: nofree noinline norecurse nounwind memory(readwrite, argmem: none) uwtable |
| 12 |
define dso_local void @bar(i32 %i) local_unnamed_addr #0 !dbg !18 { |
| 13 |
entry: |
| 14 |
#dbg_value(i32 poison, !22, !DIExpression(), !23) |
| 15 |
call void @llvm.pseudoprobe(i64 -2012135647395072713, i64 1, i32 0, i64 -1), !dbg !24 |
| 16 |
%0 = load volatile i32, ptr @x, align 4, !dbg !24, !tbaa !25 |
| 17 |
%add = add nsw i32 %0, 5, !dbg !24 |
| 18 |
store volatile i32 %add, ptr @x, align 4, !dbg !24, !tbaa !25 |
| 19 |
ret void, !dbg !29 |
| 20 |
} |
| 21 |
|
| 22 |
; Function Attrs: nofree norecurse nounwind memory(readwrite, argmem: none) uwtable |
| 23 |
define dso_local void @baz(i32 noundef %i) local_unnamed_addr #1 !dbg !30 { |
| 24 |
entry: |
| 25 |
#dbg_value(i32 %i, !32, !DIExpression(), !33) |
| 26 |
call void @llvm.pseudoprobe(i64 7546896869197086323, i64 1, i32 0, i64 -1), !dbg !34 |
| 27 |
%rem = srem i32 %i, 100, !dbg !36 |
| 28 |
%tobool.not = icmp eq i32 %rem, 0, !dbg !36 |
| 29 |
br i1 %tobool.not, label %if.end, label %if.then, !dbg !37 |
| 30 |
|
| 31 |
if.then: ; preds = %entry |
| 32 |
call void @llvm.pseudoprobe(i64 7546896869197086323, i64 2, i32 0, i64 -1), !dbg !38 |
| 33 |
%0 = load volatile i32, ptr @x, align 4, !dbg !38, !tbaa !25 |
| 34 |
%inc = add nsw i32 %0, 1, !dbg !38 |
| 35 |
store volatile i32 %inc, ptr @x, align 4, !dbg !38, !tbaa !25 |
| 36 |
br label %if.end, !dbg !39 |
| 37 |
|
| 38 |
if.end: ; preds = %if.then, %entry |
| 39 |
call void @llvm.pseudoprobe(i64 7546896869197086323, i64 3, i32 0, i64 -1), !dbg !40 |
| 40 |
%1 = load volatile i32, ptr @x, align 4, !dbg !40, !tbaa !25 |
| 41 |
%add = add nsw i32 %1, 2, !dbg !40 |
| 42 |
store volatile i32 %add, ptr @x, align 4, !dbg !40, !tbaa !25 |
| 43 |
%2 = and i32 %i, 1, !dbg !41 |
| 44 |
%tobool2.not = icmp eq i32 %2, 0, !dbg !41 |
| 45 |
br i1 %tobool2.not, label %if.else, label %if.end11, !dbg !43 |
| 46 |
|
| 47 |
if.else: ; preds = %if.end |
| 48 |
call void @llvm.pseudoprobe(i64 7546896869197086323, i64 5, i32 0, i64 -1), !dbg !44 |
| 49 |
%rem5 = srem i32 %i, 3, !dbg !46 |
| 50 |
%tobool6.not = icmp eq i32 %rem5, 0, !dbg !46 |
| 51 |
%spec.select = select i1 %tobool6.not, i32 -1, i32 2, !dbg !47 |
| 52 |
br label %if.end11, !dbg !47 |
| 53 |
|
| 54 |
if.end11: ; preds = %if.else, %if.end |
| 55 |
%.sink14 = phi i32 [ 1, %if.end ], [ %spec.select, %if.else ] |
| 56 |
%3 = load volatile i32, ptr @x, align 4, !dbg !48, !tbaa !25 |
| 57 |
%add8 = add nsw i32 %3, %.sink14, !dbg !48 |
| 58 |
store volatile i32 %add8, ptr @x, align 4, !dbg !48, !tbaa !25 |
| 59 |
call void @llvm.pseudoprobe(i64 7546896869197086323, i64 9, i32 0, i64 -1), !dbg !49 |
| 60 |
ret void, !dbg !49 |
| 61 |
} |
| 62 |
|
| 63 |
; Function Attrs: nofree norecurse nounwind uwtable |
| 64 |
define dso_local noundef i32 @main() local_unnamed_addr #2 !dbg !50 { |
| 65 |
entry: |
| 66 |
call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 1, i32 0, i64 -1), !dbg !55 |
| 67 |
#dbg_value(i32 0, !54, !DIExpression(), !56) |
| 68 |
call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 2, i32 0, i64 -1), !dbg !57 |
| 69 |
br label %while.body, !dbg !58 |
| 70 |
|
| 71 |
while.body: ; preds = %entry, %if.end |
| 72 |
%inc7 = phi i32 [ 1, %entry ], [ %inc, %if.end ] |
| 73 |
%i.06 = phi i32 [ 0, %entry ], [ %inc7, %if.end ] |
| 74 |
#dbg_value(i32 %i.06, !54, !DIExpression(), !56) |
| 75 |
call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 3, i32 0, i64 -1), !dbg !59 |
| 76 |
%rem = urem i32 %inc7, 10, !dbg !62 |
| 77 |
%tobool.not = icmp eq i32 %rem, 0, !dbg !62 |
| 78 |
br i1 %tobool.not, label %if.else, label %if.then, !dbg !63 |
| 79 |
|
| 80 |
if.then: ; preds = %while.body |
| 81 |
call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 4, i32 0, i64 -1), !dbg !64 |
| 82 |
tail call void @bar(i32 poison), !dbg !65 |
| 83 |
br label %if.end, !dbg !67 |
| 84 |
|
| 85 |
if.else: ; preds = %while.body |
| 86 |
call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 6, i32 0, i64 -1), !dbg !68 |
| 87 |
#dbg_value(i32 %inc7, !32, !DIExpression(), !69) |
| 88 |
call void @llvm.pseudoprobe(i64 7546896869197086323, i64 1, i32 0, i64 -1), !dbg !72 |
| 89 |
%rem.i4 = urem i32 %inc7, 100, !dbg !73 |
| 90 |
%tobool.not.i = icmp eq i32 %rem.i4, 0, !dbg !73 |
| 91 |
br i1 %tobool.not.i, label %if.end.i, label %if.then.i, !dbg !74 |
| 92 |
|
| 93 |
if.then.i: ; preds = %if.else |
| 94 |
call void @llvm.pseudoprobe(i64 7546896869197086323, i64 2, i32 0, i64 -1), !dbg !75 |
| 95 |
%0 = load volatile i32, ptr @x, align 4, !dbg !75, !tbaa !25 |
| 96 |
%inc.i = add nsw i32 %0, 1, !dbg !75 |
| 97 |
store volatile i32 %inc.i, ptr @x, align 4, !dbg !75, !tbaa !25 |
| 98 |
br label %if.end.i, !dbg !76 |
| 99 |
|
| 100 |
if.end.i: ; preds = %if.then.i, %if.else |
| 101 |
call void @llvm.pseudoprobe(i64 7546896869197086323, i64 3, i32 0, i64 -1), !dbg !77 |
| 102 |
%1 = load volatile i32, ptr @x, align 4, !dbg !77, !tbaa !25 |
| 103 |
%add.i = add nsw i32 %1, 2, !dbg !77 |
| 104 |
store volatile i32 %add.i, ptr @x, align 4, !dbg !77, !tbaa !25 |
| 105 |
%2 = and i32 %i.06, 1, !dbg !78 |
| 106 |
%tobool2.not.i.not = icmp eq i32 %2, 0, !dbg !78 |
| 107 |
br i1 %tobool2.not.i.not, label %baz.exit, label %if.else.i, !dbg !79 |
| 108 |
|
| 109 |
if.else.i: ; preds = %if.end.i |
| 110 |
call void @llvm.pseudoprobe(i64 7546896869197086323, i64 5, i32 0, i64 -1), !dbg !80 |
| 111 |
%rem5.i5 = urem i32 %inc7, 3, !dbg !81 |
| 112 |
%tobool6.not.i = icmp eq i32 %rem5.i5, 0, !dbg !81 |
| 113 |
%spec.select.i = select i1 %tobool6.not.i, i32 -1, i32 2, !dbg !82 |
| 114 |
br label %baz.exit, !dbg !82 |
| 115 |
|
| 116 |
baz.exit: ; preds = %if.end.i, %if.else.i |
| 117 |
%.sink14.i = phi i32 [ 1, %if.end.i ], [ %spec.select.i, %if.else.i ] |
| 118 |
%3 = load volatile i32, ptr @x, align 4, !dbg !83, !tbaa !25 |
| 119 |
%add8.i = add nsw i32 %3, %.sink14.i, !dbg !83 |
| 120 |
store volatile i32 %add8.i, ptr @x, align 4, !dbg !83, !tbaa !25 |
| 121 |
call void @llvm.pseudoprobe(i64 7546896869197086323, i64 9, i32 0, i64 -1), !dbg !84 |
| 122 |
br label %if.end |
| 123 |
|
| 124 |
if.end: ; preds = %baz.exit, %if.then |
| 125 |
call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 8, i32 0, i64 -1), !dbg !58 |
| 126 |
#dbg_value(i32 %inc7, !54, !DIExpression(), !56) |
| 127 |
call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 2, i32 0, i64 -1), !dbg !57 |
| 128 |
%inc = add nuw nsw i32 %inc7, 1, !dbg !57 |
| 129 |
#dbg_value(i32 %inc, !54, !DIExpression(), !56) |
| 130 |
%exitcond.not = icmp eq i32 %inc, 160000001, !dbg !85 |
| 131 |
br i1 %exitcond.not, label %while.end, label %while.body, !dbg !58, !llvm.loop !86 |
| 132 |
|
| 133 |
while.end: ; preds = %if.end |
| 134 |
call void @llvm.pseudoprobe(i64 -2624081020897602054, i64 9, i32 0, i64 -1), !dbg !89 |
| 135 |
ret i32 0, !dbg !89 |
| 136 |
} |
| 137 |
|
| 138 |
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) |
| 139 |
declare void @llvm.pseudoprobe(i64, i64, i32, i64) #3 |
| 140 |
|
| 141 |
attributes #0 = { nofree noinline norecurse nounwind memory(readwrite, argmem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } |
| 142 |
attributes #1 = { nofree norecurse nounwind memory(readwrite, argmem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } |
| 143 |
attributes #2 = { nofree norecurse nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "use-sample-profile"} |
| 144 |
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) } |
| 145 |
|
| 146 |
!llvm.dbg.cu = !{!2} |
| 147 |
!llvm.module.flags = !{!7, !8, !9, !10, !11, !12, !13} |
| 148 |
!llvm.ident = !{!14} |
| 149 |
!llvm.pseudo_probe_desc = !{!15, !16, !17} |
| 150 |
|
| 151 |
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) |
| 152 |
!1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true) |
| 153 |
!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang version 20.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None) |
| 154 |
!3 = !DIFile(filename: "test.c", directory: "/home", checksumkind: CSK_MD5, checksum: "b67c15e928f76c51702a59639dbebb4c") |
| 155 |
!4 = !{!0} |
| 156 |
!5 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !6) |
| 157 |
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 158 |
!7 = !{i32 7, !"Dwarf Version", i32 5} |
| 159 |
!8 = !{i32 2, !"Debug Info Version", i32 3} |
| 160 |
!9 = !{i32 1, !"wchar_size", i32 4} |
| 161 |
!10 = !{i32 8, !"PIC Level", i32 2} |
| 162 |
!11 = !{i32 7, !"PIE Level", i32 2} |
| 163 |
!12 = !{i32 7, !"uwtable", i32 2} |
| 164 |
!13 = !{i32 7, !"debug-info-assignment-tracking", i1 true} |
| 165 |
!14 = !{!"clang version 20.0.0"} |
| 166 |
!15 = !{i64 -2012135647395072713, i64 4294967295, !"bar"} |
| 167 |
!16 = !{i64 7546896869197086323, i64 191430930410, !"baz"} |
| 168 |
!17 = !{i64 -2624081020897602054, i64 563091374530180, !"main"} |
| 169 |
!18 = distinct !DISubprogram(name: "bar", scope: !3, file: !3, line: 3, type: !19, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !21) |
| 170 |
!19 = !DISubroutineType(types: !20) |
| 171 |
!20 = !{null, !6} |
| 172 |
!21 = !{!22} |
| 173 |
!22 = !DILocalVariable(name: "i", arg: 1, scope: !18, file: !3, line: 3, type: !6) |
| 174 |
!23 = !DILocation(line: 0, scope: !18) |
| 175 |
!24 = !DILocation(line: 4, column: 5, scope: !18) |
| 176 |
!25 = !{!26, !26, i64 0} |
| 177 |
!26 = !{!"int", !27, i64 0} |
| 178 |
!27 = !{!"omnipotent char", !28, i64 0} |
| 179 |
!28 = !{!"Simple C/C++ TBAA"} |
| 180 |
!29 = !DILocation(line: 8, column: 1, scope: !18) |
| 181 |
!30 = distinct !DISubprogram(name: "baz", scope: !3, file: !3, line: 10, type: !19, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !31) |
| 182 |
!31 = !{!32} |
| 183 |
!32 = !DILocalVariable(name: "i", arg: 1, scope: !30, file: !3, line: 10, type: !6) |
| 184 |
!33 = !DILocation(line: 0, scope: !30) |
| 185 |
!34 = !DILocation(line: 11, column: 6, scope: !35) |
| 186 |
!35 = distinct !DILexicalBlock(scope: !30, file: !3, line: 11, column: 6) |
| 187 |
!36 = !DILocation(line: 11, column: 7, scope: !35) |
| 188 |
!37 = !DILocation(line: 11, column: 6, scope: !30) |
| 189 |
!38 = !DILocation(line: 12, column: 6, scope: !35) |
| 190 |
!39 = !DILocation(line: 12, column: 5, scope: !35) |
| 191 |
!40 = !DILocation(line: 14, column: 5, scope: !30) |
| 192 |
!41 = !DILocation(line: 15, column: 9, scope: !42) |
| 193 |
!42 = distinct !DILexicalBlock(scope: !30, file: !3, line: 15, column: 7) |
| 194 |
!43 = !DILocation(line: 15, column: 7, scope: !30) |
| 195 |
!44 = !DILocation(line: 17, column: 12, scope: !45) |
| 196 |
!45 = distinct !DILexicalBlock(scope: !42, file: !3, line: 17, column: 12) |
| 197 |
!46 = !DILocation(line: 17, column: 14, scope: !45) |
| 198 |
!47 = !DILocation(line: 17, column: 12, scope: !42) |
| 199 |
!48 = !DILocation(line: 0, scope: !42) |
| 200 |
!49 = !DILocation(line: 21, column: 1, scope: !30) |
| 201 |
!50 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 23, type: !51, scopeLine: 23, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !53) |
| 202 |
!51 = !DISubroutineType(types: !52) |
| 203 |
!52 = !{!6} |
| 204 |
!53 = !{!54} |
| 205 |
!54 = !DILocalVariable(name: "i", scope: !50, file: !3, line: 24, type: !6) |
| 206 |
!55 = !DILocation(line: 24, column: 7, scope: !50) |
| 207 |
!56 = !DILocation(line: 0, scope: !50) |
| 208 |
!57 = !DILocation(line: 25, column: 11, scope: !50) |
| 209 |
!58 = !DILocation(line: 25, column: 3, scope: !50) |
| 210 |
!59 = !DILocation(line: 26, column: 8, scope: !60) |
| 211 |
!60 = distinct !DILexicalBlock(scope: !61, file: !3, line: 26, column: 8) |
| 212 |
!61 = distinct !DILexicalBlock(scope: !50, file: !3, line: 25, column: 30) |
| 213 |
!62 = !DILocation(line: 26, column: 10, scope: !60) |
| 214 |
!63 = !DILocation(line: 26, column: 8, scope: !61) |
| 215 |
!64 = !DILocation(line: 27, column: 10, scope: !60) |
| 216 |
!65 = !DILocation(line: 27, column: 6, scope: !66) |
| 217 |
!66 = !DILexicalBlockFile(scope: !60, file: !3, discriminator: 455082031) |
| 218 |
!67 = !DILocation(line: 27, column: 6, scope: !60) |
| 219 |
!68 = !DILocation(line: 29, column: 10, scope: !60) |
| 220 |
!69 = !DILocation(line: 0, scope: !30, inlinedAt: !70) |
| 221 |
!70 = distinct !DILocation(line: 29, column: 6, scope: !71) |
| 222 |
!71 = !DILexicalBlockFile(scope: !60, file: !3, discriminator: 455082047) |
| 223 |
!72 = !DILocation(line: 11, column: 6, scope: !35, inlinedAt: !70) |
| 224 |
!73 = !DILocation(line: 11, column: 7, scope: !35, inlinedAt: !70) |
| 225 |
!74 = !DILocation(line: 11, column: 6, scope: !30, inlinedAt: !70) |
| 226 |
!75 = !DILocation(line: 12, column: 6, scope: !35, inlinedAt: !70) |
| 227 |
!76 = !DILocation(line: 12, column: 5, scope: !35, inlinedAt: !70) |
| 228 |
!77 = !DILocation(line: 14, column: 5, scope: !30, inlinedAt: !70) |
| 229 |
!78 = !DILocation(line: 15, column: 9, scope: !42, inlinedAt: !70) |
| 230 |
!79 = !DILocation(line: 15, column: 7, scope: !30, inlinedAt: !70) |
| 231 |
!80 = !DILocation(line: 17, column: 12, scope: !45, inlinedAt: !70) |
| 232 |
!81 = !DILocation(line: 17, column: 14, scope: !45, inlinedAt: !70) |
| 233 |
!82 = !DILocation(line: 17, column: 12, scope: !42, inlinedAt: !70) |
| 234 |
!83 = !DILocation(line: 0, scope: !42, inlinedAt: !70) |
| 235 |
!84 = !DILocation(line: 21, column: 1, scope: !30, inlinedAt: !70) |
| 236 |
!85 = !DILocation(line: 25, column: 14, scope: !50) |
| 237 |
!86 = distinct !{!86, !58, !87, !88} |
| 238 |
!87 = !DILocation(line: 30, column: 3, scope: !50) |
| 239 |
!88 = !{!"llvm.loop.mustprogress"} |
| 240 |
!89 = !DILocation(line: 31, column: 3, scope: !50) |