From patchwork Thu Apr 20 12:15:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Ivchenko X-Patchwork-Id: 752778 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 3w7yXf0RWlz9s2x for ; Thu, 20 Apr 2017 22:16:49 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="rCc7V7Tn"; dkim-atps=neutral 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:from:date:message-id:subject:to:cc:content-type; q=dns; s=default; b=nbmZpPotkdnjOEZVYdZuR+fJeazUjftzx7aHqLS71BH FKg1gPIRKs5Gzy/4YbJeXaMZntSsKiXxuwKDJV1xdu+QKuPopXvQHze1WLF9V77a b9/xPE0UlmyuDqvet5uyFtL2o3qcWXzDyKf/l7RcfhCFfKBuwjT7JW7OruMEwY/I = 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:from:date:message-id:subject:to:cc:content-type; s=default; bh=+CC2vVgt6gQL2odeNhtMiONk194=; b=rCc7V7TnW/nMc7VHA gxC4cGepkKXM/yYVhV3ivzXeudNefEnmO1k32WA5S34LtjTySyhmHUGRrtK7yyZG 55YJ1DvpHmi0jXvm0tgynw7eJzBsP9MxeSVUcQZpFqVBA/FYSn8hmTSM6xi1oMY+ 3vpxMreogiIqytiXTWVyzxSKyA= Received: (qmail 44657 invoked by alias); 20 Apr 2017 12:16:34 -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 44640 invoked by uid 89); 20 Apr 2017 12:16:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=4339 X-HELO: mail-qk0-f178.google.com Received: from mail-qk0-f178.google.com (HELO mail-qk0-f178.google.com) (209.85.220.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Apr 2017 12:16:32 +0000 Received: by mail-qk0-f178.google.com with SMTP id d131so44128147qkc.3 for ; Thu, 20 Apr 2017 05:16:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=KA8W9XzXON1554p6h4QdHjCGsmQdpw5EOzD7wub3mB4=; b=XxXyXv6pIGCxNH3xFI3JpcH0yno6HiXr9UN528KwzQSMNtzwc8177RhZCvETvmc3jQ 2vNHYd4qhQIwNRhZFzaA5ozYF/gnXUuUu1cEIxZU4f2k65KwZQYtqCc1stNSgAD2uW6q kjDTq86ZyBDY60recsBuaYSxR36vxLV7bHM0f4lmNRt3hVdrAjON3+qOblgysovLBU+z vL624pgghdqRF33pNUAxHN71Rxan8Guubxv9Z6k8FCTHZsEBPJZG4XR6NpJLvc0Ewn/F Lj77ElRD/3i7mlAmwQXk7Bd8Sw3BARsr3JNr0tyuEBQKPh61S2dC7tftB/sXtY8CgICV S+Ig== X-Gm-Message-State: AN3rC/7Z8Q0uVcJkd0nRHnkN4rdwosOFkLTx3n3SAdmHF/fa4PNr3cMc c3yXF+219E8SOsf1JrDj9Gtw2B0kAg== X-Received: by 10.55.25.159 with SMTP id 31mr347060qkz.183.1492690593104; Thu, 20 Apr 2017 05:16:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.48.176 with HTTP; Thu, 20 Apr 2017 05:15:52 -0700 (PDT) From: Alexander Ivchenko Date: Thu, 20 Apr 2017 14:15:52 +0200 Message-ID: Subject: [CHKP] Fix for PR79988 To: Ilya Enkovich Cc: GCC Patches X-IsSubscribed: yes Hi Ilya, The patch below is basically what Richard proposed in Bugzilla. This approach should produce the correct code for any address spaces, because it will just strip the address space part of the pointer in all bnd* instructions; Since we will do that consistently, all checks should be consistent and correct. What do you think? gcc/testsuite/ChangeLog: * gcc.target/i386/mpx/PR79988.c: New test. gcc/ChangeLog: * tree-chkp.c (chkp_gimple_call_builtin_p): Remove gimple_call_builtin_p call to avoid the call of gimple_builtin_call_types_compatible_p. this will strip the checks for address spaces, which can be skipped without loosing the functionality diff --git a/gcc/testsuite/gcc.target/i386/mpx/PR79988.c b/gcc/testsuite/gcc.target/i386/mpx/PR79988.c new file mode 100644 index 0000000..a6e43eb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/PR79988.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + +void foo(unsigned char * __seg_gs *pointer_gs) { + pointer_gs[5] = 0; +} diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index b1ff218..1f7184d 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -433,7 +433,9 @@ chkp_gimple_call_builtin_p (gimple *call, enum built_in_function code) { tree fndecl; - if (gimple_call_builtin_p (call, BUILT_IN_MD) + if (is_gimple_call (call) + && (fndecl = gimple_call_fndecl (call)) != NULL + && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD && (fndecl = targetm.builtin_chkp_function (code)) && (DECL_FUNCTION_CODE (gimple_call_fndecl (call)) == DECL_FUNCTION_CODE (fndecl)))