<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63551>63551</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang should call `__riscv_flush_icache` for `__builtin___clear_cache` on Linux RISC-V (w/ libgcc?)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
alexrp
</td>
</tr>
</table>
<pre>
Context: https://github.com/dotnet/runtime/pull/88039
TL;DR:
Clang unconditionally emits a call to `__clear_cache` (from libgcc/compiler-rt) for `__builtin___clear_cache`. This is fine in general, but does not work out well when targeting Linux RISC-V w/ libgcc in particular because that function is just empty, leading to all sorts of subtle bugs in JIT-like programs.
That libgcc function is empty because GCC actually emits a call to `__riscv_flush_icache` when targeting Linux RISC-V. Clang should likely do the same, at least when targeting libgcc.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU81uszgUfRqzuQoiJhCyYNEvFaNv1FWnmm1kzAXcXmxkXzfN24-cVJ220nQ2IIF8_nyOCsFMFrEV1S9R3Wcq8ux8qwjf_Jr1bri0R2cZ31iUdzAzr0GUd0J2QnaT4Tn2uXaLkN3g2CIL2flo2SwoZLdGIiG7pinKgyjuRXF3ez49iPLX_WPC-fT1SMpOEK12djBsnFVEF8DFcAAFWhEBOxB1cTppQuVPWukZRV2AkM3o3QJk-klrITvtltUQ-o1nIQ8wOn8710dDbOzpO0IOT7MJYAKMxiIYCxNa9IqEPEIfGQaHAaxjODv_Ai4ynJEIzjNaYOUnZGMneDA2vsHj77-Om7_hLGT3rigBrsqz0ZGUhx61igGBZ8UwRquT2UT-HAMDLitfEi-hGhIqO0jeg_McwI0QYs-E0McpJOA_fz9tyLwgrN5NXi0h_xJ14nhX8ZnqyvKh5I_jEZTm-N-JexP062mkGOaT-Qj-B_853O4zzC7SAEkhXWBwwDNCUKkfR0jaUAX-DnQTnGdDWw6H8qAybLd1s2_28rDfZnOLardt9jVWY1UMjZKF3u2bWqmx2KlS6TEzrSxkWdRyvy3LervNx3IscOj7faNk1deV2BW4KEM50euSOz9lJoSIbV1W1TYj1SOF6ySktHiG608hZVqIb9OZTcpf7AoygcO_KGyYsP1i_ZrjDyH-bzvB2a_VErL51C5RdkIesuip_WGeSeH7a7N694w6bfXqKwjZXX3_EwAA__-0RljS">