public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* options generation and language count
@ 2011-08-30  6:57 Gary Funck
  2011-08-30 16:50 ` Joseph S. Myers
  0 siblings, 1 reply; 8+ messages in thread
From: Gary Funck @ 2011-08-30  6:57 UTC (permalink / raw)
  To: Gcc Patches


Recently, we ran "make check" on the GCC built from the GUPC branck
and compared it against "make check" run against the GCC trunk version
of the most recent merge with the trunk.  The following failure
was detected on the GUPC branch.

cc1: internal compiler error: in print_specific_help, at opts.c:1128

The following command generates the error.

gcc/xgcc -Bgcc/ test-18810.c --help=optimizers -lm -o test-18810.x

The assertion check is here:

1126 /* Sanity check: Make sure that we do not have more
1127 languages than we have bits available to enumerate them. */
1128 gcc_assert ((1U << cl_lang_count) < CL_MIN_OPTION_CLASS);

The value of 'cl_lang_count' is calculated by an AWK script that
processes the .opt files and generates .c and .h files. The value of
CL_MIN_OPTION_CLASS is defined in opts.h.

130 #define CL_PARAMS (1U << 11) /* Fake entry. Used to display --param info with --help. */
131 #define CL_WARNING (1U << 12) /* Enables an (optional) warning message. */
132 #define CL_OPTIMIZATION (1U << 13) /* Enables an (optional) optimization. */
133 #define CL_DRIVER (1U << 14) /* Driver option. */
134 #define CL_TARGET (1U << 15) /* Target-specific option. */
135 #define CL_COMMON (1U << 16) /* Language-independent. */
136
137 #define CL_MIN_OPTION_CLASS CL_PARAMS
138 #define CL_MAX_OPTION_CLASS CL_COMMON

Above, we can see that CL_MIN_OPTION_CLASS is equal to CL_PARAMS,
which is a fixed value: (1U << 11).

The options.h file is generated by the AWK scripts and is present in
the 'gcc' build directory. Here's the relevant values.

    #define CL_UPC (1U << 10)
    #define CL_LANG_ALL ((1U << 11) - 1)

The cl_lang_count value is in the generated options.c file.

    const unsigned int cl_lang_count = 11;

Although I haven't reviewed the source code in detail it looks to me
like there might be two issues here:

1) The sanity check should probably read:
   gcc_assert ((1U << cl_lang_count) <= CL_MIN_OPTION_CLASS);
In other words, it is off-by-one.

2) The fixed shift counts starting at CL_PARAMS probably need to be
adjusted upwards to allow for more languages.

A third problem, is that this sort of error would be better detected
at build time rather than waiting to run a DejaGNU test to find it.
Also, the use of fixed masks is problematic.  Perhaps the AWK script
could be changed to also generate values for CL_PARAMS, etc., ensuring
that will not conflict with the language mask values?

- Gary

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-09-02 19:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-30  6:57 options generation and language count Gary Funck
2011-08-30 16:50 ` Joseph S. Myers
2011-08-30 16:50   ` Gary Funck
2011-08-30 19:59     ` Joseph S. Myers
2011-09-01 21:49       ` [Patch, C] " Gary Funck
2011-09-02 13:42         ` Joseph S. Myers
2011-09-02 16:27           ` Gary Funck
2011-09-02 19:53             ` Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).