From mboxrd@z Thu Jan 1 00:00:00 1970 From: Luc Van Oostenryck Subject: Re: Sparse-LLVM issue compiling NULL pointers Date: Tue, 28 Feb 2017 17:47:55 +0100 Message-ID: References: <20170228150956.moyfiyd5zf7tbeze@macbook.local> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from mail-qk0-f178.google.com ([209.85.220.178]:33130 "EHLO mail-qk0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751323AbdB1Q5N (ORCPT ); Tue, 28 Feb 2017 11:57:13 -0500 Received: by mail-qk0-f178.google.com with SMTP id n127so27715253qkf.0 for ; Tue, 28 Feb 2017 08:57:12 -0800 (PST) In-Reply-To: Sender: linux-sparse-owner@vger.kernel.org List-Id: linux-sparse@vger.kernel.org To: Dibyendu Majumdar Cc: Linux-Sparse On Tue, Feb 28, 2017 at 5:04 PM, Dibyendu Majumdar wrote: > Hi Luc, > > On 28 February 2017 at 15:09, Luc Van Oostenryck > wrote: >> On Tue, Feb 28, 2017 at 06:20:43AM +0000, Dibyendu Majumdar wrote: >>> I am trying to debug a failure in sparse-llvm when compiling following: >>> >>> struct mytype { >>> int *foo; >>> }; >>> extern void init_mytype(struct mytype *mt); >>> void init_mytype(struct mytype *mt) { >>> mt->foo = (void *)0; >>> } >>> >> >> I think that the best you can do for us to be able to help you is to create >> test case showing concretely the issues you have. >> > > Above is a simple test case. If you use an LLVM build with assertions > enabled then the code generator aborts: > > Assertion failed: getOperand(0)->getType() == > cast(getOperand(1)->getType())->getElementType() && "Ptr > must be a pointer to Val type!", file > C:\d\llvm-3.9.0.src\lib\IR\Instructions.cpp, line 1436 I had hoped that "sparse-llvm file.c | llvm-dis" would give a bit more info but well ... > In the details I posted I was trying to say that : > > a) The Expression Value does not appear to pass down the fact that it > has found a NULL pointer - i.e. (void *)0. > b) And even if this is conveyed (by making changes I suggested) then > it is lost at the time of converting to value pseudo. As far as I can > tell the cast is not being optimized away, it is just lost in > translation. OK. It would certainly be a good thing to show/look at the output of test-linearize together with the C code and any info coming from sparse-llvm (and llvm-dis) since this output is the readable form of sparse-llvm's input. Luc