<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61883>61883</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Attributor] Miscompile after phi fix
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
clin111
</td>
</tr>
</table>
<pre>
After https://github.com/llvm/llvm-project/commit/0fc63d4e642fcf79e9806dc3ae7a49defaae2479, the Attributor may remove stores from the IR without propagating the values.
Attached test case:
opt -S -passes=attributor reduced.ll
The attached .pdf file has a graph of the IR.
The IR contains the following stores:
bb: 0.0 => %alloca3
bb5: %arg2 => %alloca3
bb9: 1.0 => %alloca
bb18: (loaded value of %alloca3) => %alloca
The final value of %alloca could be 0.0, 1.0, %arg2, or undef.
After the Attributor runs, %alloca3 and the associated lo
[reduced.ll.txt](https://github.com/llvm/llvm-project/files
[reduced.pdf](https://github.com/llvm/llvm-project/files/11128575/reduced.pdf)
/11128574/reduced.ll.txt)
ads and stores have been removed, but the values 0.0 and %arg2 have not been propagated anywhere. The only value stored to %alloca is 1.0.
Commenting this code in AttributorAttributes seems to fix it, which is strange because "false" should be the conservative answer.
`if(CyclePHI && isa<Instruction>(V) &&
(!C || C->contains(cast<Instruction>(V)->getParent())))
return false;`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVU2P4ygQ_TXkUmrLxvHXIYd00tH2YaXR7GrvFShiVhgswOnJv1_h2JNodvowmlZLRuHV4xWvno0h6Isl2rHqlVXHDU6xd34njLZFUWzOTt52exXJQx_jGFi5Z_zE-OmiYz-dM-EGxk_GXNfHy-jdvyQi4yfhhkGnRa5EXcot1VuuhGo66tq8lqJEanDbSVKIxLdNx_gBYk-wj9Hr8xSdhwFv4GlwV4IQnacAyrthRr1_hQ8dezdFGL0b8YJR28u8dUUzUchYfmT5fh8jip4kRAoRBAZKTcxbbozw8he8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