[mlir] Use a new constructor of ArrayRef (NFC) (#146009)

ArrayRef now has a new constructor that takes a parameter whose type
has data() and size().  This patch migrates:

  ArrayRef<T>(X.data(), X.size()

to:

  ArrayRef<T>(X)
This commit is contained in:
Kazu Hirata
2025-06-26 23:38:20 -07:00
committed by GitHub
parent 26ec66dc18
commit c7b34b0b44
2 changed files with 3 additions and 5 deletions

View File

@@ -717,7 +717,7 @@ DenseElementsAttr TensorLiteralParser::getHexAttr(SMLoc loc, ShapedType type) {
if (parseElementAttrHexValues(p, *hexStorage, data))
return nullptr;
ArrayRef<char> rawData(data.data(), data.size());
ArrayRef<char> rawData(data);
bool detectedSplat = false;
if (!DenseElementsAttr::isValidRawBuffer(type, rawData, detectedSplat)) {
p.emitError(loc) << "elements hex data size is invalid for provided type: "

View File

@@ -727,10 +727,8 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant(
}
if (auto stringAttr = dyn_cast<StringAttr>(attr)) {
return llvm::ConstantDataArray::get(
moduleTranslation.getLLVMContext(),
ArrayRef<char>{stringAttr.getValue().data(),
stringAttr.getValue().size()});
return llvm::ConstantDataArray::get(moduleTranslation.getLLVMContext(),
ArrayRef<char>{stringAttr.getValue()});
}
// Handle arrays of structs that cannot be represented as DenseElementsAttr