public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] analyzer: Fix ICE on MD builtin [PR101721]
@ 2021-08-03  7:10 Jakub Jelinek
  2021-08-03  8:13 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2021-08-03  7:10 UTC (permalink / raw)
  To: David Malcolm, Siddhesh Poyarekar; +Cc: gcc-patches

Hi!

The following testcase ICEs because DECL_FUNCTION_CODE asserts the builtin
is BUILT_IN_NORMAL, but it sees a backend (MD) builtin instead.
The FE, normal and MD builtin numbers overlap, so one should always
check what kind of builtin it is before looking at specific codes.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

On the other side, region-model.cc has:
      if (fndecl_built_in_p (callee_fndecl, BUILT_IN_NORMAL)
          && gimple_builtin_call_types_compatible_p (call, callee_fndecl))
        switch (DECL_UNCHECKED_FUNCTION_CODE (callee_fndecl))
which IMO should use DECL_FUNCTION_CODE instead, it checked first it is
a normal builtin...

2021-08-03  Jakub Jelinek  <jakub@redhat.com>

	PR analyzer/101721
	* sm-malloc.cc (known_allocator_p): Only check DECL_FUNCTION_CODE on
	BUILT_IN_NORMAL builtins.

	* gcc.dg/analyzer/pr101721.c: New test.

--- gcc/analyzer/sm-malloc.cc.jj	2021-07-29 13:24:42.664013344 +0200
+++ gcc/analyzer/sm-malloc.cc	2021-08-02 17:42:17.312821855 +0200
@@ -1543,7 +1543,7 @@ known_allocator_p (const_tree fndecl, co
 
   /* ... or it is a builtin allocator that allocates objects freed with
      __builtin_free.  */
-  if (fndecl_built_in_p (fndecl))
+  if (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
     switch (DECL_FUNCTION_CODE (fndecl))
       {
       case BUILT_IN_MALLOC:
--- gcc/testsuite/gcc.dg/analyzer/pr101721.c.jj	2021-08-02 17:48:50.375370371 +0200
+++ gcc/testsuite/gcc.dg/analyzer/pr101721.c	2021-08-02 17:49:38.967696432 +0200
@@ -0,0 +1,8 @@
+/* PR analyzer/101721 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+
+void
+foo ()
+{
+  __builtin_ia32_pause ();
+}

	Jakub


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

* Re: [PATCH] analyzer: Fix ICE on MD builtin [PR101721]
  2021-08-03  7:10 [PATCH] analyzer: Fix ICE on MD builtin [PR101721] Jakub Jelinek
@ 2021-08-03  8:13 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2021-08-03  8:13 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: David Malcolm, Siddhesh Poyarekar, GCC Patches

On Tue, Aug 3, 2021 at 9:11 AM Jakub Jelinek via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi!
>
> The following testcase ICEs because DECL_FUNCTION_CODE asserts the builtin
> is BUILT_IN_NORMAL, but it sees a backend (MD) builtin instead.
> The FE, normal and MD builtin numbers overlap, so one should always
> check what kind of builtin it is before looking at specific codes.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

OK.

> On the other side, region-model.cc has:
>       if (fndecl_built_in_p (callee_fndecl, BUILT_IN_NORMAL)
>           && gimple_builtin_call_types_compatible_p (call, callee_fndecl))
>         switch (DECL_UNCHECKED_FUNCTION_CODE (callee_fndecl))
> which IMO should use DECL_FUNCTION_CODE instead, it checked first it is
> a normal builtin...
>
> 2021-08-03  Jakub Jelinek  <jakub@redhat.com>
>
>         PR analyzer/101721
>         * sm-malloc.cc (known_allocator_p): Only check DECL_FUNCTION_CODE on
>         BUILT_IN_NORMAL builtins.
>
>         * gcc.dg/analyzer/pr101721.c: New test.
>
> --- gcc/analyzer/sm-malloc.cc.jj        2021-07-29 13:24:42.664013344 +0200
> +++ gcc/analyzer/sm-malloc.cc   2021-08-02 17:42:17.312821855 +0200
> @@ -1543,7 +1543,7 @@ known_allocator_p (const_tree fndecl, co
>
>    /* ... or it is a builtin allocator that allocates objects freed with
>       __builtin_free.  */
> -  if (fndecl_built_in_p (fndecl))
> +  if (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
>      switch (DECL_FUNCTION_CODE (fndecl))
>        {
>        case BUILT_IN_MALLOC:
> --- gcc/testsuite/gcc.dg/analyzer/pr101721.c.jj 2021-08-02 17:48:50.375370371 +0200
> +++ gcc/testsuite/gcc.dg/analyzer/pr101721.c    2021-08-02 17:49:38.967696432 +0200
> @@ -0,0 +1,8 @@
> +/* PR analyzer/101721 */
> +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
> +
> +void
> +foo ()
> +{
> +  __builtin_ia32_pause ();
> +}
>
>         Jakub
>

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

end of thread, other threads:[~2021-08-03  8:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03  7:10 [PATCH] analyzer: Fix ICE on MD builtin [PR101721] Jakub Jelinek
2021-08-03  8:13 ` Richard Biener

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