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

Dawid Jurczak via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 08:23:06 PDT 2022


Author: Dawid Jurczak
Date: 2022-07-14T17:22:32+02:00
New Revision: d71128d97df9986e98c3d2b56e5629f5e36e4c45

URL: https://github.com/llvm/llvm-project/commit/d71128d97df9986e98c3d2b56e5629f5e36e4c45
DIFF: https://github.com/llvm/llvm-project/commit/d71128d97df9986e98c3d2b56e5629f5e36e4c45.diff

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

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

Differential Revision: https://reviews.llvm.org/D129565

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index ec769ce95160f..b90b895f32e88 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -1287,7 +1287,7 @@ class MDNode : public Metadata {
     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 @@ class MDTuple : public MDNode {
                           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:

diff  --git a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
index 560f46d39d0dc..216027778fab9 100644
--- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
@@ -303,7 +303,7 @@ class TBAAStructTypeNode {
   /// given offset. Update the offset to be relative to the field type.
   TBAAStructTypeNode getField(uint64_t &Offset) const {
     bool NewFormat = isNewFormat();
-    const ArrayRef<MDOperand> Operands(Node->op_begin(), Node->op_end());
+    const ArrayRef<MDOperand> Operands = Node->operands();
     const unsigned NumOperands = Operands.size();
 
     if (NewFormat) {
@@ -811,7 +811,8 @@ MDNode *AAMDNodes::extendToTBAA(MDNode *MD, ssize_t Len) {
     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.

diff  --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 9e89cce8312e3..7ccaba7e1c5c4 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1362,8 +1362,10 @@ Error IRLinker::linkModuleFlagsMetadata() {
              "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);


        


More information about the llvm-commits mailing list