From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31503 invoked by alias); 22 Sep 2014 18:54:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 31489 invoked by uid 89); 22 Sep 2014 18:54:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 22 Sep 2014 18:54:00 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8MIrxmr001255 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 22 Sep 2014 14:53:59 -0400 Received: from stumpy.slc.redhat.com (ovpn-113-38.phx2.redhat.com [10.3.113.38]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8MIrwos030617; Mon, 22 Sep 2014 14:53:58 -0400 Message-ID: <54207046.3020709@redhat.com> Date: Mon, 22 Sep 2014 18:54:00 -0000 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: Uros Bizjak , Ilya Enkovich CC: "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH, i386, Pointer Bounds Checker 32/x] Pointer Bounds Checker hooks for i386 target References: <20140919122338.GG50194@msticlxl57.ims.intel.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-09/txt/msg01877.txt.bz2 On 09/19/14 10:21, Uros Bizjak wrote: >> +static tree >> +ix86_make_bounds_constant (HOST_WIDE_INT lb, HOST_WIDE_INT ub) >> +{ >> + tree low = lb ? build_minus_one_cst (pointer_sized_int_node) >> + : build_zero_cst (pointer_sized_int_node); >> + tree high = ub ? build_zero_cst (pointer_sized_int_node) >> + : build_minus_one_cst (pointer_sized_int_node); >> + >> + /* This function is supposed to be used to create zero and >> + none bounds only. */ >> + gcc_assert (lb == 0 || lb == -1); >> + gcc_assert (ub == 0 || ub == -1); >> + >> + return build_complex (NULL, low, high); Needs a comment, even more so than normal given the restrictive nature of the input values. One could bikeshed on using true/false vs 0/-1 since it appears that lb/ub are really boolean values. >> +} >> + >> +static int >> +ix86_initialize_bounds (tree var, tree lb, tree ub, tree *stmts) >> +{ >> + tree size_ptr = build_pointer_type (size_type_node); >> + tree lhs, modify, var_p; >> + >> + ub = build1 (BIT_NOT_EXPR, size_type_node, ub); >> + var_p = build1 (CONVERT_EXPR, size_ptr, >> + build_fold_addr_expr (var)); >> + >> + lhs = build1 (INDIRECT_REF, size_type_node, var_p); >> + modify = build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, lb); >> + append_to_statement_list (modify, stmts); >> + >> + lhs = build1 (INDIRECT_REF, size_type_node, >> + build2 (POINTER_PLUS_EXPR, size_ptr, var_p, >> + TYPE_SIZE_UNIT (size_type_node))); >> + modify = build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, ub); >> + append_to_statement_list (modify, stmts); >> + >> + return 2; >> +} Are we supposed to be emitting gimple or generic here? I don't think this is valid gimple as we have a CONVERT_EXPR embedded in the INDIRECT_REF's argument. I think it's valid generic and does the obvious thing. I just Ilya to make sure what we create does get gimplified. jeff