[PUSHED] Fix off-by-one storage problem in irange_allocator.

Andrew MacLeod amacleod@redhat.com
Tue Oct 6 12:58:17 GMT 2020


On 10/6/20 8:55 AM, Jakub Jelinek wrote:
> On Tue, Oct 06, 2020 at 08:47:53AM -0400, Andrew MacLeod wrote:
>>> I think the proper alignment will be guaranteed if irange and tree[] are
>>> obstack_alloc'd separately.  They don't need to be adjacent, do they?
>>>
>>>
>> They do not, it just seemed wasteful to do 2 allocs each time, and it'd be
>> nice to have them co-located since accessing one inevitable leads to
>> accessing the other.
> When using normal allocator like malloc or ggc allocation I'd totally agree
> here, but I actually think with obstack it is better to do two successive
> allocations.
> obstack_alloc is generally pretty cheap, in the common case there is room
> for the allocation and so it just bumps the next pointer in the structure
> and that is it, for the two allocation the same like with one.
> And, if there is room just for the irange and not for the subsequent
> allocation, with two allocations they wouldn't be collocated, but wouldn't
> waste the memory that would otherwise remain unused.
>
> 	Jakub
okeydoke then.  we can do 2 allocations.




More information about the Gcc-patches mailing list