[PATCH] D125994: [NFC] Define move and copy constructors and copy assignment operators for MDOperand.

Wolfgang Pieb via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 19 14:34:58 PDT 2022


wolfgangp added inline comments.


================
Comment at: llvm/include/llvm/IR/Metadata.h:782
+  }
+  MDOperand(const MDOperand &Op) {
+    MD = Op.MD;
----------------
dexonsmith wrote:
> I don’t think we need this and it seems better to error here. I think we should keep the copy constructor/operator deleted and make this move-only.
In that case I'm a bit stuck because the implementation of SmallVector uses std::fill_n() and std::uninitialized_fill_n() which assign and copy the value type and want the copy constructor (at least on gcc-9). Do you have any suggestions of should we roll our own hung-off storage class after all? 


================
Comment at: llvm/include/llvm/IR/Metadata.h:793
   }
   void reset(Metadata *MD, Metadata *Owner) {
     untrack();
----------------
dexonsmith wrote:
> Looking at this, is it even safe to use the standard move operators? Seems like you don’t have a way to pass in the owner…
IIUC (and I might be wrong there), only operands of uniqued nodes have an owner? Since we're only resizing non-uniqued nodes it seems it would probably work but how would one enforce the destination node always being non-uniqued?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125994/new/

https://reviews.llvm.org/D125994



More information about the llvm-commits mailing list