Commit 99063eee by Richard Sandiford Committed by Richard Sandiford

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
parent 17f78160
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
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.
2019-01-15 Richard Biener <rguenther@suse.de> 2019-01-15 Richard Biener <rguenther@suse.de>
PR debug/88046 PR debug/88046
......
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
PR inline-asm/52813
* c.opt (Wdeprecated): Move documentation and variable to common.opt.
2019-01-14 Jakub Jelinek <jakub@redhat.com> 2019-01-14 Jakub Jelinek <jakub@redhat.com>
* c-cppbuiltin.c (c_cpp_builtin): Define __cpp_guaranteed_copy_elision * c-cppbuiltin.c (c_cpp_builtin): Define __cpp_guaranteed_copy_elision
......
...@@ -477,8 +477,8 @@ C++ ObjC++ Var(warn_delnonvdtor) Warning LangEnabledBy(C++ ObjC++,Wall || Weffc+ ...@@ -477,8 +477,8 @@ C++ ObjC++ Var(warn_delnonvdtor) Warning LangEnabledBy(C++ ObjC++,Wall || Weffc+
Warn about deleting polymorphic objects with non-virtual destructors. Warn about deleting polymorphic objects with non-virtual destructors.
Wdeprecated Wdeprecated
C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) CppReason(CPP_W_DEPRECATED) Var(warn_deprecated) Init(1) Warning C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) CppReason(CPP_W_DEPRECATED)
Warn if a deprecated compiler feature, class, method, or field is used. ; Documented in common.opt
Wdeprecated-copy Wdeprecated-copy
C++ ObjC++ Var(warn_deprecated_copy) Warning LangEnabledBy(C++ ObjC++, Wextra) C++ ObjC++ Var(warn_deprecated_copy) Warning LangEnabledBy(C++ ObjC++, Wextra)
......
...@@ -2872,12 +2872,16 @@ asm_clobber_reg_is_valid (int regno, int nregs, const char *regname) ...@@ -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); error ("PIC register clobbered by %qs in %<asm%>", regname);
is_valid = false; is_valid = false;
} }
/* Clobbering the STACK POINTER register is an error. */ /* Clobbering the stack pointer register is deprecated. GCC expects
if (overlaps_hard_reg_set_p (regset, Pmode, STACK_POINTER_REGNUM)) 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
error ("Stack Pointer register clobbered by %qs in %<asm%>", regname); the usual sense. Adding the stack pointer to the clobber list has
is_valid = false; 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; return is_valid;
} }
......
...@@ -579,6 +579,10 @@ Wattribute-warning ...@@ -579,6 +579,10 @@ Wattribute-warning
Common Var(warn_attribute_warning) Init(1) Warning Common Var(warn_attribute_warning) Init(1) Warning
Warn about uses of __attribute__((warning)) declarations. Warn about uses of __attribute__((warning)) declarations.
Wdeprecated
Common Var(warn_deprecated) Init(1) Warning
Warn if a deprecated compiler feature, class, method, or field is used.
Wdeprecated-declarations Wdeprecated-declarations
Common Var(warn_deprecated_decl) Init(1) Warning Common Var(warn_deprecated_decl) Init(1) Warning
Warn about uses of __attribute__((deprecated)) declarations. Warn about uses of __attribute__((deprecated)) declarations.
......
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
PR inline-asm/52813
* lang.opt (Wdeprecated): Reference common.opt instead of c.opt.
2019-01-12 Iain Buclaw <ibuclaw@gdcproject.org> 2019-01-12 Iain Buclaw <ibuclaw@gdcproject.org>
* README.gcc: New file. * README.gcc: New file.
......
...@@ -124,7 +124,7 @@ Warn about casts that will produce a null result. ...@@ -124,7 +124,7 @@ Warn about casts that will produce a null result.
Wdeprecated Wdeprecated
D D
; Documented in C ; Documented in common.opt
Werror Werror
D D
......
...@@ -9441,6 +9441,15 @@ When the compiler selects which registers to use to represent input and output ...@@ -9441,6 +9441,15 @@ When the compiler selects which registers to use to represent input and output
operands, it does not use any of the clobbered registers. As a result, operands, it does not use any of the clobbered registers. As a result,
clobbered registers are available for any use in the assembler code. clobbered registers are available for any use in the assembler code.
Another restriction is that the clobber list should not contain the
stack pointer register. This is because the compiler requires the
value of the stack pointer to be the same after an @code{asm}
statement as it was on entry to the statement. However, previous
versions of GCC did not enforce this rule and allowed the stack
pointer to appear in the list, with unclear semantics. This behavior
is deprecated and listing the stack pointer may become an error in
future versions of GCC@.
Here is a realistic example for the VAX showing the use of clobbered Here is a realistic example for the VAX showing the use of clobbered
registers: registers:
......
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
PR inline-asm/52813
* gcc.target/i386/pr52813.c (test1): Turn the diagnostic into a
-Wdeprecated warning and expect a following note:.
2019-01-15 Richard Biener <rguenther@suse.de> 2019-01-15 Richard Biener <rguenther@suse.de>
PR debug/88046 PR debug/88046
......
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
void void
test1 (void) test1 (void)
{ {
asm volatile ("" : : : "%esp"); /* { dg-error "Stack Pointer register clobbered" } */ asm volatile ("" : : : "%esp"); /* { dg-warning "listing the stack pointer register '%esp' in a clobber list is deprecated" } */
/* { dg-message "note: the value of the stack pointer after an 'asm' statement must be the same as it was before the statement" "" { target *-*-* } .-1 } */
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment