This is an archive of the discontinued LLVM Phabricator instance.

[Mem2Reg] Fix nondeterministic corner case
ClosedPublic

Authored by JosephTremoulet on Nov 29 2018, 1:58 PM.

Details

Summary

When mem2reg inserts phi nodes in blocks with unreachable predecessors,
it adds undef operands for those incoming edges. When there are
multiple such predecessors, the order is currently based on the address
of the BasicBlocks. This change fixes that by using the BBNumbers in
the sort/search predicates, as is done elsewhere in mem2reg to ensure
determinism.

Also adds a testcase with a bunch of unreachable preds, which
(nodeterministically) fails without the fix.

Diff Detail

Repository
rL LLVM

Event Timeline

This revision is now accepted and ready to land.Nov 29 2018, 4:54 PM
This revision was automatically updated to reflect the committed changes.