[Mlir-commits] [mlir] a288d7f - [llvm][ADT] Replace uses of `makeMutableArrayRef` with deduction guides

Joe Loser llvmlistbot at llvm.org
Mon Jan 16 13:51:03 PST 2023


Author: Joe Loser
Date: 2023-01-16T14:49:37-07:00
New Revision: a288d7f937708cf67d960962bfa22ffae37ddbf4

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

LOG: [llvm][ADT] Replace uses of `makeMutableArrayRef` with deduction guides

Similar to how `makeArrayRef` is deprecated in favor of deduction guides, do the
same for `makeMutableArrayRef`.

Once all of the places in-tree are using the deduction guides for
`MutableArrayRef`, we can mark `makeMutableArrayRef` as deprecated.

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

Added: 
    

Modified: 
    bolt/lib/Profile/DataAggregator.cpp
    clang-tools-extra/clangd/FuzzyMatch.cpp
    clang-tools-extra/clangd/SemanticSelection.cpp
    clang-tools-extra/clangd/index/dex/Trigram.cpp
    clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
    clang/include/clang/AST/DeclOpenMP.h
    clang/include/clang/AST/OpenMPClause.h
    clang/include/clang/AST/StmtOpenMP.h
    clang/include/clang/Lex/MacroInfo.h
    clang/lib/AST/StmtOpenMP.cpp
    lld/COFF/Chunks.cpp
    lld/COFF/DebugTypes.cpp
    lld/COFF/Writer.cpp
    lld/ELF/InputFiles.h
    lld/ELF/SyntheticSections.cpp
    lldb/source/Host/common/NativeProcessProtocol.cpp
    llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
    llvm/include/llvm/IR/DataLayout.h
    llvm/include/llvm/IR/Metadata.h
    llvm/include/llvm/ProfileData/InstrProf.h
    llvm/include/llvm/Support/Parallel.h
    llvm/lib/Analysis/ConstantFolding.cpp
    llvm/lib/ExecutionEngine/ExecutionEngine.cpp
    llvm/lib/Support/Path.cpp
    llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
    llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
    llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
    llvm/unittests/Support/Path.cpp
    mlir/lib/Bytecode/Writer/IRNumbering.cpp
    mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
    mlir/test/mlir-tblgen/constraint-unique.td
    mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 
    


################################################################################
diff  --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp
index b320b445f0909..8ff553af4e100 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -336,7 +336,7 @@ bool DataAggregator::checkPerfDataMagic(StringRef FileName) {
 
   auto Close = make_scope_exit([&] { sys::fs::closeFile(*FD); });
   Expected<size_t> BytesRead = sys::fs::readNativeFileSlice(
-      *FD, makeMutableArrayRef(Buf, sizeof(Buf)), 0);
+      *FD, MutableArrayRef(Buf, sizeof(Buf)), 0);
   if (!BytesRead) {
     consumeError(BytesRead.takeError());
     return false;

diff  --git a/clang-tools-extra/clangd/FuzzyMatch.cpp b/clang-tools-extra/clangd/FuzzyMatch.cpp
index 82b8ad0f9527d..de7280d80361d 100644
--- a/clang-tools-extra/clangd/FuzzyMatch.cpp
+++ b/clang-tools-extra/clangd/FuzzyMatch.cpp
@@ -86,7 +86,7 @@ FuzzyMatcher::FuzzyMatcher(llvm::StringRef Pattern)
       for (Action A : {Miss, Match})
         Scores[P][W][A] = {AwfulScore, Miss};
   PatTypeSet = calculateRoles(llvm::StringRef(Pat, PatN),
-                              llvm::makeMutableArrayRef(PatRole, PatN));
+                              llvm::MutableArrayRef(PatRole, PatN));
 }
 
 std::optional<float> FuzzyMatcher::match(llvm::StringRef Word) {
@@ -200,7 +200,7 @@ bool FuzzyMatcher::init(llvm::StringRef NewWord) {
   // e.g. vsprintf is V S Print F, and should match [pri] but not [int].
   // We could add a tokenization dictionary for common stdlib names.
   WordTypeSet = calculateRoles(llvm::StringRef(Word, WordN),
-                               llvm::makeMutableArrayRef(WordRole, WordN));
+                               llvm::MutableArrayRef(WordRole, WordN));
   return true;
 }
 

diff  --git a/clang-tools-extra/clangd/SemanticSelection.cpp b/clang-tools-extra/clangd/SemanticSelection.cpp
index b3f3d2856d7ab..3d687173b2be9 100644
--- a/clang-tools-extra/clangd/SemanticSelection.cpp
+++ b/clang-tools-extra/clangd/SemanticSelection.cpp
@@ -154,7 +154,7 @@ llvm::Expected<SelectionRange> getSemanticRanges(ParsedAST &AST, Position Pos) {
   Head.range = std::move(Ranges.front());
   SelectionRange *Tail = &Head;
   for (auto &Range :
-       llvm::makeMutableArrayRef(Ranges.data(), Ranges.size()).drop_front()) {
+       llvm::MutableArrayRef(Ranges.data(), Ranges.size()).drop_front()) {
     Tail->parent = std::make_unique<SelectionRange>();
     Tail = Tail->parent.get();
     Tail->range = std::move(Range);

diff  --git a/clang-tools-extra/clangd/index/dex/Trigram.cpp b/clang-tools-extra/clangd/index/dex/Trigram.cpp
index 2cf33d551a254..c52af4e275a42 100644
--- a/clang-tools-extra/clangd/index/dex/Trigram.cpp
+++ b/clang-tools-extra/clangd/index/dex/Trigram.cpp
@@ -32,7 +32,7 @@ static void identifierTrigrams(llvm::StringRef Identifier, Func Out) {
   // Apply fuzzy matching text segmentation.
   llvm::SmallVector<CharRole> Roles(Identifier.size());
   calculateRoles(Identifier,
-                 llvm::makeMutableArrayRef(Roles.data(), Identifier.size()));
+                 llvm::MutableArrayRef(Roles.data(), Identifier.size()));
 
   std::string LowercaseIdentifier = Identifier.lower();
 
@@ -126,7 +126,7 @@ std::vector<Token> generateQueryTrigrams(llvm::StringRef Query) {
 
   // Apply fuzzy matching text segmentation.
   llvm::SmallVector<CharRole> Roles(Query.size());
-  calculateRoles(Query, llvm::makeMutableArrayRef(Roles.data(), Query.size()));
+  calculateRoles(Query, llvm::MutableArrayRef(Roles.data(), Query.size()));
 
   std::string LowercaseQuery = Query.lower();
 

diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h b/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
index 691acacdbb525..e9edb40e02b64 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
@@ -142,8 +142,8 @@ class alignas(class ForestNode *) ForestNode {
     return llvm::ArrayRef(reinterpret_cast<ForestNode *const *>(this + 1), Num);
   }
   llvm::MutableArrayRef<ForestNode *> children(uint16_t Num) {
-    return llvm::makeMutableArrayRef(reinterpret_cast<ForestNode **>(this + 1),
-                                     Num);
+    return llvm::MutableArrayRef(reinterpret_cast<ForestNode **>(this + 1),
+                                 Num);
   }
 
   Token::Index StartIndex;

diff  --git a/clang/include/clang/AST/DeclOpenMP.h b/clang/include/clang/AST/DeclOpenMP.h
index 30b5a92293b9c..dd63a4f5d680c 100644
--- a/clang/include/clang/AST/DeclOpenMP.h
+++ b/clang/include/clang/AST/DeclOpenMP.h
@@ -123,7 +123,7 @@ class OMPThreadPrivateDecl final : public OMPDeclarativeDirective<Decl> {
 
   MutableArrayRef<Expr *> getVars() {
     auto **Storage = reinterpret_cast<Expr **>(Data->getChildren().data());
-    return llvm::makeMutableArrayRef(Storage, Data->getNumChildren());
+    return llvm::MutableArrayRef(Storage, Data->getNumChildren());
   }
 
   void setVars(ArrayRef<Expr *> VL);
@@ -486,7 +486,7 @@ class OMPAllocateDecl final : public OMPDeclarativeDirective<Decl> {
 
   MutableArrayRef<Expr *> getVars() {
     auto **Storage = reinterpret_cast<Expr **>(Data->getChildren().data());
-    return llvm::makeMutableArrayRef(Storage, Data->getNumChildren());
+    return llvm::MutableArrayRef(Storage, Data->getNumChildren());
   }
 
   void setVars(ArrayRef<Expr *> VL);

diff  --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h
index f37da2dd707ad..47644c93bd426 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -5425,7 +5425,7 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
   MutableArrayRef<Expr *> getUDMapperRefs() {
     assert(SupportsMapper &&
            "Must be a clause that is possible to have user-defined mappers");
-    return llvm::makeMutableArrayRef<Expr *>(
+    return llvm::MutableArrayRef<Expr *>(
         static_cast<T *>(this)->template getTrailingObjects<Expr *>() +
             OMPVarListClause<T>::varlist_size(),
         OMPVarListClause<T>::varlist_size());
@@ -8920,7 +8920,7 @@ class OMPChildren final
 
   /// Get the clauses storage.
   MutableArrayRef<OMPClause *> getClauses() {
-    return llvm::makeMutableArrayRef(getTrailingObjects<OMPClause *>(),
+    return llvm::MutableArrayRef(getTrailingObjects<OMPClause *>(),
                                      NumClauses);
   }
   ArrayRef<OMPClause *> getClauses() const {

diff  --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h
index c4dd196a2e805..2d37fdbf4ca8f 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -1067,7 +1067,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
   MutableArrayRef<Expr *> getCounters() {
     auto **Storage = reinterpret_cast<Expr **>(
         &Data->getChildren()[getArraysOffset(getDirectiveKind())]);
-    return llvm::makeMutableArrayRef(Storage, getLoopsNumber());
+    return llvm::MutableArrayRef(Storage, getLoopsNumber());
   }
 
   /// Get the private counters storage.
@@ -1075,7 +1075,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
     auto **Storage = reinterpret_cast<Expr **>(
         &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
                              getLoopsNumber()]);
-    return llvm::makeMutableArrayRef(Storage, getLoopsNumber());
+    return llvm::MutableArrayRef(Storage, getLoopsNumber());
   }
 
   /// Get the updates storage.
@@ -1083,7 +1083,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
     auto **Storage = reinterpret_cast<Expr **>(
         &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
                              2 * getLoopsNumber()]);
-    return llvm::makeMutableArrayRef(Storage, getLoopsNumber());
+    return llvm::MutableArrayRef(Storage, getLoopsNumber());
   }
 
   /// Get the updates storage.
@@ -1091,7 +1091,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
     auto **Storage = reinterpret_cast<Expr **>(
         &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
                              3 * getLoopsNumber()]);
-    return llvm::makeMutableArrayRef(Storage, getLoopsNumber());
+    return llvm::MutableArrayRef(Storage, getLoopsNumber());
   }
 
   /// Get the final counter updates storage.
@@ -1099,7 +1099,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
     auto **Storage = reinterpret_cast<Expr **>(
         &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
                              4 * getLoopsNumber()]);
-    return llvm::makeMutableArrayRef(Storage, getLoopsNumber());
+    return llvm::MutableArrayRef(Storage, getLoopsNumber());
   }
 
   /// Get the dependent counters storage.
@@ -1107,7 +1107,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
     auto **Storage = reinterpret_cast<Expr **>(
         &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
                              5 * getLoopsNumber()]);
-    return llvm::makeMutableArrayRef(Storage, getLoopsNumber());
+    return llvm::MutableArrayRef(Storage, getLoopsNumber());
   }
 
   /// Get the dependent inits storage.
@@ -1115,7 +1115,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
     auto **Storage = reinterpret_cast<Expr **>(
         &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
                              6 * getLoopsNumber()]);
-    return llvm::makeMutableArrayRef(Storage, getLoopsNumber());
+    return llvm::MutableArrayRef(Storage, getLoopsNumber());
   }
 
   /// Get the finals conditions storage.
@@ -1123,7 +1123,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
     auto **Storage = reinterpret_cast<Expr **>(
         &Data->getChildren()[getArraysOffset(getDirectiveKind()) +
                              7 * getLoopsNumber()]);
-    return llvm::makeMutableArrayRef(Storage, getLoopsNumber());
+    return llvm::MutableArrayRef(Storage, getLoopsNumber());
   }
 
 protected:

diff  --git a/clang/include/clang/Lex/MacroInfo.h b/clang/include/clang/Lex/MacroInfo.h
index feb41e43e3183..75c9ca70dfbbf 100644
--- a/clang/include/clang/Lex/MacroInfo.h
+++ b/clang/include/clang/Lex/MacroInfo.h
@@ -257,7 +257,7 @@ class MacroInfo {
     NumReplacementTokens = NumTokens;
     Token *NewReplacementTokens = PPAllocator.Allocate<Token>(NumTokens);
     ReplacementTokens = NewReplacementTokens;
-    return llvm::makeMutableArrayRef(NewReplacementTokens, NumTokens);
+    return llvm::MutableArrayRef(NewReplacementTokens, NumTokens);
   }
 
   void setTokens(ArrayRef<Token> Tokens, llvm::BumpPtrAllocator &PPAllocator) {

diff  --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp
index 9e39930130acc..7c5b9f23fc260 100644
--- a/clang/lib/AST/StmtOpenMP.cpp
+++ b/clang/lib/AST/StmtOpenMP.cpp
@@ -31,7 +31,7 @@ void OMPChildren::setClauses(ArrayRef<OMPClause *> Clauses) {
 }
 
 MutableArrayRef<Stmt *> OMPChildren::getChildren() {
-  return llvm::makeMutableArrayRef(getTrailingObjects<Stmt *>(), NumChildren);
+  return llvm::MutableArrayRef(getTrailingObjects<Stmt *>(), NumChildren);
 }
 
 OMPChildren *OMPChildren::Create(void *Mem, ArrayRef<OMPClause *> Clauses) {

diff  --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index 01405879ae0ec..65de868a5ffd7 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -870,7 +870,7 @@ void RVAFlagTableChunk::writeTo(uint8_t *buf) const {
     uint8_t flag;
   };
   auto flags =
-      makeMutableArrayRef(reinterpret_cast<RVAFlag *>(buf), syms.size());
+      MutableArrayRef(reinterpret_cast<RVAFlag *>(buf), syms.size());
   for (auto t : zip(syms, flags)) {
     const auto &sym = std::get<0>(t);
     auto &flag = std::get<1>(t);

diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 274284f349051..7bbce84b2d548 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -642,7 +642,7 @@ void TpiSource::mergeTypeRecord(TypeIndex curIndex, CVType ty) {
   size_t offset = merged.recs.size();
   size_t newSize = alignTo(ty.length(), 4);
   merged.recs.resize(offset + newSize);
-  auto newRec = makeMutableArrayRef(&merged.recs[offset], newSize);
+  auto newRec = MutableArrayRef(&merged.recs[offset], newSize);
   memcpy(newRec.data(), ty.data().data(), newSize);
 
   // Fix up the record prefix and padding bytes if it required resizing.

diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index f1766a4cddf8b..a8fc38c5fa3e5 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -498,11 +498,11 @@ bool Writer::createThunks(OutputSection *os, int margin) {
     ArrayRef<coff_relocation> curRelocs = sc->getRelocs();
     MutableArrayRef<coff_relocation> newRelocs;
     if (originalRelocs.data() == curRelocs.data()) {
-      newRelocs = makeMutableArrayRef(
+      newRelocs = MutableArrayRef(
           bAlloc().Allocate<coff_relocation>(originalRelocs.size()),
           originalRelocs.size());
     } else {
-      newRelocs = makeMutableArrayRef(
+      newRelocs = MutableArrayRef(
           const_cast<coff_relocation *>(curRelocs.data()), curRelocs.size());
     }
 

diff  --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index 2b2f2c8fe7d25..421ea6ed1a8ed 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -181,7 +181,7 @@ class ELFFileBase : public InputFile {
                           numSymbols - firstGlobal);
   }
   MutableArrayRef<Symbol *> getMutableGlobalSymbols() {
-    return llvm::makeMutableArrayRef(symbols.get() + firstGlobal,
+    return llvm::MutableArrayRef(symbols.get() + firstGlobal,
                                      numSymbols - firstGlobal);
   }
 

diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index b0ba9c219780b..e7c437bc76535 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2818,7 +2818,7 @@ createSymbols(
   SmallVector<GdbSymbol, 0> ret;
   ret.reserve(numSymbols);
   for (SmallVector<GdbSymbol, 0> &vec :
-       makeMutableArrayRef(symbols.get(), numShards))
+       MutableArrayRef(symbols.get(), numShards))
     for (GdbSymbol &sym : vec)
       ret.push_back(std::move(sym));
 

diff  --git a/lldb/source/Host/common/NativeProcessProtocol.cpp b/lldb/source/Host/common/NativeProcessProtocol.cpp
index 590aba11d8335..975b3d0f7d533 100644
--- a/lldb/source/Host/common/NativeProcessProtocol.cpp
+++ b/lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -649,8 +649,7 @@ Status NativeProcessProtocol::ReadMemoryWithoutTrap(lldb::addr_t addr,
   if (error.Fail())
     return error;
 
-  auto data =
-      llvm::makeMutableArrayRef(static_cast<uint8_t *>(buf), bytes_read);
+  llvm::MutableArrayRef data(static_cast<uint8_t *>(buf), bytes_read);
   for (const auto &pair : m_software_breakpoints) {
     lldb::addr_t bp_addr = pair.first;
     auto saved_opcodes = llvm::ArrayRef(pair.second.saved_opcodes);

diff  --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
index e01aa412c6536..e65b193ffc861 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
@@ -187,7 +187,7 @@ class DWARFUnitIndex {
   }
 
   MutableArrayRef<Entry> getMutableRows() {
-    return makeMutableArrayRef(Rows.get(), Header.NumBuckets);
+    return MutableArrayRef(Rows.get(), Header.NumBuckets);
   }
 };
 

diff  --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h
index ff3f2b211fc2b..d6bfd213a3871 100644
--- a/llvm/include/llvm/IR/DataLayout.h
+++ b/llvm/include/llvm/IR/DataLayout.h
@@ -643,7 +643,7 @@ class StructLayout final : public TrailingObjects<StructLayout, uint64_t> {
   unsigned getElementContainingOffset(uint64_t Offset) const;
 
   MutableArrayRef<uint64_t> getMemberOffsets() {
-    return llvm::makeMutableArrayRef(getTrailingObjects<uint64_t>(),
+    return llvm::MutableArrayRef(getTrailingObjects<uint64_t>(),
                                      NumElements);
   }
 

diff  --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index 9e71c18c6f25f..954681e241564 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -1027,7 +1027,7 @@ class MDNode : public Metadata {
     MutableArrayRef<MDOperand> operands() {
       if (IsLarge)
         return getLarge();
-      return makeMutableArrayRef(
+      return MutableArrayRef(
           reinterpret_cast<MDOperand *>(this) - SmallSize, SmallNumOps);
     }
 

diff  --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index eba7885e83b7a..26c15b1fe8608 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -862,7 +862,7 @@ struct InstrProfRecord {
     // cast away the constness from the result.
     auto AR = const_cast<const InstrProfRecord *>(this)->getValueSitesForKind(
         ValueKind);
-    return makeMutableArrayRef(
+    return MutableArrayRef(
         const_cast<InstrProfValueSiteRecord *>(AR.data()), AR.size());
   }
   ArrayRef<InstrProfValueSiteRecord>

diff  --git a/llvm/include/llvm/Support/Parallel.h b/llvm/include/llvm/Support/Parallel.h
index 4500b93b130b8..219197c4eb296 100644
--- a/llvm/include/llvm/Support/Parallel.h
+++ b/llvm/include/llvm/Support/Parallel.h
@@ -203,7 +203,7 @@ ResultTy parallel_transform_reduce(IterTy Begin, IterTy End, ResultTy Init,
   // reductions are cheaper than the transformation.
   ResultTy FinalResult = std::move(Results.front());
   for (ResultTy &PartialResult :
-       makeMutableArrayRef(Results.data() + 1, Results.size() - 1))
+       MutableArrayRef(Results.data() + 1, Results.size() - 1))
     FinalResult = Reduce(FinalResult, std::move(PartialResult));
   return std::move(FinalResult);
 }

diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 3f8cd86cb2c2e..6a2d6ba767e7a 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1867,7 +1867,7 @@ Constant *ConstantFoldSSEConvertToInt(const APFloat &Val, bool roundTowardZero,
   APFloat::roundingMode mode = roundTowardZero? APFloat::rmTowardZero
                                               : APFloat::rmNearestTiesToEven;
   APFloat::opStatus status =
-      Val.convertToInteger(makeMutableArrayRef(UIntVal), ResultWidth,
+      Val.convertToInteger(MutableArrayRef(UIntVal), ResultWidth,
                            IsSigned, mode, &isExact);
   if (status != APFloat::opOK &&
       (!roundTowardZero || status != APFloat::opInexact))

diff  --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index a2b71d9502259..2a90b67bee4b5 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -719,7 +719,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
         APFloat apf = APFloat(APFloat::x87DoubleExtended(), GV.IntVal);
         uint64_t v;
         bool ignored;
-        (void)apf.convertToInteger(makeMutableArrayRef(v), BitWidth,
+        (void)apf.convertToInteger(MutableArrayRef(v), BitWidth,
                                    CE->getOpcode()==Instruction::FPToSI,
                                    APFloat::rmTowardZero, &ignored);
         GV.IntVal = v; // endian?

diff  --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index 0ffc07d68f6ef..152d902f52e67 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -1181,7 +1181,7 @@ Error readNativeFileToEOF(file_t FileHandle, SmallVectorImpl<char> &Buffer,
   for (;;) {
     Buffer.resize_for_overwrite(Size + ChunkSize);
     Expected<size_t> ReadBytes = readNativeFile(
-        FileHandle, makeMutableArrayRef(Buffer.begin() + Size, ChunkSize));
+        FileHandle, MutableArrayRef(Buffer.begin() + Size, ChunkSize));
     if (!ReadBytes)
       return ReadBytes.takeError();
     if (*ReadBytes == 0)

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
index 302889f8ffe49..514b3238547c8 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
@@ -3081,7 +3081,7 @@ void AMDGPULegalizerInfo::buildMultiply(
       } else {
         bool IsHighest = 2 * i >= Accum.size();
         Register SeparateOddOut[2];
-        auto LocalAccum = makeMutableArrayRef(SeparateOddOut)
+        auto LocalAccum = MutableArrayRef(SeparateOddOut)
                               .take_front(IsHighest ? 1 : 2);
         OddCarry = buildMadChain(LocalAccum, 2 * i - 1, OddCarryIn);
 

diff  --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index af665d909f4f4..afc78e2255929 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -195,7 +195,7 @@ static bool ConvertToSInt(const APFloat &APF, int64_t &IntVal) {
   bool isExact = false;
   // See if we can convert this to an int64_t
   uint64_t UIntVal;
-  if (APF.convertToInteger(makeMutableArrayRef(UIntVal), 64, true,
+  if (APF.convertToInteger(MutableArrayRef(UIntVal), 64, true,
                            APFloat::rmTowardZero, &isExact) != APFloat::opOK ||
       !isExact)
     return false;

diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index df46773a908f1..63fe4f42b2b65 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -8045,7 +8045,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
       return TEs.back();
     };
     (void)performExtractsShuffleAction<const TreeEntry>(
-        makeMutableArrayRef(Vector.data(), Vector.size()), Base,
+        MutableArrayRef(Vector.data(), Vector.size()), Base,
         [](const TreeEntry *E) { return E->getVectorFactor(); }, ResizeToVF,
         EstimateShufflesCost);
     InstructionCost InsertCost = TTI->getScalarizationOverhead(
@@ -9898,7 +9898,7 @@ Value *BoUpSLP::vectorizeTree(ExtraValueToDebugLocsMap &ExternallyUsedValues,
     Builder.SetInsertPoint(LastInsert);
     auto Vector = ShuffledInserts[I].ValueMasks.takeVector();
     Value *NewInst = performExtractsShuffleAction<Value>(
-        makeMutableArrayRef(Vector.data(), Vector.size()),
+        MutableArrayRef(Vector.data(), Vector.size()),
         FirstInsert->getOperand(0),
         [](Value *Vec) {
           return cast<VectorType>(Vec->getType())

diff  --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index 16e0f048ccb71..325bfc346ce46 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -1960,7 +1960,7 @@ TEST_F(FileSystemTest, readNativeFile) {
       return FD.takeError();
     auto Close = make_scope_exit([&] { fs::closeFile(*FD); });
     if (Expected<size_t> BytesRead = fs::readNativeFile(
-            *FD, makeMutableArrayRef(&*Buf.begin(), Buf.size())))
+            *FD, MutableArrayRef(&*Buf.begin(), Buf.size())))
       return Buf.substr(0, *BytesRead);
     else
       return BytesRead.takeError();
@@ -2027,7 +2027,7 @@ TEST_F(FileSystemTest, readNativeFileSlice) {
                          size_t ToRead) -> Expected<std::string> {
     std::string Buf(ToRead, '?');
     if (Expected<size_t> BytesRead = fs::readNativeFileSlice(
-            *FD, makeMutableArrayRef(&*Buf.begin(), Buf.size()), Offset))
+            *FD, MutableArrayRef(&*Buf.begin(), Buf.size()), Offset))
       return Buf.substr(0, *BytesRead);
     else
       return BytesRead.takeError();

diff  --git a/mlir/lib/Bytecode/Writer/IRNumbering.cpp b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
index 9fed3236af588..cf9be57912f68 100644
--- a/mlir/lib/Bytecode/Writer/IRNumbering.cpp
+++ b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
@@ -150,9 +150,9 @@ IRNumberingState::IRNumberingState(Operation *op) {
   // bytes it takes to encode a varint index to that sub-section. This allows
   // for more efficiently encoding components of the same dialect (e.g. we only
   // have to encode the dialect reference once).
-  groupByDialectPerByte(llvm::makeMutableArrayRef(orderedAttrs));
-  groupByDialectPerByte(llvm::makeMutableArrayRef(orderedOpNames));
-  groupByDialectPerByte(llvm::makeMutableArrayRef(orderedTypes));
+  groupByDialectPerByte(llvm::MutableArrayRef(orderedAttrs));
+  groupByDialectPerByte(llvm::MutableArrayRef(orderedOpNames));
+  groupByDialectPerByte(llvm::MutableArrayRef(orderedTypes));
 
   // Finalize the numbering of the dialect resources.
   finalizeDialectResourceNumberings(op);

diff  --git a/mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
index 3b0d690d297ca..c8c82400bac82 100644
--- a/mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
@@ -80,8 +80,7 @@ struct LoopCoalescingPass
         LLVM_DEBUG(llvm::dbgs() << "  found coalesceable band from " << start
                                 << " to " << end << '\n');
 
-        auto band =
-            llvm::makeMutableArrayRef(loops.data() + start, end - start);
+        auto band = llvm::MutableArrayRef(loops.data() + start, end - start);
         (void)coalesceLoops(band);
         break;
       }

diff  --git a/mlir/test/mlir-tblgen/constraint-unique.td b/mlir/test/mlir-tblgen/constraint-unique.td
index aafea05250bf0..0d377a454d6f5 100644
--- a/mlir/test/mlir-tblgen/constraint-unique.td
+++ b/mlir/test/mlir-tblgen/constraint-unique.td
@@ -127,10 +127,10 @@ def OpC : NS_Op<"op_c"> {
 // CHECK:         for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
 // CHECK-NEXT:      if (::mlir::failed([[$A_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
 // CHECK-NEXT:        return ::mlir::failure();
-// CHECK:         for (auto &region : ::llvm::makeMutableArrayRef((*this)->getRegion(0)))
+// CHECK:         for (auto &region : ::llvm::MutableArrayRef((*this)->getRegion(0)))
 // CHECK-NEXT:      if (::mlir::failed([[$A_REGION_CONSTRAINT]](*this, region, "d", index++)))
 // CHECK-NEXT:        return ::mlir::failure();
-// CHECK:         for (auto *successor : ::llvm::makeMutableArrayRef(c()))
+// CHECK:         for (auto *successor : ::llvm::MutableArrayRef(c()))
 // CHECK-NEXT:      if (::mlir::failed([[$A_SUCCESSOR_CONSTRAINT]](*this, successor, "c", index++)))
 // CHECK-NEXT:        return ::mlir::failure();
 
@@ -148,9 +148,9 @@ def OpC : NS_Op<"op_c"> {
 // CHECK:         for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
 // CHECK-NEXT:      if (::mlir::failed([[$O_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
 // CHECK-NEXT:        return ::mlir::failure();
-// CHECK:         for (auto &region : ::llvm::makeMutableArrayRef((*this)->getRegion(0)))
+// CHECK:         for (auto &region : ::llvm::MutableArrayRef((*this)->getRegion(0)))
 // CHECK-NEXT:      if (::mlir::failed([[$O_REGION_CONSTRAINT]](*this, region, "d", index++)))
 // CHECK-NEXT:        return ::mlir::failure();
-// CHECK:         for (auto *successor : ::llvm::makeMutableArrayRef(c()))
+// CHECK:         for (auto *successor : ::llvm::MutableArrayRef(c()))
 // CHECK-NEXT:      if (::mlir::failed([[$O_SUCCESSOR_CONSTRAINT]](*this, successor, "c", index++)))
 // CHECK-NEXT:        return ::mlir::failure();

diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 8dd1bb50b30be..83937f46e6649 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2746,7 +2746,7 @@ void OpEmitter::genRegionVerifier(MethodBody &body) {
   ///
   /// {0}: The region's index.
   const char *const getSingleRegion =
-      "::llvm::makeMutableArrayRef((*this)->getRegion({0}))";
+      "::llvm::MutableArrayRef((*this)->getRegion({0}))";
 
   // If we have no regions, there is nothing more to do.
   const auto canSkip = [](const NamedRegion &region) {
@@ -2781,7 +2781,7 @@ void OpEmitter::genSuccessorVerifier(MethodBody &body) {
   /// Get a single successor.
   ///
   /// {0}: The successor's name.
-  const char *const getSingleSuccessor = "::llvm::makeMutableArrayRef({0}())";
+  const char *const getSingleSuccessor = "::llvm::MutableArrayRef({0}())";
 
   // If we have no successors, there is nothing more to do.
   const auto canSkip = [](const NamedSuccessor &successor) {


        


More information about the Mlir-commits mailing list