From patchwork Thu Nov 20 00:54:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 412552 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C1B61140082 for ; Thu, 20 Nov 2014 11:54:42 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=o6AYn/yrs2rEMd8UkjXOtAteMXZ6SB0jZEceZTD5+MLvLv 2oqQcnAwOyANycURhT9++3KWAlCEVAKY5UcnA61DHxCMNy8+7dN9/Qk6uO4mvXQG B+Y8X+V8k7AT2lOpReC53o+9mKY9q3DsTq5PVLLYY7AJK4cwOam91kxKTRG+s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=I3qIqT92Cz2wPIafVwNG3bTQdys=; b=Z6unXkU5Qr0YRD55/C6m DEJYNxCUSex9KL2veZsl+46Ysr1d1wbTruioMDZY3V80flRY4Dj/1QrXub4bt4UE QTOA8KMRilfeXlsYgwfLMI4/1HQFACGgLH8YoJ1HphsM4Av+234PM4KzXsShLMCa jwpLy3Zzc/py8rnzJO+bnos= Received: (qmail 1001 invoked by alias); 20 Nov 2014 00:54:35 -0000 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 Received: (qmail 989 invoked by uid 89); 20 Nov 2014 00:54:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f177.google.com Received: from mail-lb0-f177.google.com (HELO mail-lb0-f177.google.com) (209.85.217.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 20 Nov 2014 00:54:33 +0000 Received: by mail-lb0-f177.google.com with SMTP id z12so1437700lbi.8 for ; Wed, 19 Nov 2014 16:54:29 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.112.138.137 with SMTP id qq9mr190907lbb.80.1416444869820; Wed, 19 Nov 2014 16:54:29 -0800 (PST) Received: by 10.25.30.7 with HTTP; Wed, 19 Nov 2014 16:54:29 -0800 (PST) Date: Wed, 19 Nov 2014 16:54:29 -0800 Message-ID: Subject: [PATCH/IPA] Fix ipa-polymorphic-call when size of Pmode is not the size of pointers in user code From: Andrew Pinski To: GCC Patches X-IsSubscribed: yes Hi, For ILP32 on AARCH64, we have ptr_mode != Pmode (we have ptr_mode being SImode while Pmode is DImode and POINTER_SIZE is 32). This breaks ipa-polymorphic-call assumption that Pmode is the correct mode for pointers. Right now before this patch we get many testcase failures in the C++ testsuite due to this. Some of the tests fail due to the wrong devirtualization happening (using the base class rather the current class). This patch fixes the issue by using POINTER_SIZE in place of GET_MODE_BITSIZE (Pmode) all over the file. OK? Bootstrapped and tested on x86_64 and cross built and tested for aarch64-elf with no regressions. Thanks, Andrew Pinski ChangeLog: ipa/63981 * ipa-polymorphic-call.c (possible_placement_new): Use POINTER_SIZE instead of GET_MODE_BITSIZE (Pmode). (ipa_polymorphic_call_context::restrict_to_inner_class): Likewise. (extr_type_from_vtbl_ptr_store): Likewise. diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index 452f2d2..a746c49 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -112,7 +112,7 @@ possible_placement_new (tree type, tree expected_type, || !tree_fits_shwi_p (TYPE_SIZE (type)) || (cur_offset + (expected_type ? tree_to_uhwi (TYPE_SIZE (expected_type)) - : GET_MODE_BITSIZE (Pmode)) + : POINTER_SIZE) <= tree_to_uhwi (TYPE_SIZE (type))))); } @@ -155,7 +155,7 @@ ipa_polymorphic_call_context::restrict_to_inner_class (tree otr_type, HOST_WIDE_INT cur_offset = offset; bool speculative = false; bool size_unknown = false; - unsigned HOST_WIDE_INT otr_type_size = GET_MODE_BITSIZE (Pmode); + unsigned HOST_WIDE_INT otr_type_size = POINTER_SIZE; /* Update OUTER_TYPE to match EXPECTED_TYPE if it is not set. */ if (!outer_type) @@ -316,7 +316,7 @@ ipa_polymorphic_call_context::restrict_to_inner_class (tree otr_type, if (pos <= (unsigned HOST_WIDE_INT)cur_offset && (pos + size) >= (unsigned HOST_WIDE_INT)cur_offset - + GET_MODE_BITSIZE (Pmode) + + POINTER_SIZE && (!otr_type || !TYPE_SIZE (TREE_TYPE (fld)) || !tree_fits_shwi_p (TYPE_SIZE (TREE_TYPE (fld))) @@ -1243,7 +1243,7 @@ extr_type_from_vtbl_ptr_store (gimple stmt, struct type_change_info *tci, print_generic_expr (dump_file, tci->instance, TDF_SLIM); fprintf (dump_file, " with offset %i\n", (int)tci->offset); } - return tci->offset > GET_MODE_BITSIZE (Pmode) ? error_mark_node : NULL_TREE; + return tci->offset > POINTER_SIZE ? error_mark_node : NULL_TREE; } if (offset != tci->offset || size != POINTER_SIZE @@ -1252,9 +1252,9 @@ extr_type_from_vtbl_ptr_store (gimple stmt, struct type_change_info *tci, if (dump_file) fprintf (dump_file, " wrong offset %i!=%i or size %i\n", (int)offset, (int)tci->offset, (int)size); - return offset + GET_MODE_BITSIZE (Pmode) <= tci->offset + return offset + POINTER_SIZE <= tci->offset || (max_size != -1 - && tci->offset + GET_MODE_BITSIZE (Pmode) > offset + max_size) + && tci->offset + POINTER_SIZE > offset + max_size) ? error_mark_node : NULL; } }