From 0aa201eaf97681f59b72baee6552aa1b9b5c9129 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Wed, 27 May 2020 13:13:13 -0700 Subject: [PATCH] [MachineLICM] Assert that locations from debug insts are not lost Summary: Assert that MachineLICM does not move a debug instruction and then drop its debug location. Later passes require each debug instruction to have a location. Testing: check-llvm, clang stage2 RelWithDebInfo build (x86_64) Reviewers: aprantl, davide, chrisjackson, jmorse Subscribers: hiraditya, asbirlea, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80665 --- llvm/lib/CodeGen/MachineLICM.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp index 2a60858b6de2..98638b9fa737 100644 --- a/llvm/lib/CodeGen/MachineLICM.cpp +++ b/llvm/lib/CodeGen/MachineLICM.cpp @@ -638,6 +638,7 @@ void MachineLICMBase::HoistPostRA(MachineInstr *MI, unsigned Def) { // Since we are moving the instruction out of its basic block, we do not // retain its debug location. Doing so would degrade the debugging // experience and adversely affect the accuracy of profiling information. + assert(!MI->isDebugInstr() && "Should not hoist debug inst"); MI->setDebugLoc(DebugLoc()); // Add register to livein list to all the BBs in the current loop since a @@ -841,6 +842,7 @@ void MachineLICMBase::SinkIntoLoop() { // The instruction is is moved from its basic block, so do not retain the // debug information. + assert(!I->isDebugInstr() && "Should not sink debug inst"); I->setDebugLoc(DebugLoc()); } } @@ -1536,6 +1538,7 @@ bool MachineLICMBase::Hoist(MachineInstr *MI, MachineBasicBlock *Preheader) { // Since we are moving the instruction out of its basic block, we do not // retain its debug location. Doing so would degrade the debugging // experience and adversely affect the accuracy of profiling information. + assert(!MI->isDebugInstr() && "Should not hoist debug inst"); MI->setDebugLoc(DebugLoc()); // Update register pressure for BBs from header to this block.