[PATCH] D125998: [Metadata] Add a resize capability to MDNodes and add a push_back interface to MDNodes.

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 12:33:22 PDT 2022


dexonsmith added inline comments.


================
Comment at: llvm/include/llvm/IR/Metadata.h:1222
 
+  void resize(size_t NumOps) {
+    assert(getMetadataID() == MDTupleKind &&
----------------
It’d be good to have a header comment explaining when it’s legal to resize. 


================
Comment at: llvm/lib/IR/Metadata.cpp:579
+    getLarge().resize(NumOps);
+  } else {
+    setSmallNumOps(NumOps);
----------------
Nit: you can reduce nesting by returning early here. 


================
Comment at: llvm/lib/IR/Metadata.cpp:590
+    getLarge().~LargeStorageVector();
+  } else {
+    MDOperand *O = reinterpret_cast<MDOperand *>(this);
----------------
Nit: you can reduce nesting by returning early inside the `if` and skipping the `else`. 


================
Comment at: llvm/unittests/IR/MetadataTest.cpp:3663
+  for (int i = 0; i < 11; i++)
+    Temp1->push_back(Value2);
+  EXPECT_EQ(Temp1->getNumOperands(), 12u);
----------------
Is this enough to exceed small size? If not, it’s be good to add one that does.


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

https://reviews.llvm.org/D125998



More information about the llvm-commits mailing list