From owner-freebsd-arm@FreeBSD.ORG Mon May 27 09:39:53 2013 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 278547B9; Mon, 27 May 2013 09:39:53 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from nibbler.fubar.geek.nz (nibbler.fubar.geek.nz [199.48.134.198]) by mx1.freebsd.org (Postfix) with ESMTP id F244B9A; Mon, 27 May 2013 09:39:52 +0000 (UTC) Received: from bender.Home (unknown [176.252.108.73]) by nibbler.fubar.geek.nz (Postfix) with ESMTPSA id 070165E1D5; Mon, 27 May 2013 09:31:21 +0000 (UTC) Date: Mon, 27 May 2013 10:31:14 +0100 From: Andrew Turner To: Tim Kientzle Subject: Re: Git crash on EABI system. Message-ID: <20130527103114.3fbb00fb@bender.Home> In-Reply-To: <2290084B-D302-4489-BB01-817497901E2B@freebsd.org> References: <51949698.80205@thieprojects.ch> <2290084B-D302-4489-BB01-817497901E2B@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/CBSQ4FQ.nDxaB1VcRwI/jng" Cc: freebsd-arm X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 May 2013 09:39:53 -0000 --MP_/CBSQ4FQ.nDxaB1VcRwI/jng Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Thu, 16 May 2013 05:04:29 -0400 Tim Kientzle wrote: > > On May 16, 2013, at 4:19 AM, Werner Thie wrote: > > >> Has anyone else seen this from git on a clang/EABI system? > >> > >> Assertion failed: (attr_stack->origin), function > >> prepare_attr_stack, file attr.c, line 630. > >> > >> Program received signal SIGABRT, Aborted. > >> [Switching to Thread 20c03300 (LWP 100076/git)] > >> 0x204b842c in thr_kill () from /lib/libc.so.7 > >> (gdb) bt > >> #0 0x204b842c in thr_kill () from /lib/libc.so.7 > >> #1 0x2044157c in raise () from /lib/libthr.so.3 > >> #2 0x20598130 in abort () from /lib/libc.so.7 > >> #3 0x20574630 in __assert () from /lib/libc.so.7 > >> #4 0x00076b28 in ?? () > >> > >> I'm planning to do a debug build and see if I can track down any > >> more details. > > > > Hi Tim > > > > just built git out of curiosity after your post on the BBone > > > > FreeBSD beaglebone 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r250144M: > > Sat May 4 14:18:20 CEST 2013 > > root@xtools:/usr/home/wthie/proj/crochet-freebsd/work/obj/arm.armv6/usr/local/src/sys/BEAGLEBONE-NOWITNESS > > arm > > > > git crashes exactly as advertised when cloning a project in > > > > Assertion failed: (attr_stack->origin), function > > prepare_attr_stack, file attr.c, line 630. > > Thanks for verifying that. > > Unfortunately, a debug build (make -DWITH_DEBUG) does > not crash for me. So I clearly have more work ahead of me > to narrow this down. Hello Tim, Can you test the attached patch for llvm. It should fix git to not crash. The patch is llvm r180609 [1]. The issue was llvm failed to correctly account for pre-indexed loads/stores. It would then use a subtraction to get the correct address of the last slash however it used the wrong subtract instruction. Andrew [1] http://llvm.org/viewvc/llvm-project?view=revision&revision=180609 --MP_/CBSQ4FQ.nDxaB1VcRwI/jng Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=llvm_180609.diff Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp (revision 180608) +++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp (revision 180609) @@ -7152,25 +7152,40 @@ assert(OtherUses[i]->getOperand(!OffsetIdx).getNode() == BasePtr.getNode() && "Expected BasePtr operand"); - APInt OV = - cast(Offset)->getAPIntValue(); - if (AM == ISD::PRE_DEC) - OV = -OV; + // We need to replace ptr0 in the following expression: + // x0 * offset0 + y0 * ptr0 = t0 + // knowing that + // x1 * offset1 + y1 * ptr0 = t1 (the indexed load/store) + // + // where x0, x1, y0 and y1 in {-1, 1} are given by the types of the + // indexed load/store and the expresion that needs to be re-written. + // + // Therefore, we have: + // t0 = (x0 * offset0 - x1 * y0 * y1 *offset1) + (y0 * y1) * t1 ConstantSDNode *CN = cast(OtherUses[i]->getOperand(OffsetIdx)); - APInt CNV = CN->getAPIntValue(); - if (OtherUses[i]->getOpcode() == ISD::SUB && OffsetIdx == 1) - CNV += OV; - else - CNV -= OV; + int X0, X1, Y0, Y1; + APInt Offset0 = CN->getAPIntValue(); + APInt Offset1 = cast(Offset)->getAPIntValue(); - SDValue NewOp1 = Result.getValue(isLoad ? 1 : 0); - SDValue NewOp2 = DAG.getConstant(CNV, CN->getValueType(0)); - if (OffsetIdx == 0) - std::swap(NewOp1, NewOp2); + X0 = (OtherUses[i]->getOpcode() == ISD::SUB && OffsetIdx == 1) ? -1 : 1; + Y0 = (OtherUses[i]->getOpcode() == ISD::SUB && OffsetIdx == 0) ? -1 : 1; + X1 = (AM == ISD::PRE_DEC && !Swapped) ? -1 : 1; + Y1 = (AM == ISD::PRE_DEC && Swapped) ? -1 : 1; - SDValue NewUse = DAG.getNode(OtherUses[i]->getOpcode(), + unsigned Opcode = (Y0 * Y1 < 0) ? ISD::SUB : ISD::ADD; + + APInt CNV = Offset0; + if (X0 < 0) CNV = -CNV; + if (X1 * Y0 * Y1 < 0) CNV = CNV + Offset1; + else CNV = CNV - Offset1; + + // We can now generate the new expression. + SDValue NewOp1 = DAG.getConstant(CNV, CN->getValueType(0)); + SDValue NewOp2 = Result.getValue(isLoad ? 1 : 0); + + SDValue NewUse = DAG.getNode(Opcode, OtherUses[i]->getDebugLoc(), OtherUses[i]->getValueType(0), NewOp1, NewOp2); DAG.ReplaceAllUsesOfValueWith(SDValue(OtherUses[i], 0), NewUse); --MP_/CBSQ4FQ.nDxaB1VcRwI/jng--