<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/142819>142819</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Improve discoverability of `CallBase` call targets that are global aliases.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mtrofin
</td>
</tr>
</table>
<pre>
In at least 2 different instances ([a](https://reviews.llvm.org/D25384), [b](https://github.com/llvm/llvm-project/pull/142657)), patch authors (one is me) used `CallBase::getCalledFunction` but then had to come back because global aliases needed handling for their scenario. One problem is that `getCalledFunction`'s documentation makes no mention of global aliases, and the reader may miss the "global aliases are not Functions". It isn't clear what the intended behavior is for the current uses of this API, and this issue tracks that.
Besides clarifying `getCalledFunction`'s handling of aliases in its documentation (which has been done in the "b" PR above), we can probably do better. Possibilities:
- add another API, e.g. `getDirectCallTarget`
- have `getCalledFunction` follow the alias link and return that, should it be a `Function`. This may be a breaking change; maybe we can have a boolean "FollowAliases" argument with some sensible default option, and that in itself would help with the discoverability of the issue
- [...]
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVMuO4zYQ_Br60lhBoiQ_DjrYOzAwpyyC_YEm2ZKYoUiDbNmYvw9I27ObwSRATgJaYHVVsViYkp080SD6k-hfNrjyHOKwcAyj9RsVzPvw6gEZHGFikGDsOFIkz2B9YvSaEgi5F_0JRf8i5H5mviTRHoU8C3mOdLV0S5Vz16UKcRLy_CL7dt8JeRDyO4j-pL46N1meV1XpsAh5zocfn2-XGP4izUKeL6tzQp6bTm77XYEriBdkPcNdSKEWPIFNsJCQB1gTGRDb-js6d8JEeWF7nIjzgMx59Zpt8GJbg1oZeCYPMxrgADosBAr1GyjSuCaCyQWFDtBZTJTAExkyMKM3zvoJxhAzgI2QNHmMNlTwhye4xKAcLZkUz8iZzlcEhNwlMEGvC3nGPIQF3_KeAHmUB2H8RC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