105 lines · plain
1; RUN: opt -loop-reduce -S %s | FileCheck %s2 3;; This test ensures that no attempt is made to translate long SCEVs into4;; DIExpressions. Attempting the translation can use excessive resources and5;; 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 !011@b = dso_local local_unnamed_addr global i32 0, align 4, !dbg !912@a = dso_local local_unnamed_addr global i32 0, align 4, !dbg !513 14define dso_local i32 @d() local_unnamed_addr #0 !dbg !16 {15entry:16 %b.promoted = load i32, ptr @b, align 4, !tbaa !2917 %mul = mul nsw i32 %b.promoted, %b.promoted, !dbg !3318 %mul.1 = mul nsw i32 %mul, %mul, !dbg !3319 %mul.2 = mul nsw i32 %mul.1, %mul.1, !dbg !3320 %mul.3 = mul nsw i32 %mul.2, %mul.2, !dbg !3321 %mul.4 = mul nsw i32 %mul.3, %mul.3, !dbg !3322 %mul.5 = mul nsw i32 %mul.4, %mul.4, !dbg !3323 %mul.6 = mul nsw i32 %mul.5, %mul.5, !dbg !3324 %mul.7 = mul nsw i32 %mul.6, %mul.6, !dbg !3325 %mul.8 = mul nsw i32 %mul.7, %mul.7, !dbg !3326 %mul.9 = mul nsw i32 %mul.8, %mul.8, !dbg !3327 store i32 49, ptr @c, align 4, !dbg !36, !tbaa !2928 store i32 %mul.9, ptr @b, align 4, !dbg !37, !tbaa !2929 %.pr = load i32, ptr @a, align 4, !dbg !38, !tbaa !2930 %tobool.not8 = icmp eq i32 %.pr, 0, !dbg !3931 br i1 %tobool.not8, label %for.end3, label %for.body2.preheader, !dbg !3932 33for.body2.preheader: ; preds = %entry34 br label %for.body2, !dbg !3935 36for.body2: ; preds = %for.body2.preheader, %for.body237 %0 = phi i32 [ %sub, %for.body2 ], [ %.pr, %for.body2.preheader ]38 %sub = sub nsw i32 %0, %mul.9, !dbg !4039 ; CHECK: #dbg_value(!DIArgList(i32 poison, i32 %mul.9), ![[VAR_e:[0-9]+]], !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 !4141 %tobool.not = icmp eq i32 %sub, 0, !dbg !3942 br i1 %tobool.not, label %for.cond1.for.end3_crit_edge, label %for.body2, !dbg !39, !llvm.loop !4243 44for.cond1.for.end3_crit_edge: ; preds = %for.body245 store i32 0, ptr @a, align 4, !dbg !40, !tbaa !2946 br label %for.end3, !dbg !3947 48for.end3: ; preds = %for.cond1.for.end3_crit_edge, %entry49 ret i32 poison, !dbg !4550}51 52declare void @llvm.dbg.value(metadata, metadata, metadata) #153 54!llvm.dbg.cu = !{!2}55!llvm.module.flags = !{!11, !12, !13, !14}56!llvm.ident = !{!15}57 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")62!4 = !{!5, !9, !0}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)76!18 = !{!8}77!19 = !{!20}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)105