This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with accessing built-ins from Fortran front-end


On Fri, Sep 26, 2014 at 10:29 AM, FX <fxcoudert@gmail.com> wrote:
> Hi,
>
> Iâm trying to make the Fortran front-end emit calls to some builtins we donât currently use (isfinite, isnormal). However, trying to use the same code as isnan doesnât work at all. Our gfc_define_builtin does three things:
>
>   decl = add_builtin_function (name, type, code, BUILT_IN_NORMAL, library_name, NULL_TREE);
>   set_call_expr_flags (decl, attr);
>   set_builtin_decl (code, decl, true);
>
> While doing so works with isnan, it fails with isfinite or isnormal. When I try to, I get an ICE in tree checking:
>
>   * frame #0: 0x0000000100c02338 f951`build_call_expr_loc_array(loc=0, fndecl=0x0000000000000000, n=2, argarray=0x00007fff5fbfeb20) + 24 at tree.h:2846

fndecl is NULL which means that fold_builtin_interclass_mathfn doesn't
expect only some of the classification builtins to exist.  In this case
probably

    CASE_FLT_FN (BUILT_IN_FINITE):
    case BUILT_IN_ISFINITE:
      {
        /* isfinite(x) -> islessequal(fabs(x),DBL_MAX).  */
        tree const isle_fn = builtin_decl_explicit (BUILT_IN_ISLESSEQUAL);

You can either amend the transforms in builtins.c to check for
the availability of the decls (simply return NULL_TREE if !isle_fn)
or make sure the fortran frontend defines all of the FP classification
and compare builtins.

Richard.

>     frame #1: 0x0000000100c0259a f951`build_call_expr(fndecl=<unavailable>, n=<unavailable>) + 186 at tree.c:10550
>     frame #2: 0x000000010046f671 f951`fold_builtin_interclass_mathfn(loc=<unavailable>, fndecl=<unavailable>, arg=0x000000014340c990) + 337 at builtins.c:9393
>     frame #3: 0x0000000100485e34 f951`fold_builtin_1(loc=260, fndecl=0x0000000143449360, arg0=0x000000014340c990, ignore=<unavailable>) + 2964 at builtins.c:10050
>     frame #4: 0x000000010049030c f951`fold_builtin_n(loc=<unavailable>, fndecl=<unavailable>, args=<unavailable>, nargs=<unavailable>, ignore=<unavailable>) + 1116 at builtins.c:10409
>     frame #5: 0x0000000100491c33 f951`fold_builtin_call_array(loc=260, type=0x0000000143405690, fn=0x000000014351fc40, n=1, argarray=0x00007fff5fbfeeb0) + 355 at builtins.c:10575
>     frame #6: 0x0000000100c024c5 f951`build_call_expr_loc(loc=<unavailable>, fndecl=<unavailable>, n=<unavailable>) + 181 at tree.c:10533
>
>
> I donât understand how the middle-end builtins decl should work, would someone have a hint of how to fix this?
>
> Thanks,
> FX
>
>
> PS: the attached patch emits isfinite instead of isnan to test the built-in changes with minimal. With that patch, the Fortran source attached triggers the ICE above.
>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]