* Fix x86 segfault on thread-local asm operands
@ 2003-11-28 16:32 Richard Sandiford
2003-11-28 22:43 ` Richard Henderson
0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2003-11-28 16:32 UTC (permalink / raw)
To: gcc-patches
If "i" is a thread-local variable, using the deprecated:
asm volatile ("" :: "m" (&i));
will cause gcc to segfault on x86. We try to force the constant
into memory but don't check for success.
Patch bootstrapped & regression tested on i686-pc-linux-gnu.
OK to install?
Richard
* stmt.c (expand_asm_operands): Check whether force_const_mem
succeeded.
testsuite/
* gcc.dg/tls/asm-1.C: New test.
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.336
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.336 stmt.c
*** stmt.c 20 Nov 2003 00:28:39 -0000 1.336
--- stmt.c 28 Nov 2003 14:00:04 -0000
*************** expand_asm_operands (tree string, tree o
*** 1712,1724 ****
if (CONSTANT_P (op))
{
! op = force_const_mem (TYPE_MODE (type), op);
! op = validize_mem (op);
}
! else if (GET_CODE (op) == REG
! || GET_CODE (op) == SUBREG
! || GET_CODE (op) == ADDRESSOF
! || GET_CODE (op) == CONCAT)
{
tree qual_type = build_qualified_type (type,
(TYPE_QUALS (type)
--- 1712,1727 ----
if (CONSTANT_P (op))
{
! rtx mem = force_const_mem (TYPE_MODE (type), op);
! if (mem)
! op = validize_mem (mem);
! else
! op = force_reg (TYPE_MODE (type), op);
}
! if (GET_CODE (op) == REG
! || GET_CODE (op) == SUBREG
! || GET_CODE (op) == ADDRESSOF
! || GET_CODE (op) == CONCAT)
{
tree qual_type = build_qualified_type (type,
(TYPE_QUALS (type)
*** /dev/null Tue Mar 19 20:01:09 2002
--- testsuite/gcc.dg/tls/asm-1.c Fri Nov 28 13:56:54 2003
***************
*** 0 ****
--- 1,7 ----
+ /* { dg-options "" } */
+ __thread int i;
+
+ int foo ()
+ {
+ asm volatile ("" :: "m" (&i)); /* { dg-warning "input without lvalue" } */
+ }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix x86 segfault on thread-local asm operands
2003-11-28 16:32 Fix x86 segfault on thread-local asm operands Richard Sandiford
@ 2003-11-28 22:43 ` Richard Henderson
2003-11-29 21:53 ` Richard Sandiford
0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2003-11-28 22:43 UTC (permalink / raw)
To: Richard Sandiford; +Cc: gcc-patches
On Fri, Nov 28, 2003 at 02:14:59PM +0000, Richard Sandiford wrote:
> * stmt.c (expand_asm_operands): Check whether force_const_mem
> succeeded.
> * gcc.dg/tls/asm-1.C: New test.
I guess this is ok. We'll just have to remember to remove the
test case when it gets merged to tree-ssa, as there it's a hard
error not a warning.
Or perhaps you could use dg-error and add -Werror to the options?
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix x86 segfault on thread-local asm operands
2003-11-28 22:43 ` Richard Henderson
@ 2003-11-29 21:53 ` Richard Sandiford
0 siblings, 0 replies; 3+ messages in thread
From: Richard Sandiford @ 2003-11-29 21:53 UTC (permalink / raw)
To: Richard Henderson; +Cc: gcc-patches
Richard Henderson <rth@redhat.com> writes:
> Or perhaps you could use dg-error and add -Werror to the options?
OK, here's what I committed (after checking that the test case still passes).
Richard
* stmt.c (expand_asm_operands): Check whether force_const_mem
succeeded.
testsuite/
* gcc.dg/tls/asm-1.C: New test.
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.336
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.336 stmt.c
*** stmt.c 20 Nov 2003 00:28:39 -0000 1.336
--- stmt.c 29 Nov 2003 18:50:25 -0000
*************** expand_asm_operands (tree string, tree o
*** 1712,1724 ****
if (CONSTANT_P (op))
{
! op = force_const_mem (TYPE_MODE (type), op);
! op = validize_mem (op);
}
! else if (GET_CODE (op) == REG
! || GET_CODE (op) == SUBREG
! || GET_CODE (op) == ADDRESSOF
! || GET_CODE (op) == CONCAT)
{
tree qual_type = build_qualified_type (type,
(TYPE_QUALS (type)
--- 1712,1727 ----
if (CONSTANT_P (op))
{
! rtx mem = force_const_mem (TYPE_MODE (type), op);
! if (mem)
! op = validize_mem (mem);
! else
! op = force_reg (TYPE_MODE (type), op);
}
! if (GET_CODE (op) == REG
! || GET_CODE (op) == SUBREG
! || GET_CODE (op) == ADDRESSOF
! || GET_CODE (op) == CONCAT)
{
tree qual_type = build_qualified_type (type,
(TYPE_QUALS (type)
*** /dev/null Tue Mar 19 20:01:09 2002
--- testsuite/gcc.dg/tls/asm-1.c Sat Nov 29 18:49:09 2003
***************
*** 0 ****
--- 1,7 ----
+ /* { dg-options "-Werror" } */
+ __thread int i;
+
+ int foo ()
+ {
+ asm volatile ("" :: "m" (&i)); /* { dg-error "lvalue" } */
+ }
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-11-29 18:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-28 16:32 Fix x86 segfault on thread-local asm operands Richard Sandiford
2003-11-28 22:43 ` Richard Henderson
2003-11-29 21:53 ` Richard Sandiford
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).