1; RUN: opt < %s -passes=globalopt -S | llvm-as | llvm-dis | FileCheck %s 2 3; The %struct.S type would not get emitted after @s was removed, resulting in 4; llvm-as failing to parse the dbg.value intrinsic using that type. However, 5; with opaque pointers this is no longer necessary. 6 7; CHECK-NOT: @s 8 9; CHECK: #dbg_value(!DIArgList(ptr poison 10 11%struct.S = type { i32 } 12 13@s = internal global [1 x %struct.S] zeroinitializer, align 4, !dbg !0 14@idx = dso_local global i32 0, align 4, !dbg !6 15 16define dso_local void @fn() !dbg !20 { 17entry: 18 %0 = load i32, ptr @idx, align 4, !dbg !26 19 %idxprom = sext i32 %0 to i64, !dbg !26 20 call void @llvm.dbg.value(metadata !DIArgList(ptr @s, i64 %idxprom), metadata !24, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_constu, 4, DW_OP_mul, DW_OP_plus, DW_OP_stack_value)), !dbg !26 21 ret void, !dbg !26 22} 23 24declare void @llvm.dbg.value(metadata, metadata, metadata) 25 26!llvm.dbg.cu = !{!2} 27!llvm.module.flags = !{!15, !16, !17, !18} 28!llvm.ident = !{!19} 29 30!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 31!1 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 1, type: !9, isLocal: true, isDefinition: true) 32!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None) 33!3 = !DIFile(filename: "foo.c", directory: "/") 34!4 = !{} 35!5 = !{!0, !6} 36!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) 37!7 = distinct !DIGlobalVariable(name: "idx", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true) 38!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 39!9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 32, elements: !13) 40!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !3, line: 1, size: 32, elements: !11) 41!11 = !{!12} 42!12 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !10, file: !3, line: 1, baseType: !8, size: 32) 43!13 = !{!14} 44!14 = !DISubrange(count: 1) 45!15 = !{i32 7, !"Dwarf Version", i32 4} 46!16 = !{i32 2, !"Debug Info Version", i32 3} 47!17 = !{i32 1, !"wchar_size", i32 4} 48!18 = !{i32 7, !"uwtable", i32 1} 49!19 = !{!"clang version 13.0.0"} 50!20 = distinct !DISubprogram(name: "fn", scope: !3, file: !3, line: 4, type: !21, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !23) 51!21 = !DISubroutineType(types: !22) 52!22 = !{null} 53!23 = !{!24} 54!24 = !DILocalVariable(name: "local", scope: !20, file: !3, line: 5, type: !25) 55!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64) 56!26 = !DILocation(line: 5, scope: !20) 57