From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dibyendu Majumdar Subject: Re: [PATCH] llvm: fix output_op_[ptr]cast() Date: Fri, 3 Mar 2017 19:54:23 +0000 Message-ID: References: <20170303052459.2351-1-luc.vanoostenryck@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from mail-it0-f42.google.com ([209.85.214.42]:37902 "EHLO mail-it0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752460AbdCCUSZ (ORCPT ); Fri, 3 Mar 2017 15:18:25 -0500 Received: by mail-it0-f42.google.com with SMTP id m27so20221209iti.1 for ; Fri, 03 Mar 2017 12:18:24 -0800 (PST) In-Reply-To: Sender: linux-sparse-owner@vger.kernel.org List-Id: linux-sparse@vger.kernel.org To: Luc Van Oostenryck Cc: Linux-Sparse On 3 March 2017 at 19:50, Luc Van Oostenryck wrote: > On Fri, Mar 3, 2017 at 7:06 PM, Dibyendu Majumdar > wrote: >> The problem occurs in this sequence: >> >> ptrcast.64 %r26 <- (64) %r20 >> add.64 %r27 <- %r26, %r23 >> cast.64 %r28 <- (64) %r27 >> store.64 %r28 -> 16[%arg1] >> >> The last cast finds that the instruction type in an integer and does a >> cast to Integer, so that causes the store to fail as it expects a >> pointer. > > What is the corresponding C code? > With the patches I've posted, the three example you've given are handled > without error for me. > C code below, it is the last += that is failing. typedef unsigned long long size_t; struct buffer_type_st { struct buffer_type_st *next_buffer; char *buffer; }; typedef struct buffer_type_st buffer_type_t; struct link_st { struct link_st *next; }; typedef struct link_st link_t; struct allocator_st { buffer_type_t *buffer_list; link_t *free_list; char *next_avail; char *last; size_t size; size_t n; }; typedef struct allocator_st allocator; extern void * alloc_node(allocator * a); extern void grow_allocator(allocator * a); void * alloc_node(allocator * a) { link_t *tmp; tmp = a->free_list; if (a->free_list) { a->free_list = (link_t *) (a->free_list->next); return (void *) tmp; } else { if (a->next_avail == a->last) { grow_allocator(a); } { void *tmp; tmp = (void *) a->next_avail; a->next_avail += a->size; return tmp; } } }