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

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 12 10:26:12 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());
----------------
SLTozer wrote:

I tried that first, but Instruction.h defines a template specialization for Instruction, so unfortunately the predeclaration doesn't work.

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


More information about the llvm-commits mailing list