diff options
author | Harald van Dijk <harald.vandijk@codeplay.com> | 2025-02-12 17:38:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-12 17:38:59 +0000 |
commit | 3ec9f7494b31f2fe51d5ed0e07adcf4b7199def6 (patch) | |
tree | 89381a101050af46d7df249b16cd0d2c41885810 /llvm/lib/Transforms/Utils/Local.cpp | |
parent | f8c7457c79eece1bd1b7f15e7679517c7c63ad89 (diff) | |
download | llvm-3ec9f7494b31f2fe51d5ed0e07adcf4b7199def6.zip llvm-3ec9f7494b31f2fe51d5ed0e07adcf4b7199def6.tar.gz llvm-3ec9f7494b31f2fe51d5ed0e07adcf4b7199def6.tar.bz2 |
[DebugInfo] Update DIBuilder insertion to take InsertPosition (#126059)
After #124287 updated several functions to return iterators rather than
Instruction *, it was no longer straightforward to pass their result to
DIBuilder. This commit updates DIBuilder methods to accept an
InsertPosition instead, so that they can be called with an iterator
(preferred), or with a deprecation warning an Instruction *, or a
BasicBlock *. This commit also updates the existing calls to the
DIBuilder methods to pass in iterators.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 2c63283..6d7c710 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1693,9 +1693,7 @@ static void insertDbgValueOrDbgVariableRecord(DIBuilder &Builder, Value *DV, const DebugLoc &NewLoc, BasicBlock::iterator Instr) { if (!UseNewDbgInfoFormat) { - auto DbgVal = Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc, - (Instruction *)nullptr); - cast<Instruction *>(DbgVal)->insertBefore(Instr); + Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, NewLoc, Instr); } else { // RemoveDIs: if we're using the new debug-info format, allocate a // DbgVariableRecord directly instead of a dbg.value intrinsic. @@ -1708,19 +1706,10 @@ 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) { + BasicBlock::iterator NextIt = std::next(Instr->getIterator()); + NextIt.setHeadBit(true); + insertDbgValueOrDbgVariableRecord(Builder, DV, DIVar, DIExpr, NewLoc, NextIt); } /// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value @@ -1812,7 +1801,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, // preferable to keep tracking both the loaded value and the original // address in case the alloca can not be elided. insertDbgValueOrDbgVariableRecordAfter(Builder, LI, DIVar, DIExpr, NewLoc, - LI->getIterator()); + LI); } void llvm::ConvertDebugDeclareToDebugValue(DbgVariableRecord *DVR, |