[LICM] Salvage DI from dying Instructions

LICM deletes trivially dead instructions which it won't attempt to sink.
Attempt to salvage debug values which reference these instructions.

llvm-svn: 327800
This commit is contained in:
Anastasis Grammenos 2018-03-18 15:59:19 +00:00
parent e6da3063a5
commit 3a589103a4
2 changed files with 5 additions and 0 deletions

View File

@ -393,6 +393,7 @@ bool llvm::sinkRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,
// used in the loop, instead, just delete it.
if (isInstructionTriviallyDead(&I, TLI)) {
DEBUG(dbgs() << "LICM deleting dead inst: " << I << '\n');
salvageDebugInfo(I);
++II;
CurAST->deleteValue(&I);
I.eraseFromParent();

View File

@ -1,4 +1,5 @@
; RUN: opt < %s -basicaa -licm -S | FileCheck %s
; RUN: opt < %s -debugify -basicaa -licm -S | FileCheck %s -check-prefix=DEBUGIFY
declare i32 @strlen(i8*) readonly nounwind
@ -249,6 +250,9 @@ Out:
; CHECK-LABEL: @test11(
; CHECK: Out:
; CHECK-NEXT: ret void
; DEBUGIFY-LABEL: @test11(
; DEBUGIFY: call void @llvm.dbg.value(metadata %Ty* @X2, metadata {{.*}}, metadata !DIExpression(DW_OP_stack_value))
}
@c = common global [1 x i32] zeroinitializer, align 4