<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/130172>130172</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Optimzations make assumption about function names
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
smaillet
</td>
</tr>
</table>
<pre>
Given the following module as an input
```llvm ir
define double @anon_expr_1() {
entry:
%calltmp = call double @cos(double 1.234000e+00)
ret double %calltmp
}
declare double @cos(double)
```
optimization with a minimal set of passes "simplifycfg,instcombine,reassociate,gvn" will produce the following module:
```llvm ir
define double @anon_expr_1() {
entry:
%calltmp = call double @cos(double 1.234000e+00)
ret double 0x3FD526571FE8C7A5
}
declare double @cos(double)
```
NOTE: The return of this function is the IEEE Hex form of 0.33046510807172985 which is the mathematical Cosine of 1.234. Thus, the optimizations have ***Assumed*** that the function named `cos` is in fact the mathematical function of the same name common in C runtime libraries - but it doesn't ***KNOW*** that. It could well be that this is just a function that happens to have the name `cos` (and has NO reliance on the C runtime). The expectation is that this does something completely different that might even have side effects so ignoring the return value and substituting a const is just ***WRONG*** behavior. (One would hope that subsequent optimization stages would remove the call due to the possibility of side effects, but ignoring the return and substituting a const value is still wrong)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVU2P2zYQ_TX0ZRCDomTLPujg7K7ToMAuUATIMaCokcWUH6pmaO_21xeUdu0smpx6KSDYIjTz-N6b4VAT2VNAbMTmo9jcr3TiIU4NeW2dQ161sXtpPtkzBuABoY_OxYsNJ_CxSw5BE-gANoyJhTyIrVwe584e7CTkocPeBoQuptYhiErqEMM3fB6nb4VQO6H2IOqPQh4w8PQiyoOQBwChNkY7x34EUd5Dfv8BwkQSave6LtaqrKSUKNRHKYXazwAT8jXhipUZ1vf5N_MyTk_4C9QF5ipnSYkjW2__1mxjgIvlATR4G6zXDggZYg-jJkICoRRZPz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