1 ; RUN: opt -loop-reduce -S %s | FileCheck %s
3 ;; This test ensures that no attempt is made to translate long SCEVs into
4 ;; DIExpressions. Attempting the translation can use excessive resources and
7 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-unknown-linux-gnu"
10 @c = dso_local local_unnamed_addr global i32 0, align 4, !dbg !0
11 @b = dso_local local_unnamed_addr global i32 0, align 4, !dbg !9
12 @a = dso_local local_unnamed_addr global i32 0, align 4, !dbg !5
14 define dso_local i32 @d() local_unnamed_addr #0 !dbg !16 {
16 %b.promoted = load i32, ptr @b, align 4, !tbaa !29
17 %mul = mul nsw i32 %b.promoted, %b.promoted, !dbg !33
18 %mul.1 = mul nsw i32 %mul, %mul, !dbg !33
19 %mul.2 = mul nsw i32 %mul.1, %mul.1, !dbg !33
20 %mul.3 = mul nsw i32 %mul.2, %mul.2, !dbg !33
21 %mul.4 = mul nsw i32 %mul.3, %mul.3, !dbg !33
22 %mul.5 = mul nsw i32 %mul.4, %mul.4, !dbg !33
23 %mul.6 = mul nsw i32 %mul.5, %mul.5, !dbg !33
24 %mul.7 = mul nsw i32 %mul.6, %mul.6, !dbg !33
25 %mul.8 = mul nsw i32 %mul.7, %mul.7, !dbg !33
26 %mul.9 = mul nsw i32 %mul.8, %mul.8, !dbg !33
27 store i32 49, ptr @c, align 4, !dbg !36, !tbaa !29
28 store i32 %mul.9, ptr @b, align 4, !dbg !37, !tbaa !29
29 %.pr = load i32, ptr @a, align 4, !dbg !38, !tbaa !29
30 %tobool.not8 = icmp eq i32 %.pr, 0, !dbg !39
31 br i1 %tobool.not8, label %for.end3, label %for.body2.preheader, !dbg !39
33 for.body2.preheader: ; preds = %entry
34 br label %for.body2, !dbg !39
36 for.body2: ; preds = %for.body2.preheader, %for.body2
37 %0 = phi i32 [ %sub, %for.body2 ], [ %.pr, %for.body2.preheader ]
38 %sub = sub nsw i32 %0, %mul.9, !dbg !40
39 ; CHECK: call void @llvm.dbg.value(metadata !DIArgList(i32 poison, i32 %mul.9), metadata ![[VAR_e:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_minus, DW_OP_LLVM_convert, 32, DW_ATE_signed, DW_OP_LLVM_convert, 64, DW_ATE_signed, DW_OP_stack_value))
40 call void @llvm.dbg.value(metadata i32 %sub, metadata !20, metadata !DIExpression(DW_OP_LLVM_convert, 32, DW_ATE_signed, DW_OP_LLVM_convert, 64, DW_ATE_signed, DW_OP_stack_value)), !dbg !41
41 %tobool.not = icmp eq i32 %sub, 0, !dbg !39
42 br i1 %tobool.not, label %for.cond1.for.end3_crit_edge, label %for.body2, !dbg !39, !llvm.loop !42
44 for.cond1.for.end3_crit_edge: ; preds = %for.body2
45 store i32 0, ptr @a, align 4, !dbg !40, !tbaa !29
46 br label %for.end3, !dbg !39
48 for.end3: ; preds = %for.cond1.for.end3_crit_edge, %entry
49 ret i32 poison, !dbg !45
52 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
55 !llvm.module.flags = !{!11, !12, !13, !14}
58 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
59 !1 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !7, line: 2, type: !8, isLocal: false, isDefinition: true)
60 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 14.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
61 !3 = !DIFile(filename: "test.c", directory: "/test")
63 !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
64 !6 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !7, line: 2, type: !8, isLocal: false, isDefinition: true)
65 !7 = !DIFile(filename: "./test.c", directory: "/test")
66 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
67 !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
68 !10 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !7, line: 2, type: !8, isLocal: false, isDefinition: true)
69 !11 = !{i32 7, !"Dwarf Version", i32 4}
70 !12 = !{i32 2, !"Debug Info Version", i32 3}
71 !13 = !{i32 1, !"wchar_size", i32 4}
72 !14 = !{i32 7, !"uwtable", i32 1}
73 !15 = !{!"clang version 14.0.0"}
74 !16 = distinct !DISubprogram(name: "d", scope: !7, file: !7, line: 3, type: !17, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !19)
75 !17 = !DISubroutineType(types: !18)
78 ; CHECK: ![[VAR_e]] = !DILocalVariable(name: "e", scope: !21, file: !7, line: 8, type: !24)
79 !20 = !DILocalVariable(name: "e", scope: !21, file: !7, line: 8, type: !24)
80 !21 = distinct !DILexicalBlock(scope: !22, file: !7, line: 7, column: 14)
81 !22 = distinct !DILexicalBlock(scope: !23, file: !7, line: 7, column: 3)
82 !23 = distinct !DILexicalBlock(scope: !16, file: !7, line: 7, column: 3)
83 !24 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint64_t", file: !25, line: 27, baseType: !26)
84 !25 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h", directory: "")
85 !26 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint64_t", file: !27, line: 44, baseType: !28)
86 !27 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/types.h", directory: "")
87 !28 = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned)
88 !29 = !{!30, !30, i64 0}
89 !30 = !{!"int", !31, i64 0}
90 !31 = !{!"omnipotent char", !32, i64 0}
91 !32 = !{!"Simple C/C++ TBAA"}
92 !33 = !DILocation(line: 6, column: 7, scope: !34)
93 !34 = distinct !DILexicalBlock(scope: !35, file: !7, line: 5, column: 3)
94 !35 = distinct !DILexicalBlock(scope: !16, file: !7, line: 5, column: 3)
95 !36 = !DILocation(line: 0, scope: !16)
96 !37 = !DILocation(line: 0, scope: !34)
97 !38 = !DILocation(line: 7, column: 10, scope: !22)
98 !39 = !DILocation(line: 7, column: 3, scope: !23)
99 !40 = !DILocation(line: 8, column: 20, scope: !21)
100 !41 = !DILocation(line: 0, scope: !21)
101 !42 = distinct !{!42, !39, !43, !44}
102 !43 = !DILocation(line: 9, column: 3, scope: !23)
103 !44 = !{!"llvm.loop.mustprogress"}
104 !45 = !DILocation(line: 10, column: 1, scope: !16)