1; Check for setting dbg.value as undef which depends on trivially dead instructions. 2; RUN: opt -passes=instcombine -S -o - %s | FileCheck %s 3; RUN: opt -passes=instcombine -S -o - %s --try-experimental-debuginfo-iterators | FileCheck %s 4 5@a = common dso_local global i8 0, align 1, !dbg !0 6@b = common dso_local global i8 0, align 1, !dbg !6 7 8define dso_local i32 @main() !dbg !13 { 9entry: 10 %0 = load i8, ptr @a, align 1, !dbg !17 11 %dec = add i8 %0, -1, !dbg !17 12 store i8 %dec, ptr @a, align 1, !dbg !17 13;CHECK: #dbg_value(i32 poison 14;CHECK: #dbg_value(i32 -8 15;CHECK: #dbg_value(i32 poison 16 %conv = sext i8 %dec to i32, !dbg !17 17 %udiv = udiv i32 %conv, 4, !dbg !17 18 call void @llvm.dbg.value(metadata i32 %udiv, metadata !18, metadata !DIExpression()), !dbg !19 19 call void @llvm.dbg.value(metadata i32 -8, metadata !20, metadata !DIExpression()), !dbg !19 20 call void @llvm.dbg.value(metadata i32 %udiv, metadata !20, metadata !DIExpression()), !dbg !19 21 store i8 0, ptr @b, align 1, !dbg !21 22 %cmp = icmp sgt i32 %conv, 0, !dbg !22 23 %conv1 = zext i1 %cmp to i32, !dbg !22 24 ret i32 0, !dbg !23 25} 26 27declare void @llvm.dbg.value(metadata, metadata, metadata) 28 29!llvm.dbg.cu = !{!2} 30!llvm.module.flags = !{!9, !10, !11} 31!llvm.ident = !{!12} 32 33!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 34!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true) 35!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None) 36!3 = !DIFile(filename: "test", directory: "n") 37!4 = !{} 38!5 = !{!0, !6} 39!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) 40!7 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true) 41!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) 42!9 = !{i32 2, !"Dwarf Version", i32 4} 43!10 = !{i32 2, !"Debug Info Version", i32 3} 44!11 = !{i32 1, !"wchar_size", i32 4} 45!12 = !{!"clang version 10.0.0"} 46!13 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 2, type: !14, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4) 47!14 = !DISubroutineType(types: !15) 48!15 = !{!16} 49!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 50!17 = !DILocation(line: 4, column: 11, scope: !13) 51!18 = !DILocalVariable(name: "c", scope: !13, file: !3, line: 4, type: !16) 52!19 = !DILocation(line: 0, scope: !13) 53!20 = !DILocalVariable(name: "l_1240", scope: !13, file: !3, line: 6, type: !16) 54!21 = !DILocation(line: 10, column: 10, scope: !13) 55!22 = !DILocation(line: 10, column: 5, scope: !13) 56!23 = !DILocation(line: 12, column: 1, scope: !13) 57