1; RUN: opt < %s -reassociate -S | FileCheck %s 2 3; Check that reassociate pass now salvages debug info when dropping instructions. 4 5define hidden i32 @main(i32 %argc, i8** %argv) { 6entry: 7 ; CHECK: call void @llvm.dbg.value(metadata i32 %argc, metadata [[VAR_B:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value)) 8 %add = add nsw i32 %argc, 1, !dbg !26 9 call void @llvm.dbg.value(metadata i32 %add, metadata !22, metadata !DIExpression()), !dbg !25 10 %add1 = add nsw i32 %argc, %add, !dbg !27 11 ret i32 %add1, !dbg !28 12} 13 14declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 15declare void @llvm.dbg.value(metadata, metadata, metadata) #1 16 17!llvm.dbg.cu = !{!0} 18!llvm.module.flags = !{!3, !4, !5, !6} 19!llvm.ident = !{!7} 20 21!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, debugInfoForProfiling: true, nameTableKind: None) 22!1 = !DIFile(filename: "test2.cpp", directory: "C:\") 23!2 = !{} 24!3 = !{i32 2, !"Dwarf Version", i32 4} 25!4 = !{i32 2, !"Debug Info Version", i32 3} 26!5 = !{i32 1, !"wchar_size", i32 2} 27!6 = !{i32 7, !"PIC Level", i32 2} 28!7 = !{!"clang version 10.0.0"} 29!8 = distinct !DISubprogram(name: "main", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !18) 30!9 = !DIFile(filename: "./test2.cpp", directory: "C:\") 31!10 = !DISubroutineType(types: !11) 32!11 = !{!12, !13, !14} 33!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 34!13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !12) 35!14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 64) 36!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64) 37!16 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !17) 38!17 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) 39!18 = !{!19, !20, !21, !22, !23, !24} 40!19 = !DILocalVariable(name: "argc", arg: 1, scope: !8, file: !9, line: 1, type: !13) 41!20 = !DILocalVariable(name: "argv", arg: 2, scope: !8, file: !9, line: 1, type: !14) 42!21 = !DILocalVariable(name: "a", scope: !8, file: !9, line: 2, type: !12) 43; CHECK: [[VAR_B]] = !DILocalVariable(name: "b" 44!22 = !DILocalVariable(name: "b", scope: !8, file: !9, line: 3, type: !12) 45!23 = !DILocalVariable(name: "to_return", scope: !8, file: !9, line: 4, type: !12) 46!24 = !DILocalVariable(name: "result", scope: !8, file: !9, line: 5, type: !12) 47!25 = !DILocation(line: 0, scope: !8) 48!26 = !DILocation(line: 3, scope: !8) 49!27 = !DILocation(line: 4, scope: !8) 50!28 = !DILocation(line: 6, scope: !8) 51