[Mlir-commits] [mlir] [mlir][llvmir] implement missing attrs `getChecked` (PR #121248)
Maksim Levental
llvmlistbot at llvm.org
Sat Dec 28 13:42:15 PST 2024
================
@@ -296,6 +305,20 @@ TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context,
return get(context, features);
}
+TargetFeaturesAttr TargetFeaturesAttr::getChecked(
+ llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
+ MLIRContext *context, StringRef targetFeatures) {
+ SmallVector<StringRef> features;
+ targetFeatures.split(features, ',', /*MaxSplit=*/-1,
+ /*KeepEmpty=*/false);
+ SmallVector<StringAttr> featuresAttrs;
+ featuresAttrs.reserve(features.size());
+ for (StringRef feature : features) {
+ featuresAttrs.push_back(StringAttr::get(context, feature));
+ }
+ return getChecked(emitError, context, featuresAttrs);
----------------
makslevental wrote:
Now I remember - for some reason that correct `ArrayRef(SmallVector)` ctor wasn't being deduced so it was going all the way to StorageBase (which then winds its way back to the `ArrayRef<StringAttr>` builder. Adding `ArrayRef featuresRef(features)` fixed.
https://github.com/llvm/llvm-project/pull/121248
More information about the Mlir-commits
mailing list