summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-23 20:39:59 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-23 20:39:59 +0000
commitc68c23aba227fe6d449414adf262fc4683445164 (patch)
tree6be0cd9642ffdeb173e3fdad8079590f6f59e342
parent95f39a983a595ff5892459b6338fe2d05a159cbc (diff)
downloadgcc-c68c23aba227fe6d449414adf262fc4683445164.tar.gz
PR debug/82630
* target.def (const_not_ok_for_debug_p): Default to default_const_not_ok_for_debug_p instead of hook_bool_rtx_false. * targhooks.h (default_const_not_ok_for_debug_p): New declaration. * targhooks.c (default_const_not_ok_for_debug_p): New function. * dwarf2out.c (const_ok_for_output_1): Only reject UNSPECs for which targetm.const_not_ok_for_debug_p returned true. * config/arm/arm.c (arm_const_not_ok_for_debug_p): Return true for UNSPECs. * config/powerpcspe/powerpcspe.c (rs6000_const_not_ok_for_debug_p): Likewise. * config/rs6000/rs6000.c (rs6000_const_not_ok_for_debug_p): Likewise. * config/i386/i386.c (ix86_delegitimize_address_1): Don't delegitimize UNSPEC_GOTOFF with addend into addend - _GLOBAL_OFFSET_TABLE_ + symbol if !base_term_p. (ix86_const_not_ok_for_debug_p): New function. (i386_asm_output_addr_const_extra): Handle UNSPEC_GOTOFF. (TARGET_CONST_NOT_OK_FOR_DEBUG_P): Redefine. * g++.dg/guality/pr82630.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254025 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog21
-rw-r--r--gcc/config/arm/arm.c2
-rw-r--r--gcc/config/i386/i386.c34
-rw-r--r--gcc/config/powerpcspe/powerpcspe.c2
-rw-r--r--gcc/config/rs6000/rs6000.c2
-rw-r--r--gcc/dwarf2out.c19
-rw-r--r--gcc/target.def2
-rw-r--r--gcc/targhooks.c8
-rw-r--r--gcc/targhooks.h1
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/guality/pr82630.C58
11 files changed, 142 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8aa652dfd11..b9be7254ff7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,24 @@
+2017-10-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/82630
+ * target.def (const_not_ok_for_debug_p): Default to
+ default_const_not_ok_for_debug_p instead of hook_bool_rtx_false.
+ * targhooks.h (default_const_not_ok_for_debug_p): New declaration.
+ * targhooks.c (default_const_not_ok_for_debug_p): New function.
+ * dwarf2out.c (const_ok_for_output_1): Only reject UNSPECs for
+ which targetm.const_not_ok_for_debug_p returned true.
+ * config/arm/arm.c (arm_const_not_ok_for_debug_p): Return true
+ for UNSPECs.
+ * config/powerpcspe/powerpcspe.c (rs6000_const_not_ok_for_debug_p):
+ Likewise.
+ * config/rs6000/rs6000.c (rs6000_const_not_ok_for_debug_p): Likewise.
+ * config/i386/i386.c (ix86_delegitimize_address_1): Don't delegitimize
+ UNSPEC_GOTOFF with addend into addend - _GLOBAL_OFFSET_TABLE_ + symbol
+ if !base_term_p.
+ (ix86_const_not_ok_for_debug_p): New function.
+ (i386_asm_output_addr_const_extra): Handle UNSPEC_GOTOFF.
+ (TARGET_CONST_NOT_OK_FOR_DEBUG_P): Redefine.
+
2017-10-23 David Malcolm <dmalcolm@redhat.com>
PR bootstrap/82610
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 6f01021a351..22e169318ad 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -30391,6 +30391,8 @@ arm_const_not_ok_for_debug_p (rtx p)
tree decl_op0 = NULL;
tree decl_op1 = NULL;
+ if (GET_CODE (p) == UNSPEC)
+ return true;
if (GET_CODE (p) == MINUS)
{
if (GET_CODE (XEXP (p, 1)) == SYMBOL_REF)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 3fafcfe9613..72caf62bbf8 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -16840,13 +16840,17 @@ ix86_delegitimize_address_1 (rtx x, bool base_term_p)
movl foo@GOTOFF(%ecx), %edx
in which case we return (%ecx - %ebx) + foo
or (%ecx - _GLOBAL_OFFSET_TABLE_) + foo if pseudo_pic_reg
- and reload has completed. */
+ and reload has completed. Don't do the latter for debug,
+ as _GLOBAL_OFFSET_TABLE_ can't be expressed in the assembly. */
if (pic_offset_table_rtx
&& (!reload_completed || !ix86_use_pseudo_pic_reg ()))
result = gen_rtx_PLUS (Pmode, gen_rtx_MINUS (Pmode, copy_rtx (addend),
pic_offset_table_rtx),
result);
- else if (pic_offset_table_rtx && !TARGET_MACHO && !TARGET_VXWORKS_RTP)
+ else if (base_term_p
+ && pic_offset_table_rtx
+ && !TARGET_MACHO
+ && !TARGET_VXWORKS_RTP)
{
rtx tmp = gen_rtx_SYMBOL_REF (Pmode, GOT_SYMBOL_NAME);
tmp = gen_rtx_MINUS (Pmode, copy_rtx (addend), tmp);
@@ -16899,6 +16903,25 @@ ix86_find_base_term (rtx x)
return ix86_delegitimize_address_1 (x, true);
}
+
+/* Return true if X shouldn't be emitted into the debug info.
+ Disallow UNSPECs other than @gotoff - we can't emit _GLOBAL_OFFSET_TABLE_
+ symbol easily into the .debug_info section, so we need not to
+ delegitimize, but instead assemble as @gotoff.
+ Disallow _GLOBAL_OFFSET_TABLE_ SYMBOL_REF - the assembler magically
+ assembles that as _GLOBAL_OFFSET_TABLE_-. expression. */
+
+static bool
+ix86_const_not_ok_for_debug_p (rtx x)
+{
+ if (GET_CODE (x) == UNSPEC && XINT (x, 1) != UNSPEC_GOTOFF)
+ return true;
+
+ if (SYMBOL_REF_P (x) && strcmp (XSTR (x, 0), GOT_SYMBOL_NAME) == 0)
+ return true;
+
+ return false;
+}
static void
put_condition_code (enum rtx_code code, machine_mode mode, bool reverse,
@@ -18217,6 +18240,10 @@ i386_asm_output_addr_const_extra (FILE *file, rtx x)
op = XVECEXP (x, 0, 0);
switch (XINT (x, 1))
{
+ case UNSPEC_GOTOFF:
+ output_addr_const (file, op);
+ fputs ("@gotoff", file);
+ break;
case UNSPEC_GOTTPOFF:
output_addr_const (file, op);
/* FIXME: This might be @TPOFF in Sun ld. */
@@ -49827,6 +49854,9 @@ ix86_run_selftests (void)
#undef TARGET_DELEGITIMIZE_ADDRESS
#define TARGET_DELEGITIMIZE_ADDRESS ix86_delegitimize_address
+#undef TARGET_CONST_NOT_OK_FOR_DEBUG_P
+#define TARGET_CONST_NOT_OK_FOR_DEBUG_P ix86_const_not_ok_for_debug_p
+
#undef TARGET_MS_BITFIELD_LAYOUT_P
#define TARGET_MS_BITFIELD_LAYOUT_P ix86_ms_bitfield_layout_p
diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c
index b39a8f8559f..b5fc656a8f1 100644
--- a/gcc/config/powerpcspe/powerpcspe.c
+++ b/gcc/config/powerpcspe/powerpcspe.c
@@ -9539,6 +9539,8 @@ rs6000_delegitimize_address (rtx orig_x)
static bool
rs6000_const_not_ok_for_debug_p (rtx x)
{
+ if (GET_CODE (x) == UNSPEC)
+ return true;
if (GET_CODE (x) == SYMBOL_REF
&& CONSTANT_POOL_ADDRESS_P (x))
{
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 06713ad2b32..309541933cd 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -8988,6 +8988,8 @@ rs6000_delegitimize_address (rtx orig_x)
static bool
rs6000_const_not_ok_for_debug_p (rtx x)
{
+ if (GET_CODE (x) == UNSPEC)
+ return true;
if (GET_CODE (x) == SYMBOL_REF
&& CONSTANT_POOL_ADDRESS_P (x))
{
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 81c95ece095..dcc624e6fe0 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -13740,9 +13740,17 @@ expansion_failed (tree expr, rtx rtl, char const *reason)
static bool
const_ok_for_output_1 (rtx rtl)
{
- if (GET_CODE (rtl) == UNSPEC)
+ if (targetm.const_not_ok_for_debug_p (rtl))
{
- /* If delegitimize_address couldn't do anything with the UNSPEC, assume
+ if (GET_CODE (rtl) != UNSPEC)
+ {
+ expansion_failed (NULL_TREE, rtl,
+ "Expression rejected for debug by the backend.\n");
+ return false;
+ }
+
+ /* If delegitimize_address couldn't do anything with the UNSPEC, and
+ the target hook doesn't explicitly allow it in debug info, assume
we can't express it in the debug info. */
/* Don't complain about TLS UNSPECs, those are just too hard to
delegitimize. Note this could be a non-decl SYMBOL_REF such as
@@ -13769,13 +13777,6 @@ const_ok_for_output_1 (rtx rtl)
return false;
}
- if (targetm.const_not_ok_for_debug_p (rtl))
- {
- expansion_failed (NULL_TREE, rtl,
- "Expression rejected for debug by the backend.\n");
- return false;
- }
-
/* FIXME: Refer to PR60655. It is possible for simplification
of rtl expressions in var tracking to produce such expressions.
We should really identify / validate expressions
diff --git a/gcc/target.def b/gcc/target.def
index b7dda5b5f2e..435849c3d35 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -2822,7 +2822,7 @@ DEFHOOK
"This hook should return true if @var{x} should not be emitted into\n\
debug sections.",
bool, (rtx x),
- hook_bool_rtx_false)
+ default_const_not_ok_for_debug_p)
/* Given an address RTX, say whether it is valid. */
DEFHOOK
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index ae2595113f8..41cab3825df 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -177,6 +177,14 @@ default_legitimize_address_displacement (rtx *disp ATTRIBUTE_UNUSED,
return false;
}
+bool
+default_const_not_ok_for_debug_p (rtx x)
+{
+ if (GET_CODE (x) == UNSPEC)
+ return true;
+ return false;
+}
+
rtx
default_expand_builtin_saveregs (void)
{
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index db1a087942a..1510bb97a9c 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -26,6 +26,7 @@ extern void default_external_libcall (rtx);
extern rtx default_legitimize_address (rtx, rtx, machine_mode);
extern bool default_legitimize_address_displacement (rtx *, rtx *,
machine_mode);
+extern bool default_const_not_ok_for_debug_p (rtx);
extern int default_unspec_may_trap_p (const_rtx, unsigned);
extern machine_mode default_promote_function_mode (const_tree, machine_mode,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0e3a0e3867d..f6fd200329a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-10-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/82630
+ * g++.dg/guality/pr82630.C: New test.
+
2017-10-23 Uros Bizjak <ubizjak@gmail.com>
PR target/82662
diff --git a/gcc/testsuite/g++.dg/guality/pr82630.C b/gcc/testsuite/g++.dg/guality/pr82630.C
new file mode 100644
index 00000000000..71d11acf5e2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/guality/pr82630.C
@@ -0,0 +1,58 @@
+// PR debug/82630
+// { dg-do run }
+// { dg-additional-options "-fPIC" { target fpic } }
+
+struct C
+{
+ int &c;
+ long d;
+ __attribute__((always_inline)) C (int &x) : c(x), d() {}
+};
+int v;
+
+__attribute__((noipa)) void
+fn1 (const void *x)
+{
+ asm volatile ("" : : "g" (x) : "memory");
+}
+
+__attribute__((noipa)) void
+fn2 (C x)
+{
+ int a = x.c + x.d;
+ asm volatile ("" : : "g" (a) : "memory");
+}
+
+__attribute__((noipa)) void
+fn3 (void)
+{
+ asm volatile ("" : : : "memory");
+}
+
+__attribute__((noipa))
+#ifdef __i386__
+__attribute__((regparm (2)))
+#endif
+static void
+fn4 (int *x, const char *y, C z)
+{
+ fn2 (C (*x));
+ fn1 ("baz");
+ fn2 (z); // { dg-final { gdb-test 41 "y\[0\]" "'f'" } }
+ fn1 ("baz"); // { dg-final { gdb-test 41 "y\[1\]" "'o'" } }
+}
+
+__attribute__((noipa)) void
+fn5 (int *x)
+{
+ fn4 (x, "foo", C (*x));
+ fn3 ();
+}
+
+int
+main ()
+{
+ int a = 10;
+ fn5 (&a);
+ return 0;
+}