Hi Richard,

thank you very much for your suggestions, it seems to be working well. Now, the temporary variables survive the SSA optimisations.

and the txn_save_* variables are optimised "away". Is there any way to
prevent this kind of optimisations on SSA form for a particular group of
variables? Here I would like to see the txn_save_* variables behave as a
container for the values of the real variables and be sure that these
variables are not touched by any optimisations.

Well, if you are inserting this abnormal control flow after going into SSA
then you need to make sure all SSA variables affected are marked
as SSA_NAME_OCCURS_IN_ABNORMAL_PHI and make sure that
SSA names from a single base variable not have overlapping life-ranges.
Currently, the control flow and some function calls for setting up a transaction are introduced on GIMPLE. Thus, when the program is rewritten into SSA the function calls to stm_* force the merging of overlapping live ranges of single base variables: I tried it with Diegos nice example and introduced the call to stm_new in the following:

int
foo(int a, int b, int c)
{
 void * txn_handle;
 a = b;
 if (c < a)
   {
     b = b + a;
     c = c + a;
   }
 txn_handle = stm_new ();
 return b + c;
}

Usually, b has two overlapping live ranges where the stm_new was introduced and going into SSA shows the following:

foo (a, b, c)
{
 void * txn_handle;
 int D.1184;
 int D.1183;

 # BLOCK 2
 # PRED: ENTRY (fallthru)
 a_4 = b_3(D);
 if (c_5(D) < a_4)
   goto <bb 3>;
 else
   goto <bb 4>;
 # SUCC: 3 (true) 4 (false)

 # BLOCK 3
 # PRED: 2 (true)
 b_6 = b_3(D) + a_4;
 c_7 = c_5(D) + a_4;
 # SUCC: 4 (fallthru)

 # BLOCK 4
 # PRED: 2 (false) 3 (fallthru)
 # b_2 = PHI <b_3(D)(2), b_6(3)>
 # c_1 = PHI <c_5(D)(2), c_7(3)>
 D.1183_8 = stm_new ();
 txn_handle_9 = (void *) D.1183_8;
 D.1184_10 = b_2 + c_1;
 return D.1184_10;
 # SUCC: EXIT

}

The PHI-node to merge the two live ranges is introduced before the call to stm_new(). I believe this solves my problem because the checkpointing would be done afterwards and there only b_2 remains to checkpoint. Do you agree?

Which means what you are doing is not really going to be easy in
SSA form and you should rather try to do it before going into SSA.
And I would suggest you use the exception handling machinery of
GCC to do it and not insert setjmp/longjmp calls yourself or try to
track the complete program state.
You are right to propose to use the exception handling machinery to do the handling of setjmp/longjmp. But I see two issues with this approach: first, I am not experienced in programming GCC and don't know how to use this machinery. Second, the longjmp is executed by the library and, thus, not part of the implementation in GCC. I am not sure if this affects the EH mechanisms but I can imagine it could.

Regards,
Martin



Reply via email to