This previously caused miscompilations as a result of phi nodes receiving
undef incoming values from blocks dominated by such successors.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
I'm by no means a GVN expert, but the code change looks trivially safer, so LGTM.
I'd like to improve the test case though:
- Please minimize/edit to make it more obvious how this can cause a miscompile.
- Add a comment to explain why the test exists (something similar to the code comment should do it).
This may not be minimal, and with the 'undefs' I don't think it can actually cause a miscompile, but I whittled it down this far to see what happens before and after the patch:
define void @widget() { entry: br label %bb2 bb2: %t1 = phi i64 [ 0, %entry ], [ %t5, %bb7 ] %t2 = add i64 %t1, 1 %t3 = icmp ult i64 0, %t2 br i1 %t3, label %bb3, label %bb4 bb3: %t4 = call i64 @f() br label %bb4 bb4: ; CHECK-NOT: phi {{.*}} undef %foo = phi i64 [ %t4, %bb3 ], [ 0, %bb2 ] br i1 undef, label %bb5, label %bb6 bb5: br i1 true, label %bb7, label %bb7 bb6: br i1 true, label %bb7, label %bb7 bb7: %t5 = add i64 %t1, 1 br i1 undef, label %bb2, label %bb8 bb8: ret void
}
Comment Actions
Thanks for working on reducing the test case! I was able to eliminate the undefinedness in the branches using a function argument. I couldn't find a way to reduce it any further though.