[Mlir-commits] [mlir] Avoid copies in getChecked (PR #147721)
Alexandru Lorinti
llvmlistbot at llvm.org
Tue Jul 15 06:18:50 PDT 2025
AlexandruLorinti wrote:
Thanks @joker-eph for feedback!
As per current implementation of `getChecked`, we only have a return and wouldn't get in the situation of a use-after-move:
` auto scope = body.scope("return Base::getChecked(emitError, context", ");");
for (const auto ¶m : params)
body << ", " << param.getName();`
just an example, without the change we would have this generated code:
`ModuleFlagAttr ModuleFlagAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ModFlagBehavior behavior, StringAttr key, Attribute value) {
return Base::getChecked(emitError, context, behavior, key, value);
}`
and with the change, the above generated code would be:
`ModuleFlagAttr ModuleFlagAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ModFlagBehavior behavior, StringAttr key, Attribute value) {
return Base::getChecked(emitError, context, std::move(behavior), std::move(key), std::move(value));
}`
Could you point me to specific test that would need to be updated?
https://github.com/llvm/llvm-project/pull/147721
More information about the Mlir-commits
mailing list