Index: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp =================================================================== --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp @@ -1286,6 +1286,19 @@ } } + // Erase debug info intrinsics. Variable updates within the new function are + // invisible to debuggers. This could be improved by defining a DISubprogram + // for the new function. + for (BasicBlock &BB : *newFunction) { + auto BlockIt = BB.begin(); + while (BlockIt != BB.end()) { + Instruction *Inst = &*BlockIt; + ++BlockIt; + if (isa(Inst)) + Inst->eraseFromParent(); + } + } + LLVM_DEBUG(if (verifyFunction(*newFunction)) report_fatal_error("verifyFunction failed!")); return newFunction; Index: llvm/trunk/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll =================================================================== --- llvm/trunk/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll +++ llvm/trunk/test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll @@ -0,0 +1,51 @@ +; RUN: opt -hotcoldsplit -S < %s | FileCheck %s + +; CHECK-LABEL: define {{.*}}@foo_if.end +; CHECK-NOT: llvm.dbg.value + +define void @foo(i32 %arg1) !dbg !6 { +entry: + %var = add i32 0, 0, !dbg !11 + br i1 undef, label %if.then, label %if.end, !dbg !12 + +if.then: ; preds = %entry + unreachable, !dbg !13 + +if.end: ; preds = %entry + call void @llvm.dbg.value(metadata i32 %arg1, metadata !9, metadata !DIExpression()), !dbg !11 + br label %if.then12, !dbg !14 + +if.then12: ; preds = %if.end + br label %cleanup40, !dbg !15 + +cleanup40: ; preds = %if.then12 + br label %return, !dbg !16 + +return: ; preds = %cleanup40 + ret void, !dbg !17 +} + +declare void @llvm.dbg.value(metadata, metadata, metadata) + +!llvm.dbg.cu = !{!0} +!llvm.debugify = !{!3, !4} +!llvm.module.flags = !{!5} + +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) +!1 = !DIFile(filename: "", directory: "/") +!2 = !{} +!3 = !{i32 7} +!4 = !{i32 1} +!5 = !{i32 2, !"Debug Info Version", i32 3} +!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !8) +!7 = !DISubroutineType(types: !2) +!8 = !{!9} +!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10) +!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) +!11 = !DILocation(line: 1, column: 1, scope: !6) +!12 = !DILocation(line: 2, column: 1, scope: !6) +!13 = !DILocation(line: 3, column: 1, scope: !6) +!14 = !DILocation(line: 4, column: 1, scope: !6) +!15 = !DILocation(line: 5, column: 1, scope: !6) +!16 = !DILocation(line: 6, column: 1, scope: !6) +!17 = !DILocation(line: 7, column: 1, scope: !6)