[Mono-devel-list] Patch for wrong out BB

Massimiliano Mantione massi at ximian.com
Mon Dec 6 15:18:29 EST 2004

I noticed that in mono_method_to_ir, when creating BBs, the last
"proper" BB is always linked to the exit BB, even when it has an
explicit branch instruction at the end.

This means that if one method has as last CIL instruction a jump
to somewhere inside the method (which is legal), one of its BBs
(the last "proper" one) will have two out BBs: the jump target,
and the exit BB, which is wrong.

This causes a bug when using both consprop (or copyprop) and
ssapre, even if the issue is not risen by ssapre, but from the
removal of critical edges: removing critical edges that "last"
BB is not the "last" one anymore, nevertheless it has the exit
BB as out BB (which it should not have), and this gives troubles.

The attached patch solves the issue, and also enables SSAPRE when
consprop|copyprop are used, because the bug is gone ;-)

OK to commit?

As an alternative, I could make so that critical edges removal
never "splits" edges pointing to the exit BB, even if they are
critical. This should not harm, because the exit BB is always
empty so critical edges would be harmless there, and would save
some BB and some branches in these cases.
However, I would find it somewhat "unclean", and probably also
dangerous in unexpected situations.


P.S. The bug showed up in the "odd-even" regression test, which
is coded in IL and has an unusual branch pattern...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: branch-on-last-bb.patch
Type: text/x-patch
Size: 1788 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20041206/a3555caf/attachment.bin 

More information about the Mono-devel-list mailing list