public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99198] New: when combinating nested function and __builtin_call_with_static_chain, optimization triggers an internal compiler error (verify_gimple)
@ 2021-02-22 12:50 zhan3299 at purdue dot edu
  2021-02-22 12:57 ` [Bug c/99198] " rguenth at gcc dot gnu.org
  2021-02-22 16:05 ` msebor at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: zhan3299 at purdue dot edu @ 2021-02-22 12:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99198
           Summary: when combinating nested function and
                    __builtin_call_with_static_chain, optimization
                    triggers an internal compiler error (verify_gimple)
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhan3299 at purdue dot edu
  Target Milestone: ---

Following code is reduced by c-reduce and meaningless, but seems valid as gcc
-O0 accept it. 

Under O0, the program can be successfully compiled
(https://godbolt.org/z/zvGxTP); but under O1, it triggers an internal compiler
error (https://godbolt.org/z/xbvrs6). Besides, any version prior version 11.0
has no such problem.

$ cat test.c
int main() {
    void f() {}
    __builtin_call_with_static_chain(f(), &f);

    return 0;
}

$ gcc --version
gcc (Compiler-Explorer-Build) 11.0.0 20210221 (experimental)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -O0 test.c # Execution build compiler returned: 0

$ gcc -O1 test.c
<source>: In function 'main':
<source>:1:5: error: static chain with function that doesn't use one
    1 | int main() {
      |     ^~~~
f (); [static-chain: f]
during GIMPLE pass: *warn_unused_result
<source>:1:5: internal compiler error: 'verify_gimple' failed
0x1a31d99 internal_error(char const*, ...)
        ???:0
0xdc218d verify_gimple_in_seq(gimple*)
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

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

* [Bug c/99198] when combinating nested function and __builtin_call_with_static_chain, optimization triggers an internal compiler error (verify_gimple)
  2021-02-22 12:50 [Bug c/99198] New: when combinating nested function and __builtin_call_with_static_chain, optimization triggers an internal compiler error (verify_gimple) zhan3299 at purdue dot edu
@ 2021-02-22 12:57 ` rguenth at gcc dot gnu.org
  2021-02-22 16:05 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-22 12:57 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-checking
   Last reconfirmed|                            |2021-02-22

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we verify

  /* If there is a static chain argument, the call should either be
     indirect, or the decl should have DECL_STATIC_CHAIN set.  */
  if (gimple_call_chain (stmt)
      && fndecl
      && !DECL_STATIC_CHAIN (fndecl))
    {
      error ("static chain with function that doesn%'t use one");
      return true;
    }

and when changing the testcase to

int main() {
    void f() {}
    void (*g)() = f;
    __builtin_call_with_static_chain(g(), &f);

    return 0;
}

CCP properly clears the static chain when propagating 'f'.  Thus folding
of __builtin_call_with_static_chain should properly do the same.

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

* [Bug c/99198] when combinating nested function and __builtin_call_with_static_chain, optimization triggers an internal compiler error (verify_gimple)
  2021-02-22 12:50 [Bug c/99198] New: when combinating nested function and __builtin_call_with_static_chain, optimization triggers an internal compiler error (verify_gimple) zhan3299 at purdue dot edu
  2021-02-22 12:57 ` [Bug c/99198] " rguenth at gcc dot gnu.org
@ 2021-02-22 16:05 ` msebor at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-02-22 16:05 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.2.0, 11.0, 5.5.0, 6.4.0,
                   |                            |7.2.0, 8.3.0, 9.1.0
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Bisection points to r217771 (I think that's GCC 5.0) as the first revision to
ICE, which is also when __builtin_call_with_static_chain was introduced, so
it's not really a regression.

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

end of thread, other threads:[~2021-02-22 16:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22 12:50 [Bug c/99198] New: when combinating nested function and __builtin_call_with_static_chain, optimization triggers an internal compiler error (verify_gimple) zhan3299 at purdue dot edu
2021-02-22 12:57 ` [Bug c/99198] " rguenth at gcc dot gnu.org
2021-02-22 16:05 ` msebor at gcc dot gnu.org

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).