<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57684>57684</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64][Windows] explicit 'inreg' function argument attribute leads to wrong code generation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
amitin
</td>
</tr>
</table>
<pre>
A function declaration with explicit 'inreg' function argument attribute causes incorrect code generation.
For example, `define fastcc %struct.Foo* @foobar(%struct.Bar* inreg %0, %struct.Foo* inreg %1)`
(`ccc` calling conv affected as well).
Affected is aarch64-pc-windows-msvc target, for aarch64-linux-gnu it generates the code correctly.
It seems the instructions get deleted by TailMergeBlocks() of the BranchFolder pass.
A self-contained sample reproducing this behaviour is attached.
[aarch64-windows-msvc.zip](https://github.com/llvm/llvm-project/files/9543407/aarch64-windows-msvc.zip)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVU02vmzAQ_DVwsYLAAQIHDqRPkXrorVLPxl7ArbGRP5KX_vouDmnaSj08CYFX652dmV0GI-5dT8aguZdGEwFcMcvi-Sb9TOB9VZJLTxJ6ktrChN_XdWansID2hHlv5RA8EM6CA0ek5sZa4J5wI4BMoOEBmyX5W5L3F2MRmy2rgoR-IkmdCxilBjIy5znHdpXzNnCfXYxJaE-SMh-NGZhNaPNKnre4J5HZVpNHsH9rf6eLhLbY6kFhA6pzzjm-kbZSUk_IVl8JG0dkDoIwR26gFFbttPtnRjrCmOVzXR5WfrhJLczNHRZ35cSjK-A3IiOKfN5C9PB-mHQgaOZuB_rkZ3g4tNul7nunz544gOVxQ-qHIPTPYbHHOSnYaAx38pVJ9QWw5VkZ_sNFe1pixlh4tkzz-WKUAEtW5tyOvqvBFmo8oGbP0HtBXBwIsbBaIwLfDPEzSh1gZldpgo26vWd8BpGRHas6P0X-6UP2U65J9YZ8Zu9XlxzR8As-E65VGDJuFgyUuj4_B-z5HR3AcJQKUMilrcpjmZ_w9N8GOM9IIoWuqGva0qoty1R0R9EeW5Z66RV0yLDvI8BGqDp_e6Bg8PH9VsAEDsWQmzVxX_7a7jRY1X1Yr3QuRMHVqW7KdO4gh4o3xdCIoTw1RdWIumQFpbzgcKIlTRUbQLlNGIpIZUdzSvO2KIq2orTMctHQsgHalk1FGcvx54EF9yTbGmfGTqntIochTA6TSjrvXkncEzlpgCc-C342tmOL9FKnkW0Xqf4C2NlmCg">