update build cfg egde code
This commit is contained in:
parent
cf8ba4ae9e
commit
d805638feb
|
@ -476,8 +476,8 @@ insert_cond_and_build_ssa_cfg (gimple_stmt_iterator *gp,
|
||||||
{
|
{
|
||||||
gimple cs, g;
|
gimple cs, g;
|
||||||
gimple_stmt_iterator first, gsi;
|
gimple_stmt_iterator first, gsi;
|
||||||
gimple assign; // test gimple we insert.
|
gimple assign; // assign gimple we insert.
|
||||||
gimple test; // test gimple we insert.
|
gimple cond; // test gimple we insert.
|
||||||
gimple catch; // catch function we insert.
|
gimple catch; // catch function we insert.
|
||||||
gimple branch; // goto gimple we insert.
|
gimple branch; // goto gimple we insert.
|
||||||
gimple call; // call label gimple we insert.
|
gimple call; // call label gimple we insert.
|
||||||
|
@ -503,9 +503,9 @@ insert_cond_and_build_ssa_cfg (gimple_stmt_iterator *gp,
|
||||||
gimple_set_block (assign, gimple_block (cs));
|
gimple_set_block (assign, gimple_block (cs));
|
||||||
gsi_insert_before (&gsi, assign, GSI_SAME_STMT);
|
gsi_insert_before (&gsi, assign, GSI_SAME_STMT);
|
||||||
// if (lhs != s_) goto cfi_catch else goto call
|
// if (lhs != s_) goto cfi_catch else goto call
|
||||||
test = gimple_build_cond (NE_EXPR, lhs, s_, NULL, NULL);
|
cond = gimple_build_cond (NE_EXPR, lhs, s_, NULL, NULL);
|
||||||
gimple_set_block (test, gimple_block (cs));
|
gimple_set_block (cond, gimple_block (cs));
|
||||||
gsi_insert_before (&gsi, test, GSI_SAME_STMT);
|
gsi_insert_before (&gsi, cond, GSI_SAME_STMT);
|
||||||
// goto call_label
|
// goto call_label
|
||||||
//branch = gimple_build_goto (call);
|
//branch = gimple_build_goto (call);
|
||||||
//gimple_set_block (branch, gimple_block (cs));
|
//gimple_set_block (branch, gimple_block (cs));
|
||||||
|
@ -535,7 +535,7 @@ insert_cond_and_build_ssa_cfg (gimple_stmt_iterator *gp,
|
||||||
/* We can sure we have this code fragment(write as gimple pointers):
|
/* We can sure we have this code fragment(write as gimple pointers):
|
||||||
# old code
|
# old code
|
||||||
assign
|
assign
|
||||||
test
|
cond
|
||||||
<new bb> #true
|
<new bb> #true
|
||||||
catch
|
catch
|
||||||
<old bb> #false
|
<old bb> #false
|
||||||
|
@ -545,24 +545,28 @@ insert_cond_and_build_ssa_cfg (gimple_stmt_iterator *gp,
|
||||||
stmt_starts_bb_p ();
|
stmt_starts_bb_p ();
|
||||||
stmt_ends_bb_p ();
|
stmt_ends_bb_p ();
|
||||||
{
|
{
|
||||||
basic_block bb = ENTRY_BLOCK_PTR;
|
basic_block bb_cond;
|
||||||
|
basic_block bb_catch;
|
||||||
|
basic_block bb_call;
|
||||||
|
edge edge_false;
|
||||||
|
edge edge_true;
|
||||||
//
|
//
|
||||||
g = gsi_for_stmt (test);
|
g = gsi_for_stmt (cond);
|
||||||
gsi_split_seq_before (&g, &test);
|
gsi_split_seq_before (&g, &cond);
|
||||||
bb = create_basic_block (test, NULL, bb);
|
bb_cond = create_basic_block (cond, NULL, bb);
|
||||||
gimple_set_bb (assign, bb);
|
gimple_set_bb (assign, bb_cond);
|
||||||
gimple_set_bb (test, bb);
|
gimple_set_bb (cond, bb_cond);
|
||||||
|
|
||||||
// EDGE_TRUE_VALUE
|
// EDGE_TRUE_VALUE
|
||||||
g = gsi_for_stmt (catch);
|
g = gsi_for_stmt (catch);
|
||||||
gsi_split_seq_before (&g, &catch);
|
gsi_split_seq_before (&g, &catch);
|
||||||
bb = create_basic_block (catch, NULL, bb);
|
bb_catch = create_basic_block (catch, NULL, bb_catch);
|
||||||
gimple_set_bb (catch, bb);
|
gimple_set_bb (catch, bb_catch);
|
||||||
//
|
// EDGE_FALSE_VALUE
|
||||||
g = gsi_for_stmt (call);
|
/* Split the block between the catch and original call. */
|
||||||
gsi_split_seq_before (&g, &call);
|
bb_call = gimple_bb (call);
|
||||||
bb = create_basic_block (call, NULL, bb);
|
edge_false = split_block (bb_call, catch);
|
||||||
gimple_set_bb (call, bb);
|
GIMPLE_CHECK (edge_false->dest->il.gimple.seq, GIMPLE_CALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue