From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1722 Path: news.gmane.org!not-for-mail From: agent Newsgroups: gmane.linux.lib.musl.general Subject: Re: build musl with clang Date: Fri, 24 Aug 2012 18:22:11 +0600 Message-ID: <503771F3.2040204@gmail.com> References: <5035E16E.50004@gmail.com> <20120823122414.GM27715@brightrain.aerifal.cx> <50362C19.5080509@gmail.com> <20120823175545.GQ27715@brightrain.aerifal.cx> <5037181B.9050508@gmail.com> <20120824060611.GX27715@brightrain.aerifal.cx> <5037596C.1030409@gmail.com> <20120824110153.GA23569@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1345811016 5491 80.91.229.3 (24 Aug 2012 12:23:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Aug 2012 12:23:36 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1723-gllmg-musl=m.gmane.org@lists.openwall.com Fri Aug 24 14:23:35 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1T4svE-00069P-Pg for gllmg-musl@plane.gmane.org; Fri, 24 Aug 2012 14:23:32 +0200 Original-Received: (qmail 3289 invoked by uid 550); 24 Aug 2012 12:23:31 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 3280 invoked from network); 24 Aug 2012 12:23:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Lx3LODX9TKWQaDDshdCpVS1ZedOPXKpwe8vQ2A4SsMg=; b=yMGpdn6ffUgM6uLOse8NJsUEPRo2XQiw6e/ulUm6O6eYIqsTHzzPIIs++Hevu7lbwn fqQn791ByiQV7kBeA5Qvg4zwQeeAqo4ZaxlW5QfKgINoDJHNYobDHfJ1LQMN8g6YK1fd 6n994VJ3gXAXLzQE+KC5C0QJAspo23tUWrI0CG9KupakG9oIfieXtxw6Fk0wKkkB7Fnh 4WPMaJToCF7B8hQP/XuuUSCO7zomGWjZsqbRbCtbCqNFZOedECRzsR3gXQDjqCkx2vKb ukrrNW7P+BcqEZ7G5cKbHjyakPV0Us8+svoA6JZnKSx7sI6R2hGB52nGF3LVSAcY5F2j BwDw== User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0 In-Reply-To: <20120824110153.GA23569@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:1722 Archived-At: 24.08.2012 17:01, Szabolcs Nagy пишет: > so the bug is still present > > try to make a minimal testcase > > eg. > > void *f() > { > char *p; > > p = malloc(100); > if (p && p[0]) > p[0] = 0; > return p; > } > > > and compile with -O3 -ffreestanding -S > > if the check is eliminated then it's a bug f: # @f # BB#0: # %entry subl $12, %esp movl $100, (%esp) calll malloc testl %eax, %eax je .LBB0_2 # BB#1: # %if.then movb $0, (%eax) .LBB0_2: # %if.end addl $12, %esp ret i suppose, 'if' is not elliminated. but if i create a function f2 with contents of musl's calloc it fails the test. then i noticed in musl's calloc a cycle is wrapped into an 'if' with p with negative subscript and tried the following: void *f1() { char *p; int i; p = malloc(100); if (p[-1]) p[0] = 0; return p; } and that's i we get: f1: # @f1 # BB#0: # %if.end subl $12, %esp movl $100, (%esp) calll malloc movb $0, (%eax) addl $12, %esp ret but if we have if (p && p[-1]) -- 'if' is not optimized out.