Applying the `nocapture` attribute to reference-passed arguments in Fortran subroutines

I’d like someone else to handle adding attributes to llvm.call. However, I would like to try adding nocapture to func.func.

Thanks for the clear example. I understand now that LLVM might not be able to add nocapture even if a body exists.

I think the condition for adding nocapture to func.func are: it has a body or comes from a module, it’s not a bind(c) procedure, and its dummy arguments don’t have the target, pointer, volatile, or asynchronous attributes.

Regarding implementation, if func.func has a body, I’m considering adding the nocapture by checking dummy argument’s attributes within the FunctionAttr pass. However, if func.func comes from a module, while the fir.target attribute can be determined from the dummy argument’s attributes, the asynchronous attribute appears to be lost(Compiler Explorer). In this case, should nocapture be added in an earlier phase?