-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[mlir] Use a new constructor of ArrayRef (NFC) #146009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mlir] Use a new constructor of ArrayRef (NFC) #146009
Conversation
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)
@llvm/pr-subscribers-mlir-llvm @llvm/pr-subscribers-mlir-core Author: Kazu Hirata (kazutakahirata) ChangesArrayRef now has a new constructor that takes a parameter whose type ArrayRef<T>(X.data(), X.size() to: ArrayRef<T>(X) Full diff: https://github.com/llvm/llvm-project/pull/146009.diff 2 Files Affected:
diff --git a/mlir/lib/AsmParser/AttributeParser.cpp b/mlir/lib/AsmParser/AttributeParser.cpp
index 2474e88373e04..dcb21e7d0831d 100644
--- a/mlir/lib/AsmParser/AttributeParser.cpp
+++ b/mlir/lib/AsmParser/AttributeParser.cpp
@@ -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: "
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 1253c2f83b07b..8dcffc66f7f7b 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -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
|
@llvm/pr-subscribers-mlir Author: Kazu Hirata (kazutakahirata) ChangesArrayRef now has a new constructor that takes a parameter whose type ArrayRef<T>(X.data(), X.size() to: ArrayRef<T>(X) Full diff: https://github.com/llvm/llvm-project/pull/146009.diff 2 Files Affected:
diff --git a/mlir/lib/AsmParser/AttributeParser.cpp b/mlir/lib/AsmParser/AttributeParser.cpp
index 2474e88373e04..dcb21e7d0831d 100644
--- a/mlir/lib/AsmParser/AttributeParser.cpp
+++ b/mlir/lib/AsmParser/AttributeParser.cpp
@@ -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: "
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 1253c2f83b07b..8dcffc66f7f7b 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -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
|
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)
ArrayRef now has a new constructor that takes a parameter whose type
has data() and size(). This patch migrates:
ArrayRef(X.data(), X.size()
to:
ArrayRef(X)