62 lines · plain
1; RUN: opt -S %s -passes=declare-to-assign -o - | FileCheck %s2 3;; Check declare-to-assign ignores VLA-backed variables (for now).4;; From C++ source:5;; __attribute__ ((nodebug)) int sz;6;; void fun() {7;; int x[sz];8;; }9 10; CHECK: #dbg_declare(ptr %vla, ![[#]], !DIExpression(),11 12@sz = dso_local global i32 0, align 413 14define dso_local void @_Z3funv() #0 !dbg !10 {15entry:16 %saved_stack = alloca ptr, align 817 %__vla_expr0 = alloca i64, align 818 %0 = load i32, ptr @sz, align 4, !dbg !1419 %1 = zext i32 %0 to i64, !dbg !1520 %2 = call ptr @llvm.stacksave(), !dbg !1521 store ptr %2, ptr %saved_stack, align 8, !dbg !1522 %vla = alloca i32, i64 %1, align 16, !dbg !1523 store i64 %1, ptr %__vla_expr0, align 8, !dbg !1524 ;; Ignore this artificial variable for the purpose of the test.25 ; call void @llvm.dbg.declare(metadata ptr %__vla_expr0, metadata !16, metadata !DIExpression()), !dbg !1826 call void @llvm.dbg.declare(metadata ptr %vla, metadata !19, metadata !DIExpression()), !dbg !2427 %3 = load ptr, ptr %saved_stack, align 8, !dbg !2528 call void @llvm.stackrestore(ptr %3), !dbg !2529 ret void, !dbg !2530}31 32declare ptr @llvm.stacksave() #133declare void @llvm.dbg.declare(metadata, metadata, metadata) #234declare void @llvm.stackrestore(ptr) #135 36!llvm.dbg.cu = !{!0}37!llvm.module.flags = !{!2, !3}38!llvm.ident = !{!9}39 40!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)41!1 = !DIFile(filename: "test.cpp", directory: "/")42!2 = !{i32 7, !"Dwarf Version", i32 5}43!3 = !{i32 2, !"Debug Info Version", i32 3}44!8 = !{i32 7, !"frame-pointer", i32 2}45!9 = !{!"clang version 17.0.0"}46!10 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 2, type: !11, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !13)47!11 = !DISubroutineType(types: !12)48!12 = !{null}49!13 = !{}50!14 = !DILocation(line: 3, column: 9, scope: !10)51!15 = !DILocation(line: 3, column: 3, scope: !10)52!16 = !DILocalVariable(name: "__vla_expr0", scope: !10, type: !17, flags: DIFlagArtificial)53!17 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned)54!18 = !DILocation(line: 0, scope: !10)55!19 = !DILocalVariable(name: "x", scope: !10, file: !1, line: 3, type: !20)56!20 = !DICompositeType(tag: DW_TAG_array_type, baseType: !21, elements: !22)57!21 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)58!22 = !{!23}59!23 = !DISubrange(count: !16)60!24 = !DILocation(line: 3, column: 7, scope: !10)61!25 = !DILocation(line: 4, column: 1, scope: !10)62