diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp --- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp @@ -1136,6 +1136,8 @@ LLVM_DEBUG(dbgs() << "Skipping due to debug counter\n"); continue; } + //Salvage debug info early to be compatible with removeRedundantDbgInstrsUsingBackwardScan(). + salvageDebugInfoOrMarkUndef(Inst); if (!Inst.use_empty()) Inst.replaceAllUsesWith(Op); salvageKnowledge(&Inst, &AC);