1; RUN: opt -loop-reduce -S %s | FileCheck %s 2 3;; This test ensures that no attempt is made to translate long SCEVs into 4;; DIExpressions. Attempting the translation can use excessive resources and 5;; result in crashes. 6 7target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 8target triple = "x86_64-unknown-linux-gnu" 9 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 13 14define dso_local i32 @d() local_unnamed_addr #0 !dbg !16 { 15entry: 16 %b.promoted = load i32, i32* @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 %mul.10 = mul nsw i32 %mul.9, %mul.9, !dbg !33 28 %mul.11 = mul nsw i32 %mul.10, %mul.10, !dbg !33 29 %mul.12 = mul nsw i32 %mul.11, %mul.11, !dbg !33 30 %mul.13 = mul nsw i32 %mul.12, %mul.12, !dbg !33 31 %mul.14 = mul nsw i32 %mul.13, %mul.13, !dbg !33 32 %mul.15 = mul nsw i32 %mul.14, %mul.14, !dbg !33 33 %mul.16 = mul nsw i32 %mul.15, %mul.15, !dbg !33 34 %mul.17 = mul nsw i32 %mul.16, %mul.16, !dbg !33 35 %mul.18 = mul nsw i32 %mul.17, %mul.17, !dbg !33 36 %mul.19 = mul nsw i32 %mul.18, %mul.18, !dbg !33 37 %mul.20 = mul nsw i32 %mul.19, %mul.19, !dbg !33 38 %mul.21 = mul nsw i32 %mul.20, %mul.20, !dbg !33 39 %mul.22 = mul nsw i32 %mul.21, %mul.21, !dbg !33 40 %mul.23 = mul nsw i32 %mul.22, %mul.22, !dbg !33 41 %mul.24 = mul nsw i32 %mul.23, %mul.23, !dbg !33 42 %mul.25 = mul nsw i32 %mul.24, %mul.24, !dbg !33 43 %mul.26 = mul nsw i32 %mul.25, %mul.25, !dbg !33 44 %mul.27 = mul nsw i32 %mul.26, %mul.26, !dbg !33 45 %mul.28 = mul nsw i32 %mul.27, %mul.27, !dbg !33 46 %mul.29 = mul nsw i32 %mul.28, %mul.28, !dbg !33 47 %mul.30 = mul nsw i32 %mul.29, %mul.29, !dbg !33 48 %mul.31 = mul nsw i32 %mul.30, %mul.30, !dbg !33 49 %mul.32 = mul nsw i32 %mul.31, %mul.31, !dbg !33 50 %mul.33 = mul nsw i32 %mul.32, %mul.32, !dbg !33 51 %mul.34 = mul nsw i32 %mul.33, %mul.33, !dbg !33 52 %mul.35 = mul nsw i32 %mul.34, %mul.34, !dbg !33 53 %mul.36 = mul nsw i32 %mul.35, %mul.35, !dbg !33 54 %mul.37 = mul nsw i32 %mul.36, %mul.36, !dbg !33 55 %mul.38 = mul nsw i32 %mul.37, %mul.37, !dbg !33 56 %mul.39 = mul nsw i32 %mul.38, %mul.38, !dbg !33 57 %mul.40 = mul nsw i32 %mul.39, %mul.39, !dbg !33 58 %mul.41 = mul nsw i32 %mul.40, %mul.40, !dbg !33 59 %mul.42 = mul nsw i32 %mul.41, %mul.41, !dbg !33 60 %mul.43 = mul nsw i32 %mul.42, %mul.42, !dbg !33 61 %mul.44 = mul nsw i32 %mul.43, %mul.43, !dbg !33 62 %mul.45 = mul nsw i32 %mul.44, %mul.44, !dbg !33 63 %mul.46 = mul nsw i32 %mul.45, %mul.45, !dbg !33 64 %mul.47 = mul nsw i32 %mul.46, %mul.46, !dbg !33 65 store i32 49, i32* @c, align 4, !dbg !36, !tbaa !29 66 store i32 %mul.47, i32* @b, align 4, !dbg !37, !tbaa !29 67 %.pr = load i32, i32* @a, align 4, !dbg !38, !tbaa !29 68 %tobool.not8 = icmp eq i32 %.pr, 0, !dbg !39 69 br i1 %tobool.not8, label %for.end3, label %for.body2.preheader, !dbg !39 70 71for.body2.preheader: ; preds = %entry 72 br label %for.body2, !dbg !39 73 74for.body2: ; preds = %for.body2.preheader, %for.body2 75 %0 = phi i32 [ %sub, %for.body2 ], [ %.pr, %for.body2.preheader ] 76 %sub = sub nsw i32 %0, %mul.47, !dbg !40 77 ; CHECK: call void @llvm.dbg.value(metadata !DIArgList(i32 poison, i32 %mul.47), 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)) 78 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 79 %tobool.not = icmp eq i32 %sub, 0, !dbg !39 80 br i1 %tobool.not, label %for.cond1.for.end3_crit_edge, label %for.body2, !dbg !39, !llvm.loop !42 81 82for.cond1.for.end3_crit_edge: ; preds = %for.body2 83 store i32 0, i32* @a, align 4, !dbg !40, !tbaa !29 84 br label %for.end3, !dbg !39 85 86for.end3: ; preds = %for.cond1.for.end3_crit_edge, %entry 87 ret i32 poison, !dbg !45 88} 89 90declare void @llvm.dbg.value(metadata, metadata, metadata) #1 91 92!llvm.dbg.cu = !{!2} 93!llvm.module.flags = !{!11, !12, !13, !14} 94!llvm.ident = !{!15} 95 96!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 97!1 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !7, line: 2, type: !8, isLocal: false, isDefinition: true) 98!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) 99!3 = !DIFile(filename: "test.c", directory: "/test") 100!4 = !{!5, !9, !0} 101!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression()) 102!6 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !7, line: 2, type: !8, isLocal: false, isDefinition: true) 103!7 = !DIFile(filename: "./test.c", directory: "/test") 104!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 105!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) 106!10 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !7, line: 2, type: !8, isLocal: false, isDefinition: true) 107!11 = !{i32 7, !"Dwarf Version", i32 4} 108!12 = !{i32 2, !"Debug Info Version", i32 3} 109!13 = !{i32 1, !"wchar_size", i32 4} 110!14 = !{i32 7, !"uwtable", i32 1} 111!15 = !{!"clang version 14.0.0"} 112!16 = distinct !DISubprogram(name: "d", scope: !7, file: !7, line: 3, type: !17, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !19) 113!17 = !DISubroutineType(types: !18) 114!18 = !{!8} 115!19 = !{!20} 116; CHECK: ![[VAR_e]] = !DILocalVariable(name: "e", scope: !21, file: !7, line: 8, type: !24) 117!20 = !DILocalVariable(name: "e", scope: !21, file: !7, line: 8, type: !24) 118!21 = distinct !DILexicalBlock(scope: !22, file: !7, line: 7, column: 14) 119!22 = distinct !DILexicalBlock(scope: !23, file: !7, line: 7, column: 3) 120!23 = distinct !DILexicalBlock(scope: !16, file: !7, line: 7, column: 3) 121!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint64_t", file: !25, line: 27, baseType: !26) 122!25 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h", directory: "") 123!26 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint64_t", file: !27, line: 44, baseType: !28) 124!27 = !DIFile(filename: "/usr/include/x86_64-linux-gnu/bits/types.h", directory: "") 125!28 = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned) 126!29 = !{!30, !30, i64 0} 127!30 = !{!"int", !31, i64 0} 128!31 = !{!"omnipotent char", !32, i64 0} 129!32 = !{!"Simple C/C++ TBAA"} 130!33 = !DILocation(line: 6, column: 7, scope: !34) 131!34 = distinct !DILexicalBlock(scope: !35, file: !7, line: 5, column: 3) 132!35 = distinct !DILexicalBlock(scope: !16, file: !7, line: 5, column: 3) 133!36 = !DILocation(line: 0, scope: !16) 134!37 = !DILocation(line: 0, scope: !34) 135!38 = !DILocation(line: 7, column: 10, scope: !22) 136!39 = !DILocation(line: 7, column: 3, scope: !23) 137!40 = !DILocation(line: 8, column: 20, scope: !21) 138!41 = !DILocation(line: 0, scope: !21) 139!42 = distinct !{!42, !39, !43, !44} 140!43 = !DILocation(line: 9, column: 3, scope: !23) 141!44 = !{!"llvm.loop.mustprogress"} 142!45 = !DILocation(line: 10, column: 1, scope: !16) 143