1; RUN: opt -S -reassociate < %s | FileCheck %s 2 3; PR34231 4; 5; Verify that the original debug location is kept if the 6; replacement debug location is missing when 7; reassociating expressions. 8 9define i16 @fn1() !dbg !3 { 10 ret i16 undef 11} 12 13define void @fn2() !dbg !6 { 14; CHECK-LABEL: @fn2 15; CHECK: call i16 @fn1(), !dbg ![[LOC1:[0-9]+]] 16; CHECK-NOT: or i16 17 %inlinable_call = call i16 @fn1(), !dbg !7 18 %dbgless_instruction = or i16 %inlinable_call, 0 19 store i16 %dbgless_instruction, i16* undef, align 1 20 unreachable 21} 22 23define void @fn3() !dbg !8 { 24; CHECK-LABEL: @fn3 25; CHECK: load i16, i16* undef, !dbg ![[LOC2:[0-9]+]] 26; CHECK-NOT: or i16 27 %instruction = load i16, i16* undef, !dbg !9 28 %dbgless_instruction = or i16 %instruction, 0 29 store i16 %dbgless_instruction, i16* undef, align 1 30 unreachable 31} 32 33; CHECK: ![[LOC1]] = !DILocation(line: 7 34; CHECK: ![[LOC2]] = !DILocation(line: 9 35 36!llvm.dbg.cu = !{!0} 37!llvm.module.flags = !{!2} 38 39!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly) 40!1 = !DIFile(filename: "foo.c", directory: "/") 41!2 = !{i32 2, !"Debug Info Version", i32 3} 42!3 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 2, type: !4, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !0) 43!4 = !DISubroutineType(types: !5) 44!5 = !{} 45!6 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !4, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0) 46!7 = !DILocation(line: 7, column: 10, scope: !6) 47!8 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 8, type: !4, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0) 48!9 = !DILocation(line: 9, column: 10, scope: !8) 49