<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64910>64910</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`-fzero-call-used-regs` mitigation flags breaks `asm` code.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
KOLANICH
</td>
</tr>
</table>
<pre>
[`-fzero-call-used-regs`](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-zero_005fcall_005fused_005fregs-function-attribute) is intended to mitigate some exploitation techniques and it causes functions to zero CPU registers. In fully compiler-generated code it doesn't cause breakage. But if one uses `asm` and either
1. calls a function from `asm` code
2. uses a `register VarType var_name ("%reg")` to store a value for and then uses it in `asm` statement,
then it causes breakage: the regs got zeroed. As a workaround one can create a stack frame and `push` and `pop` all the regs around calls to functions, but it causes severe performance penalties in the cases where `-fzero-call-used-regs` is not used. Also manipulatig `%rsp` in `asm` code (and so the necessity to clobber it in order not to allow the compiler to use it for `"m"` local vars and force it to rely on `%ebp`) is unjustifiedly deprecated.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VEFz4zYP_TX0BSMNQ9myfdDB64zn2_k6bQ9trzsUCUncUKRKQsm6v74D2t6ke9hLApnEew8PIHTObgyIndh9ErvnjV5piqn7_2-_nH79fP7fpo_2Ws5aWQ3_YIqV0d5Xa0ZbJRyzaKXYPQt1mIiWLJqTUBehLqMx9RjWOqZRqEsM3gW00eTbkVCXc5znGKrLGgy5GKoTUXL9SpjriWYvVOOCxW8VU36RcjcwbQmYugRMXw0PAP0AEOoILoMLhMGiBYowO3KjJoQcZwT8tvjoSHMaEJopuL9XzKCDBUdg9JoxwwM4MwCrgPPvf0LC0WXClGv4HGBYvb-CifPiPKZqxIBJE1ow0SJj2Yg5CLW_o0KfUL_oEWv4tBK4AWJAKHSilTrPopVFBjqaMA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