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

Given Peter answer, with which I rather agree, yes we will have to decorate llvm.call instead of llvm.func in certain cases, but not all, we can start by limiting ourselves to the cases where we cannot be sure that the provided interface is correct: external procedures not defined in the current compilation unit. That is, at the FIR level, when the func.func has a body, or if it it comes from a module (which we can know from the mangling), it is OK to add the attributes on the func.func directly in the FunctionAttr pass.

For the other cases, we will need:

  1. In lowering, to set the Fortran attributes to the fir.call according to the call interface when it is a call to an external procedures not defined in the current compilation unit.
  2. In codegen, when lowering fir.call to llvm.call, to translate the Fortran attributes to LLVM nocapture as described in previous discussions.

This will also imply adding attribute to llvm.call arguments in LLVM MLIR dialect and codegen, which as mentioned above, is not supported currently (see this disccussion).