[llvm] [RemoveDIs][DebugInfo] Add DPVAssign variant of DPValue (PR #77912)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 15 00:58:46 PST 2024


================
@@ -152,26 +152,47 @@ DPValue *DebugValueUser::getUser() { return static_cast<DPValue *>(this); }
 const DPValue *DebugValueUser::getUser() const {
   return static_cast<const DPValue *>(this);
 }
-void DebugValueUser::handleChangedValue(Metadata *NewMD) {
-  getUser()->handleChangedLocation(NewMD);
+
+void DebugValueUser::handleChangedValue(void *Old, Metadata *New) {
+  // NOTE: We could inform the "owner" that a value has changed through
+  // getOwner, if needed.
+  auto OldMD = static_cast<Metadata **>(Old);
+  ptrdiff_t Idx = std::distance(DebugValues.begin(), OldMD);
+  resetDebugValue(Idx, New);
----------------
jmorse wrote:

Hmmm, are there any alternatives to this? The method name and signature feel mismatched with what it does, in that calling this function will replace _a_ Old/New metadata pair, but possibly not the one that the caller expected.

To be clear, the code is fine, it's the risk of someone reading this and either being confused or having an incorrect understanding that I worry about.

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


More information about the llvm-commits mailing list