aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2018-07-30 15:26:37 +0300
committerAlexander Monakov <amonakov@gcc.gnu.org>2018-07-30 15:26:37 +0300
commit4cc035143dba51e38b35ffa27dbafdb07fe82e71 (patch)
tree8431c42ce190bdfc39e1c627738c4f81b3cacdaf /gcc
parent1dcadcf01d48dda372630478140e3fb4f6bc73ee (diff)
downloadgcc-4cc035143dba51e38b35ffa27dbafdb07fe82e71.zip
gcc-4cc035143dba51e38b35ffa27dbafdb07fe82e71.tar.gz
gcc-4cc035143dba51e38b35ffa27dbafdb07fe82e71.tar.bz2
doc: discourage const/volatile on register variables (PR 86673)
PR target/86673 * doc/extend.texi (Global Register Variables): Discourage use of type qualifiers. (Local Register Variables): Likewise. From-SVN: r263065
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/doc/extend.texi11
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 33f5e9f..18376ae 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-07-30 Alexander Monakov <amonakov@ispras.ru>
+
+ PR target/86673
+ * doc/extend.texi (Global Register Variables): Discourage use of type
+ qualifiers.
+ (Local Register Variables): Likewise.
+
2018-07-30 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/86506
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 7b4fc7c..63ef39a 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -9591,6 +9591,11 @@ a global variable the declaration appears outside a function. The
@code{static}. The register name must be a valid register name for the
target platform.
+Do not use type qualifiers such as @code{const} and @code{volatile}, as
+the outcome may be contrary to expectations. In particular, using the
+@code{volatile} qualifier does not fully prevent the compiler from
+optimizing accesses to the register.
+
Registers are a scarce resource on most systems and allowing the
compiler to manage their usage usually results in the best code. However,
under special circumstances it can make sense to reserve some globally.
@@ -9698,6 +9703,12 @@ but for a local variable the declaration appears within a function. The
@code{static}. The register name must be a valid register name for the
target platform.
+Do not use type qualifiers such as @code{const} and @code{volatile}, as
+the outcome may be contrary to expectations. In particular, when the
+@code{const} qualifier is used, the compiler may substitute the
+variable with its initializer in @code{asm} statements, which may cause
+the corresponding operand to appear in a different register.
+
As with global register variables, it is recommended that you choose
a register that is normally saved and restored by function calls on your
machine, so that calls to library routines will not clobber it.