]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix rtx_code_size static initialization order fiasco
authorIlya Leoshkevich <iii@linux.ibm.com>
Thu, 25 Oct 2018 13:47:10 +0000 (13:47 +0000)
committerIlya Leoshkevich <iii@gcc.gnu.org>
Thu, 25 Oct 2018 13:47:10 +0000 (13:47 +0000)
r264556 and r264537 changed the format of EQ_ATTR_ALT RTXs to "ww",
which also required adjusting rtx_code_size initializer.  In order to
simplify things, the list of rtx_codes known to use HOST_WIDE_INTs was
replaced by the format string check.  However, unlike the old one, this
new check cannot be always performed at compile time, in which case a
static constructor is generated.  This may lead to a static
initialization order fiasco with respect to other static constructors
in the compiler, in case of PR87747, cselib's pool_allocator.

gcc/ChangeLog:

2018-10-25  Ilya Leoshkevich  <iii@linux.ibm.com>

PR bootstrap/87747
* rtl.c (RTX_CODE_HWINT_P_1): New helper macro.
(RTX_CODE_HWINT_P): New macro.
(rtx_code_size): Use RTX_CODE_HWINT_P ().

From-SVN: r265488

gcc/ChangeLog
gcc/rtl.c

index 2490eef47a540566329311041fe8e7c48fdddb9f..425c6202965db4a8c63d83128485fe0f8f91b9f3 100644 (file)
@@ -1,3 +1,10 @@
+2018-10-25  Ilya Leoshkevich  <iii@linux.ibm.com>
+
+       PR bootstrap/87747
+       * rtl.c (RTX_CODE_HWINT_P_1): New helper macro.
+       (RTX_CODE_HWINT_P): New macro.
+       (rtx_code_size): Use RTX_CODE_HWINT_P ().
+
 2018-10-25  Jan Hubicka  <jh@suse.cz>
 
        * ipa-devirt.c (odr_types_equivalent_p): Do not ICE if one of types
index ca5c25c422ffa6c2f0f61f4e1dc101206f58af86..86a40b11cf4c4c433cff22f69885996d53f8fb81 100644 (file)
--- a/gcc/rtl.c
+++ b/gcc/rtl.c
@@ -106,11 +106,23 @@ const enum rtx_class rtx_class[NUM_RTX_CODE] = {
 #undef DEF_RTL_EXPR
 };
 
+/* Whether rtxs with the given code code store data in the hwint field.  */
+
+#define RTX_CODE_HWINT_P_1(ENUM)                                       \
+    ((ENUM) == CONST_INT || (ENUM) == CONST_DOUBLE                     \
+     || (ENUM) == CONST_FIXED || (ENUM) == CONST_WIDE_INT)
+#ifdef GENERATOR_FILE
+#define RTX_CODE_HWINT_P(ENUM)                                         \
+    (RTX_CODE_HWINT_P_1 (ENUM) || (ENUM) == EQ_ATTR_ALT)
+#else
+#define RTX_CODE_HWINT_P RTX_CODE_HWINT_P_1
+#endif
+
 /* Indexed by rtx code, gives the size of the rtx in bytes.  */
 
 const unsigned char rtx_code_size[NUM_RTX_CODE] = {
 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)                                \
-  ((FORMAT)[0] == 'w'                                                  \
+  (RTX_CODE_HWINT_P (ENUM)                                             \
    ? RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (HOST_WIDE_INT)       \
    : (ENUM) == REG                                                     \
    ? RTX_HDR_SIZE + sizeof (reg_info)                                  \