diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-01-15 16:46:54 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-01-15 16:46:54 +0000 |
commit | 99063eeecbfb15fece3c72747a9dd14077c41afd (patch) | |
tree | 907872956c50b6376f90ebf8728f92652457d81c /gcc/cfgexpand.c | |
parent | 17f781605e695711a3383b0474e806ce8150cf49 (diff) | |
download | gcc-99063eeecbfb15fece3c72747a9dd14077c41afd.zip gcc-99063eeecbfb15fece3c72747a9dd14077c41afd.tar.gz gcc-99063eeecbfb15fece3c72747a9dd14077c41afd.tar.bz2 |
PR inline-asm/52813 revisited
The original patch for this PR made it an error to list the stack
pointer in the clobber list of an inline asm. However, the general
feeling seemed to be that going straight to a hard error was too harsh,
since there's quite a bit of existing code that has the clobber.
This patch implements the compromise discussed on IRC of making it
a -Wdeprecated warning instead.
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR inline-asm/52813
* doc/extend.texi: Document that listing the stack pointer in the
clobber list of an asm is a deprecated feature.
* common.opt (Wdeprecated): Moved from c-family/c.opt.
* cfgexpand.c (asm_clobber_reg_is_valid): Issue a -Wdeprecated
warning instead of an error for clobbers of the stack pointer.
Add a note explaining why.
gcc/c-family/
PR inline-asm/52813
* c.opt (Wdeprecated): Move documentation and variable to common.opt.
gcc/d/
PR inline-asm/52813
* lang.opt (Wdeprecated): Reference common.opt instead of c.opt.
gcc/testsuite/
PR inline-asm/52813
* gcc.target/i386/pr52813.c (test1): Turn the diagnostic into a
-Wdeprecated warning and expect a following note:.
From-SVN: r267941
Diffstat (limited to 'gcc/cfgexpand.c')
-rw-r--r-- | gcc/cfgexpand.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 3b7a6e5..2337c63 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2872,12 +2872,16 @@ asm_clobber_reg_is_valid (int regno, int nregs, const char *regname) error ("PIC register clobbered by %qs in %<asm%>", regname); is_valid = false; } - /* Clobbering the STACK POINTER register is an error. */ - if (overlaps_hard_reg_set_p (regset, Pmode, STACK_POINTER_REGNUM)) - { - error ("Stack Pointer register clobbered by %qs in %<asm%>", regname); - is_valid = false; - } + /* Clobbering the stack pointer register is deprecated. GCC expects + the value of the stack pointer after an asm statement to be the same + as it was before, so no asm can validly clobber the stack pointer in + the usual sense. Adding the stack pointer to the clobber list has + traditionally had some undocumented and somewhat obscure side-effects. */ + if (overlaps_hard_reg_set_p (regset, Pmode, STACK_POINTER_REGNUM) + && warning (OPT_Wdeprecated, "listing the stack pointer register" + " %qs in a clobber list is deprecated", regname)) + inform (input_location, "the value of the stack pointer after an %<asm%>" + " statement must be the same as it was before the statement"); return is_valid; } |