mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[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
This commit is contained in:
parent
d8c8ff1f1e
commit
4d4e52ff5c
@ -284,20 +284,10 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
|
||||
// Add unreachable to now empty BB.
|
||||
new UnreachableInst(BB->getContext(), BB);
|
||||
|
||||
// Eliminate duplicate dbg.values describing the entry PHI node post-splice.
|
||||
for (auto Incoming : IncomingValues) {
|
||||
if (isa<Instruction>(*Incoming)) {
|
||||
SmallVector<DbgValueInst *, 2> DbgValues;
|
||||
SmallDenseSet<std::pair<DILocalVariable *, DIExpression *>, 2>
|
||||
DbgValueSet;
|
||||
llvm::findDbgValues(DbgValues, Incoming);
|
||||
for (auto &DVI : DbgValues) {
|
||||
auto R = DbgValueSet.insert({DVI->getVariable(), DVI->getExpression()});
|
||||
if (!R.second)
|
||||
DVI->eraseFromParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Eliminate duplicate/redundant dbg.values. This seems to be a good place to
|
||||
// do that since we might end up with redundant dbg.values describing the
|
||||
// entry PHI node post-splice.
|
||||
RemoveRedundantDbgInstrs(PredBB);
|
||||
|
||||
// Inherit predecessors name if it exists.
|
||||
if (!PredBB->hasName())
|
||||
|
@ -43,8 +43,8 @@ declare void @llvm.dbg.value(metadata, metadata, metadata) #1
|
||||
; CHECK: .loc [[CU2:[0-9]+]] 6 0
|
||||
; CHECK: Lfunc_begin1:
|
||||
; CHECK: .loc [[CU2]] 6 0
|
||||
; CHECK: //DEBUG_VALUE: baz:z <- {{[0-9]+}}
|
||||
; CHECK: //DEBUG_VALUE: baz:z <- {{[0-9]+}}
|
||||
; CHECK-NOT: //DEBUG_VALUE: baz:z
|
||||
; CHECK: //DEBUG_VALUE: baz:z <- undef
|
||||
; CHECK: .loc [[CU2]] 10 0
|
||||
; CHECK: ret;
|
||||
; CHECK: }
|
||||
|
@ -11,12 +11,10 @@ define dso_local i16 @main() local_unnamed_addr #0 !dbg !7 {
|
||||
; CHECK-NEXT: call void @llvm.dbg.value(metadata i16 [[TMP1]], metadata !12, metadata !DIExpression()), !dbg !13
|
||||
; CHECK-NEXT: [[TMP4:%.*]] = call i16 @wibble(i16 [[TMP1]]), !dbg !14
|
||||
; CHECK-NEXT: [[TMP5]] = add nsw i16 [[TMP4]], [[TMP1]], !dbg !14
|
||||
; CHECK-NEXT: call void @llvm.dbg.value(metadata i16 [[TMP5]], metadata !12, metadata !DIExpression()), !dbg !13
|
||||
; CHECK-NEXT: [[TMP6:%.*]] = call i16 @wibble(i16 [[TMP4]]), !dbg !14
|
||||
; CHECK-NEXT: [[TMP7:%.*]] = mul nsw i16 [[TMP6]], 3, !dbg !14
|
||||
; CHECK-NEXT: [[TMP8:%.*]] = call i16 @wibble(i16 [[TMP7]]), !dbg !14
|
||||
; BUG: This dbg.value is expected to be placed directly after the add above.
|
||||
; Otherwise variable "x" (!12) won't be described as having the correct value at the call to wibble just after the add.
|
||||
; CHECK-NEXT: call void @llvm.dbg.value(metadata i16 [[TMP5]], metadata !12, metadata !DIExpression()), !dbg !13
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i16 [[TMP5]], 17, !dbg !14
|
||||
; CHECK-NEXT: br i1 [[TMP2]], label [[BB2]], label [[BB3:%.*]], !dbg !14
|
||||
; CHECK: bb3:
|
||||
|
@ -8,7 +8,6 @@ init:
|
||||
|
||||
; CHECK: %vala = load i64, i64* %ptr
|
||||
; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %vala, metadata [[MD:![0-9]*]]
|
||||
; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %vala, metadata [[MD]]
|
||||
; CHECK-NEXT: %valbmasked = and i64 %vala, 1
|
||||
|
||||
a: ; preds = %init
|
||||
|
Loading…
Reference in New Issue
Block a user