<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58885>58885</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] Discussion about the ABI of function result of Fortran and C
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          PeixinQiao
      </td>
    </tr>
</table>

<pre>
    After https://reviews.llvm.org/rGc336e72c82b11732f1728ab2f608ed99c7843258, @jeanPerier left several questions, which I quote as follows:

I feel C_PTR is special enough so that we should not treat it as a struct {i64} in function interface. I just feel using fir.ref<None> will ensure it is OK regardless of the ABI (it is likely i64 works with most, but it would just be simpler to use fir.ref<None> than to verify this assumption for every ABI).

Then, I am not entirely clear where you are going with the next change extending this to single component derived types. Is this only in the BIND(C) context or for all functions ? For BIND(C), I agree we may have to go down that rabbit hole, and it won't be fun to replicate the C ABI generated by clang for structs, that I guess is likely target dependent.
Outside of the BIND(C) context, it is not clear to me what would be the reason for doing this (ifort and nvfortran are not doing this I believe). I would stay away from it (the only issue I see is that in the abstract result rewrite pass you do not have a way to tell if a function type is bind(C) or not, and with indirect calls, there may not be a funcOp declaration to tell that).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtVVtv4jgU_jXhxVpEHCDhgYcWtiO00rS7mveVk5wk7hg7Yzsw_Pv9jgOdrjRSm4tjn_PdbGrX3vZPXSQvhhjHkBVPmXzBn6eLpmtYGnM5L53veehLUxRbKmVTyTrPy0J2eSkrVctuu6qo3e2asloXclNl8iCy9eqdlH0jr1HcUBdFoAt5ZcSPiULUzgaedx10M4gTBl0koYLonDHumpCsjtnqfj2JjsiIw79v3_4ROogwUqNRi6yb-kEEJ-KgoriSCIObTCusiyJ6wpiOXFaJEP3URJGVz3q7zsqj0FZ0k20YCp6hQacaWgLL-xTi3G8K2vai037p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