[M3devel] try/finally and ter optimization?

Jay K jay.krell at cornell.edu
Wed Jul 7 23:01:33 CEST 2010


This is an example that crashes the backend if ter is enabled.
TryFinStmt has three modes: Compile1, Compile2, Compile3.
 - stack walker
 - two other modes depending on the form of the function (I didn't read closely).
  One of them calls setjmp, one does not.
  In this case, no call to setjmp.
  Needs further investigation.
 Even if I put code in the finally block, same thing.
 TryStmt.m3 only has two modes, stack walker and not.
 So I think the problem is somewhere in TryFinStmt -- it doesn't generate a call to setjmp (Marker.CaptureState)



(* Compiling this program has crashed some backends.
 * (gcc backend with -O3, no volatile, 'ter')
 * This is reduced from libm3/Formatter.m3
 * The point therefore is merely to compile it without crashing.
 *)

MODULE Main;
 
VAR NoAlignOp: CARDINAL;

PROCEDURE PeekOp(<*NOWARN*> i: CARDINAL): CARDINAL =
  BEGIN RETURN NoAlignOp; END PeekOp;

VAR pos1: CARDINAL := 0;

<*NOWARN*> PROCEDURE PrintAlign(VAR pos: CARDINAL) =
  VAR op, endRun: CARDINAL := 0;
  BEGIN
    TRY
      LOOP
        op := PeekOp(pos);
        LOOP
          IF op = NoAlignOp THEN
            IF endRun = pos THEN
              INC(endRun);
            END;
            EXIT;
          END;
          op := PeekOp(pos1);
        END;
      END;
    FINALLY
    END;
  END PrintAlign;

BEGIN
END Main.

 		 	   		  


More information about the M3devel mailing list