[llvm] [RemoveDIs][DebugInfo][NFC] Add Instruction and convenience functions to DPValue (PR #77896)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 12 08:10:38 PST 2024


================
@@ -41,6 +41,36 @@ DPValue::DPValue(Metadata *Location, DILocalVariable *DV, DIExpression *Expr,
 
 void DPValue::deleteInstr() { delete this; }
 
+DPValue *DPValue::createDPValue(Value *Location, DILocalVariable *DV,
+                                DIExpression *Expr, const DILocation *DI,
+                                Instruction *InsertBefore) {
+  auto *NewDPValue = new DPValue(ValueAsMetadata::get(Location), DV, Expr, DI,
+                                 LocationType::Value);
+  if (InsertBefore)
+    InsertBefore->getParent()->insertDPValueBefore(NewDPValue,
+                                                   InsertBefore->getIterator());
----------------
jmorse wrote:

Do you think it's worth having an iterator-taking version too, to match the equivalent insertBefore with BasicBlock::iterator? We don't do before-or-after debuginfo shenanigans here, but that might be necessary if you're looking to have source-equivalence between dbg.value and DPValue mode implementations of code.

https://github.com/llvm/llvm-project/pull/77896


More information about the llvm-commits mailing list