From: Alexander Monakov Date: Mon, 30 Jul 2018 12:26:37 +0000 (+0300) Subject: doc: discourage const/volatile on register variables (PR 86673) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4cc035143dba51e38b35ffa27dbafdb07fe82e71;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33f5e9f5225..18376aeeec1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-07-30 Alexander Monakov + + PR target/86673 + * doc/extend.texi (Global Register Variables): Discourage use of type + qualifiers. + (Local Register Variables): Likewise. + 2018-07-30 Richard Sandiford PR tree-optimization/86506 diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 7b4fc7c1e1e..63ef39a16fe 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.