1; RUN: opt -deadargelim -S < %s | FileCheck %s 2 3; Verify that the dbg.value intrinsics that use the dead argument and return 4; value are marked as undef to indicate that the values are optimized out. 5 6; Reproducer for PR23260. 7 8; CHECK-LABEL: define internal void @bar() 9; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata ![[LOCAL1:[0-9]+]] 10; CHECK: call void @sink() 11 12; Function Attrs: alwaysinline nounwind uwtable 13define internal i32 @bar(i32 %deadarg) #1 !dbg !10 { 14entry: 15 call void @llvm.dbg.value(metadata i32 %deadarg, metadata !15, metadata !DIExpression()), !dbg !17 16 call void @sink(), !dbg !17 17 ret i32 123, !dbg !17 18} 19 20; CHECK-LABEL: define void @foo() 21; CHECK: call void @bar() 22; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata ![[LOCAL2:[0-9]+]] 23; CHECK: call void @bar() 24 25; Function Attrs: nounwind uwtable 26define void @foo() #0 !dbg !6 { 27entry: 28 %deadret = call i32 @bar(i32 0), !dbg !9 29 call void @llvm.dbg.value(metadata i32 %deadret, metadata !16, metadata !DIExpression()), !dbg !9 30 call i32 @bar(i32 1), !dbg !9 31 ret void, !dbg !9 32} 33 34declare void @sink() local_unnamed_addr 35 36; Function Attrs: nounwind readnone speculatable 37declare void @llvm.dbg.value(metadata, metadata, metadata) #2 38 39attributes #0 = { nounwind uwtable } 40attributes #1 = { alwaysinline nounwind uwtable } 41attributes #2 = { nounwind readnone speculatable } 42 43!llvm.dbg.cu = !{!0} 44!llvm.module.flags = !{!3, !4} 45!llvm.ident = !{!5} 46 47; CHECK: ![[LOCAL1]] = !DILocalVariable(name: "local1" 48; CHECK: ![[LOCAL2]] = !DILocalVariable(name: "local2" 49 50!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) 51!1 = !DIFile(filename: "pr23260.c", directory: "/") 52!2 = !{} 53!3 = !{i32 2, !"Dwarf Version", i32 4} 54!4 = !{i32 2, !"Debug Info Version", i32 3} 55!5 = !{!"clang version 8.0.0"} 56!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 57!7 = !DISubroutineType(types: !8) 58!8 = !{null} 59!9 = !DILocation(line: 4, column: 3, scope: !6) 60!10 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !11, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14) 61!11 = !DISubroutineType(types: !12) 62!12 = !{!13, !13} 63!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 64!14 = !{!15} 65!15 = !DILocalVariable(name: "local1", arg: 1, scope: !10, file: !1, line: 2, type: !13) 66!16 = !DILocalVariable(name: "local2", arg: 1, scope: !6, file: !1, line: 2, type: !13) 67!17 = !DILocation(line: 2, column: 52, scope: !10) 68