diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h --- a/llvm/utils/TableGen/CodeGenDAGPatterns.h +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h @@ -193,7 +193,7 @@ struct TypeSetByHwMode : public InfoByHwMode { using SetType = MachineValueTypeSet; - SmallVector AddrSpaces; + unsigned AddrSpace = std::numeric_limits::max(); TypeSetByHwMode() = default; TypeSetByHwMode(const TypeSetByHwMode &VTS) = default; diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -83,10 +83,12 @@ // inference will apply to each mode separately. TypeSetByHwMode::TypeSetByHwMode(ArrayRef VTList) { - for (const ValueTypeByHwMode &VVT : VTList) { + // Take the address space from the first type in the list. + if (!VTList.empty()) + AddrSpace = VTList[0].PtrAddrSpace; + + for (const ValueTypeByHwMode &VVT : VTList) insert(VVT); - AddrSpaces.push_back(VVT.PtrAddrSpace); - } } bool TypeSetByHwMode::isValueTypeByHwMode(bool AllowEmpty) const { @@ -103,13 +105,11 @@ assert(isValueTypeByHwMode(true) && "The type set has multiple types for at least one HW mode"); ValueTypeByHwMode VVT; - auto ASI = AddrSpaces.begin(); + VVT.PtrAddrSpace = AddrSpace; for (const auto &I : *this) { MVT T = I.second.empty() ? MVT::Other : *I.second.begin(); VVT.getOrCreateTypeForMode(I.first, T); - if (ASI != AddrSpaces.end()) - VVT.PtrAddrSpace = *ASI++; } return VVT; }