[win/asan] GetInstructionSize: Fix `83 E4 XX` to return 3. (#119644)
[llvm-project.git] / llvm / test / Transforms / LoopStrengthReduce / debuginfo-scev-salvage-4.ll
blobd71827081362053ce9e6caa4051c730115d2de6f
1 ; RUN: opt -S -loop-reduce %s -o - | FileCheck %s
2 ; RUN: opt --try-experimental-debuginfo-iterators -S -loop-reduce %s -o - | FileCheck %s
3 ; REQUIRES: x86-registered-target
5 ;; Ensure that we retain debuginfo for the induction variable and dependant
6 ;; variables when loop strength reduction is applied to the loop. This test
7 ;; covers the translation of a SCEVCastExpr to DIExpression containg 
8 ;; DW_OP_LLVM_CONVERT. This IR produced from:
9 ;;
10 ;; clang -S -emit-llvm -Xclang -disable-llvm-passes -g lsr-basic.cpp -o
11 ;; Then executing opt -O2 up to the the loopFullUnroll pass.
12 ;; void mul_pow_of_2_to_shift(unsigned size, unsigned *data) {
13 ;; 
14 ;; void zext_scev(int64_t *arr, uint32_t factor0, int16_t factor1) {
15 ;;     uint32_t i = 0;
16 ;;     while(i < 63) {
17 ;;         uint32_t comp = factor0 - (4*i*factor1);
18 ;;         arr[i] = comp;
19 ;;         ++i;
20 ;;     }
21 ;; }
22 ; CHECK: #dbg_value(i64 %lsr.iv, ![[i:[0-9]+]], !DIExpression(),
23 ; CHECK: #dbg_value(!DIArgList(i64 %lsr.iv, i16 %factor1, i32 %factor0), ![[comp:[0-9]+]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_consts, 18446744073709551612, DW_OP_LLVM_arg, 1, DW_OP_LLVM_convert, 32, DW_ATE_signed, DW_OP_mul, DW_OP_mul, DW_OP_LLVM_arg, 2, DW_OP_plus, DW_OP_stack_value),
24 ; CHECK: #dbg_value(i64 %lsr.iv, ![[i]], !DIExpression(DW_OP_consts, 1, DW_OP_plus, DW_OP_stack_value),
25 ; CHECK: ![[i]] = !DILocalVariable(name: "i"
26 ; CHECK: ![[comp]] = !DILocalVariable(name: "comp"
28 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
29 target triple = "x86_64-unknown-linux-gnu"
31 define dso_local void @_Z9zext_scevPljs(ptr nocapture %arr, i32 %factor0, i16 signext %factor1) local_unnamed_addr !dbg !90 {
32 entry:
33   call void @llvm.dbg.value(metadata ptr %arr, metadata !94, metadata !DIExpression()), !dbg !95
34   call void @llvm.dbg.value(metadata i32 %factor0, metadata !96, metadata !DIExpression()), !dbg !95
35   call void @llvm.dbg.value(metadata i16 %factor1, metadata !97, metadata !DIExpression()), !dbg !95
36   call void @llvm.dbg.value(metadata i32 0, metadata !98, metadata !DIExpression()), !dbg !95
37   %conv = sext i16 %factor1 to i32
38   %mul.neg = mul i32 %conv, -4
39   call void @llvm.dbg.value(metadata i32 0, metadata !98, metadata !DIExpression()), !dbg !95
40   br label %while.body, !dbg !95
42 while.body:                                       ; preds = %while.body, %entry
43   %i.04 = phi i32 [ 0, %entry ], [ %inc, %while.body ]
44   call void @llvm.dbg.value(metadata i32 %i.04, metadata !98, metadata !DIExpression()), !dbg !95
45   %mul1.neg = mul i32 %mul.neg, %i.04, !dbg !99
46   %sub = add i32 %mul1.neg, %factor0, !dbg !99
47   call void @llvm.dbg.value(metadata i32 %sub, metadata !101, metadata !DIExpression()), !dbg !99
48   %conv2 = zext i32 %sub to i64, !dbg !99
49   %idxprom = zext i32 %i.04 to i64, !dbg !99
50   %arrayidx = getelementptr inbounds i64, ptr %arr, i64 %idxprom, !dbg !99
51   store i64 %conv2, ptr %arrayidx, align 8, !dbg !99
52   %inc = add nuw nsw i32 %i.04, 1, !dbg !99
53   call void @llvm.dbg.value(metadata i32 %inc, metadata !98, metadata !DIExpression()), !dbg !95
54   %cmp = icmp ult i32 %inc, 63, !dbg !95
55   br i1 %cmp, label %while.body, label %while.end, !dbg !95, !llvm.loop !102
57 while.end:                                        ; preds = %while.body
58   ret void, !dbg !95
61 declare void @llvm.dbg.value(metadata, metadata, metadata)
63 attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }
65 !llvm.dbg.cu = !{!0}
66 !llvm.module.flags = !{!84, !85, !86, !87, !88}
67 !llvm.ident = !{!89}
69 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, imports: !3, splitDebugInlining: false, nameTableKind: None)
70 !1 = !DIFile(filename: "cast.cpp", directory: "/test")
71 !2 = !{}
72 !3 = !{!4, !12, !16, !20, !24, !27, !29, !31, !33, !35, !37, !39, !41, !44, !46, !51, !55, !59, !63, !65, !67, !69, !71, !73, !75, !77, !79, !82}
73 !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !6, file: !11, line: 48)
74 !5 = !DINamespace(name: "std", scope: null)
75 !6 = !DIDerivedType(tag: DW_TAG_typedef, name: "int8_t", file: !7, line: 24, baseType: !8)
76 !7 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/stdint-intn.h", directory: "")
77 !8 = !DIDerivedType(tag: DW_TAG_typedef, name: "__int8_t", file: !9, line: 36, baseType: !10)
78 !9 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/types.h", directory: "")
79 !10 = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
80 !11 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/cstdint", directory: "")
81 !12 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !13, file: !11, line: 49)
82 !13 = !DIDerivedType(tag: DW_TAG_typedef, name: "int16_t", file: !7, line: 25, baseType: !14)
83 !14 = !DIDerivedType(tag: DW_TAG_typedef, name: "__int16_t", file: !9, line: 38, baseType: !15)
84 !15 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
85 !16 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !17, file: !11, line: 50)
86 !17 = !DIDerivedType(tag: DW_TAG_typedef, name: "int32_t", file: !7, line: 26, baseType: !18)
87 !18 = !DIDerivedType(tag: DW_TAG_typedef, name: "__int32_t", file: !9, line: 40, baseType: !19)
88 !19 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
89 !20 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !21, file: !11, line: 51)
90 !21 = !DIDerivedType(tag: DW_TAG_typedef, name: "int64_t", file: !7, line: 27, baseType: !22)
91 !22 = !DIDerivedType(tag: DW_TAG_typedef, name: "__int64_t", file: !9, line: 43, baseType: !23)
92 !23 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
93 !24 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !25, file: !11, line: 53)
94 !25 = !DIDerivedType(tag: DW_TAG_typedef, name: "int_fast8_t", file: !26, line: 68, baseType: !10)
95 !26 = !DIFile(filename: "/usr/include/stdint.h", directory: "")
96 !27 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !28, file: !11, line: 54)
97 !28 = !DIDerivedType(tag: DW_TAG_typedef, name: "int_fast16_t", file: !26, line: 70, baseType: !23)
98 !29 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !30, file: !11, line: 55)
99 !30 = !DIDerivedType(tag: DW_TAG_typedef, name: "int_fast32_t", file: !26, line: 71, baseType: !23)
100 !31 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !32, file: !11, line: 56)
101 !32 = !DIDerivedType(tag: DW_TAG_typedef, name: "int_fast64_t", file: !26, line: 72, baseType: !23)
102 !33 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !34, file: !11, line: 58)
103 !34 = !DIDerivedType(tag: DW_TAG_typedef, name: "int_least8_t", file: !26, line: 43, baseType: !10)
104 !35 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !36, file: !11, line: 59)
105 !36 = !DIDerivedType(tag: DW_TAG_typedef, name: "int_least16_t", file: !26, line: 44, baseType: !15)
106 !37 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !38, file: !11, line: 60)
107 !38 = !DIDerivedType(tag: DW_TAG_typedef, name: "int_least32_t", file: !26, line: 45, baseType: !19)
108 !39 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !40, file: !11, line: 61)
109 !40 = !DIDerivedType(tag: DW_TAG_typedef, name: "int_least64_t", file: !26, line: 47, baseType: !23)
110 !41 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !42, file: !11, line: 63)
111 !42 = !DIDerivedType(tag: DW_TAG_typedef, name: "intmax_t", file: !26, line: 111, baseType: !43)
112 !43 = !DIDerivedType(tag: DW_TAG_typedef, name: "__intmax_t", file: !9, line: 61, baseType: !23)
113 !44 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !45, file: !11, line: 64)
114 !45 = !DIDerivedType(tag: DW_TAG_typedef, name: "intptr_t", file: !26, line: 97, baseType: !23)
115 !46 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !47, file: !11, line: 66)
116 !47 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint8_t", file: !48, line: 24, baseType: !49)
117 !48 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h", directory: "")
118 !49 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint8_t", file: !9, line: 37, baseType: !50)
119 !50 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
120 !51 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !52, file: !11, line: 67)
121 !52 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint16_t", file: !48, line: 25, baseType: !53)
122 !53 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint16_t", file: !9, line: 39, baseType: !54)
123 !54 = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)
124 !55 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !56, file: !11, line: 68)
125 !56 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint32_t", file: !48, line: 26, baseType: !57)
126 !57 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint32_t", file: !9, line: 41, baseType: !58)
127 !58 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
128 !59 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !60, file: !11, line: 69)
129 !60 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint64_t", file: !48, line: 27, baseType: !61)
130 !61 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint64_t", file: !9, line: 44, baseType: !62)
131 !62 = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned)
132 !63 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !64, file: !11, line: 71)
133 !64 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint_fast8_t", file: !26, line: 81, baseType: !50)
134 !65 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !66, file: !11, line: 72)
135 !66 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint_fast16_t", file: !26, line: 83, baseType: !62)
136 !67 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !68, file: !11, line: 73)
137 !68 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint_fast32_t", file: !26, line: 84, baseType: !62)
138 !69 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !70, file: !11, line: 74)
139 !70 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint_fast64_t", file: !26, line: 85, baseType: !62)
140 !71 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !72, file: !11, line: 76)
141 !72 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint_least8_t", file: !26, line: 54, baseType: !50)
142 !73 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !74, file: !11, line: 77)
143 !74 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint_least16_t", file: !26, line: 55, baseType: !54)
144 !75 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !76, file: !11, line: 78)
145 !76 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint_least32_t", file: !26, line: 56, baseType: !58)
146 !77 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !78, file: !11, line: 79)
147 !78 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint_least64_t", file: !26, line: 58, baseType: !62)
148 !79 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !80, file: !11, line: 81)
149 !80 = !DIDerivedType(tag: DW_TAG_typedef, name: "uintmax_t", file: !26, line: 112, baseType: !81)
150 !81 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uintmax_t", file: !9, line: 62, baseType: !62)
151 !82 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !83, file: !11, line: 82)
152 !83 = !DIDerivedType(tag: DW_TAG_typedef, name: "uintptr_t", file: !26, line: 100, baseType: !62)
153 !84 = !{i32 7, !"Dwarf Version", i32 4}
154 !85 = !{i32 2, !"Debug Info Version", i32 3}
155 !86 = !{i32 1, !"wchar_size", i32 4}
156 !87 = !{i32 7, !"uwtable", i32 1}
157 !88 = !{i32 7, !"frame-pointer", i32 2}
158 !89 = !{!"clang version 13.0.0"}
159 !90 = distinct !DISubprogram(name: "zext_scev", linkageName: "_Z9zext_scevPljs", scope: !1, file: !1, line: 4, type: !91, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
160 !91 = !DISubroutineType(types: !92)
161 !92 = !{null, !93, !56, !13}
162 !93 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !21, size: 64)
163 !94 = !DILocalVariable(name: "arr", arg: 1, scope: !90, file: !1, line: 4, type: !93)
164 !95 = !DILocation(line: 0, scope: !90)
165 !96 = !DILocalVariable(name: "factor0", arg: 2, scope: !90, file: !1, line: 4, type: !56)
166 !97 = !DILocalVariable(name: "factor1", arg: 3, scope: !90, file: !1, line: 4, type: !13)
167 !98 = !DILocalVariable(name: "i", scope: !90, file: !1, line: 5, type: !56)
168 !99 = !DILocation(line: 7, column: 39, scope: !100)
169 !100 = distinct !DILexicalBlock(scope: !90, file: !1, line: 6, column: 19)
170 !101 = !DILocalVariable(name: "comp", scope: !100, file: !1, line: 7, type: !56)
171 !102 = distinct !{!102, !103, !104, !105}
172 !103 = !DILocation(line: 6, column: 5, scope: !90)
173 !104 = !DILocation(line: 10, column: 5, scope: !90)
174 !105 = !{!"llvm.loop.mustprogress"}