<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64721>64721</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SROA] LLVM ERROR on atomic memory access
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ericliuu
</td>
</tr>
</table>
<pre>
The following IR crashes with an LLVM ERROR when being optimized by the SROAPass:
```llvm
define i32 @foo() {
%A = alloca i1, align 1
%1 = load atomic volatile i32, ptr %A seq_cst, align 4
ret i32 %1
}
```
Here is the before and after from the SROAPass that causes the LLVM ERROR:
```llvm
*** IR Dump Before SROAPass on foo ***
define i32 @foo() {
%A = alloca i1, align 1
%1 = load atomic volatile i32, ptr %A seq_cst, align 4
ret i32 %1
}
*** IR Dump After SROAPass on foo ***
define i32 @foo() {
%A = alloca i1, align 1
%A.0. = load atomic volatile i1, ptr %A seq_cst, align 4
%A.0.load.ext = zext i1 %A.0. to i32
ret i32 %A.0.load.ext
}
atomic memory access' size must be byte-sized
i1 %A.0. = load atomic volatile i1, ptr %A seq_cst, align 4
LLVM ERROR: Broken function found, compilation aborted!
```
Here is the crash on godbolt: https://godbolt.org/z/3TYoYYYoq
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVMFu2zgQ_RrqMoghjSTLPuhgr9fYBVKkcIMCPhUUNbLYUqJDUnHtry9IObGTFEWAnAoIpkHOvJn3hnzcWrnriUqWL1m-ivjgWm1KMlIoOQxRpetjed8SNFopfZD9Dv7fgDDctmThIF0LvIfb26-f4N_N5m4Dh5Z6qMgH6r2TnTxRDdURXEvwZXO3-MytZemCxSsWP_1O4_FT6rEbt2pqZE8gUwSWxY3WDGcM58CK5RgAwDBfAEtXwJXSgoNMGP4DXMldD8lVUBKClOY1cKc7KeBRK-6kCvA-Z-_MiGbp4Zuw7oKTPeEYcmMzmJ-xWbF61f01pf_IEEgbWFfUaEPA-xp448hAY3T3Qg9wLXcg-GBpTLnoeZHqrUgMz58fyWro9rAcSz3j6h4areE58O8T9w3FRZDwwwzfS3AxiSd_4Ji8k-IZyYNM6KcLiCf_RybPVZwOmr0V5TrzlT7nhjrqtDkCF4KsZViAlSeCbrAOKoLq6OjG79Rn8KuiH6X24qbC0ugf1EMz9MLJMJqhr32O0N1eemTdA6-0cVQzTN75gILb-EnvdF1p5Xyl1rl98BFcM1yfDyba7BiuTwzX6f1Wb7db_RDVZVrP0zmPqEymc0zyNMY0akuK84rm1YxEnhFlBS8EzuoZNvE0ywViJEuMMY1nydQvmE7SIk-aIs0wy2gWZznLYuq4VBP_JH3tSFo7UDnNCkwixStSNvgqYk8HCIcM0dusKX3OTTXsLMtiJa2zFxQnnQqG7G85y1fX9ur1-83MIRqMKl-JIl07VBOhO4br4BrjcrM3-jsJx3AdWrIM16HlXwEAAP__XRfEXA">