Valery Pykhtin | 604c29e | 2023-12-01 09:10:29 +0100 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 |
| 2 | ; RUN: opt -mtriple=amdgcn-- -S -structurizecfg -si-annotate-control-flow %s | FileCheck -check-prefix=OPT %s |
Jeremy Morse | 52a8bed | 2024-01-22 14:25:08 +0000 | [diff] [blame] | 3 | ; RUN: opt -mtriple=amdgcn-- -S -structurizecfg -si-annotate-control-flow %s --try-experimental-debuginfo-iterators | FileCheck -check-prefix=OPT %s |
Valery Pykhtin | 604c29e | 2023-12-01 09:10:29 +0100 | [diff] [blame] | 4 | |
| 5 | define amdgpu_ps i32 @if_else(i32 %0) !dbg !5 { |
| 6 | ; OPT-LABEL: define amdgpu_ps i32 @if_else( |
| 7 | ; OPT-SAME: i32 [[TMP0:%.*]]) !dbg [[DBG5:![0-9]+]] { |
| 8 | ; OPT-NEXT: [[C:%.*]] = icmp ne i32 [[TMP0]], 0, !dbg [[DBG13:![0-9]+]] |
Stephen Tozer | 0945727 | 2024-06-14 15:07:27 +0100 | [diff] [blame] | 9 | ; OPT-NEXT: #dbg_value(i1 [[C]], [[META9:![0-9]+]], !DIExpression(), [[DBG13]]) |
Valery Pykhtin | a01392c | 2023-12-04 09:56:24 +0100 | [diff] [blame] | 10 | ; OPT-NEXT: [[TMP2:%.*]] = call { i1, i64 } @llvm.amdgcn.if.i64(i1 [[C]]), !dbg [[DBG14:![0-9]+]] |
| 11 | ; OPT-NEXT: [[TMP3:%.*]] = extractvalue { i1, i64 } [[TMP2]], 0, !dbg [[DBG14]] |
| 12 | ; OPT-NEXT: [[TMP4:%.*]] = extractvalue { i1, i64 } [[TMP2]], 1, !dbg [[DBG14]] |
| 13 | ; OPT-NEXT: br i1 [[TMP3]], label [[FALSE:%.*]], label [[FLOW:%.*]], !dbg [[DBG14]] |
Valery Pykhtin | 604c29e | 2023-12-01 09:10:29 +0100 | [diff] [blame] | 14 | ; OPT: Flow: |
| 15 | ; OPT-NEXT: [[TMP5:%.*]] = phi i32 [ 33, [[FALSE]] ], [ undef, [[TMP1:%.*]] ] |
Valery Pykhtin | a01392c | 2023-12-04 09:56:24 +0100 | [diff] [blame] | 16 | ; OPT-NEXT: [[TMP6:%.*]] = call { i1, i64 } @llvm.amdgcn.else.i64.i64(i64 [[TMP4]]), !dbg [[DBG14]] |
| 17 | ; OPT-NEXT: [[TMP7:%.*]] = extractvalue { i1, i64 } [[TMP6]], 0, !dbg [[DBG14]] |
| 18 | ; OPT-NEXT: [[TMP8:%.*]] = extractvalue { i1, i64 } [[TMP6]], 1, !dbg [[DBG14]] |
Valery Pykhtin | 604c29e | 2023-12-01 09:10:29 +0100 | [diff] [blame] | 19 | ; OPT-NEXT: br i1 [[TMP7]], label [[TRUE:%.*]], label [[EXIT:%.*]], !dbg [[DBG14]] |
| 20 | ; OPT: true: |
| 21 | ; OPT-NEXT: br label [[EXIT]], !dbg [[DBG15:![0-9]+]] |
| 22 | ; OPT: false: |
| 23 | ; OPT-NEXT: br label [[FLOW]], !dbg [[DBG16:![0-9]+]] |
| 24 | ; OPT: exit: |
| 25 | ; OPT-NEXT: [[RET:%.*]] = phi i32 [ [[TMP5]], [[FLOW]] ], [ 42, [[TRUE]] ], !dbg [[DBG17:![0-9]+]] |
Valery Pykhtin | 981aa6f | 2024-05-02 12:59:31 +0200 | [diff] [blame] | 26 | ; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP8]]) |
Stephen Tozer | 0945727 | 2024-06-14 15:07:27 +0100 | [diff] [blame] | 27 | ; OPT-NEXT: #dbg_value(i32 [[RET]], [[META11:![0-9]+]], !DIExpression(), [[DBG17]]) |
Valery Pykhtin | 981aa6f | 2024-05-02 12:59:31 +0200 | [diff] [blame] | 28 | ; OPT-NEXT: ret i32 [[RET]], !dbg [[DBG18:![0-9]+]] |
Valery Pykhtin | 604c29e | 2023-12-01 09:10:29 +0100 | [diff] [blame] | 29 | ; |
| 30 | %c = icmp eq i32 %0, 0, !dbg !13 |
| 31 | tail call void @llvm.dbg.value(metadata i1 %c, metadata !9, metadata !DIExpression()), !dbg !13 |
| 32 | br i1 %c, label %true, label %false, !dbg !14 |
| 33 | |
| 34 | true: ; preds = %1 |
| 35 | br label %exit, !dbg !15 |
| 36 | |
| 37 | false: ; preds = %1 |
| 38 | br label %exit, !dbg !16 |
| 39 | |
| 40 | exit: ; preds = %false, %true |
| 41 | %ret = phi i32 [ 42, %true ], [ 33, %false ], !dbg !17 |
| 42 | tail call void @llvm.dbg.value(metadata i32 %ret, metadata !11, metadata !DIExpression()), !dbg !17 |
| 43 | ret i32 %ret, !dbg !18 |
| 44 | } |
| 45 | |
| 46 | define amdgpu_ps void @loop_if_break(i32 %n) !dbg !19 { |
| 47 | ; OPT-LABEL: define amdgpu_ps void @loop_if_break( |
| 48 | ; OPT-SAME: i32 [[N:%.*]]) !dbg [[DBG19:![0-9]+]] { |
| 49 | ; OPT-NEXT: entry: |
| 50 | ; OPT-NEXT: br label [[LOOP:%.*]], !dbg [[DBG24:![0-9]+]] |
| 51 | ; OPT: loop: |
| 52 | ; OPT-NEXT: [[PHI_BROKEN:%.*]] = phi i64 [ [[TMP5:%.*]], [[FLOW:%.*]] ], [ 0, [[ENTRY:%.*]] ] |
| 53 | ; OPT-NEXT: [[I:%.*]] = phi i32 [ [[N]], [[ENTRY]] ], [ [[TMP3:%.*]], [[FLOW]] ], !dbg [[DBG25:![0-9]+]] |
Stephen Tozer | 0945727 | 2024-06-14 15:07:27 +0100 | [diff] [blame] | 54 | ; OPT-NEXT: #dbg_value(i32 [[I]], [[META21:![0-9]+]], !DIExpression(), [[DBG25]]) |
Valery Pykhtin | 604c29e | 2023-12-01 09:10:29 +0100 | [diff] [blame] | 55 | ; OPT-NEXT: [[C:%.*]] = icmp ugt i32 [[I]], 0, !dbg [[DBG26:![0-9]+]] |
Stephen Tozer | 0945727 | 2024-06-14 15:07:27 +0100 | [diff] [blame] | 56 | ; OPT-NEXT: #dbg_value(i1 [[C]], [[META22:![0-9]+]], !DIExpression(), [[DBG26]]) |
Valery Pykhtin | a01392c | 2023-12-04 09:56:24 +0100 | [diff] [blame] | 57 | ; OPT-NEXT: [[TMP0:%.*]] = call { i1, i64 } @llvm.amdgcn.if.i64(i1 [[C]]), !dbg [[DBG27:![0-9]+]] |
| 58 | ; OPT-NEXT: [[TMP1:%.*]] = extractvalue { i1, i64 } [[TMP0]], 0, !dbg [[DBG27]] |
| 59 | ; OPT-NEXT: [[TMP2:%.*]] = extractvalue { i1, i64 } [[TMP0]], 1, !dbg [[DBG27]] |
| 60 | ; OPT-NEXT: br i1 [[TMP1]], label [[LOOP_BODY:%.*]], label [[FLOW]], !dbg [[DBG27]] |
Valery Pykhtin | 604c29e | 2023-12-01 09:10:29 +0100 | [diff] [blame] | 61 | ; OPT: loop_body: |
| 62 | ; OPT-NEXT: [[I_NEXT:%.*]] = sub i32 [[I]], 1, !dbg [[DBG28:![0-9]+]] |
Stephen Tozer | 0945727 | 2024-06-14 15:07:27 +0100 | [diff] [blame] | 63 | ; OPT-NEXT: #dbg_value(i32 [[I_NEXT]], [[META23:![0-9]+]], !DIExpression(), [[DBG28]]) |
Valery Pykhtin | 604c29e | 2023-12-01 09:10:29 +0100 | [diff] [blame] | 64 | ; OPT-NEXT: br label [[FLOW]], !dbg [[DBG29:![0-9]+]] |
| 65 | ; OPT: Flow: |
| 66 | ; OPT-NEXT: [[TMP3]] = phi i32 [ [[I_NEXT]], [[LOOP_BODY]] ], [ undef, [[LOOP]] ] |
| 67 | ; OPT-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[LOOP_BODY]] ], [ true, [[LOOP]] ] |
Valery Pykhtin | 981aa6f | 2024-05-02 12:59:31 +0200 | [diff] [blame] | 68 | ; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP2]]) |
Valery Pykhtin | a01392c | 2023-12-04 09:56:24 +0100 | [diff] [blame] | 69 | ; OPT-NEXT: [[TMP5]] = call i64 @llvm.amdgcn.if.break.i64(i1 [[TMP4]], i64 [[PHI_BROKEN]]), !dbg [[DBG27]] |
| 70 | ; OPT-NEXT: [[TMP6:%.*]] = call i1 @llvm.amdgcn.loop.i64(i64 [[TMP5]]), !dbg [[DBG27]] |
Valery Pykhtin | 604c29e | 2023-12-01 09:10:29 +0100 | [diff] [blame] | 71 | ; OPT-NEXT: br i1 [[TMP6]], label [[EXIT:%.*]], label [[LOOP]], !dbg [[DBG27]] |
| 72 | ; OPT: exit: |
Valery Pykhtin | 981aa6f | 2024-05-02 12:59:31 +0200 | [diff] [blame] | 73 | ; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP5]]) |
| 74 | ; OPT-NEXT: ret void, !dbg [[DBG30:![0-9]+]] |
Valery Pykhtin | 604c29e | 2023-12-01 09:10:29 +0100 | [diff] [blame] | 75 | ; |
| 76 | entry: |
| 77 | br label %loop, !dbg !24 |
| 78 | |
| 79 | loop: ; preds = %loop_body, %entry |
| 80 | %i = phi i32 [ %n, %entry ], [ %i.next, %loop_body ], !dbg !25 |
| 81 | tail call void @llvm.dbg.value(metadata i32 %i, metadata !21, metadata !DIExpression()), !dbg !25 |
| 82 | %c = icmp ugt i32 %i, 0, !dbg !26 |
| 83 | tail call void @llvm.dbg.value(metadata i1 %c, metadata !22, metadata !DIExpression()), !dbg !26 |
| 84 | br i1 %c, label %loop_body, label %exit, !dbg !27 |
| 85 | |
| 86 | loop_body: ; preds = %loop |
| 87 | %i.next = sub i32 %i, 1, !dbg !28 |
| 88 | tail call void @llvm.dbg.value(metadata i32 %i.next, metadata !23, metadata !DIExpression()), !dbg !28 |
| 89 | br label %loop, !dbg !29 |
| 90 | |
| 91 | exit: ; preds = %loop |
| 92 | ret void, !dbg !30 |
| 93 | } |
| 94 | |
| 95 | ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) |
| 96 | declare void @llvm.dbg.value(metadata, metadata, metadata) #0 |
| 97 | |
| 98 | attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } |
| 99 | |
| 100 | !llvm.dbg.cu = !{!0} |
| 101 | !llvm.debugify = !{!2, !3} |
| 102 | !llvm.module.flags = !{!4} |
| 103 | |
| 104 | !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 105 | !1 = !DIFile(filename: "../../../test/CodeGen/AMDGPU/si-annotate-dbg-info.ll", directory: "/") |
| 106 | !2 = !{i32 13} |
| 107 | !3 = !{i32 5} |
| 108 | !4 = !{i32 2, !"Debug Info Version", i32 3} |
| 109 | !5 = distinct !DISubprogram(name: "if_else", linkageName: "if_else", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8) |
| 110 | !6 = !DISubroutineType(types: !7) |
| 111 | !7 = !{} |
| 112 | !8 = !{!9, !11} |
| 113 | !9 = !DILocalVariable(name: "1", scope: !5, file: !1, line: 1, type: !10) |
| 114 | !10 = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned) |
| 115 | !11 = !DILocalVariable(name: "2", scope: !5, file: !1, line: 5, type: !12) |
| 116 | !12 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) |
| 117 | !13 = !DILocation(line: 1, column: 1, scope: !5) |
| 118 | !14 = !DILocation(line: 2, column: 1, scope: !5) |
| 119 | !15 = !DILocation(line: 3, column: 1, scope: !5) |
| 120 | !16 = !DILocation(line: 4, column: 1, scope: !5) |
| 121 | !17 = !DILocation(line: 5, column: 1, scope: !5) |
| 122 | !18 = !DILocation(line: 6, column: 1, scope: !5) |
| 123 | !19 = distinct !DISubprogram(name: "loop_if_break", linkageName: "loop_if_break", scope: null, file: !1, line: 7, type: !6, scopeLine: 7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !20) |
| 124 | !20 = !{!21, !22, !23} |
| 125 | !21 = !DILocalVariable(name: "3", scope: !19, file: !1, line: 8, type: !12) |
| 126 | !22 = !DILocalVariable(name: "4", scope: !19, file: !1, line: 9, type: !10) |
| 127 | !23 = !DILocalVariable(name: "5", scope: !19, file: !1, line: 11, type: !12) |
| 128 | !24 = !DILocation(line: 7, column: 1, scope: !19) |
| 129 | !25 = !DILocation(line: 8, column: 1, scope: !19) |
| 130 | !26 = !DILocation(line: 9, column: 1, scope: !19) |
| 131 | !27 = !DILocation(line: 10, column: 1, scope: !19) |
| 132 | !28 = !DILocation(line: 11, column: 1, scope: !19) |
| 133 | !29 = !DILocation(line: 12, column: 1, scope: !19) |
| 134 | !30 = !DILocation(line: 13, column: 1, scope: !19) |
| 135 | ;. |
| 136 | ; OPT: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C, file: [[META1:![0-9]+]], producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 137 | ; OPT: [[META1]] = !DIFile(filename: "../../../test/CodeGen/AMDGPU/si-annotate-dbg-info.ll", directory: {{.*}}) |
| 138 | ; OPT: [[DBG5]] = distinct !DISubprogram(name: "if_else", linkageName: "if_else", scope: null, file: [[META1]], line: 1, type: [[META6:![0-9]+]], scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META8:![0-9]+]]) |
| 139 | ; OPT: [[META6]] = !DISubroutineType(types: [[META7:![0-9]+]]) |
| 140 | ; OPT: [[META7]] = !{} |
| 141 | ; OPT: [[META8]] = !{[[META9]], [[META11]]} |
| 142 | ; OPT: [[META9]] = !DILocalVariable(name: "1", scope: [[DBG5]], file: [[META1]], line: 1, type: [[META10:![0-9]+]]) |
| 143 | ; OPT: [[META10]] = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned) |
| 144 | ; OPT: [[META11]] = !DILocalVariable(name: "2", scope: [[DBG5]], file: [[META1]], line: 5, type: [[META12:![0-9]+]]) |
| 145 | ; OPT: [[META12]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) |
| 146 | ; OPT: [[DBG13]] = !DILocation(line: 1, column: 1, scope: [[DBG5]]) |
| 147 | ; OPT: [[DBG14]] = !DILocation(line: 2, column: 1, scope: [[DBG5]]) |
| 148 | ; OPT: [[DBG15]] = !DILocation(line: 3, column: 1, scope: [[DBG5]]) |
| 149 | ; OPT: [[DBG16]] = !DILocation(line: 4, column: 1, scope: [[DBG5]]) |
| 150 | ; OPT: [[DBG17]] = !DILocation(line: 5, column: 1, scope: [[DBG5]]) |
| 151 | ; OPT: [[DBG18]] = !DILocation(line: 6, column: 1, scope: [[DBG5]]) |
| 152 | ; OPT: [[DBG19]] = distinct !DISubprogram(name: "loop_if_break", linkageName: "loop_if_break", scope: null, file: [[META1]], line: 7, type: [[META6]], scopeLine: 7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META20:![0-9]+]]) |
| 153 | ; OPT: [[META20]] = !{[[META21]], [[META22]], [[META23]]} |
| 154 | ; OPT: [[META21]] = !DILocalVariable(name: "3", scope: [[DBG19]], file: [[META1]], line: 8, type: [[META12]]) |
| 155 | ; OPT: [[META22]] = !DILocalVariable(name: "4", scope: [[DBG19]], file: [[META1]], line: 9, type: [[META10]]) |
| 156 | ; OPT: [[META23]] = !DILocalVariable(name: "5", scope: [[DBG19]], file: [[META1]], line: 11, type: [[META12]]) |
| 157 | ; OPT: [[DBG24]] = !DILocation(line: 7, column: 1, scope: [[DBG19]]) |
| 158 | ; OPT: [[DBG25]] = !DILocation(line: 8, column: 1, scope: [[DBG19]]) |
| 159 | ; OPT: [[DBG26]] = !DILocation(line: 9, column: 1, scope: [[DBG19]]) |
| 160 | ; OPT: [[DBG27]] = !DILocation(line: 10, column: 1, scope: [[DBG19]]) |
| 161 | ; OPT: [[DBG28]] = !DILocation(line: 11, column: 1, scope: [[DBG19]]) |
| 162 | ; OPT: [[DBG29]] = !DILocation(line: 12, column: 1, scope: [[DBG19]]) |
| 163 | ; OPT: [[DBG30]] = !DILocation(line: 13, column: 1, scope: [[DBG19]]) |
| 164 | ;. |