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

Massimiliano Mantione massi at ximian.com
Tue Dec 14 04:30:21 EST 2004


On Mon, 2004-12-13 at 12:24, Paolo Molaro wrote: 
> Right, so my list included too many opcodes. We need
> to link the block for CEE_RET, CEE_JMP, CEE_THROW and after tail calls
> (and the RETOBJ, didn't read the details of that).
> Removing the link in all cases is wrong.

Just to sum it up: removing the statement that the links the last BB
in the IL code block to the end BB is ok, because the link should be
created when the BB is generated (as agreed on IRC).

The existing code already handled all the "RET" cases correctly.

This patch adds the link from BBs ending with tail calls or throw
statements to the end BB.

I was a bit unsure about throw/rethrow statements, but looking
at how this method was handled I got convinced:

static int test_0_catch () {
	Exception x = new Exception ();

	try {
		throw x;
	} catch (Exception e) {
	if (e == x)
		return 0;
	}
	return 1;
}

I sow that in the resulting CFG the end BB was *unreachable* from
the entry BB (the BB with the throw had no out BB at all, and this
does not depend from being the "last BB": it isn't the last one).

With this patch, the BB with the throw gets connected to the end BB.

Of course the patch passes all regression test... In any case, the
tests passed also without the (corrected) patch.
I think that this correction will most likely prevent *future*
problems, when we will apply SSA (at least to some variables) also
in the presence of catch/finally clauses.

OK to commit?

Ciao,
  Massi

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


More information about the Mono-devel-list mailing list