Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset (pr 77608)

2016-12-02 Thread Richard Biener
On Thu, Dec 1, 2016 at 6:58 PM, Martin Sebor wrote: >> Sure - but then you maybe instead want to check for op being in >> range [0, max-of-signed-type-of-op] instead? So similar to >> expr_not_equal_to add a expr_in_range helper? >> >> Your function returns true for sizetype

Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset (pr 77608)

2016-12-01 Thread Martin Sebor
Sure - but then you maybe instead want to check for op being in range [0, max-of-signed-type-of-op] instead? So similar to expr_not_equal_to add a expr_in_range helper? Your function returns true for sizetype vars even if it might be effectively signed, like for sizetype i_1 = -4; i_2 = i_1

Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset (pr 77608)

2016-11-28 Thread Jeff Law
On 11/24/2016 05:11 AM, Richard Biener wrote: where CST is unsigned implying that the lower bound of the offset is the greater of CST and MIN. For instance, in the following it determines that bos(p, 0) is 4 (and if the 3 were greater than 7 and overflowed the addition the result would be

Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset (pr 77608)

2016-11-24 Thread Richard Biener
On Fri, Nov 11, 2016 at 4:56 PM, Martin Sebor wrote: > Thanks for the review and comments! First of all sorry for the late response. >> >> @@ -158,14 +170,149 @@ compute_object_offset (const_tree expr, const_tree >> var) >>return size_binop (code, base, off); >> } >> >>

PING [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset (pr 77608)

2016-11-21 Thread Martin Sebor
Richard, Attached is a lightly updated patch mostly with just clarifying comments and a small bug fix. I'd appreciate your input (please see my reply and questions below). I'm hoping to finalize this patch based on your feedback so it can be committed soon.

Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset (pr 77608)

2016-11-11 Thread Martin Sebor
Thanks for the review and comments! @@ -158,14 +170,149 @@ compute_object_offset (const_tree expr, const_tree var) return size_binop (code, base, off); } +static bool +operand_unsigned_p (tree op) +{ + if (TREE_CODE (op) == SSA_NAME) new functions need a comment. But maybe you want to

Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset (pr 77608)

2016-11-10 Thread Richard Biener
On Tue, Nov 8, 2016 at 5:03 AM, Martin Sebor wrote: > It's taken me longer than I expected to finally get back to this > project. Sorry about the delay. > > https://gcc.gnu.org/ml/gcc-patches/2016-09/msg01110.html > > Attached is an updated patch with this enhancement and

Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset (pr 77608)

2016-11-07 Thread Martin Sebor
It's taken me longer than I expected to finally get back to this project. Sorry about the delay. https://gcc.gnu.org/ml/gcc-patches/2016-09/msg01110.html Attached is an updated patch with this enhancement and reflecting you previous comment. Besides running the GCC test suite I tested the

Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset

2016-09-16 Thread Martin Sebor
On 09/16/2016 04:29 AM, Richard Biener wrote: On Fri, Sep 16, 2016 at 5:29 AM, Martin Sebor wrote: __builtin_object_size fails for POINTER_PLUS expressions involving non-constant offsets into objects of known size, causing GCC to fail to detect (and add instrumentation to

Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset

2016-09-16 Thread Jakub Jelinek
On Fri, Sep 16, 2016 at 12:29:49PM +0200, Richard Biener wrote: > > PS What would be a good way to arrange for the VRP pass to run before > > the object size pass so that the latter can benefit more from range > > information? As an experiment I added another instance of the VRP > > pass before

Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset

2016-09-16 Thread Richard Biener
On Fri, Sep 16, 2016 at 5:29 AM, Martin Sebor wrote: > __builtin_object_size fails for POINTER_PLUS expressions involving > non-constant offsets into objects of known size, causing GCC to fail > to detect (and add instrumentation to prevent) buffer overflow in > some basic cases

Re: [PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset

2016-09-16 Thread kugan
Hi, On 16/09/16 13:29, Martin Sebor wrote: __builtin_object_size fails for POINTER_PLUS expressions involving non-constant offsets into objects of known size, causing GCC to fail to detect (and add instrumentation to prevent) buffer overflow in some basic cases such as the following: void f

[PATCH] have __builtin_object_size handle POINTER_PLUS with non-const offset

2016-09-15 Thread Martin Sebor
__builtin_object_size fails for POINTER_PLUS expressions involving non-constant offsets into objects of known size, causing GCC to fail to detect (and add instrumentation to prevent) buffer overflow in some basic cases such as the following: void f (unsigned i) { char d [3]; memcpy