public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] enable adjustment of return_pc debug attrs
@ 2023-03-24 6:25 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2023-03-24 6:25 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:fcbc3270d9ce1db7f4f9c7205dc38cc8db4589bd
commit fcbc3270d9ce1db7f4f9c7205dc38cc8db4589bd
Author: Alexandre Oliva <oliva@adacore.com>
Date: Thu Mar 23 00:44:58 2023 -0300
enable adjustment of return_pc debug attrs
This patch introduces infrastructure for targets to add an offset to
the label issued after the call_insn to set the call_return_pc
attribute. This will be used on rs6000, that sometimes issues another
instruction after the call proper as part of a call insn.
for gcc/ChangeLog
* target.def (call_offset_return_label): New hook.
* gcc/doc/tm.texi.in (TARGET_CALL_OFFSET_RETURN_LABEL): Add
placeholder.
* gcc/doc/tm.texi: Rebuild.
* dwarf2out.cc (struct call_arg_loc_node): Record call_insn
instad of call_arg_loc_note.
(add_AT_lbl_id): Add optional offset argument.
(gen_call_site_die): Compute and pass on a return pc offset.
(gen_subprogram_die): Move call_arg_loc_note computation...
(dwarf2out_var_location): ... from here. Set call_insn.
Diff:
---
gcc/doc/tm.texi | 7 +++++++
gcc/doc/tm.texi.in | 2 ++
gcc/dwarf2out.cc | 26 +++++++++++++++++---------
gcc/target.def | 9 +++++++++
4 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 4bb48c5428c..83ebe3d51b7 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -5426,6 +5426,13 @@ except the last are treated as named.
You need not define this hook if it always returns @code{false}.
@end deftypefn
+@deftypefn {Target Hook} int TARGET_CALL_OFFSET_RETURN_LABEL (rtx_insn *@var{call_insn})
+While generating call-site debug info for a CALL insn, or a SEQUENCE
+insn starting with a CALL, this target hook is invoked to compute the
+offset to be added to the debug label emitted after the call to obtain
+the return address that should be recorded as the return PC.
+@end deftypefn
+
@deftypefn {Target Hook} void TARGET_CALL_ARGS (rtx, @var{tree})
While generating RTL for a function call, this target hook is invoked once
for each argument passed to the function, either a register returned by
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index f7ab5d48a63..89dfe94953d 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3785,6 +3785,8 @@ These machine description macros help implement varargs:
@hook TARGET_STRICT_ARGUMENT_NAMING
+@hook TARGET_CALL_OFFSET_RETURN_LABEL
+
@hook TARGET_CALL_ARGS
@hook TARGET_END_CALL_ARGS
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 1711ad2c2da..d1db918c439 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -3584,7 +3584,7 @@ typedef struct var_loc_list_def var_loc_list;
/* Call argument location list. */
struct GTY ((chain_next ("%h.next"))) call_arg_loc_node {
- rtx GTY (()) call_arg_loc_note;
+ rtx_insn * GTY (()) call_insn;
const char * GTY (()) label;
tree GTY (()) block;
bool tail_call_p;
@@ -3768,7 +3768,8 @@ static void remove_addr_table_entry (addr_table_entry *);
static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool);
static inline rtx AT_addr (dw_attr_node *);
static void add_AT_symview (dw_die_ref, enum dwarf_attribute, const char *);
-static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
+static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *,
+ int = 0);
static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
@@ -5327,14 +5328,17 @@ add_AT_symview (dw_die_ref die, enum dwarf_attribute attr_kind,
static inline void
add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
- const char *lbl_id)
+ const char *lbl_id, int offset)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr.dw_attr_val.val_entry = NULL;
- attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ if (!offset)
+ attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ else
+ attr.dw_attr_val.v.val_lbl_id = xasprintf ("%s%+i", lbl_id, offset);
if (dwarf_split_debug_info)
attr.dw_attr_val.val_entry
= add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
@@ -23405,7 +23409,9 @@ gen_call_site_die (tree decl, dw_die_ref subr_die,
if (stmt_die == NULL)
stmt_die = subr_die;
die = new_die (dwarf_TAG (DW_TAG_call_site), stmt_die, NULL_TREE);
- add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc), ca_loc->label);
+ add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc),
+ ca_loc->label,
+ targetm.calls.call_offset_return_label (ca_loc->call_insn));
if (ca_loc->tail_call_p)
add_AT_flag (die, dwarf_AT (DW_AT_call_tail_call), 1);
if (ca_loc->symbol_ref)
@@ -24092,11 +24098,14 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
{
dw_die_ref die = NULL;
rtx tloc = NULL_RTX, tlocc = NULL_RTX;
+ rtx call_arg_loc_note
+ = find_reg_note (ca_loc->call_insn,
+ REG_CALL_ARG_LOCATION, NULL_RTX);
rtx arg, next_arg;
tree arg_decl = NULL_TREE;
- for (arg = (ca_loc->call_arg_loc_note != NULL_RTX
- ? XEXP (ca_loc->call_arg_loc_note, 0)
+ for (arg = (call_arg_loc_note != NULL_RTX
+ ? XEXP (call_arg_loc_note, 0)
: NULL_RTX);
arg; arg = next_arg)
{
@@ -28125,8 +28134,7 @@ create_label:
= ggc_cleared_alloc<call_arg_loc_node> ();
rtx_insn *prev = call_insn;
- ca_loc->call_arg_loc_note
- = find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX);
+ ca_loc->call_insn = call_insn;
ca_loc->next = NULL;
ca_loc->label = last_label;
gcc_assert (prev
diff --git a/gcc/target.def b/gcc/target.def
index 1b9c882229e..38c72670fef 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4722,6 +4722,15 @@ not generate any instructions in this case.",
int *pretend_args_size, int second_time),
default_setup_incoming_varargs)
+DEFHOOK
+(call_offset_return_label,
+ "While generating call-site debug info for a CALL insn, or a SEQUENCE\n\
+insn starting with a CALL, this target hook is invoked to compute the\n\
+offset to be added to the debug label emitted after the call to obtain\n\
+the return address that should be recorded as the return PC.",
+ int, (rtx_insn *call_insn),
+ hook_int_rtx_insn_0)
+
DEFHOOK
(call_args,
"While generating RTL for a function call, this target hook is invoked once\n\
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] enable adjustment of return_pc debug attrs
@ 2024-05-29 6:58 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2024-05-29 6:58 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:99047b701feb580e047a1b13bdf85a7fd21224e2
commit 99047b701feb580e047a1b13bdf85a7fd21224e2
Author: Alexandre Oliva <oliva@adacore.com>
Date: Wed May 29 02:52:07 2024 -0300
enable adjustment of return_pc debug attrs
This patch introduces infrastructure for targets to add an offset to
the label issued after the call_insn to set the call_return_pc
attribute. This will be used on rs6000, that sometimes issues another
instruction after the call proper as part of a call insn.
for gcc/ChangeLog
* target.def (call_offset_return_label): New hook.
* gcc/doc/tm.texi.in (TARGET_CALL_OFFSET_RETURN_LABEL): Add
placeholder.
* gcc/doc/tm.texi: Rebuild.
* dwarf2out.cc (struct call_arg_loc_node): Record call_insn
instad of call_arg_loc_note.
(add_AT_lbl_id): Add optional offset argument.
(gen_call_site_die): Compute and pass on a return pc offset.
(gen_subprogram_die): Move call_arg_loc_note computation...
(dwarf2out_var_location): ... from here. Set call_insn.
Diff:
---
gcc/doc/tm.texi | 7 +++++++
gcc/doc/tm.texi.in | 2 ++
gcc/dwarf2out.cc | 26 +++++++++++++++++---------
gcc/target.def | 9 +++++++++
4 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index cd50078227d..8a7aa70d605 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -5557,6 +5557,13 @@ except the last are treated as named.
You need not define this hook if it always returns @code{false}.
@end deftypefn
+@deftypefn {Target Hook} int TARGET_CALL_OFFSET_RETURN_LABEL (rtx_insn *@var{call_insn})
+While generating call-site debug info for a CALL insn, or a SEQUENCE
+insn starting with a CALL, this target hook is invoked to compute the
+offset to be added to the debug label emitted after the call to obtain
+the return address that should be recorded as the return PC.
+@end deftypefn
+
@deftypefn {Target Hook} void TARGET_START_CALL_ARGS (cumulative_args_t @var{complete_args})
This target hook is invoked while generating RTL for a function call,
after the argument values have been computed, and after stack arguments
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 058bd56487a..9e0830758ae 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3887,6 +3887,8 @@ These machine description macros help implement varargs:
@hook TARGET_STRICT_ARGUMENT_NAMING
+@hook TARGET_CALL_OFFSET_RETURN_LABEL
+
@hook TARGET_START_CALL_ARGS
@hook TARGET_CALL_ARGS
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 5b064ffd78a..1092880738d 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -3593,7 +3593,7 @@ typedef struct var_loc_list_def var_loc_list;
/* Call argument location list. */
struct GTY ((chain_next ("%h.next"))) call_arg_loc_node {
- rtx GTY (()) call_arg_loc_note;
+ rtx_insn * GTY (()) call_insn;
const char * GTY (()) label;
tree GTY (()) block;
bool tail_call_p;
@@ -3777,7 +3777,8 @@ static void remove_addr_table_entry (addr_table_entry *);
static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool);
static inline rtx AT_addr (dw_attr_node *);
static void add_AT_symview (dw_die_ref, enum dwarf_attribute, const char *);
-static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
+static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *,
+ int = 0);
static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
@@ -5353,14 +5354,17 @@ add_AT_symview (dw_die_ref die, enum dwarf_attribute attr_kind,
static inline void
add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
- const char *lbl_id)
+ const char *lbl_id, int offset)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr.dw_attr_val.val_entry = NULL;
- attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ if (!offset)
+ attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ else
+ attr.dw_attr_val.v.val_lbl_id = xasprintf ("%s%+i", lbl_id, offset);
if (dwarf_split_debug_info)
attr.dw_attr_val.val_entry
= add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
@@ -23515,7 +23519,9 @@ gen_call_site_die (tree decl, dw_die_ref subr_die,
if (stmt_die == NULL)
stmt_die = subr_die;
die = new_die (dwarf_TAG (DW_TAG_call_site), stmt_die, NULL_TREE);
- add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc), ca_loc->label);
+ add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc),
+ ca_loc->label,
+ targetm.calls.call_offset_return_label (ca_loc->call_insn));
if (ca_loc->tail_call_p)
add_AT_flag (die, dwarf_AT (DW_AT_call_tail_call), 1);
if (ca_loc->symbol_ref)
@@ -24202,11 +24208,14 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
{
dw_die_ref die = NULL;
rtx tloc = NULL_RTX, tlocc = NULL_RTX;
+ rtx call_arg_loc_note
+ = find_reg_note (ca_loc->call_insn,
+ REG_CALL_ARG_LOCATION, NULL_RTX);
rtx arg, next_arg;
tree arg_decl = NULL_TREE;
- for (arg = (ca_loc->call_arg_loc_note != NULL_RTX
- ? XEXP (ca_loc->call_arg_loc_note, 0)
+ for (arg = (call_arg_loc_note != NULL_RTX
+ ? XEXP (call_arg_loc_note, 0)
: NULL_RTX);
arg; arg = next_arg)
{
@@ -28251,8 +28260,7 @@ create_label:
= ggc_cleared_alloc<call_arg_loc_node> ();
rtx_insn *prev = call_insn;
- ca_loc->call_arg_loc_note
- = find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX);
+ ca_loc->call_insn = call_insn;
ca_loc->next = NULL;
ca_loc->label = last_label;
gcc_assert (prev
diff --git a/gcc/target.def b/gcc/target.def
index c27df8095be..70070caebc7 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4890,6 +4890,15 @@ Most ports do not need to implement anything for this hook.",
void, (cumulative_args_t complete_args),
hook_void_CUMULATIVE_ARGS)
+DEFHOOK
+(call_offset_return_label,
+ "While generating call-site debug info for a CALL insn, or a SEQUENCE\n\
+insn starting with a CALL, this target hook is invoked to compute the\n\
+offset to be added to the debug label emitted after the call to obtain\n\
+the return address that should be recorded as the return PC.",
+ int, (rtx_insn *call_insn),
+ hook_int_rtx_insn_0)
+
DEFHOOK
(push_argument,
"This target hook returns @code{true} if push instructions will be\n\
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] enable adjustment of return_pc debug attrs
@ 2024-05-25 8:07 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2024-05-25 8:07 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a56062c190d0324f8b84be3705fee494be390894
commit a56062c190d0324f8b84be3705fee494be390894
Author: Alexandre Oliva <oliva@adacore.com>
Date: Fri Apr 14 23:53:34 2023 -0300
enable adjustment of return_pc debug attrs
This patch introduces infrastructure for targets to add an offset to
the label issued after the call_insn to set the call_return_pc
attribute. This will be used on rs6000, that sometimes issues another
instruction after the call proper as part of a call insn.
for gcc/ChangeLog
* target.def (call_offset_return_label): New hook.
* gcc/doc/tm.texi.in (TARGET_CALL_OFFSET_RETURN_LABEL): Add
placeholder.
* gcc/doc/tm.texi: Rebuild.
* dwarf2out.cc (struct call_arg_loc_node): Record call_insn
instad of call_arg_loc_note.
(add_AT_lbl_id): Add optional offset argument.
(gen_call_site_die): Compute and pass on a return pc offset.
(gen_subprogram_die): Move call_arg_loc_note computation...
(dwarf2out_var_location): ... from here. Set call_insn.
Diff:
---
gcc/doc/tm.texi | 7 +++++++
gcc/doc/tm.texi.in | 2 ++
gcc/dwarf2out.cc | 26 +++++++++++++++++---------
gcc/target.def | 9 +++++++++
4 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index cd50078227d..8a7aa70d605 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -5557,6 +5557,13 @@ except the last are treated as named.
You need not define this hook if it always returns @code{false}.
@end deftypefn
+@deftypefn {Target Hook} int TARGET_CALL_OFFSET_RETURN_LABEL (rtx_insn *@var{call_insn})
+While generating call-site debug info for a CALL insn, or a SEQUENCE
+insn starting with a CALL, this target hook is invoked to compute the
+offset to be added to the debug label emitted after the call to obtain
+the return address that should be recorded as the return PC.
+@end deftypefn
+
@deftypefn {Target Hook} void TARGET_START_CALL_ARGS (cumulative_args_t @var{complete_args})
This target hook is invoked while generating RTL for a function call,
after the argument values have been computed, and after stack arguments
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 058bd56487a..9e0830758ae 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3887,6 +3887,8 @@ These machine description macros help implement varargs:
@hook TARGET_STRICT_ARGUMENT_NAMING
+@hook TARGET_CALL_OFFSET_RETURN_LABEL
+
@hook TARGET_START_CALL_ARGS
@hook TARGET_CALL_ARGS
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 5b064ffd78a..1092880738d 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -3593,7 +3593,7 @@ typedef struct var_loc_list_def var_loc_list;
/* Call argument location list. */
struct GTY ((chain_next ("%h.next"))) call_arg_loc_node {
- rtx GTY (()) call_arg_loc_note;
+ rtx_insn * GTY (()) call_insn;
const char * GTY (()) label;
tree GTY (()) block;
bool tail_call_p;
@@ -3777,7 +3777,8 @@ static void remove_addr_table_entry (addr_table_entry *);
static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool);
static inline rtx AT_addr (dw_attr_node *);
static void add_AT_symview (dw_die_ref, enum dwarf_attribute, const char *);
-static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
+static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *,
+ int = 0);
static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
@@ -5353,14 +5354,17 @@ add_AT_symview (dw_die_ref die, enum dwarf_attribute attr_kind,
static inline void
add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
- const char *lbl_id)
+ const char *lbl_id, int offset)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr.dw_attr_val.val_entry = NULL;
- attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ if (!offset)
+ attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ else
+ attr.dw_attr_val.v.val_lbl_id = xasprintf ("%s%+i", lbl_id, offset);
if (dwarf_split_debug_info)
attr.dw_attr_val.val_entry
= add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
@@ -23515,7 +23519,9 @@ gen_call_site_die (tree decl, dw_die_ref subr_die,
if (stmt_die == NULL)
stmt_die = subr_die;
die = new_die (dwarf_TAG (DW_TAG_call_site), stmt_die, NULL_TREE);
- add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc), ca_loc->label);
+ add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc),
+ ca_loc->label,
+ targetm.calls.call_offset_return_label (ca_loc->call_insn));
if (ca_loc->tail_call_p)
add_AT_flag (die, dwarf_AT (DW_AT_call_tail_call), 1);
if (ca_loc->symbol_ref)
@@ -24202,11 +24208,14 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
{
dw_die_ref die = NULL;
rtx tloc = NULL_RTX, tlocc = NULL_RTX;
+ rtx call_arg_loc_note
+ = find_reg_note (ca_loc->call_insn,
+ REG_CALL_ARG_LOCATION, NULL_RTX);
rtx arg, next_arg;
tree arg_decl = NULL_TREE;
- for (arg = (ca_loc->call_arg_loc_note != NULL_RTX
- ? XEXP (ca_loc->call_arg_loc_note, 0)
+ for (arg = (call_arg_loc_note != NULL_RTX
+ ? XEXP (call_arg_loc_note, 0)
: NULL_RTX);
arg; arg = next_arg)
{
@@ -28251,8 +28260,7 @@ create_label:
= ggc_cleared_alloc<call_arg_loc_node> ();
rtx_insn *prev = call_insn;
- ca_loc->call_arg_loc_note
- = find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX);
+ ca_loc->call_insn = call_insn;
ca_loc->next = NULL;
ca_loc->label = last_label;
gcc_assert (prev
diff --git a/gcc/target.def b/gcc/target.def
index c27df8095be..70070caebc7 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4890,6 +4890,15 @@ Most ports do not need to implement anything for this hook.",
void, (cumulative_args_t complete_args),
hook_void_CUMULATIVE_ARGS)
+DEFHOOK
+(call_offset_return_label,
+ "While generating call-site debug info for a CALL insn, or a SEQUENCE\n\
+insn starting with a CALL, this target hook is invoked to compute the\n\
+offset to be added to the debug label emitted after the call to obtain\n\
+the return address that should be recorded as the return PC.",
+ int, (rtx_insn *call_insn),
+ hook_int_rtx_insn_0)
+
DEFHOOK
(push_argument,
"This target hook returns @code{true} if push instructions will be\n\
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] enable adjustment of return_pc debug attrs
@ 2023-04-06 6:35 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2023-04-06 6:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8588284518541b83f343153c09dbc3503692c4d5
commit 8588284518541b83f343153c09dbc3503692c4d5
Author: Alexandre Oliva <oliva@adacore.com>
Date: Wed Apr 5 11:27:06 2023 -0300
enable adjustment of return_pc debug attrs
This patch introduces infrastructure for targets to add an offset to
the label issued after the call_insn to set the call_return_pc
attribute. This will be used on rs6000, that sometimes issues another
instruction after the call proper as part of a call insn.
for gcc/ChangeLog
* target.def (call_offset_return_label): New hook.
* gcc/doc/tm.texi.in (TARGET_CALL_OFFSET_RETURN_LABEL): Add
placeholder.
* gcc/doc/tm.texi: Rebuild.
* dwarf2out.cc (struct call_arg_loc_node): Record call_insn
instad of call_arg_loc_note.
(add_AT_lbl_id): Add optional offset argument.
(gen_call_site_die): Compute and pass on a return pc offset.
(gen_subprogram_die): Move call_arg_loc_note computation...
(dwarf2out_var_location): ... from here. Set call_insn.
Diff:
---
gcc/doc/tm.texi | 7 +++++++
gcc/doc/tm.texi.in | 2 ++
gcc/dwarf2out.cc | 26 +++++++++++++++++---------
gcc/target.def | 9 +++++++++
4 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index a660e33739b..309dda8883a 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -5428,6 +5428,13 @@ except the last are treated as named.
You need not define this hook if it always returns @code{false}.
@end deftypefn
+@deftypefn {Target Hook} int TARGET_CALL_OFFSET_RETURN_LABEL (rtx_insn *@var{call_insn})
+While generating call-site debug info for a CALL insn, or a SEQUENCE
+insn starting with a CALL, this target hook is invoked to compute the
+offset to be added to the debug label emitted after the call to obtain
+the return address that should be recorded as the return PC.
+@end deftypefn
+
@deftypefn {Target Hook} void TARGET_CALL_ARGS (rtx, @var{tree})
While generating RTL for a function call, this target hook is invoked once
for each argument passed to the function, either a register returned by
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index f7ab5d48a63..89dfe94953d 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3785,6 +3785,8 @@ These machine description macros help implement varargs:
@hook TARGET_STRICT_ARGUMENT_NAMING
+@hook TARGET_CALL_OFFSET_RETURN_LABEL
+
@hook TARGET_CALL_ARGS
@hook TARGET_END_CALL_ARGS
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 1a0015ce00f..3d00835628a 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -3584,7 +3584,7 @@ typedef struct var_loc_list_def var_loc_list;
/* Call argument location list. */
struct GTY ((chain_next ("%h.next"))) call_arg_loc_node {
- rtx GTY (()) call_arg_loc_note;
+ rtx_insn * GTY (()) call_insn;
const char * GTY (()) label;
tree GTY (()) block;
bool tail_call_p;
@@ -3768,7 +3768,8 @@ static void remove_addr_table_entry (addr_table_entry *);
static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool);
static inline rtx AT_addr (dw_attr_node *);
static void add_AT_symview (dw_die_ref, enum dwarf_attribute, const char *);
-static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
+static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *,
+ int = 0);
static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
@@ -5327,14 +5328,17 @@ add_AT_symview (dw_die_ref die, enum dwarf_attribute attr_kind,
static inline void
add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
- const char *lbl_id)
+ const char *lbl_id, int offset)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr.dw_attr_val.val_entry = NULL;
- attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ if (!offset)
+ attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ else
+ attr.dw_attr_val.v.val_lbl_id = xasprintf ("%s%+i", lbl_id, offset);
if (dwarf_split_debug_info)
attr.dw_attr_val.val_entry
= add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
@@ -23406,7 +23410,9 @@ gen_call_site_die (tree decl, dw_die_ref subr_die,
if (stmt_die == NULL)
stmt_die = subr_die;
die = new_die (dwarf_TAG (DW_TAG_call_site), stmt_die, NULL_TREE);
- add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc), ca_loc->label);
+ add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc),
+ ca_loc->label,
+ targetm.calls.call_offset_return_label (ca_loc->call_insn));
if (ca_loc->tail_call_p)
add_AT_flag (die, dwarf_AT (DW_AT_call_tail_call), 1);
if (ca_loc->symbol_ref)
@@ -24093,11 +24099,14 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
{
dw_die_ref die = NULL;
rtx tloc = NULL_RTX, tlocc = NULL_RTX;
+ rtx call_arg_loc_note
+ = find_reg_note (ca_loc->call_insn,
+ REG_CALL_ARG_LOCATION, NULL_RTX);
rtx arg, next_arg;
tree arg_decl = NULL_TREE;
- for (arg = (ca_loc->call_arg_loc_note != NULL_RTX
- ? XEXP (ca_loc->call_arg_loc_note, 0)
+ for (arg = (call_arg_loc_note != NULL_RTX
+ ? XEXP (call_arg_loc_note, 0)
: NULL_RTX);
arg; arg = next_arg)
{
@@ -28126,8 +28135,7 @@ create_label:
= ggc_cleared_alloc<call_arg_loc_node> ();
rtx_insn *prev = call_insn;
- ca_loc->call_arg_loc_note
- = find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX);
+ ca_loc->call_insn = call_insn;
ca_loc->next = NULL;
ca_loc->label = last_label;
gcc_assert (prev
diff --git a/gcc/target.def b/gcc/target.def
index 171bbd1caf1..8acc61b5337 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4722,6 +4722,15 @@ not generate any instructions in this case.",
int *pretend_args_size, int second_time),
default_setup_incoming_varargs)
+DEFHOOK
+(call_offset_return_label,
+ "While generating call-site debug info for a CALL insn, or a SEQUENCE\n\
+insn starting with a CALL, this target hook is invoked to compute the\n\
+offset to be added to the debug label emitted after the call to obtain\n\
+the return address that should be recorded as the return PC.",
+ int, (rtx_insn *call_insn),
+ hook_int_rtx_insn_0)
+
DEFHOOK
(call_args,
"While generating RTL for a function call, this target hook is invoked once\n\
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] enable adjustment of return_pc debug attrs
@ 2023-03-30 14:07 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2023-03-30 14:07 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:de28eb401aa16233fd0a5a1bf3af0f2262f18095
commit de28eb401aa16233fd0a5a1bf3af0f2262f18095
Author: Alexandre Oliva <oliva@adacore.com>
Date: Thu Mar 30 05:07:15 2023 -0300
enable adjustment of return_pc debug attrs
This patch introduces infrastructure for targets to add an offset to
the label issued after the call_insn to set the call_return_pc
attribute. This will be used on rs6000, that sometimes issues another
instruction after the call proper as part of a call insn.
for gcc/ChangeLog
* target.def (call_offset_return_label): New hook.
* gcc/doc/tm.texi.in (TARGET_CALL_OFFSET_RETURN_LABEL): Add
placeholder.
* gcc/doc/tm.texi: Rebuild.
* dwarf2out.cc (struct call_arg_loc_node): Record call_insn
instad of call_arg_loc_note.
(add_AT_lbl_id): Add optional offset argument.
(gen_call_site_die): Compute and pass on a return pc offset.
(gen_subprogram_die): Move call_arg_loc_note computation...
(dwarf2out_var_location): ... from here. Set call_insn.
Diff:
---
gcc/doc/tm.texi | 7 +++++++
gcc/doc/tm.texi.in | 2 ++
gcc/dwarf2out.cc | 26 +++++++++++++++++---------
gcc/target.def | 9 +++++++++
4 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 4bb48c5428c..83ebe3d51b7 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -5426,6 +5426,13 @@ except the last are treated as named.
You need not define this hook if it always returns @code{false}.
@end deftypefn
+@deftypefn {Target Hook} int TARGET_CALL_OFFSET_RETURN_LABEL (rtx_insn *@var{call_insn})
+While generating call-site debug info for a CALL insn, or a SEQUENCE
+insn starting with a CALL, this target hook is invoked to compute the
+offset to be added to the debug label emitted after the call to obtain
+the return address that should be recorded as the return PC.
+@end deftypefn
+
@deftypefn {Target Hook} void TARGET_CALL_ARGS (rtx, @var{tree})
While generating RTL for a function call, this target hook is invoked once
for each argument passed to the function, either a register returned by
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index f7ab5d48a63..89dfe94953d 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3785,6 +3785,8 @@ These machine description macros help implement varargs:
@hook TARGET_STRICT_ARGUMENT_NAMING
+@hook TARGET_CALL_OFFSET_RETURN_LABEL
+
@hook TARGET_CALL_ARGS
@hook TARGET_END_CALL_ARGS
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 1a0015ce00f..3d00835628a 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -3584,7 +3584,7 @@ typedef struct var_loc_list_def var_loc_list;
/* Call argument location list. */
struct GTY ((chain_next ("%h.next"))) call_arg_loc_node {
- rtx GTY (()) call_arg_loc_note;
+ rtx_insn * GTY (()) call_insn;
const char * GTY (()) label;
tree GTY (()) block;
bool tail_call_p;
@@ -3768,7 +3768,8 @@ static void remove_addr_table_entry (addr_table_entry *);
static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool);
static inline rtx AT_addr (dw_attr_node *);
static void add_AT_symview (dw_die_ref, enum dwarf_attribute, const char *);
-static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
+static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *,
+ int = 0);
static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
@@ -5327,14 +5328,17 @@ add_AT_symview (dw_die_ref die, enum dwarf_attribute attr_kind,
static inline void
add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
- const char *lbl_id)
+ const char *lbl_id, int offset)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr.dw_attr_val.val_entry = NULL;
- attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ if (!offset)
+ attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ else
+ attr.dw_attr_val.v.val_lbl_id = xasprintf ("%s%+i", lbl_id, offset);
if (dwarf_split_debug_info)
attr.dw_attr_val.val_entry
= add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
@@ -23406,7 +23410,9 @@ gen_call_site_die (tree decl, dw_die_ref subr_die,
if (stmt_die == NULL)
stmt_die = subr_die;
die = new_die (dwarf_TAG (DW_TAG_call_site), stmt_die, NULL_TREE);
- add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc), ca_loc->label);
+ add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc),
+ ca_loc->label,
+ targetm.calls.call_offset_return_label (ca_loc->call_insn));
if (ca_loc->tail_call_p)
add_AT_flag (die, dwarf_AT (DW_AT_call_tail_call), 1);
if (ca_loc->symbol_ref)
@@ -24093,11 +24099,14 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
{
dw_die_ref die = NULL;
rtx tloc = NULL_RTX, tlocc = NULL_RTX;
+ rtx call_arg_loc_note
+ = find_reg_note (ca_loc->call_insn,
+ REG_CALL_ARG_LOCATION, NULL_RTX);
rtx arg, next_arg;
tree arg_decl = NULL_TREE;
- for (arg = (ca_loc->call_arg_loc_note != NULL_RTX
- ? XEXP (ca_loc->call_arg_loc_note, 0)
+ for (arg = (call_arg_loc_note != NULL_RTX
+ ? XEXP (call_arg_loc_note, 0)
: NULL_RTX);
arg; arg = next_arg)
{
@@ -28126,8 +28135,7 @@ create_label:
= ggc_cleared_alloc<call_arg_loc_node> ();
rtx_insn *prev = call_insn;
- ca_loc->call_arg_loc_note
- = find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX);
+ ca_loc->call_insn = call_insn;
ca_loc->next = NULL;
ca_loc->label = last_label;
gcc_assert (prev
diff --git a/gcc/target.def b/gcc/target.def
index 1b9c882229e..38c72670fef 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4722,6 +4722,15 @@ not generate any instructions in this case.",
int *pretend_args_size, int second_time),
default_setup_incoming_varargs)
+DEFHOOK
+(call_offset_return_label,
+ "While generating call-site debug info for a CALL insn, or a SEQUENCE\n\
+insn starting with a CALL, this target hook is invoked to compute the\n\
+offset to be added to the debug label emitted after the call to obtain\n\
+the return address that should be recorded as the return PC.",
+ int, (rtx_insn *call_insn),
+ hook_int_rtx_insn_0)
+
DEFHOOK
(call_args,
"While generating RTL for a function call, this target hook is invoked once\n\
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] enable adjustment of return_pc debug attrs
@ 2023-03-23 3:48 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2023-03-23 3:48 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:cec5a04e13d8c868a8231afa344f444187d7f8b4
commit cec5a04e13d8c868a8231afa344f444187d7f8b4
Author: Alexandre Oliva <oliva@adacore.com>
Date: Thu Mar 23 00:44:58 2023 -0300
enable adjustment of return_pc debug attrs
This patch introduces infrastructure for targets to add an offset to
the label issued after the call_insn to set the call_return_pc
attribute. This will be used on rs6000, that sometimes issues another
instruction after the call proper as part of a call insn.
for gcc/ChangeLog
* target.def (call_offset_return_label): New hook.
* gcc/doc/tm.texi.in (TARGET_CALL_OFFSET_RETURN_LABEL): Add
placeholder.
* gcc/doc/tm.texi: Rebuild.
* dwarf2out.cc (struct call_arg_loc_node): Record call_insn
instad of call_arg_loc_note.
(add_AT_lbl_id): Add optional offset argument.
(gen_call_site_die): Compute and pass on a return pc offset.
(gen_subprogram_die): Move call_arg_loc_note computation...
(dwarf2out_var_location): ... from here. Set call_insn.
Diff:
---
gcc/doc/tm.texi | 7 +++++++
gcc/doc/tm.texi.in | 2 ++
gcc/dwarf2out.cc | 26 +++++++++++++++++---------
gcc/target.def | 9 +++++++++
4 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 4bb48c5428c..83ebe3d51b7 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -5426,6 +5426,13 @@ except the last are treated as named.
You need not define this hook if it always returns @code{false}.
@end deftypefn
+@deftypefn {Target Hook} int TARGET_CALL_OFFSET_RETURN_LABEL (rtx_insn *@var{call_insn})
+While generating call-site debug info for a CALL insn, or a SEQUENCE
+insn starting with a CALL, this target hook is invoked to compute the
+offset to be added to the debug label emitted after the call to obtain
+the return address that should be recorded as the return PC.
+@end deftypefn
+
@deftypefn {Target Hook} void TARGET_CALL_ARGS (rtx, @var{tree})
While generating RTL for a function call, this target hook is invoked once
for each argument passed to the function, either a register returned by
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index f7ab5d48a63..89dfe94953d 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3785,6 +3785,8 @@ These machine description macros help implement varargs:
@hook TARGET_STRICT_ARGUMENT_NAMING
+@hook TARGET_CALL_OFFSET_RETURN_LABEL
+
@hook TARGET_CALL_ARGS
@hook TARGET_END_CALL_ARGS
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 1711ad2c2da..d1db918c439 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -3584,7 +3584,7 @@ typedef struct var_loc_list_def var_loc_list;
/* Call argument location list. */
struct GTY ((chain_next ("%h.next"))) call_arg_loc_node {
- rtx GTY (()) call_arg_loc_note;
+ rtx_insn * GTY (()) call_insn;
const char * GTY (()) label;
tree GTY (()) block;
bool tail_call_p;
@@ -3768,7 +3768,8 @@ static void remove_addr_table_entry (addr_table_entry *);
static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool);
static inline rtx AT_addr (dw_attr_node *);
static void add_AT_symview (dw_die_ref, enum dwarf_attribute, const char *);
-static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
+static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *,
+ int = 0);
static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
@@ -5327,14 +5328,17 @@ add_AT_symview (dw_die_ref die, enum dwarf_attribute attr_kind,
static inline void
add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
- const char *lbl_id)
+ const char *lbl_id, int offset)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr.dw_attr_val.val_entry = NULL;
- attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ if (!offset)
+ attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ else
+ attr.dw_attr_val.v.val_lbl_id = xasprintf ("%s%+i", lbl_id, offset);
if (dwarf_split_debug_info)
attr.dw_attr_val.val_entry
= add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
@@ -23405,7 +23409,9 @@ gen_call_site_die (tree decl, dw_die_ref subr_die,
if (stmt_die == NULL)
stmt_die = subr_die;
die = new_die (dwarf_TAG (DW_TAG_call_site), stmt_die, NULL_TREE);
- add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc), ca_loc->label);
+ add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc),
+ ca_loc->label,
+ targetm.calls.call_offset_return_label (ca_loc->call_insn));
if (ca_loc->tail_call_p)
add_AT_flag (die, dwarf_AT (DW_AT_call_tail_call), 1);
if (ca_loc->symbol_ref)
@@ -24092,11 +24098,14 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
{
dw_die_ref die = NULL;
rtx tloc = NULL_RTX, tlocc = NULL_RTX;
+ rtx call_arg_loc_note
+ = find_reg_note (ca_loc->call_insn,
+ REG_CALL_ARG_LOCATION, NULL_RTX);
rtx arg, next_arg;
tree arg_decl = NULL_TREE;
- for (arg = (ca_loc->call_arg_loc_note != NULL_RTX
- ? XEXP (ca_loc->call_arg_loc_note, 0)
+ for (arg = (call_arg_loc_note != NULL_RTX
+ ? XEXP (call_arg_loc_note, 0)
: NULL_RTX);
arg; arg = next_arg)
{
@@ -28125,8 +28134,7 @@ create_label:
= ggc_cleared_alloc<call_arg_loc_node> ();
rtx_insn *prev = call_insn;
- ca_loc->call_arg_loc_note
- = find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX);
+ ca_loc->call_insn = call_insn;
ca_loc->next = NULL;
ca_loc->label = last_label;
gcc_assert (prev
diff --git a/gcc/target.def b/gcc/target.def
index 1b9c882229e..38c72670fef 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4722,6 +4722,15 @@ not generate any instructions in this case.",
int *pretend_args_size, int second_time),
default_setup_incoming_varargs)
+DEFHOOK
+(call_offset_return_label,
+ "While generating call-site debug info for a CALL insn, or a SEQUENCE\n\
+insn starting with a CALL, this target hook is invoked to compute the\n\
+offset to be added to the debug label emitted after the call to obtain\n\
+the return address that should be recorded as the return PC.",
+ int, (rtx_insn *call_insn),
+ hook_int_rtx_insn_0)
+
DEFHOOK
(call_args,
"While generating RTL for a function call, this target hook is invoked once\n\
^ permalink raw reply [flat|nested] 7+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] enable adjustment of return_pc debug attrs
@ 2023-03-16 14:22 Alexandre Oliva
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 2023-03-16 14:22 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f2c0d09a1730eb3c999e355a50fb543d5624154c
commit f2c0d09a1730eb3c999e355a50fb543d5624154c
Author: Alexandre Oliva <oliva@adacore.com>
Date: Thu Mar 16 11:04:48 2023 -0300
enable adjustment of return_pc debug attrs
This patch introduces infrastructure for targets to add an offset to
the label issued after the call_insn to set the call_return_pc
attribute. This will be used on rs6000, that sometimes issues another
instruction after the call proper as part of a call insn.
for gcc/ChangeLog
* target.def (call_offset_return_label): New hook.
* gcc/doc/tm.texi.in (TARGET_CALL_OFFSET_RETURN_LABEL): Add
placeholder.
* gcc/doc/tm.texi: Rebuild.
* dwarf2out.cc (struct call_arg_loc_node): Record call_insn
instad of call_arg_loc_note.
(add_AT_lbl_id): Add optional offset argument.
(gen_call_site_die): Compute and pass on a return pc offset.
(gen_subprogram_die): Move call_arg_loc_note computation...
(dwarf2out_var_location): ... from here. Set call_insn.
Diff:
---
gcc/doc/tm.texi | 7 +++++++
gcc/doc/tm.texi.in | 2 ++
gcc/dwarf2out.cc | 26 +++++++++++++++++---------
gcc/target.def | 9 +++++++++
4 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index c4a92a5ebee..44e4c18ad5c 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -5426,6 +5426,13 @@ except the last are treated as named.
You need not define this hook if it always returns @code{false}.
@end deftypefn
+@deftypefn {Target Hook} int TARGET_CALL_OFFSET_RETURN_LABEL (rtx_insn *@var{call_insn})
+While generating call-site debug info for a CALL insn, or a SEQUENCE
+insn starting with a CALL, this target hook is invoked to compute the
+offset to be added to the debug label emitted after the call to obtain
+the return address that should be recorded as the return PC.
+@end deftypefn
+
@deftypefn {Target Hook} void TARGET_CALL_ARGS (rtx, @var{tree})
While generating RTL for a function call, this target hook is invoked once
for each argument passed to the function, either a register returned by
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 4075e71624c..68856978fe3 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3785,6 +3785,8 @@ These machine description macros help implement varargs:
@hook TARGET_STRICT_ARGUMENT_NAMING
+@hook TARGET_CALL_OFFSET_RETURN_LABEL
+
@hook TARGET_CALL_ARGS
@hook TARGET_END_CALL_ARGS
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 1711ad2c2da..d1db918c439 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -3584,7 +3584,7 @@ typedef struct var_loc_list_def var_loc_list;
/* Call argument location list. */
struct GTY ((chain_next ("%h.next"))) call_arg_loc_node {
- rtx GTY (()) call_arg_loc_note;
+ rtx_insn * GTY (()) call_insn;
const char * GTY (()) label;
tree GTY (()) block;
bool tail_call_p;
@@ -3768,7 +3768,8 @@ static void remove_addr_table_entry (addr_table_entry *);
static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool);
static inline rtx AT_addr (dw_attr_node *);
static void add_AT_symview (dw_die_ref, enum dwarf_attribute, const char *);
-static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
+static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *,
+ int = 0);
static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
@@ -5327,14 +5328,17 @@ add_AT_symview (dw_die_ref die, enum dwarf_attribute attr_kind,
static inline void
add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
- const char *lbl_id)
+ const char *lbl_id, int offset)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
attr.dw_attr_val.val_entry = NULL;
- attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ if (!offset)
+ attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ else
+ attr.dw_attr_val.v.val_lbl_id = xasprintf ("%s%+i", lbl_id, offset);
if (dwarf_split_debug_info)
attr.dw_attr_val.val_entry
= add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
@@ -23405,7 +23409,9 @@ gen_call_site_die (tree decl, dw_die_ref subr_die,
if (stmt_die == NULL)
stmt_die = subr_die;
die = new_die (dwarf_TAG (DW_TAG_call_site), stmt_die, NULL_TREE);
- add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc), ca_loc->label);
+ add_AT_lbl_id (die, dwarf_AT (DW_AT_call_return_pc),
+ ca_loc->label,
+ targetm.calls.call_offset_return_label (ca_loc->call_insn));
if (ca_loc->tail_call_p)
add_AT_flag (die, dwarf_AT (DW_AT_call_tail_call), 1);
if (ca_loc->symbol_ref)
@@ -24092,11 +24098,14 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
{
dw_die_ref die = NULL;
rtx tloc = NULL_RTX, tlocc = NULL_RTX;
+ rtx call_arg_loc_note
+ = find_reg_note (ca_loc->call_insn,
+ REG_CALL_ARG_LOCATION, NULL_RTX);
rtx arg, next_arg;
tree arg_decl = NULL_TREE;
- for (arg = (ca_loc->call_arg_loc_note != NULL_RTX
- ? XEXP (ca_loc->call_arg_loc_note, 0)
+ for (arg = (call_arg_loc_note != NULL_RTX
+ ? XEXP (call_arg_loc_note, 0)
: NULL_RTX);
arg; arg = next_arg)
{
@@ -28125,8 +28134,7 @@ create_label:
= ggc_cleared_alloc<call_arg_loc_node> ();
rtx_insn *prev = call_insn;
- ca_loc->call_arg_loc_note
- = find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX);
+ ca_loc->call_insn = call_insn;
ca_loc->next = NULL;
ca_loc->label = last_label;
gcc_assert (prev
diff --git a/gcc/target.def b/gcc/target.def
index f401fe148ee..94c0e228196 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4731,6 +4731,15 @@ not generate any instructions in this case.",
int *pretend_args_size, int second_time),
default_setup_incoming_varargs)
+DEFHOOK
+(call_offset_return_label,
+ "While generating call-site debug info for a CALL insn, or a SEQUENCE\n\
+insn starting with a CALL, this target hook is invoked to compute the\n\
+offset to be added to the debug label emitted after the call to obtain\n\
+the return address that should be recorded as the return PC.",
+ int, (rtx_insn *call_insn),
+ hook_int_rtx_insn_0)
+
DEFHOOK
(call_args,
"While generating RTL for a function call, this target hook is invoked once\n\
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-05-29 6:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 6:25 [gcc(refs/users/aoliva/heads/testme)] enable adjustment of return_pc debug attrs Alexandre Oliva
-- strict thread matches above, loose matches on Subject: below --
2024-05-29 6:58 Alexandre Oliva
2024-05-25 8:07 Alexandre Oliva
2023-04-06 6:35 Alexandre Oliva
2023-03-30 14:07 Alexandre Oliva
2023-03-23 3:48 Alexandre Oliva
2023-03-16 14:22 Alexandre Oliva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).