<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/131829>131829</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][debug] Number function arguments in FIR
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:ir,
flang,
flang:fir-hlfir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
vzakhari
</td>
</tr>
</table>
<pre>
AddDebugInfo pass uses fragile logic for figuring out the positional number of a dummy argument in the list of function arguments. This causes issues like https://github.com/llvm/llvm-project/pull/131672
It seems that we need to number the dummy arguments in a more reliable way, e.g. attribute `[hl]fir.declare` operations with the proper number early in the pipeline (maybe even during lowering).
There are some questions that I do not know answers for. @abidh please feel free to comment, if you know the answers.
1. How is the numbering affected by AbstractResultOpt pass that may introduce a new function argument for the result of function? E.g. let's say we set number 1 for the first Fortran dummy argument of a function. Then AbstractResultOpt adds a new dummy argument before the first one. Should all the numbers shift at this time?
2. How is the numbering affected by MLIR inlining? E.g. when a callee with dummy arguments is inlined into the caller, should we still attribute those used to be dummy arguments with `arg = ...`?
3. How is the numbering affected by ABI handling. E.g. if a single Fortran dummy argument is received by a function via two low-level function arguments, does it mean the positional numbers should be shifted at this point?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVV1v4zYQ_DX0yyKCREX-eNCDc65RA_0A0vyBlbiS2FCkyiVtuL--oBQnufMVuHtKLJG7M7OzI2TWvSWqRfUkqsMKYxicr8__4uuAXq8ap671XqkDNbE_2c7BhMwQmRg6j702BMb1uoXOeeh0H722PbgYIAwEk2MdtLNowMaxIQ-uAwQVx_EK6Ps4kg2g7XzYaA7pfRdtmy69H-AMXgbN0OLcVzNHYjD6lWAIYWJR7oU8CnnsdRhik7VuFPJozPn252Hy7m9qg5DHKRoj5LEoi_VGinwv8v0pABONDGHAABcCS6QguBvkhO1rxJwgI4zOE3gyGhtDcMGrkF-Asj4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