update build cfg code

This commit is contained in:
fanfuqiang 2018-10-16 23:39:52 +08:00
parent 60cb5de6cf
commit cf8ba4ae9e

@ -459,11 +459,10 @@ cfi_make_blocks_and_edgs ()
stmt1; stmt1;
lhs = t_; lhs = t_;
ne_expr (lhs, s_); ne_expr (lhs, s_);
// true
goto call_label;
// FALLTHRU // FALLTHRU
<bb ???> # true
cfi_catch(); cfi_catch();
call_label: <bb ???> # false
call fptr; call fptr;
+-------- +--------
@ -508,9 +507,9 @@ insert_cond_and_build_ssa_cfg (gimple_stmt_iterator *gp,
gimple_set_block (test, gimple_block (cs)); gimple_set_block (test, gimple_block (cs));
gsi_insert_before (&gsi, test, GSI_SAME_STMT); gsi_insert_before (&gsi, test, 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));
gsi_insert_before (&gsi, branch, GSI_SAME_STMT); //gsi_insert_before (&gsi, branch, GSI_SAME_STMT);
/* catch function */ /* catch function */
//hl_fe_cfi_catch (); //hl_fe_cfi_catch ();
@ -519,10 +518,11 @@ insert_cond_and_build_ssa_cfg (gimple_stmt_iterator *gp,
gsi_insert_before (&gsi, catch, GSI_SAME_STMT); gsi_insert_before (&gsi, catch, GSI_SAME_STMT);
/* call_label: */ /* call_label: */
label = create_artificial_label (gimple_location (cs)); //label = create_artificial_label (gimple_location (cs));
call = gimple_build_label (label); //call = gimple_build_label (label);
gimple_set_block (call, gimple_block (cs)); //gimple_set_block (call, gimple_block (cs));
gsi_insert_before (&gsi, call, GSI_SAME_STMT); //gsi_insert_before (&gsi, call, GSI_SAME_STMT);
call = cs;
// current statement should be original call. // current statement should be original call.
gcc_assert (is_gimple_call (gsi_stmt (gsi))); gcc_assert (is_gimple_call (gsi_stmt (gsi)));
@ -535,8 +535,10 @@ 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
branch test
<new bb> #true
catch catch
<old bb> #false
call call
# old code */ # old code */
/* Make the blocks & edges. */ /* Make the blocks & edges. */
@ -545,13 +547,13 @@ insert_cond_and_build_ssa_cfg (gimple_stmt_iterator *gp,
{ {
basic_block bb = ENTRY_BLOCK_PTR; basic_block bb = ENTRY_BLOCK_PTR;
// //
g = gsi_for_stmt (branch); g = gsi_for_stmt (test);
gsi_split_seq_before (&g, &branch); gsi_split_seq_before (&g, &test);
bb = create_basic_block (branch, NULL, bb); bb = create_basic_block (test, NULL, bb);
gimple_set_bb (assign, bb); gimple_set_bb (assign, bb);
gimple_set_bb (branch, bb); gimple_set_bb (test, bb);
// // 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 = create_basic_block (catch, NULL, bb);