public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/48016] New: Inconsistency in non-local goto save area
@ 2011-03-07 14:06 hjl.tools at gmail dot com
2011-03-07 14:13 ` [Bug middle-end/48016] " rguenth at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2011-03-07 14:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48016
Summary: Inconsistency in non-local goto save area
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: hjl.tools@gmail.com
We have
void
emit_stack_save (enum save_level save_level, rtx *psave)
{
rtx sa = *psave;
/* The default is that we use a move insn and save in a Pmode object. */
rtx (*fcn) (rtx, rtx) = gen_move_insn;
enum machine_mode mode = STACK_SAVEAREA_MODE (save_level);
....
void
update_nonlocal_goto_save_area (void)
{
tree t_save;
rtx r_save;
/* The nonlocal_goto_save_area object is an array of N pointers. The
first one is used for the frame pointer save; the rest are sized by
STACK_SAVEAREA_MODE. Create a reference to array index 1, the first
of the stack save area slots. */
t_save = build4 (ARRAY_REF, ptr_type_node, cfun->nonlocal_goto_save_area,
integer_one_node, NULL_TREE, NULL_TREE);
r_save = expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE);
emit_stack_save (SAVE_NONLOCAL, &r_save);
}
The mode of PSAVE passed to emit_stack_save is the mode of
ptr_type_node, which may not be STACK_SAVEAREA_MODE which
is expected by emit_stack_save.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/48016] Inconsistency in non-local goto save area
2011-03-07 14:06 [Bug middle-end/48016] New: Inconsistency in non-local goto save area hjl.tools at gmail dot com
@ 2011-03-07 14:13 ` rguenth at gcc dot gnu.org
2011-03-07 14:40 ` hjl.tools at gmail dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-07 14:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48016
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-07 14:13:10 UTC ---
The gimple middle-end only knows one pointer type mode, ptr_type_mode. If
we want to save Pmode then we need to use an appropriate integer type
and a proper alias set.
I guess this code should be simply replaced to emit RTL directly instead
of going through expansion of an ARRAY_REF.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/48016] Inconsistency in non-local goto save area
2011-03-07 14:06 [Bug middle-end/48016] New: Inconsistency in non-local goto save area hjl.tools at gmail dot com
2011-03-07 14:13 ` [Bug middle-end/48016] " rguenth at gcc dot gnu.org
@ 2011-03-07 14:40 ` hjl.tools at gmail dot com
2011-03-07 14:44 ` hjl at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2011-03-07 14:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48016
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> 2011-03-07 14:40:35 UTC ---
(In reply to comment #1)
> The gimple middle-end only knows one pointer type mode, ptr_type_mode. If
> we want to save Pmode then we need to use an appropriate integer type
> and a proper alias set.
>
> I guess this code should be simply replaced to emit RTL directly instead
> of going through expansion of an ARRAY_REF.
For x32 target, we expand function h in:
extern void foo (void) __attribute__((noreturn));
int n;
void
g (void)
{
__label__ lab;
void h (void) { if (n == 2) goto lab; }
void (*f1) (void) = foo;
void (*f2) (void) = h;
f2 ();
if (n)
f1 ();
n = 1;
lab:
n++;
}
to
h ()
{
int n.3;
long long unsigned int[3] * D.2708;
# BLOCK 2
# PRED: ENTRY (fallthru)
n.3_1 = n;
if (n.3_1 == 2)
goto <bb 3>;
else
goto <bb 4>;
# SUCC: 3 (true) 4 (false)
# BLOCK 3
# PRED: 2 (true)
D.2708_3 = &CHAIN.5_2(D)->__nl_goto_buf;
__builtin_nonlocal_goto (&<L2>, D.2708_3);
# SUCC:
# BLOCK 4
# PRED: 2 (false)
return;
# SUCC: EXIT
}
I am checking this patch as a workaround on x32 branch.
diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index f39563b..3f1f953 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,8 @@
+2011-03-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR middle-end/48016
+ * explow.c (emit_stack_save): Adjust mode of stack save area.
+
2011-03-06 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/predicates.md (aligned_operand): Check SUBREG_REG
diff --git a/gcc/explow.c b/gcc/explow.c
index 3401e49..460af1f 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -1008,6 +1008,14 @@ emit_stack_save (enum save_level save_level, rtx *psave)
do_pending_stack_adjust ();
if (sa != 0)
sa = validize_mem (sa);
+ /* FIXME: update_nonlocal_goto_save_area may pass SA in the wrong mode. */
+ if (GET_MODE (sa) != mode)
+ {
+ gcc_assert (ptr_mode != Pmode
+ && GET_MODE (sa) == ptr_mode
+ && mode == Pmode);
+ sa = adjust_address (sa, mode, 0);
+ }
emit_insn (fcn (sa, stack_pointer_rtx));
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/48016] Inconsistency in non-local goto save area
2011-03-07 14:06 [Bug middle-end/48016] New: Inconsistency in non-local goto save area hjl.tools at gmail dot com
2011-03-07 14:13 ` [Bug middle-end/48016] " rguenth at gcc dot gnu.org
2011-03-07 14:40 ` hjl.tools at gmail dot com
@ 2011-03-07 14:44 ` hjl at gcc dot gnu.org
2011-03-16 16:54 ` hjl.tools at gmail dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: hjl at gcc dot gnu.org @ 2011-03-07 14:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48016
--- Comment #3 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> 2011-03-07 14:44:49 UTC ---
Author: hjl
Date: Mon Mar 7 14:44:45 2011
New Revision: 170735
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170735
Log:
Adjust mode of non-local goto stack save area.
2011-03-07 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/48016
* explow.c (emit_stack_save): Adjust mode of stack save area.
Modified:
branches/x32/gcc/ChangeLog.x32
branches/x32/gcc/explow.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/48016] Inconsistency in non-local goto save area
2011-03-07 14:06 [Bug middle-end/48016] New: Inconsistency in non-local goto save area hjl.tools at gmail dot com
` (2 preceding siblings ...)
2011-03-07 14:44 ` hjl at gcc dot gnu.org
@ 2011-03-16 16:54 ` hjl.tools at gmail dot com
2011-04-02 5:27 ` hjl at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2011-03-16 16:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48016
--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> 2011-03-16 16:40:31 UTC ---
Another problem. expand_function_start has
t_save = build4 (ARRAY_REF, ptr_type_node,
cfun->nonlocal_goto_save_area,
integer_zero_node, NULL_TREE, NULL_TREE);
r_save = expand_expr (t_save, NULL_RTX, VOIDmode, EXPAND_WRITE);
r_save = convert_memory_address (Pmode, r_save);
emit_move_insn (r_save, targetm.builtin_setjmp_frame_value ());
For
Breakpoint 4, expand_function_start (subr=0x7ffff0cebf00)
at /export/gnu/import/git/gcc-x32/gcc/function.c:4765
4765 r_save = convert_memory_address (Pmode, r_save);
(gdb) call debug_rtx (r_save)
(mem/s/f/j/c:SI (plus:DI (reg/f:DI 54 virtual-stack-vars)
(const_int -32 [0xffffffffffffffe0])) [0 FRAME.0.__nl_goto_buf+0 S4
A64])
(gdb) next
4767 emit_move_insn (r_save, targetm.builtin_setjmp_frame_value ());
(gdb) call debug_rtx (r_save)
(reg:DI 61)
(gdb)
we generate
(insn 3 2 4 2 (set (reg:DI 61)
(zero_extend:DI (mem/s/f/j/c:SI (plus:DI (reg/f:DI 54
virtual-stack-vars)
(const_int -32 [0xffffffffffffffe0])) [0
FRAME.0.__nl_goto_buf+0 S4 A64]))) x.c:2 -1
(nil))
(insn 4 3 5 2 (set (reg:DI 61)
(reg/f:DI 54 virtual-stack-vars)) x.c:2 -1
(nil))
Instead of
(insn 3 2 4 2 (set (mem/s/f/j/c:SI (plus:DI (reg/f:DI 54 virtual-stack-vars)
(const_int -32 [0xffffffffffffffe0])) [0
FRAME.0.__nl_goto_buf+0 S8 A64])
((subreg:SI reg/f:DI 54 virtual-stack-vars)) x.c:2 -1
(nil))
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/48016] Inconsistency in non-local goto save area
2011-03-07 14:06 [Bug middle-end/48016] New: Inconsistency in non-local goto save area hjl.tools at gmail dot com
` (3 preceding siblings ...)
2011-03-16 16:54 ` hjl.tools at gmail dot com
@ 2011-04-02 5:27 ` hjl at gcc dot gnu.org
2011-06-20 13:58 ` hjl at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: hjl at gcc dot gnu.org @ 2011-04-02 5:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48016
--- Comment #5 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> 2011-04-02 05:27:14 UTC ---
Author: hjl
Date: Sat Apr 2 05:27:09 2011
New Revision: 171869
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171869
Log:
Properly store frame pointer for non-local goto.
2011-03-16 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/48016
* function.c (expand_function_start): Properly store frame
pointer for non-local goto.
Modified:
branches/x32/gcc/ChangeLog.x32
branches/x32/gcc/function.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/48016] Inconsistency in non-local goto save area
2011-03-07 14:06 [Bug middle-end/48016] New: Inconsistency in non-local goto save area hjl.tools at gmail dot com
` (4 preceding siblings ...)
2011-04-02 5:27 ` hjl at gcc dot gnu.org
@ 2011-06-20 13:58 ` hjl at gcc dot gnu.org
2011-07-01 12:57 ` hjl at gcc dot gnu.org
2011-07-01 13:00 ` hjl.tools at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: hjl at gcc dot gnu.org @ 2011-06-20 13:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48016
--- Comment #6 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> 2011-06-20 13:58:03 UTC ---
Author: hjl
Date: Mon Jun 20 13:57:59 2011
New Revision: 175210
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175210
Log:
Use proper mode for stack save area.
2011-06-15 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/48016
* explow.c (emit_stack_save): Don'ty adjust mode of stack save
area.
(update_nonlocal_goto_save_area): Use proper mode for stack save
area.
Modified:
branches/x32/gcc/ChangeLog.x32
branches/x32/gcc/explow.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/48016] Inconsistency in non-local goto save area
2011-03-07 14:06 [Bug middle-end/48016] New: Inconsistency in non-local goto save area hjl.tools at gmail dot com
` (5 preceding siblings ...)
2011-06-20 13:58 ` hjl at gcc dot gnu.org
@ 2011-07-01 12:57 ` hjl at gcc dot gnu.org
2011-07-01 13:00 ` hjl.tools at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: hjl at gcc dot gnu.org @ 2011-07-01 12:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48016
--- Comment #7 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> 2011-07-01 12:57:15 UTC ---
Author: hjl
Date: Fri Jul 1 12:57:11 2011
New Revision: 175756
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175756
Log:
Use proper mode for stack save area.
2011-07-01 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/48016
* explow.c (update_nonlocal_goto_save_area): Use proper mode
for stack save area.
* function.c (expand_function_start): Likewise.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/explow.c
trunk/gcc/function.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/48016] Inconsistency in non-local goto save area
2011-03-07 14:06 [Bug middle-end/48016] New: Inconsistency in non-local goto save area hjl.tools at gmail dot com
` (6 preceding siblings ...)
2011-07-01 12:57 ` hjl at gcc dot gnu.org
@ 2011-07-01 13:00 ` hjl.tools at gmail dot com
7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2011-07-01 13:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48016
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.7.0
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> 2011-07-01 13:00:11 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-07-01 13:00 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-07 14:06 [Bug middle-end/48016] New: Inconsistency in non-local goto save area hjl.tools at gmail dot com
2011-03-07 14:13 ` [Bug middle-end/48016] " rguenth at gcc dot gnu.org
2011-03-07 14:40 ` hjl.tools at gmail dot com
2011-03-07 14:44 ` hjl at gcc dot gnu.org
2011-03-16 16:54 ` hjl.tools at gmail dot com
2011-04-02 5:27 ` hjl at gcc dot gnu.org
2011-06-20 13:58 ` hjl at gcc dot gnu.org
2011-07-01 12:57 ` hjl at gcc dot gnu.org
2011-07-01 13:00 ` hjl.tools at gmail dot com
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).