[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 09:07:46 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:

Perhaps - there might be performance concerns here though: allowing `BasicBlock::iterator` to be passed as an argument here would require `DebugProgramInstruction.h` to `#include "llvm/IR/Instruction.h"`, which _might_ impact performance (including `DebugInfoMetadata.h` here caused a `+2.10%` compile time increase entirely by itself!). I agree that we should probably take a BasicBlock::iterator if possible though; would you consider it acceptable to simply remove the `Instruction *InsertBefore` version (the `DPValue* InsertBefore` is the one that is actually _needed_ for these patches, this overload is optional) and add an iterator-taking version when/if it's confirmed to work, or some other workaround is established?

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


More information about the llvm-commits mailing list