#include "diagnostic.h"
#include "tree-pretty-print.h"
#include "tree-pass.h"
-#include "pointer-set.h"
#include "cfgloop.h"
#include "builtins.h"
{
duplicate_eh_regions_map label_map;
void *label_map_data;
- struct pointer_map_t *eh_map;
+ hash_map<void *, void *> *eh_map;
};
static void
{
eh_landing_pad old_lp, new_lp;
eh_region new_r;
- void **slot;
new_r = gen_eh_region (old_r->type, outer);
- slot = pointer_map_insert (data->eh_map, (void *)old_r);
- gcc_assert (*slot == NULL);
- *slot = (void *)new_r;
+ gcc_assert (!data->eh_map->put (old_r, new_r));
switch (old_r->type)
{
continue;
new_lp = gen_eh_landing_pad (new_r);
- slot = pointer_map_insert (data->eh_map, (void *)old_lp);
- gcc_assert (*slot == NULL);
- *slot = (void *)new_lp;
+ gcc_assert (!data->eh_map->put (old_lp, new_lp));
new_lp->post_landing_pad
= data->label_map (old_lp->post_landing_pad, data->label_map_data);
that allows the caller to remap uses of both EH regions and
EH landing pads. */
-struct pointer_map_t *
+hash_map<void *, void *> *
duplicate_eh_regions (struct function *ifun,
eh_region copy_region, int outer_lp,
duplicate_eh_regions_map map, void *map_data)
data.label_map = map;
data.label_map_data = map_data;
- data.eh_map = pointer_map_create ();
+ data.eh_map = new hash_map<void *, void *>;
outer_region = get_eh_region_from_lp_number (outer_lp);
first instruction of some existing BB and return the newly
produced block. */
static basic_block
-emit_to_new_bb_before (rtx seq, rtx insn)
+emit_to_new_bb_before (rtx_insn *seq, rtx insn)
{
- rtx last;
+ rtx_insn *last;
basic_block bb;
edge e;
edge_iterator ei;
for (i = 1; vec_safe_iterate (cfun->eh->lp_array, i, &lp); ++i)
{
basic_block bb;
- rtx seq;
+ rtx_insn *seq;
edge e;
if (lp == NULL || lp->post_landing_pad == NULL)
sjlj_mark_call_sites (void)
{
int last_call_site = -2;
- rtx insn, mem;
+ rtx_insn *insn;
+ rtx mem;
for (insn = get_insns (); insn ; insn = NEXT_INSN (insn))
{
eh_region r;
bool nothrow;
int this_call_site;
- rtx before, p;
+ rtx_insn *before, *p;
/* Reset value tracking at extended basic block boundaries. */
if (LABEL_P (insn))
/* Construct the SjLj_Function_Context. */
static void
-sjlj_emit_function_enter (rtx dispatch_label)
+sjlj_emit_function_enter (rtx_code_label *dispatch_label)
{
- rtx fn_begin, fc, mem, seq;
+ rtx_insn *fn_begin, *seq;
+ rtx fc, mem;
bool fn_begin_outside_block;
rtx personality = get_personality_function (current_function_decl);
the call to unwind_sjlj_unregister_libfunc if needed. */
void
-sjlj_emit_function_exit_after (rtx after)
+sjlj_emit_function_exit_after (rtx_insn *after)
{
crtl->eh.sjlj_exit_after = after;
}
static void
sjlj_emit_function_exit (void)
{
- rtx seq, insn;
+ rtx_insn *seq, *insn;
start_sequence ();
}
static void
-sjlj_emit_dispatch_table (rtx dispatch_label, int num_dispatch)
+sjlj_emit_dispatch_table (rtx_code_label *dispatch_label, int num_dispatch)
{
enum machine_mode unwind_word_mode = targetm.unwind_word_mode ();
enum machine_mode filter_mode = targetm.eh_return_filter_mode ();
eh_landing_pad lp;
- rtx mem, seq, fc, before, exc_ptr_reg, filter_reg;
+ rtx mem, fc, before, exc_ptr_reg, filter_reg;
+ rtx_insn *seq;
rtx first_reachable_label;
basic_block bb;
eh_region r;
CFG edges more exactly, we can use the forced_labels list instead. */
LABEL_PRESERVE_P (dispatch_label) = 1;
forced_labels
- = gen_rtx_EXPR_LIST (VOIDmode, dispatch_label, forced_labels);
+ = gen_rtx_INSN_LIST (VOIDmode, dispatch_label, forced_labels);
#endif
/* Load up exc_ptr and filter values from the function context. */
for (i = 1; vec_safe_iterate (cfun->eh->lp_array, i, &lp); ++i)
if (lp && lp->post_landing_pad)
{
- rtx seq2, label;
+ rtx_insn *seq2;
+ rtx label;
start_sequence ();
num_dispatch = sjlj_assign_call_site_values ();
if (num_dispatch > 0)
{
- rtx dispatch_label = gen_label_rtx ();
+ rtx_code_label *dispatch_label = gen_label_rtx ();
int align = STACK_SLOT_ALIGNMENT (sjlj_fc_type_node,
TYPE_MODE (sjlj_fc_type_node),
TYPE_ALIGN (sjlj_fc_type_node));
align);
sjlj_mark_call_sites ();
- sjlj_emit_function_enter (NULL_RTX);
+ sjlj_emit_function_enter (NULL);
sjlj_emit_function_exit ();
}
to look for a note, or the note itself. */
void
-copy_reg_eh_region_note_forward (rtx note_or_insn, rtx first, rtx last)
+copy_reg_eh_region_note_forward (rtx note_or_insn, rtx_insn *first, rtx last)
{
- rtx insn, note = note_or_insn;
+ rtx_insn *insn;
+ rtx note = note_or_insn;
if (INSN_P (note_or_insn))
{
/* Likewise, but iterate backward. */
void
-copy_reg_eh_region_note_backward (rtx note_or_insn, rtx last, rtx first)
+copy_reg_eh_region_note_backward (rtx note_or_insn, rtx_insn *last, rtx first)
{
- rtx insn, note = note_or_insn;
+ rtx_insn *insn;
+ rtx note = note_or_insn;
if (INSN_P (note_or_insn))
{
if (NONJUMP_INSN_P (insn)
&& GET_CODE (PATTERN (insn)) == SEQUENCE)
{
- rtx seq = PATTERN (insn);
- int i, n = XVECLEN (seq, 0);
+ rtx_sequence *seq = as_a <rtx_sequence *> (PATTERN (insn));
+ int i, n = seq->len ();
for (i = 0; i < n; i++)
- if (can_throw_external (XVECEXP (seq, 0, i)))
+ if (can_throw_external (seq->element (i)))
return true;
return false;
if (NONJUMP_INSN_P (insn)
&& GET_CODE (PATTERN (insn)) == SEQUENCE)
{
- rtx seq = PATTERN (insn);
- int i, n = XVECLEN (seq, 0);
+ rtx_sequence *seq = as_a <rtx_sequence *> (PATTERN (insn));
+ int i, n = seq->len ();
for (i = 0; i < n; i++)
- if (!insn_nothrow_p (XVECEXP (seq, 0, i)))
+ if (!insn_nothrow_p (seq->element (i)))
return false;
return true;
static unsigned int
set_nothrow_function_flags (void)
{
- rtx insn;
+ rtx_insn *insn;
crtl->nothrow = 1;
}
if (crtl->nothrow
- && (cgraph_function_body_availability (cgraph_get_node
- (current_function_decl))
+ && (cgraph_node::get (current_function_decl)->get_availability ()
>= AVAIL_AVAILABLE))
{
- struct cgraph_node *node = cgraph_get_node (current_function_decl);
+ struct cgraph_node *node = cgraph_node::get (current_function_decl);
struct cgraph_edge *e;
for (e = node->callers; e; e = e->next_caller)
e->can_throw_external = false;
- cgraph_set_nothrow_flag (node, true);
+ node->set_nothrow_flag (true);
if (dump_file)
fprintf (dump_file, "Marking function nothrow: %s\n\n",
RTL_PASS, /* type */
"nothrow", /* name */
OPTGROUP_NONE, /* optinfo_flags */
- true, /* has_execute */
TV_NONE, /* tv_id */
0, /* properties_required */
0, /* properties_provided */
void
expand_eh_return (void)
{
- rtx around_label;
+ rtx_code_label *around_label;
if (! crtl->eh.ehr_label)
return;
return call_site_base + crtl->eh.call_site_record_v[section]->length () - 1;
}
+static rtx_note *
+emit_note_eh_region_end (rtx insn)
+{
+ rtx_insn *next = NEXT_INSN (insn);
+
+ /* Make sure we do not split a call and its corresponding
+ CALL_ARG_LOCATION note. */
+ if (next && NOTE_P (next)
+ && NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION)
+ insn = next;
+
+ return emit_note_after (NOTE_INSN_EH_REGION_END, insn);
+}
+
/* Turn REG_EH_REGION notes back into NOTE_INSN_EH_REGION notes.
The new note numbers will not refer to region numbers, but
instead to call site entries. */
static unsigned int
convert_to_eh_region_ranges (void)
{
- rtx insn, iter, note;
+ rtx insn;
+ rtx_insn *iter;
+ rtx_note *note;
action_hash_type ar_hash (31);
int last_action = -3;
- rtx last_action_insn = NULL_RTX;
+ rtx_insn *last_action_insn = NULL;
rtx last_landing_pad = NULL_RTX;
- rtx first_no_action_insn = NULL_RTX;
+ rtx_insn *first_no_action_insn = NULL;
int call_site = 0;
int cur_sec = 0;
rtx section_switch_note = NULL_RTX;
- rtx first_no_action_insn_before_switch = NULL_RTX;
- rtx last_no_action_insn_before_switch = NULL_RTX;
+ rtx_insn *first_no_action_insn_before_switch = NULL;
+ rtx_insn *last_no_action_insn_before_switch = NULL;
int saved_call_site_base = call_site_base;
vec_alloc (crtl->eh.action_record_data, 64);
note = emit_note_before (NOTE_INSN_EH_REGION_BEG,
first_no_action_insn_before_switch);
NOTE_EH_HANDLER (note) = call_site;
- note = emit_note_after (NOTE_INSN_EH_REGION_END,
- last_no_action_insn_before_switch);
+ note
+ = emit_note_eh_region_end (last_no_action_insn_before_switch);
NOTE_EH_HANDLER (note) = call_site;
gcc_assert (last_action != -3
|| (last_action_insn
== last_no_action_insn_before_switch));
- first_no_action_insn_before_switch = NULL_RTX;
- last_no_action_insn_before_switch = NULL_RTX;
+ first_no_action_insn_before_switch = NULL;
+ last_no_action_insn_before_switch = NULL;
call_site_base++;
}
/* If we'd not seen a previous action (-3) or the previous
note = emit_note_before (NOTE_INSN_EH_REGION_BEG,
first_no_action_insn);
NOTE_EH_HANDLER (note) = call_site;
- first_no_action_insn = NULL_RTX;
+ first_no_action_insn = NULL;
}
- note = emit_note_after (NOTE_INSN_EH_REGION_END,
- last_action_insn);
+ note = emit_note_eh_region_end (last_action_insn);
NOTE_EH_HANDLER (note) = call_site;
}
{
first_no_action_insn_before_switch = first_no_action_insn;
last_no_action_insn_before_switch = last_action_insn;
- first_no_action_insn = NULL_RTX;
+ first_no_action_insn = NULL;
gcc_assert (last_action == -1);
last_action = -3;
}
if (last_action >= -1 && ! first_no_action_insn)
{
- note = emit_note_after (NOTE_INSN_EH_REGION_END, last_action_insn);
+ note = emit_note_eh_region_end (last_action_insn);
NOTE_EH_HANDLER (note) = call_site;
}
RTL_PASS, /* type */
"eh_ranges", /* name */
OPTGROUP_NONE, /* optinfo_flags */
- true, /* has_execute */
TV_NONE, /* tv_id */
0, /* properties_required */
0, /* properties_provided */