<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/153526>153526</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] No way to generate addrspacecast with C++ style cast
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang,
c++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
choikwa
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/zbrTTqMPv demonstrates C++ casts (static_cast, reinterpret_cast, etc) can't be used to generate addrspacecast. Only C style cast is lowered to addrspacecast. This is important for noalias analysis as addrspacecast is needed (vs PtrToInt) for ptr provenance and set appropriate alias.scope.
A typical scenario may be using reinterpret_cast<AS(n) T*>(reinterpret_cast<uintptr_t>(ptr)) but this inadvertently generates PtrToInt and IntToPtr which is considered as 'capturing' the pointer and llvm cannot trace it back to the underlying objects.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0U8GO4zYM_Rr5QqzhyFYSH3zIZBpgD20HaO4LWmJidRVJlegE7tcXchYzxbR7MGwafI98jyTmbK-eaBDqRajXCmeeQhr0FOz3B1ZjMMswMccs2oOQJyFP12DG4LgO6Srk6e_yjOl8_uvXtzsYugWfOSFThqOQL0K-gMbMGYTcZ0a2-luJhTxCIuuZUkzE7_-ItZA9aPRC7hhGgjmTAQ5wJU-FF9CYlCNqKpgafvdugSNkXhytpcBmcOFB6Yn7lH6ebC4Z9hZDYvQMl5DAB3QWM6BHt2SboXz_G1ggnsiQKULuGd44ncNXz6XbwhA5QUzhTh69JkBvIBMDxphCTHZtvJSosw6RatEcRHM4AC_RanSQNXlMNsANl6dq66__dag9Hv4Qcu9L1bOQB9H-IuT-f9Jm6zly-sbPjMhJyL6gxpmBVw88mjslJs9ueXf3Q9gq4avnc3jjBI_J6qmYoIPP1qzmYhnqTmPkOVl_FXIHPBHEsHaz4p2738owfWDghJrAMoyov5fJlOTZG0puKWLD-CdpznVlhtb0bY8VDZudUpu2V6qrpmGruk2vTKe3e0ldc9lSP5qxbS47SdvNRVd2kI1UzX7TNbJTqqubXjU9El3ai7y0nRJdQze0ri59lQWubM4zDRvVKrmtHI7k8noJUmqHRZMU8lii5y6XWL1WaSgEX8b5mkXXOJs5f1CyZbee05NBvcJvAR64_HyJ4WF5ej-Xj02u5uQ-H5_laR5rHW5CnkrJH68vMYVin5CnVVIW8vRD1X2Q_wQAAP___eVQiw">