================
@@ -212,22 +284,23 @@ LogicalResult
CIRABIRewriteContext::rewriteFunctionDefinition(
Type newFnTy = funcOp.cloneTypeWith(newArgTypes, newResultTypes);
funcOp.setFunctionTypeAttr(TypeAttr::get(newFnTy));
- // Keep the arg_attrs array in sync with the new argument count by
- // dropping entries for every Ignored argument. Without this the
- // attribute array would have stale entries that no longer match any
- // block argument.
- SmallVector<unsigned> ignored = ignoredArgIndices(fc);
- if (!ignored.empty()) {
- if (auto existing = funcOp->getAttrOfType<ArrayAttr>("arg_attrs")) {
- SmallVector<Attribute> kept;
- kept.reserve(newArgTypes.size());
- for (auto [oldIdx, attr] : llvm::enumerate(existing.getValue())) {
- if (oldIdx >= fc.argInfos.size() ||
- fc.argInfos[oldIdx].kind != ArgKind::Ignore)
- kept.push_back(attr);
- }
- funcOp->setAttr("arg_attrs", ArrayAttr::get(ctx, kept));
- }
+ // Rebuild arg_attrs: drop entries for Ignore'd args, layer
+ // llvm.signext / llvm.zeroext onto Extend args, preserve everything else.
+ bool needsArgAttrUpdate = !ignoredArgIndices(fc).empty();
+ for (const ArgClassification &ac : fc.argInfos)
----------------
andykaylor wrote:
This is potentially the third time we've looped over the argInfos in this
function (the other two being in calls to `ignoredArgIndices()`). Can this be
made more efficient?
https://github.com/llvm/llvm-project/pull/195745
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits