[Bug c/82817] New: C frontend errors on SSA name from REG_EXPR

thopre01 at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 2 18:07:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82817

            Bug ID: 82817
           Summary: C frontend errors on SSA name from REG_EXPR
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thopre01 at gcc dot gnu.org
                CC: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 42538
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42538&action=edit
unparsable RTL

Hi,

when parsing a __RTL function with expression containing a SSA name of a local
variable (of the form <varname>.<ver>_<ver>, the C parser errors out because
libcpp think it is a floating-point but validation remarks that it is invalid:

error: invalid suffix "_2" on floating constant
       (cinsn 11 (set (reg:SI r3 [orig:111 c.1_2 ] [111])


We could strip the REG_EXPR expression when printing RTL for the frontend via
print_rtx_function but I believe going through libcpp is wrong. Here is how we
get there:

#0  cpp_classify_number (pfile=0x25585b0, token=0x25ac998,
ud_suffix=0x7fffffffd7d0, 
    virtual_location=166019)
    at /data/dev/builds/arm-none-eabi/default/src/libcpp/expr.c:685
#1  0x00000000008b68ab in c_lex_with_flags (value=0x7ffff654e010,
loc=0x7ffff654e00c, 
    cpp_flags=0x7ffff654e018 "\001", lex_flags=0)
    at /data/dev/builds/arm-none-eabi/default/src/gcc/c-family/c-lex.c:415
#2  0x0000000000817b69 in c_lex_one_token (parser=0x7ffff654e000,
token=0x7ffff654e008)
    at /data/dev/builds/arm-none-eabi/default/src/gcc/c/c-parser.c:251
#3  0x0000000000817fa4 in c_parser_peek_token (parser=0x7ffff654e000)
    at /data/dev/builds/arm-none-eabi/default/src/gcc/c/c-parser.c:438
#4  0x0000000000850852 in c_parser_parse_rtl_body (parser=0x7ffff654e000, 
    start_with_pass=0x25f45f0 "shorten")
    at /data/dev/builds/arm-none-eabi/default/src/gcc/c/c-parser.c:18639

Looking at the use done of c_parser_peek_token in c_parser_parse_rtl_body, I
wonder why not call a much lower level function that just reads the input file
and parse parenthesis and end of file itself. Tokenization does not seem
necessary here since all the validation for RTL is done outside the C frontend.

I've reduced manually the RTL function I had to the attached function. I'm not
sure it's valid RTL but at least the syntax should be correct. When building it
with arm-none-eabi-gcc -c -march=armv7e-m -mfloat-abi=hard -mfpu=fpv5-sp-d16
one gets the following errors:

prxxxxx.c: In function 'fn1':
prxxxxx.c:14:44: error: invalid suffix "_2" on floating constant
       (cinsn 11 (set (reg:SI r3 [orig:111 c.1_2 ] [111])
                                            ^~~~
prxxxxx.c:12:56: error: expected character `[', found `)'
prxxxxx.c:12:85: note: following context is ` [0  S4 A32])) "testcase.c":7'


More information about the Gcc-bugs mailing list