diff mbox

Fix Bug 51162

Message ID 1322131357.23412.76.camel@e102549-lin.cambridge.arm.com
State New
Headers show

Commit Message

Sameera Deshpande Nov. 24, 2011, 10:42 a.m. UTC
Hi,

Please find attached the patch fixing bugzilla issue
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51162.

ARM architecture implements vec_[load|store]_lanes<mode><mode> which are
implemented as internal function calls. The function gimple_call_fn ()
returns NULL for internal calls. Hence, this patch guards dereferences
of 'fn' in dump_gimple_call ().

Tests in gcc-dg/vect failing with 'segmentation fault', pass with this
patch.

gcc/Changelog entry:
2011-11-24  Sameera Deshpande  <sameera.deshpande@arm.com>

       * gimple-pretty-print.c (dump_gimple_call): Check if fn is NULL
         before dereferencing.

--

Comments

Jason Merrill Nov. 30, 2011, 7:43 p.m. UTC | #1
On 11/24/2011 05:42 AM, Sameera Deshpande wrote:
> -  if (TREE_CODE (fn) == ADDR_EXPR)
> +  if (fn != NULL && TREE_CODE (fn) == ADDR_EXPR)
>      fn = TREE_OPERAND (fn, 0);
> -  if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
> +  if (fn != NULL && TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
>      pp_string (buffer, " [tm-clone]");
> -  if (TREE_CODE (fn) == FUNCTION_DECL
> +  if (fn != NULL

I'd rather not add the null check so many times.  How about just 
returning if fn is null?

Jason
diff mbox

Patch

diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index f0e7c50..6d96868 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -699,11 +699,12 @@  dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
     pp_string (buffer, " [tail call]");
 
   /* Dump the arguments of _ITM_beginTransaction sanely.  */
-  if (TREE_CODE (fn) == ADDR_EXPR)
+  if (fn != NULL && TREE_CODE (fn) == ADDR_EXPR)
     fn = TREE_OPERAND (fn, 0);
-  if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
+  if (fn != NULL && TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
     pp_string (buffer, " [tm-clone]");
-  if (TREE_CODE (fn) == FUNCTION_DECL
+  if (fn != NULL
+      && TREE_CODE (fn) == FUNCTION_DECL
       && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
       && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
       && gimple_call_num_args (gs) > 0)