llvm-mirror/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll
Bjorn Pettersson 4d4e52ff5c [BasicBlockUtils] Fix dbg.value elimination problem in MergeBlockIntoPredecessor
Summary:
In commit d60f34c20a2f31335c8d5626e (llvm-svn 317128,
PR35113) MergeBlockIntoPredecessor was changed into
discarding some dbg.value intrinsics referring to
PHI values, post-splice due to loop rotation.

That elimination of dbg.value intrinsics did not
consider which dbg.value to keep depending on the
context (e.g. if the variable is changing its value
several times inside the basic block).

In the past that hasn't been such a big problem since
CodeGenPrepare::placeDbgValues has moved the dbg.value
to be next to the PHI node anyway. But after commit
00e238896cd8ad3a7d7 CodeGenPrepare isn't doing that
any longer, so we need to be more careful when avoiding
duplicate dbg.value intrinsics in MergeBlockIntoPredecessor.

This patch replaces the code that tried to avoid duplicate
dbg.values by using the RemoveRedundantDbgInstrs helper.

Reviewers: aprantl, jmorse, vsk

Reviewed By: aprantl, vsk

Subscribers: jholewinski, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D71480
2019-12-16 11:41:21 +01:00

51 lines
2.2 KiB
LLVM

; RUN: opt -simplifycfg -S < %s | FileCheck %s
; Verify that we don't crash due an invalid !dbg location on the hoisted llvm.dbg.value
define i64 @caller(i64* %ptr, i64 %flag) !dbg !10 {
init:
%v9 = icmp eq i64 %flag, 0
br i1 %v9, label %a, label %b
; CHECK: %vala = load i64, i64* %ptr
; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %vala, metadata [[MD:![0-9]*]]
; CHECK-NEXT: %valbmasked = and i64 %vala, 1
a: ; preds = %init
%vala = load i64, i64* %ptr, align 8
call void @llvm.dbg.value(metadata i64 %vala, metadata !8, metadata !DIExpression()), !dbg !12
br label %test.exit
b: ; preds = %init
%valb = load i64, i64* %ptr, align 8
call void @llvm.dbg.value(metadata i64 %valb, metadata !8, metadata !DIExpression()), !dbg !13
%valbmasked = and i64 %valb, 1
br label %test.exit
test.exit: ; preds = %a, %b
%retv = phi i64 [ %vala, %a ], [ %valbmasked, %b ]
ret i64 %retv
}
; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.value(metadata, metadata, metadata) #0
attributes #0 = { nounwind readnone speculatable }
!llvm.module.flags = !{!0}
!llvm.dbg.cu = !{!1}
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !3)
!2 = !DIFile(filename: "optbug", directory: "")
!3 = !{}
!4 = distinct !DISubprogram(name: "callee", scope: !2, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !1, retainedNodes: !7)
!5 = !DISubroutineType(types: !6)
!6 = !{null}
!7 = !{!8}
!8 = !DILocalVariable(name: "var", scope: !4, file: !2, type: !9)
!9 = !DIBasicType(name: "var_t", size: 64, encoding: DW_ATE_unsigned)
!10 = distinct !DISubprogram(name: "caller", scope: !2, file: !2, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, isOptimized: false, unit: !1, retainedNodes: !3)
!11 = distinct !DILocation(line: 6, scope: !10)
!12 = !DILocation(line: 2, scope: !4, inlinedAt: !11)
!13 = !DILocation(line: 3, scope: !4, inlinedAt: !11)