Index: lib/Transforms/Scalar/LICM.cpp =================================================================== --- lib/Transforms/Scalar/LICM.cpp +++ lib/Transforms/Scalar/LICM.cpp @@ -393,6 +393,7 @@ // 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(); Index: test/Transforms/LICM/sinking.ll =================================================================== --- test/Transforms/LICM/sinking.ll +++ test/Transforms/LICM/sinking.ll @@ -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 @@ ; CHECK-LABEL: @test11( ; CHECK: Out: ; CHECK-NEXT: ret void + +; DEBUGIFY-LABEL: @PR18753( +; DEBUGIFY: call void @llvm.dbg.value(metadata i32 %l.le, metadata {{.*}}, metadata !DIExpression()) } @c = common global [1 x i32] zeroinitializer, align 4