diff mbox

[GOOGLE] Fix uninitialized memory in AutoFDO implementation

Message ID CAO2gOZUboa7DGiM1c4=856p-zD_XzqWeykeWtc-fkurgw5s=Dw@mail.gmail.com
State New
Headers show

Commit Message

Dehao Chen June 2, 2013, 4:05 a.m. UTC
This patch fixes an uninitialized memory error and a hashtable
comparison bug in AutoFDO.

Bootstrapped and passed regression test.

OK for google branches?

Thanks,
Dehao

Comments

Xinliang David Li June 2, 2013, 5:54 a.m. UTC | #1
ok.

David

On Sat, Jun 1, 2013 at 9:05 PM, Dehao Chen <dehao@google.com> wrote:
> This patch fixes an uninitialized memory error and a hashtable
> comparison bug in AutoFDO.
>
> Bootstrapped and passed regression test.
>
> OK for google branches?
>
> Thanks,
> Dehao
>
> Index: gcc/auto-profile.c
> ===================================================================
> --- gcc/auto-profile.c (revision 199461)
> +++ gcc/auto-profile.c (working copy)
> @@ -310,10 +310,11 @@ afdo_stack_eq (const void *p, const void *q)
>        if (s2->callee_name != NULL)
>   return 0;
>      }
> -  else if (s2->callee_name != NULL
> -   && strcmp (afdo_get_bfd_name (s1->callee_name),
> -      afdo_get_bfd_name (s2->callee_name)))
> +  else if (s2->callee_name == NULL)
>      return 0;
> +  else if (strcmp (afdo_get_bfd_name (s1->callee_name),
> +   afdo_get_bfd_name (s2->callee_name)))
> +    return 0;
>
>    i = afdo_get_original_name_size (s1->func_name);
>    if (i != afdo_get_original_name_size (s2->func_name))
> @@ -1214,6 +1215,8 @@ process_auto_profile (void)
>        new_stack->num_inst = 0;
>        new_stack->count = 0;
>        new_stack->max_count = 0;
> +      new_stack->hist_size = 0;
> +      new_stack->hist = NULL;
>        stack_slot = (struct gcov_stack **)
>    htab_find_slot (stack_htab, new_stack, INSERT);
>        if (!*stack_slot)
diff mbox

Patch

Index: gcc/auto-profile.c
===================================================================
--- gcc/auto-profile.c (revision 199461)
+++ gcc/auto-profile.c (working copy)
@@ -310,10 +310,11 @@  afdo_stack_eq (const void *p, const void *q)
       if (s2->callee_name != NULL)
  return 0;
     }
-  else if (s2->callee_name != NULL
-   && strcmp (afdo_get_bfd_name (s1->callee_name),
-      afdo_get_bfd_name (s2->callee_name)))
+  else if (s2->callee_name == NULL)
     return 0;
+  else if (strcmp (afdo_get_bfd_name (s1->callee_name),
+   afdo_get_bfd_name (s2->callee_name)))
+    return 0;

   i = afdo_get_original_name_size (s1->func_name);
   if (i != afdo_get_original_name_size (s2->func_name))
@@ -1214,6 +1215,8 @@  process_auto_profile (void)
       new_stack->num_inst = 0;
       new_stack->count = 0;
       new_stack->max_count = 0;
+      new_stack->hist_size = 0;
+      new_stack->hist = NULL;
       stack_slot = (struct gcov_stack **)
   htab_find_slot (stack_htab, new_stack, INSERT);
       if (!*stack_slot)