[clang] [llvm] [DebugInfo] Update DIBuilder insertion to take InsertPosition (PR #126059)
Jeremy Morse via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 7 08:07:36 PST 2025
================
@@ -1708,19 +1706,9 @@ static void insertDbgValueOrDbgVariableRecord(DIBuilder &Builder, Value *DV,
static void insertDbgValueOrDbgVariableRecordAfter(
DIBuilder &Builder, Value *DV, DILocalVariable *DIVar, DIExpression *DIExpr,
- const DebugLoc &NewLoc, BasicBlock::iterator Instr) {
- if (!UseNewDbgInfoFormat) {
- auto DbgVal = Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc,
- (Instruction *)nullptr);
- cast<Instruction *>(DbgVal)->insertAfter(Instr);
- } else {
- // RemoveDIs: if we're using the new debug-info format, allocate a
- // DbgVariableRecord directly instead of a dbg.value intrinsic.
- ValueAsMetadata *DVAM = ValueAsMetadata::get(DV);
- DbgVariableRecord *DV =
- new DbgVariableRecord(DVAM, DIVar, DIExpr, NewLoc.get());
- Instr->getParent()->insertDbgRecordAfter(DV, &*Instr);
- }
+ const DebugLoc &NewLoc, Instruction *Instr) {
+ insertDbgValueOrDbgVariableRecord(Builder, DV, DIVar, DIExpr, NewLoc,
+ std::next(Instr->getIterator()));
----------------
jmorse wrote:
I endorse the amount of red here; I believe we need to call `setHeadBit(true)` on the next-iterator though, to ensure that in sequences such as:
inst
#dbg_value
inst2
Inserting after `inst` will come before the pre-existing dbg_value, rather than after it.
https://github.com/llvm/llvm-project/pull/126059
More information about the cfe-commits
mailing list