[PATCH] D129565: [NFC][Metadata] Change MDNode::operands()'s return type from op_range to ArrayRef<MDOperand>

Dawid Jurczak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 12 07:59:16 PDT 2022


yurai007 created this revision.
yurai007 added reviewers: dexonsmith, wolfgangp, nikic.
Herald added subscribers: jeroen.dobbelaere, hiraditya.
Herald added a project: All.
yurai007 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch is https://reviews.llvm.org/D129468 follow-up and address one of comment coming from that review: https://reviews.llvm.org/D129468#3643295


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129565

Files:
  llvm/include/llvm/IR/Metadata.h
  llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
  llvm/lib/Linker/IRMover.cpp


Index: llvm/lib/Linker/IRMover.cpp
===================================================================
--- llvm/lib/Linker/IRMover.cpp
+++ llvm/lib/Linker/IRMover.cpp
@@ -1362,8 +1362,10 @@
              "Expected MDTuple when appending module flags");
       if (DstValue->isDistinct())
         return dyn_cast<MDTuple>(DstValue);
+      ArrayRef<MDOperand> DstOperands = DstValue->operands();
       MDTuple *New = MDTuple::getDistinct(
-          DstM.getContext(), SmallVector<Metadata *, 4>(DstValue->operands()));
+          DstM.getContext(),
+          SmallVector<Metadata *, 4>(DstOperands.begin(), DstOperands.end()));
       Metadata *FlagOps[] = {DstOp->getOperand(0), ID, New};
       MDNode *Flag = MDTuple::getDistinct(DstM.getContext(), FlagOps);
       DstModFlags->setOperand(DstIndex, Flag);
Index: llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
+++ llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
@@ -811,7 +811,8 @@
     return nullptr;
 
   // Otherwise, create TBAA with the new Len
-  SmallVector<Metadata *, 4> NextNodes(MD->operands());
+  ArrayRef<MDOperand> MDOperands = MD->operands();
+  SmallVector<Metadata *, 4> NextNodes(MDOperands.begin(), MDOperands.end());
   ConstantInt *PreviousSize = mdconst::extract<ConstantInt>(NextNodes[3]);
 
   // Don't create a new MDNode if it is the same length.
Index: llvm/include/llvm/IR/Metadata.h
===================================================================
--- llvm/include/llvm/IR/Metadata.h
+++ llvm/include/llvm/IR/Metadata.h
@@ -1287,7 +1287,7 @@
     return const_cast<MDNode *>(this)->mutable_end();
   }
 
-  op_range operands() const { return op_range(op_begin(), op_end()); }
+  ArrayRef<MDOperand> operands() const { return getHeader().operands(); }
 
   const MDOperand &getOperand(unsigned I) const {
     assert(I < getNumOperands() && "Out of range");
@@ -1345,7 +1345,9 @@
                           StorageType Storage, bool ShouldCreate = true);
 
   TempMDTuple cloneImpl() const {
-    return getTemporary(getContext(), SmallVector<Metadata *, 4>(operands()));
+    ArrayRef<MDOperand> Operands = operands();
+    return getTemporary(getContext(), SmallVector<Metadata *, 4>(
+                                          Operands.begin(), Operands.end()));
   }
 
 public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129565.443942.patch
Type: text/x-patch
Size: 2384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220712/b7d14e2c/attachment.bin>


More information about the llvm-commits mailing list