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

Paolo Molaro lupus at ximian.com
Mon Dec 13 06:24:48 EST 2004


On 12/10/04 Massimiliano Mantione wrote:
> The standard does not allow the control flow to reach the end of
> a method, so that link seems not needed, and the patch gets even

We need to link each basic block that ends a method to the end_bblock.
The dominator/postdominator etc code needs a basic block that
represents the end of a method.

> On Tue, 2004-12-07 at 18:40, Paolo Molaro wrote:
> > Besides CEE_BR, CEE_BR_S, CEE_SWITCH we have also CEE_RET,
> > CEE_JMP, CEE_THROW, CEE_ENDFILTER, CEE_ENDFINALLY, CEE_RETHROW,
> > CEE_LEAVE, CEE_LEAVE_S. Hope I didn't miss any. Using the ip var
> > is better, because after the internal representation is generated,
> > there is no easy way to check bblock->last_ins e check for all
> > these cases.
> 
> Looking at the code, I noticed that "start_new_bblock != 0" if and
> only if the last BB instruction is one of the following:
> 
> CEE_JMP, CEE_RET, CEE_BR_S, CEE_BR, CEE_THROW, CEE_ENDFINALLY,
> CEE_LEAVE, CEE_LEAVE_S, CEE_MONO_RETOBJ, CEE_ENDFILTER, CEE_RETHROW.
> 
> Moreover, it is set also when ADD_UNCOND and ADD_UNCOND are used,
> which is with the "CEE_BR(FALSE|TRUE)(_S)?" and "CEE_B(..)(_UN)?(_S)?"
> opcode families (conditional branches), and in the presence of tail
> calls (ins_flag & MONO_INST_TAILCALL).
> 
> With respect to your opcode list, CEE_SWITCH is missing... I looked

Yes. CEE_SWITCH does a fall through.

> After one more test program, I checked the ECMA spec again, and
> found out that "Control is not permitted to simply  fall through
> the end of a method. All paths shall terminate with one of these
> instructions: ret, throw, jmp, or (tail. followed by call, calli,
> or callvirt)" (Partition I, section 12.4, point 6).

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.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list