From patchwork Mon Jul 11 22:53:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Delesley Hutchins X-Patchwork-Id: 104295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1446AB6F75 for ; Tue, 12 Jul 2011 08:53:41 +1000 (EST) Received: (qmail 6836 invoked by alias); 11 Jul 2011 22:53:39 -0000 Received: (qmail 6828 invoked by uid 22791); 11 Jul 2011 22:53:39 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Jul 2011 22:53:25 +0000 Received: from kpbe17.cbf.corp.google.com (kpbe17.cbf.corp.google.com [172.25.105.81]) by smtp-out.google.com with ESMTP id p6BMrNDx009189 for ; Mon, 11 Jul 2011 15:53:23 -0700 Received: from yxm34 (yxm34.prod.google.com [10.190.4.34]) by kpbe17.cbf.corp.google.com with ESMTP id p6BMqpEj031802 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Mon, 11 Jul 2011 15:53:22 -0700 Received: by yxm34 with SMTP id 34so2377009yxm.10 for ; Mon, 11 Jul 2011 15:53:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.113.9 with SMTP id l9mr4451531ybc.389.1310424801770; Mon, 11 Jul 2011 15:53:21 -0700 (PDT) Received: by 10.151.10.2 with HTTP; Mon, 11 Jul 2011 15:53:21 -0700 (PDT) Date: Mon, 11 Jul 2011 15:53:21 -0700 Message-ID: Subject: [PATCH] [Annotalysis] Fix to get_canonical_lock_expr From: Delesley Hutchins To: gcc-patches@gcc.gnu.org, Diego Novillo , Le-Chun Wu X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * 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 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: