<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/100315>100315</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang not clearing callee used registers
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
royger
</td>
</tr>
</table>
<pre>
Hello,
Under some circumstances clang seems to fail to properly clear callee used registers between function calls. Given the example here:
https://godbolt.org/z/qvxMGd84q
clang generates the following inner loop assembly code:
.LBB1_1: # =>This Inner Loop Header: Depth=1
orq %rbx, %rdi
callq func
andq $-256, %rdi
decl %r14d
jne .LBB1_1
Which only clears the low 8bits of %rdi, possibly leaving the high bits of %rdi containing garbage between 'func' calls, as %rdi is not a callee-saved register.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsU19vmz4U_TTm5SoRGAjJAw9t80v7k7q3TXucjH0BV8YmviZt9-knA9nSbpbACJ9z_5x7LIh0ZxFrVt6z8piIKfTO1969d-iTxqn3-gmNcYw_sPTI0rvl_c0q9EBuQJDay2mgIKxEAmmE7YAQB4LgoBXaxH30bkRv3kEaFB6kMAYRJkIFHjtNAT1Bg-EV0UI7WRm0szOMtgCP-oIWQo-Ab2IYDUKPHll-d1tSH8JI8R8_MX7qnGqcCVvnO8ZPPxk_nS9vXx7VvjjfkpZyO7ToRUCac7TOGPeqbQfaWvRgnBtBEOHQxAac-px5-3x_n_3IWH4HjOfA8iPL__vaa4L_5wDPMcATCoU-Yo44hp7lx2xhw7qcP88746Vv3hh_mL-UXlFRiwiI4nwkCqvOC7HY8HL3F3NdCqW5xs8KtR6-WJxPrz3ctPW917IHZ69TW9Qx7hX2jQ4Err3m4Q8wOiId9TEoLlG7iO1118NHLEhng9A2QjrhG9Hh77kzXs3d8WqZfIwr6ErUBNYFEKt5NiQuN-7ZJqrO1SE_iATrrOLZPt2VvEz6escPJVZlJqs0z9KylIUsGtlWBzyobL8rEl3zlBdpFZ-85OX20BZZWxWHfSuVaPYVK1IchDZbYy5DdFSiiSasszTNszIxokFD1wvk64jaNFNHrEiNpkB_eEEHg_ViutjMrGuU4p8XIpm8qT_ZWod-arbSDYyfYth124zevaAMjJ_m2ojx01repea_AgAA__9QODfp">