Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h =================================================================== --- llvm/include/llvm/CodeGen/MachineBasicBlock.h +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h @@ -837,6 +837,10 @@ DebugLoc findDebugLoc(iterator MBBI) { return findDebugLoc(MBBI.getInstrIterator()); } + DebugLoc rfindDebugLoc(reverse_instr_iterator MBBI); + DebugLoc rfindDebugLoc(reverse_iterator MBBI) { + return rfindDebugLoc(MBBI.getInstrIterator()); + } /// Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE /// instructions. Return UnknownLoc if there is none. @@ -844,6 +848,10 @@ DebugLoc findPrevDebugLoc(iterator MBBI) { return findPrevDebugLoc(MBBI.getInstrIterator()); } + DebugLoc rfindPrevDebugLoc(reverse_instr_iterator MBBI); + DebugLoc rfindPrevDebugLoc(reverse_iterator MBBI) { + return rfindPrevDebugLoc(MBBI.getInstrIterator()); + } /// Find and return the merged DebugLoc of the branch instructions of the /// block. Return UnknownLoc if there is none. Index: llvm/lib/CodeGen/MachineBasicBlock.cpp =================================================================== --- llvm/lib/CodeGen/MachineBasicBlock.cpp +++ llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -1335,6 +1335,13 @@ return MBBI->getDebugLoc(); return {}; } +DebugLoc +MachineBasicBlock::rfindDebugLoc(reverse_instr_iterator MBBI) { + // Skip debug declarations, we don't want a DebugLoc from them. + MBBI = skipDebugInstructionsBackward(MBBI, instr_rbegin()); + if (!MBBI->isDebugInstr()) return MBBI->getDebugLoc(); + return {}; +} /// Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE /// instructions. Return UnknownLoc if there is none. @@ -1345,6 +1352,13 @@ if (!MBBI->isDebugInstr()) return MBBI->getDebugLoc(); return {}; } +DebugLoc MachineBasicBlock::rfindPrevDebugLoc(reverse_instr_iterator MBBI) { + // Skip debug declarations, we don't want a DebugLoc from them. + MBBI = skipDebugInstructionsForward(std::prev(MBBI), instr_rend()); + if (MBBI != instr_rend()) + return MBBI->getDebugLoc(); + return {}; +} /// Find and return the merged DebugLoc of the branch instructions of the block. /// Return UnknownLoc if there is none. Index: llvm/lib/CodeGen/MachineVerifier.cpp =================================================================== --- llvm/lib/CodeGen/MachineVerifier.cpp +++ llvm/lib/CodeGen/MachineVerifier.cpp @@ -1645,8 +1645,7 @@ if (MCOI.OperandType == MCOI::OPERAND_REGISTER && !MO->isReg() && !MO->isFI()) report("Expected a register operand.", MO, MONum); - if ((MCOI.OperandType == MCOI::OPERAND_IMMEDIATE || - MCOI.OperandType == MCOI::OPERAND_PCREL) && MO->isReg()) + if (MCOI.OperandType == MCOI::OPERAND_IMMEDIATE && MO->isReg()) report("Expected a non-register operand.", MO, MONum); }