diff mbox

[Annotalysis] Fix to get_canonical_lock_expr

Message ID CAF6KqwWv4Sj6BnxEKA5HD_0h3iUUVb2JseV7MtFXJGxQU=WTNA@mail.gmail.com
State New
Headers show

Commit Message

Delesley Hutchins July 11, 2011, 10:53 p.m. UTC
This patch fixes get_canonical_lock_expr so that it works on lock
expressions that involve a MEM_REF.  Gimple code can use either
MEM_REF or INDIRECT_REF in many expressions, and the choice of which
to use is somewhat arbitrary.  The canonical form of a lock expression
must rewrite all MEM_REFs to INDIRECT_REFs to accurately compare
expressions.  The surrounding "if" block prevented this rewrite from
happening in certain cases.

Bootstrapped and passed GCC regression testsuite on x86_64-unknown-linux-gnu.

Okay for branches/annotalysis and google/main?

 -DeLesley


2011-07-06   DeLesley Hutchins  <delesley@google.com>
      * cp_get_virtual_function_decl.c (handle_call_gs): Changes
      function to return null if the method cannot be found.
      * thread_annot_lock-79.C: Additional annotalysis test cases

Comments

Delesley Hutchins July 11, 2011, 10:58 p.m. UTC | #1
Oops.  Changlog entry should read:

 2011-07-11   DeLesley Hutchins  <delesley@google.com>
      * tree-threadsafe-analyze.c (tree-threadsafe-analyze.c)
        Changed to force rewrite on MEM_REF
Diego Novillo July 12, 2011, 11:25 p.m. UTC | #2
On 11-07-11 18:53 , Delesley Hutchins wrote:
> This patch fixes get_canonical_lock_expr so that it works on lock
> expressions that involve a MEM_REF.  Gimple code can use either
> MEM_REF or INDIRECT_REF in many expressions, and the choice of which
> to use is somewhat arbitrary.  The canonical form of a lock expression
> must rewrite all MEM_REFs to INDIRECT_REFs to accurately compare
> expressions.  The surrounding "if" block prevented this rewrite from
> happening in certain cases.
>
> Bootstrapped and passed GCC regression testsuite on x86_64-unknown-linux-gnu.
>
> Okay for branches/annotalysis and google/main?

Remember
>
>   -DeLesley
>
>
> 2011-07-06   DeLesley Hutchins<delesley@google.com>
>        * cp_get_virtual_function_decl.c (handle_call_gs): Changes
>        function to return null if the method cannot be found.

 >   2011-07-11   DeLesley Hutchins<delesley@google.com>
 >         * tree-threadsafe-analyze.c (tree-threadsafe-analyze.c)
 >          Changed to force rewrite on MEM_REF

You keep forgetting a blank line after the date line :)
Needs a ':' after ')', and the sentence should end in '.'.

The change description does not seem to be related to the change in the 
code.

OK, otherwise.


Diego.
diff mbox

Patch

Index: gcc/tree-threadsafe-analyze.c
===================================================================
--- gcc/tree-threadsafe-analyze.c       (revision 176188)
+++ gcc/tree-threadsafe-analyze.c       (working copy)
@@ -959,19 +959,17 @@  get_canonical_lock_expr (tree lock, tree base_obj,
           tree canon_base = get_canonical_lock_expr (base, base_obj,
                                                      true /* is_temp_expr */,
                                                      new_leftmost_base_var);
-          if (base != canon_base)
-            {
-              /* If CANON_BASE is an ADDR_EXPR (e.g. &a), doing an indirect or
-                 memory reference on top of it is equivalent to accessing the
-                 variable itself. That is, *(&a) == a. So if that's the case,
-                 simply return the variable. Otherwise, build an indirect ref
-                 expression.  */
-              if (TREE_CODE (canon_base) == ADDR_EXPR)
-                lock = TREE_OPERAND (canon_base, 0);
-              else
-                lock = build1 (INDIRECT_REF,
-                               TREE_TYPE (TREE_TYPE (canon_base)), canon_base);
-            }
+
+          /* If CANON_BASE is an ADDR_EXPR (e.g. &a), doing an indirect or
+             memory reference on top of it is equivalent to accessing the
+             variable itself. That is, *(&a) == a. So if that's the case,
+             simply return the variable. Otherwise, build an indirect ref
+             expression.  */
+          if (TREE_CODE (canon_base) == ADDR_EXPR)
+            lock = TREE_OPERAND (canon_base, 0);
+          else
+            lock = build1 (INDIRECT_REF,
+                           TREE_TYPE (TREE_TYPE (canon_base)), canon_base);
           break;
         }
       default: