From owner-freebsd-bugs@FreeBSD.ORG Thu Dec 6 17:50:00 2012 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E163E552 for ; Thu, 6 Dec 2012 17:50:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id B1C928FC12 for ; Thu, 6 Dec 2012 17:50:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id qB6Ho0jp055097 for ; Thu, 6 Dec 2012 17:50:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id qB6Ho0Nl055096; Thu, 6 Dec 2012 17:50:00 GMT (envelope-from gnats) Resent-Date: Thu, 6 Dec 2012 17:50:00 GMT Resent-Message-Id: <201212061750.qB6Ho0Nl055096@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Keith White Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 880CE230 for ; Thu, 6 Dec 2012 17:40:03 +0000 (UTC) (envelope-from kwhite@telecomottawa.net) Received: from smtp1.vianet.ca (smtp1.vianet.ca [209.91.128.18]) by mx1.freebsd.org (Postfix) with ESMTP id 557888FC13 for ; Thu, 6 Dec 2012 17:40:02 +0000 (UTC) Received: from localhost.my.domain (dsl-66-225-185-197.vianet.ca [66.225.185.197]) by smtp1.vianet.ca (Postfix) with ESMTPS id 51645179E3B for ; Thu, 6 Dec 2012 12:30:28 -0500 (EST) Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.my.domain (8.14.5/8.14.5) with ESMTP id qB6HHrt8004278 for ; Thu, 6 Dec 2012 12:17:53 -0500 (EST) (envelope-from kwhite@telecomottawa.net) Received: (from kwhite@localhost) by localhost.my.domain (8.14.5/8.14.5/Submit) id qB6HHrNW004277; Thu, 6 Dec 2012 12:17:53 -0500 (EST) (envelope-from kwhite) Message-Id: <201212061717.qB6HHrNW004277@localhost.my.domain> Date: Thu, 6 Dec 2012 12:17:53 -0500 (EST) From: Keith White To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.114 Subject: bin/174240: bin/clang i386 generates incorrect code for ports/devel/dev86 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Keith White List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2012 17:50:00 -0000 >Number: 174240 >Category: bin >Synopsis: bin/clang i386 generates incorrect code for ports/devel/dev86 >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Dec 06 17:50:00 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Keith White >Release: FreeBSD 10.0-CURRENT amd64 >Organization: SITE, University of Ottawa >Environment: System: FreeBSD freebsd10 10.0-CURRENT FreeBSD 10.0-CURRENT #10 r243890M: Wed Dec 5 11:39:25 EST 2012 root@freebsd10:/usr/obj/usr/src/sys/GENERIC amd64 >Description: clang (i386) compiles ports/devel/dev86/.../as/genlist.c:build_number() to an infinite loop when optimization -O2 is turned on. >How-To-Repeat: Extract build_number() from ports/devel/dev86/.../as/genlist.c === bn.c === PUBLIC char *build_number(num, width, where) unsigned num; unsigned width; register char *where; { static unsigned powers_of_10[] = {1, 10, 100, 1000, 10000,}; unsigned char digit; unsigned char power; register unsigned power_of_10; power = 5; /* actually 1 more than power */ do { for (digit = '0', power_of_10 = (powers_of_10 - 1)[power]; num >= power_of_10; num -= power_of_10) ++digit; if (power <= width) *where++ = digit; } while (--power != 0); return where; } ============ clang -m32 --version FreeBSD clang version 3.2 (branches/release_32 168974) 20121130 Target: i386-unknown-freebsd10.0 Thread model: posix clang -O2 -DPUBLIC="" -m32 -c -save-temps bn.c cat bn.s ... build_number: # @build_number # BB#0: # %for.body.lr.ph .align 16, 0x90 .LBB0_1: # %for.body # =>This Inner Loop Header: Depth=1 jmp .LBB0_1 ... >Fix: Fix to clang unknown. clang generates correct code when "power" is made volatile. ==== devel/dev86 port patch ==== --- dev86-0.16.18/as/genlist.c.orig 2001-06-23 16:13:19.000000000 -0400 +++ dev86-0.16.18/as/genlist.c 2012-12-06 12:11:26.000000000 -0500 @@ -113,7 +113,7 @@ { static unsigned powers_of_10[] = {1, 10, 100, 1000, 10000,}; unsigned char digit; - unsigned char power; + volatile unsigned char power; register unsigned power_of_10; power = 5; /* actually 1 more than power */ ==== ...keith >Release-Note: >Audit-Trail: >Unformatted: