From natebegeman at mac.com Mon Oct 12 00:53:58 2009 From: natebegeman at mac.com (Nate Begeman) Date: Mon, 12 Oct 2009 05:53:58 -0000 Subject: [llvm-commits] [llvm] r83824 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Message-ID: <200910120553.n9C5rwDF004682@zion.cs.uiuc.edu> Author: sampo Date: Mon Oct 12 00:53:58 2009 New Revision: 83824 URL: http://llvm.org/viewvc/llvm-project?rev=83824&view=rev Log: More heuristics for Combiner-AA. Still catches all important cases, but compile time penalty on gnugo, the worst case in MultiSource, is down to about 2.5% from 30% Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=83824&r1=83823&r2=83824&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Oct 12 00:53:58 2009 @@ -6230,13 +6230,28 @@ // Starting off. Chains.push_back(OriginalChain); - + unsigned Depth = 0; + // Look at each chain and determine if it is an alias. If so, add it to the // aliases list. If not, then continue up the chain looking for the next // candidate. while (!Chains.empty()) { SDValue Chain = Chains.back(); Chains.pop_back(); + + // For TokenFactor nodes, look at each operand and only continue up the + // chain until we find two aliases. If we've seen two aliases, assume we'll + // find more and revert to original chain since the xform is unlikely to be + // profitable. + // + // FIXME: The depth check could be made to return the last non-aliasing + // chain we found before we hit a tokenfactor rather than the original + // chain. + if (Depth > 6 || Aliases.size() == 2) { + Aliases.clear(); + Aliases.push_back(OriginalChain); + break; + } // Don't bother if we've been before. if (!Visited.insert(Chain.getNode())) @@ -6268,8 +6283,7 @@ } else { // Look further up the chain. Chains.push_back(Chain.getOperand(0)); - // Clean up old chain. - AddToWorkList(Chain.getNode()); + ++Depth; } break; } @@ -6285,8 +6299,7 @@ } for (unsigned n = Chain.getNumOperands(); n;) Chains.push_back(Chain.getOperand(--n)); - // Eliminate the token factor if we can. - AddToWorkList(Chain.getNode()); + ++Depth; break; default: @@ -6312,7 +6325,7 @@ // If a single operand then chain to it. We don't need to revisit it. return Aliases[0]; } - + // Construct a custom tailored token factor. return DAG.getNode(ISD::TokenFactor, N->getDebugLoc(), MVT::Other, &Aliases[0], Aliases.size()); From eocallaghan at auroraux.org Mon Oct 12 01:14:06 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Mon, 12 Oct 2009 06:14:06 -0000 Subject: [llvm-commits] [llvm] r83825 - in /llvm/trunk/test/Transforms/InstCombine: 2004-11-27-SetCCForCastLargerAndConstant.ll 2006-04-28-ShiftShiftLongLong.ll 2008-01-21-MismatchedCastAndCompare.ll 2008-01-21-MulTrunc.ll zext.ll Message-ID: <200910120614.n9C6E6Gn005360@zion.cs.uiuc.edu> Author: evocallaghan Date: Mon Oct 12 01:14:06 2009 New Revision: 83825 URL: http://llvm.org/viewvc/llvm-project?rev=83825&view=rev Log: Convert InstCombine tests from notcast to FileCheck. Modified: llvm/trunk/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll llvm/trunk/test/Transforms/InstCombine/2006-04-28-ShiftShiftLongLong.ll llvm/trunk/test/Transforms/InstCombine/2008-01-21-MismatchedCastAndCompare.ll llvm/trunk/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll llvm/trunk/test/Transforms/InstCombine/zext.ll Modified: llvm/trunk/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll?rev=83825&r1=83824&r2=83825&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll Mon Oct 12 01:14:06 2009 @@ -9,124 +9,152 @@ ; be eliminated. In many cases the setCC is also eliminated based on the ; constant value and the range of the casted value. ; -; RUN: opt < %s -instcombine -S | \ -; RUN: notcast .*int +; RUN: opt < %s -instcombine -S | FileCheck %s ; END. define i1 @lt_signed_to_large_unsigned(i8 %SB) { %Y = sext i8 %SB to i32 ; [#uses=1] %C = icmp ult i32 %Y, 1024 ; [#uses=1] ret i1 %C +; CHECK: %C1 = icmp sgt i8 %SB, -1 +; CHECK: ret i1 %C1 } define i1 @lt_signed_to_large_signed(i8 %SB) { %Y = sext i8 %SB to i32 ; [#uses=1] %C = icmp slt i32 %Y, 1024 ; [#uses=1] ret i1 %C +; CHECK: ret i1 true } define i1 @lt_signed_to_large_negative(i8 %SB) { %Y = sext i8 %SB to i32 ; [#uses=1] %C = icmp slt i32 %Y, -1024 ; [#uses=1] ret i1 %C +; CHECK: ret i1 false } define i1 @lt_signed_to_small_signed(i8 %SB) { %Y = sext i8 %SB to i32 ; [#uses=1] %C = icmp slt i32 %Y, 17 ; [#uses=1] ret i1 %C +; CHECK: %C = icmp slt i8 %SB, 17 +; CHECK: ret i1 %C } define i1 @lt_signed_to_small_negative(i8 %SB) { %Y = sext i8 %SB to i32 ; [#uses=1] %C = icmp slt i32 %Y, -17 ; [#uses=1] ret i1 %C +; CHECK: %C = icmp slt i8 %SB, -17 +; CHECK: ret i1 %C } define i1 @lt_unsigned_to_large_unsigned(i8 %SB) { %Y = zext i8 %SB to i32 ; [#uses=1] %C = icmp ult i32 %Y, 1024 ; [#uses=1] ret i1 %C +; CHECK: ret i1 true } define i1 @lt_unsigned_to_large_signed(i8 %SB) { %Y = zext i8 %SB to i32 ; [#uses=1] %C = icmp slt i32 %Y, 1024 ; [#uses=1] ret i1 %C +; CHECK: ret i1 true } define i1 @lt_unsigned_to_large_negative(i8 %SB) { %Y = zext i8 %SB to i32 ; [#uses=1] %C = icmp slt i32 %Y, -1024 ; [#uses=1] ret i1 %C +; CHECK: ret i1 false } define i1 @lt_unsigned_to_small_unsigned(i8 %SB) { %Y = zext i8 %SB to i32 ; [#uses=1] %C = icmp ult i32 %Y, 17 ; [#uses=1] ret i1 %C +; CHECK: %C = icmp ult i8 %SB, 17 +; CHECK: ret i1 %C } define i1 @lt_unsigned_to_small_negative(i8 %SB) { %Y = zext i8 %SB to i32 ; [#uses=1] %C = icmp slt i32 %Y, -17 ; [#uses=1] ret i1 %C +; CHECK: ret i1 false } define i1 @gt_signed_to_large_unsigned(i8 %SB) { %Y = sext i8 %SB to i32 ; [#uses=1] %C = icmp ugt i32 %Y, 1024 ; [#uses=1] ret i1 %C +; CHECK: %C = icmp slt i8 %SB, 0 +; CHECK: ret i1 %C } define i1 @gt_signed_to_large_signed(i8 %SB) { %Y = sext i8 %SB to i32 ; [#uses=1] %C = icmp sgt i32 %Y, 1024 ; [#uses=1] ret i1 %C +; CHECK: ret i1 false } define i1 @gt_signed_to_large_negative(i8 %SB) { %Y = sext i8 %SB to i32 ; [#uses=1] %C = icmp sgt i32 %Y, -1024 ; [#uses=1] ret i1 %C +; CHECK: ret i1 true } + define i1 @gt_signed_to_small_signed(i8 %SB) { %Y = sext i8 %SB to i32 ; [#uses=1] %C = icmp sgt i32 %Y, 17 ; [#uses=1] ret i1 %C +; CHECK: %C = icmp sgt i8 %SB, 17 +; CHECK: ret i1 %C } define i1 @gt_signed_to_small_negative(i8 %SB) { %Y = sext i8 %SB to i32 ; [#uses=1] %C = icmp sgt i32 %Y, -17 ; [#uses=1] ret i1 %C +; CHECK: %C = icmp sgt i8 %SB, -17 +; CHECK: ret i1 %C } define i1 @gt_unsigned_to_large_unsigned(i8 %SB) { %Y = zext i8 %SB to i32 ; [#uses=1] %C = icmp ugt i32 %Y, 1024 ; [#uses=1] ret i1 %C +; CHECK: ret i1 false } define i1 @gt_unsigned_to_large_signed(i8 %SB) { %Y = zext i8 %SB to i32 ; [#uses=1] %C = icmp sgt i32 %Y, 1024 ; [#uses=1] ret i1 %C +; CHECK: ret i1 false } define i1 @gt_unsigned_to_large_negative(i8 %SB) { %Y = zext i8 %SB to i32 ; [#uses=1] %C = icmp sgt i32 %Y, -1024 ; [#uses=1] ret i1 %C +; CHECK: ret i1 true } define i1 @gt_unsigned_to_small_unsigned(i8 %SB) { %Y = zext i8 %SB to i32 ; [#uses=1] %C = icmp ugt i32 %Y, 17 ; [#uses=1] ret i1 %C +; CHECK: %C = icmp ugt i8 %SB, 17 +; CHECK: ret i1 %C } define i1 @gt_unsigned_to_small_negative(i8 %SB) { %Y = zext i8 %SB to i32 ; [#uses=1] %C = icmp sgt i32 %Y, -17 ; [#uses=1] ret i1 %C +; CHECK: ret i1 true } Modified: llvm/trunk/test/Transforms/InstCombine/2006-04-28-ShiftShiftLongLong.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2006-04-28-ShiftShiftLongLong.ll?rev=83825&r1=83824&r2=83825&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2006-04-28-ShiftShiftLongLong.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2006-04-28-ShiftShiftLongLong.ll Mon Oct 12 01:14:06 2009 @@ -1,11 +1,13 @@ -; RUN: opt < %s -instcombine -S | grep shl -; RUN: opt < %s -instcombine -S | notcast +; RUN: opt < %s -instcombine -S | FileCheck %s ; This cannot be turned into a sign extending cast! define i64 @test(i64 %X) { %Y = shl i64 %X, 16 ; [#uses=1] +; CHECK: %Y = shl i64 %X, 16 %Z = ashr i64 %Y, 16 ; [#uses=1] +; CHECK: %Z = ashr i64 %Y, 16 ret i64 %Z +; CHECK: ret i64 %Z } Modified: llvm/trunk/test/Transforms/InstCombine/2008-01-21-MismatchedCastAndCompare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-01-21-MismatchedCastAndCompare.ll?rev=83825&r1=83824&r2=83825&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2008-01-21-MismatchedCastAndCompare.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2008-01-21-MismatchedCastAndCompare.ll Mon Oct 12 01:14:06 2009 @@ -1,5 +1,4 @@ -; RUN: opt < %s -instcombine -S | notcast -; RUN: opt < %s -instcombine -S | not grep {icmp s} +; RUN: opt < %s -instcombine -S | FileCheck %s ; PR1940 define i1 @test1(i8 %A, i8 %B) { @@ -7,6 +6,8 @@ %b = zext i8 %B to i32 %c = icmp sgt i32 %a, %b ret i1 %c +; CHECK: %c = icmp ugt i8 %A, %B +; CHECK: ret i1 %c } define i1 @test2(i8 %A, i8 %B) { @@ -14,4 +15,6 @@ %b = sext i8 %B to i32 %c = icmp ugt i32 %a, %b ret i1 %c +; CHECK: %c = icmp ugt i8 %A, %B +; CHECK: ret i1 %c } Modified: llvm/trunk/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll?rev=83825&r1=83824&r2=83825&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2008-01-21-MulTrunc.ll Mon Oct 12 01:14:06 2009 @@ -1,11 +1,15 @@ -; RUN: opt < %s -instcombine -S | notcast +; RUN: opt < %s -instcombine -S | FileCheck %s define i16 @test1(i16 %a) { %tmp = zext i16 %a to i32 ; [#uses=2] %tmp21 = lshr i32 %tmp, 8 ; [#uses=1] +; CHECK: %tmp21 = lshr i16 %a, 8 %tmp5 = mul i32 %tmp, 5 ; [#uses=1] +; CHECK: %tmp5 = mul i16 %a, 5 %tmp.upgrd.32 = or i32 %tmp21, %tmp5 ; [#uses=1] +; CHECK: %tmp.upgrd.32 = or i16 %tmp21, %tmp5 %tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16 ; [#uses=1] ret i16 %tmp.upgrd.3 +; CHECK: ret i16 %tmp.upgrd.32 } Modified: llvm/trunk/test/Transforms/InstCombine/zext.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/zext.ll?rev=83825&r1=83824&r2=83825&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/zext.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/zext.ll Mon Oct 12 01:14:06 2009 @@ -1,11 +1,13 @@ ; Tests to make sure elimination of casts is working correctly -; RUN: opt < %s -instcombine -S | \ -; RUN: notcast {} {%c1.*} +; RUN: opt < %s -instcombine -S | FileCheck %s define i64 @test_sext_zext(i16 %A) { %c1 = zext i16 %A to i32 ; [#uses=1] %c2 = sext i32 %c1 to i64 ; [#uses=1] ret i64 %c2 +CHECK-NOT: %c1 +CHECK: %c2 = zext i16 %A to i64 +CHECK: ret i64 %c2 } ; PR3599 @@ -29,5 +31,6 @@ %tmp16 = or i32 %tmp15, %tmp6 ; [#uses=1] %tmp17 = or i32 %tmp16, %tmp3 ; [#uses=1] ret i32 %tmp17 +CHECK: ret i1 true } From eocallaghan at auroraux.org Mon Oct 12 01:23:57 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Mon, 12 Oct 2009 06:23:57 -0000 Subject: [llvm-commits] [llvm] r83826 - in /llvm/trunk/test/Transforms/InstCombine: 2003-11-13-ConstExprCastCall.ll zext.ll Message-ID: <200910120623.n9C6Nv6c005800@zion.cs.uiuc.edu> Author: evocallaghan Date: Mon Oct 12 01:23:56 2009 New Revision: 83826 URL: http://llvm.org/viewvc/llvm-project?rev=83826&view=rev Log: Fix syntax error missed in converting zext.ll test. Convert 2003-11-13-ConstExprCastCall.ll to FileCheck from notcast. Modified: llvm/trunk/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll llvm/trunk/test/Transforms/InstCombine/zext.ll Modified: llvm/trunk/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll?rev=83826&r1=83825&r2=83826&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2003-11-13-ConstExprCastCall.ll Mon Oct 12 01:23:56 2009 @@ -1,8 +1,11 @@ -; RUN: opt < %s -instcombine -S | grep call | notcast +; RUN: opt < %s -instcombine -S | FileCheck %s declare void @free(i8*) define void @test(i32* %X) { call void (...)* bitcast (void (i8*)* @free to void (...)*)( i32* %X ) ; :1 [#uses=0] +; CHECK: %tmp = bitcast i32* %X to i8* +; CHECK: call void @free(i8* %tmp) ret void +; CHECK: ret void } Modified: llvm/trunk/test/Transforms/InstCombine/zext.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/zext.ll?rev=83826&r1=83825&r2=83826&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/zext.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/zext.ll Mon Oct 12 01:23:56 2009 @@ -5,9 +5,9 @@ %c1 = zext i16 %A to i32 ; [#uses=1] %c2 = sext i32 %c1 to i64 ; [#uses=1] ret i64 %c2 -CHECK-NOT: %c1 -CHECK: %c2 = zext i16 %A to i64 -CHECK: ret i64 %c2 +; CHECK-NOT: %c1 +; CHECK: %c2 = zext i16 %A to i64 +; CHECK: ret i64 %c2 } ; PR3599 @@ -31,6 +31,6 @@ %tmp16 = or i32 %tmp15, %tmp6 ; [#uses=1] %tmp17 = or i32 %tmp16, %tmp3 ; [#uses=1] ret i32 %tmp17 -CHECK: ret i1 true +; CHECK: ret i1 true } From nicholas at mxc.ca Mon Oct 12 01:32:42 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 12 Oct 2009 06:32:42 -0000 Subject: [llvm-commits] [llvm] r83827 - /llvm/trunk/test/Transforms/InstCombine/zext.ll Message-ID: <200910120632.n9C6Wh5l006101@zion.cs.uiuc.edu> Author: nicholas Date: Mon Oct 12 01:32:42 2009 New Revision: 83827 URL: http://llvm.org/viewvc/llvm-project?rev=83827&view=rev Log: Remove this part of the test, it never actually tested anything anyways. This unbreaks make check after evocallaghan's changes. Modified: llvm/trunk/test/Transforms/InstCombine/zext.ll Modified: llvm/trunk/test/Transforms/InstCombine/zext.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/zext.ll?rev=83827&r1=83826&r2=83827&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/zext.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/zext.ll Mon Oct 12 01:32:42 2009 @@ -9,28 +9,3 @@ ; CHECK: %c2 = zext i16 %A to i64 ; CHECK: ret i64 %c2 } - -; PR3599 -define i32 @test2(i64 %tmp) nounwind readnone { -entry: - %tmp5 = trunc i64 %tmp to i8 ; [#uses=1] - %tmp7 = lshr i64 %tmp, 8 ; [#uses=1] - %tmp8 = trunc i64 %tmp7 to i8 ; [#uses=1] - %tmp10 = lshr i64 %tmp, 16 ; [#uses=1] - %tmp11 = trunc i64 %tmp10 to i8 ; [#uses=1] - %tmp13 = lshr i64 %tmp, 24 ; [#uses=1] - %tmp14 = trunc i64 %tmp13 to i8 ; [#uses=1] - %tmp1 = zext i8 %tmp5 to i32 ; [#uses=1] - %tmp2 = zext i8 %tmp8 to i32 ; [#uses=1] - %tmp3 = shl i32 %tmp2, 8 ; [#uses=1] - %tmp4 = zext i8 %tmp11 to i32 ; [#uses=1] - %tmp6 = shl i32 %tmp4, 16 ; [#uses=1] - %tmp9 = zext i8 %tmp14 to i32 ; [#uses=1] - %tmp12 = shl i32 %tmp9, 24 ; [#uses=1] - %tmp15 = or i32 %tmp12, %tmp1 ; [#uses=1] - %tmp16 = or i32 %tmp15, %tmp6 ; [#uses=1] - %tmp17 = or i32 %tmp16, %tmp3 ; [#uses=1] - ret i32 %tmp17 -; CHECK: ret i1 true -} - From eocallaghan at auroraux.org Mon Oct 12 02:18:15 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Mon, 12 Oct 2009 07:18:15 -0000 Subject: [llvm-commits] [llvm] r83828 - in /llvm/trunk/test/Transforms/InstCombine: IntPtrCast.ll apint-cast.ll apint-zext1.ll apint-zext2.ll binop-cast.ll cast-mul-select.ll cast-set.ll cast.ll cast2.ll fpcast.ll Message-ID: <200910120718.n9C7IFjQ007882@zion.cs.uiuc.edu> Author: evocallaghan Date: Mon Oct 12 02:18:14 2009 New Revision: 83828 URL: http://llvm.org/viewvc/llvm-project?rev=83828&view=rev Log: Convert the rest of the InstCombine tests from notcast to FileCheck. Modified: llvm/trunk/test/Transforms/InstCombine/IntPtrCast.ll llvm/trunk/test/Transforms/InstCombine/apint-cast.ll llvm/trunk/test/Transforms/InstCombine/apint-zext1.ll llvm/trunk/test/Transforms/InstCombine/apint-zext2.ll llvm/trunk/test/Transforms/InstCombine/binop-cast.ll llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll llvm/trunk/test/Transforms/InstCombine/cast-set.ll llvm/trunk/test/Transforms/InstCombine/cast.ll llvm/trunk/test/Transforms/InstCombine/cast2.ll llvm/trunk/test/Transforms/InstCombine/fpcast.ll Modified: llvm/trunk/test/Transforms/InstCombine/IntPtrCast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/IntPtrCast.ll?rev=83828&r1=83827&r2=83828&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/IntPtrCast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/IntPtrCast.ll Mon Oct 12 02:18:14 2009 @@ -1,9 +1,10 @@ -; RUN: opt < %s -instcombine -S | notcast +; RUN: opt < %s -instcombine -S | FileCheck %s target datalayout = "e-p:32:32" define i32* @test(i32* %P) { %V = ptrtoint i32* %P to i32 ; [#uses=1] %P2 = inttoptr i32 %V to i32* ; [#uses=1] ret i32* %P2 +; CHECK: ret i32* %P } Modified: llvm/trunk/test/Transforms/InstCombine/apint-cast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/apint-cast.ll?rev=83828&r1=83827&r2=83828&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/apint-cast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/apint-cast.ll Mon Oct 12 02:18:14 2009 @@ -1,20 +1,28 @@ ; Tests to make sure elimination of casts is working correctly -; RUN: opt < %s -instcombine -S | notcast +; RUN: opt < %s -instcombine -S | FileCheck %s define i17 @test1(i17 %a) { %tmp = zext i17 %a to i37 ; [#uses=2] %tmp21 = lshr i37 %tmp, 8 ; [#uses=1] +; CHECK: %tmp21 = lshr i17 %a, 8 %tmp5 = shl i37 %tmp, 8 ; [#uses=1] +; CHECK: %tmp5 = shl i17 %a, 8 %tmp.upgrd.32 = or i37 %tmp21, %tmp5 ; [#uses=1] +; CHECK: %tmp.upgrd.32 = or i17 %tmp21, %tmp5 %tmp.upgrd.3 = trunc i37 %tmp.upgrd.32 to i17 ; [#uses=1] ret i17 %tmp.upgrd.3 +; CHECK: ret i17 %tmp.upgrd.32 } define i167 @test2(i167 %a) { %tmp = zext i167 %a to i577 ; [#uses=2] %tmp21 = lshr i577 %tmp, 9 ; [#uses=1] +; CHECK: %tmp21 = lshr i167 %a, 9 %tmp5 = shl i577 %tmp, 8 ; [#uses=1] +; CHECK: %tmp5 = shl i167 %a, 8 %tmp.upgrd.32 = or i577 %tmp21, %tmp5 ; [#uses=1] +; CHECK: %tmp.upgrd.32 = or i167 %tmp21, %tmp5 %tmp.upgrd.3 = trunc i577 %tmp.upgrd.32 to i167 ; [#uses=1] ret i167 %tmp.upgrd.3 +; CHECK: ret i167 %tmp.upgrd.32 } Modified: llvm/trunk/test/Transforms/InstCombine/apint-zext1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/apint-zext1.ll?rev=83828&r1=83827&r2=83828&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/apint-zext1.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/apint-zext1.ll Mon Oct 12 02:18:14 2009 @@ -1,9 +1,11 @@ ; Tests to make sure elimination of casts is working correctly ; This test is for Integer BitWidth <= 64 && BitWidth % 2 != 0. -; RUN: opt < %s -instcombine -S | notcast {} {%c1.*} +; RUN: opt < %s -instcombine -S | FileCheck %s define i47 @test_sext_zext(i11 %A) { %c1 = zext i11 %A to i39 %c2 = sext i39 %c1 to i47 ret i47 %c2 +; CHECK: %c2 = zext i11 %A to i47 +; CHECK: ret i47 %c2 } Modified: llvm/trunk/test/Transforms/InstCombine/apint-zext2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/apint-zext2.ll?rev=83828&r1=83827&r2=83828&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/apint-zext2.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/apint-zext2.ll Mon Oct 12 02:18:14 2009 @@ -1,9 +1,11 @@ ; Tests to make sure elimination of casts is working correctly ; This test is for Integer BitWidth > 64 && BitWidth <= 1024. -; RUN: opt < %s -instcombine -S | notcast {} {%c1.*} +; RUN: opt < %s -instcombine -S | FileCheck %s define i1024 @test_sext_zext(i77 %A) { %c1 = zext i77 %A to i533 %c2 = sext i533 %c1 to i1024 ret i1024 %c2 +; CHECK: %c2 = zext i77 %A to i1024 +; CHECK: ret i1024 %c2 } Modified: llvm/trunk/test/Transforms/InstCombine/binop-cast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/binop-cast.ll?rev=83828&r1=83827&r2=83828&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/binop-cast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/binop-cast.ll Mon Oct 12 02:18:14 2009 @@ -1,7 +1,9 @@ -; RUN: opt < %s -instcombine -S | notcast +; RUN: opt < %s -instcombine -S | FileCheck %s define i32 @testAdd(i32 %X, i32 %Y) { %tmp = add i32 %X, %Y +; CHECK: %tmp = add i32 %X, %Y %tmp.l = bitcast i32 %tmp to i32 ret i32 %tmp.l +; CHECK: ret i32 %tmp } Modified: llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll?rev=83828&r1=83827&r2=83828&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast-mul-select.ll Mon Oct 12 02:18:14 2009 @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | notcast +; RUN: opt < %s -instcombine -S | FileCheck %s define i32 @mul(i32 %x, i32 %y) { %A = trunc i32 %x to i8 @@ -6,6 +6,9 @@ %C = mul i8 %A, %B %D = zext i8 %C to i32 ret i32 %D +; CHECK: %C = mul i32 %x, %y +; CHECK: %D = and i32 %C, 255 +; CHECK: ret i32 %D } define i32 @select1(i1 %cond, i32 %x, i32 %y, i32 %z) { @@ -16,6 +19,10 @@ %E = select i1 %cond, i8 %C, i8 %D %F = zext i8 %E to i32 ret i32 %F +; CHECK: %D = add i32 %x, %y +; CHECK: %E = select i1 %cond, i32 %z, i32 %D +; CHECK: %F = and i32 %E, 255 +; CHECK: ret i32 %F } define i8 @select2(i1 %cond, i8 %x, i8 %y, i8 %z) { @@ -26,4 +33,7 @@ %E = select i1 %cond, i32 %C, i32 %D %F = trunc i32 %E to i8 ret i8 %F +; CHECK: %D = add i8 %x, %y +; CHECK: %E = select i1 %cond, i8 %z, i8 %D +; CHECK: ret i8 %E } Modified: llvm/trunk/test/Transforms/InstCombine/cast-set.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast-set.ll?rev=83828&r1=83827&r2=83828&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast-set.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast-set.ll Mon Oct 12 02:18:14 2009 @@ -1,13 +1,15 @@ ; This tests for various complex cast elimination cases instcombine should ; handle. -; RUN: opt < %s -instcombine -S | notcast +; RUN: opt < %s -instcombine -S | FileCheck %s define i1 @test1(i32 %X) { %A = bitcast i32 %X to i32 ; [#uses=1] ; Convert to setne int %X, 12 %c = icmp ne i32 %A, 12 ; [#uses=1] ret i1 %c +; CHECK: %c = icmp ne i32 %X, 12 +; CHECK: ret i1 %c } define i1 @test2(i32 %X, i32 %Y) { @@ -16,6 +18,8 @@ ; Convert to setne int %X, %Y %c = icmp ne i32 %A, %B ; [#uses=1] ret i1 %c +; CHECK: %c = icmp ne i32 %X, %Y +; CHECK: ret i1 %c } define i32 @test4(i32 %A) { @@ -23,6 +27,8 @@ %C = shl i32 %B, 2 ; [#uses=1] %D = bitcast i32 %C to i32 ; [#uses=1] ret i32 %D +; CHECK: %C = shl i32 %A, 2 +; CHECK: ret i32 %C } define i16 @test5(i16 %A) { @@ -30,22 +36,28 @@ %C = and i32 %B, 15 ; [#uses=1] %D = trunc i32 %C to i16 ; [#uses=1] ret i16 %D +; CHECK: %C = and i16 %A, 15 +; CHECK: ret i16 %C } define i1 @test6(i1 %A) { %B = zext i1 %A to i32 ; [#uses=1] %C = icmp ne i32 %B, 0 ; [#uses=1] ret i1 %C +; CHECK: ret i1 %A } define i1 @test6a(i1 %A) { %B = zext i1 %A to i32 ; [#uses=1] %C = icmp ne i32 %B, -1 ; [#uses=1] ret i1 %C +; CHECK: ret i1 true } define i1 @test7(i8* %A) { %B = bitcast i8* %A to i32* ; [#uses=1] %C = icmp eq i32* %B, null ; [#uses=1] ret i1 %C +; CHECK: %C = icmp eq i8* %A, null +; CHECK: ret i1 %C } Modified: llvm/trunk/test/Transforms/InstCombine/cast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast.ll?rev=83828&r1=83827&r2=83828&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast.ll Mon Oct 12 02:18:14 2009 @@ -1,5 +1,5 @@ ; Tests to make sure elimination of casts is working correctly -; RUN: opt < %s -instcombine -S | grep %c | notcast +; RUN: opt < %s -instcombine -S | FileCheck %s @inbuf = external global [32832 x i8] ; <[32832 x i8]*> [#uses=1] @@ -7,6 +7,7 @@ %c1 = bitcast i32 %A to i32 ; [#uses=1] %c2 = bitcast i32 %c1 to i32 ; [#uses=1] ret i32 %c2 +; CHECK: ret i32 %A } define i64 @test2(i8 %A) { @@ -14,6 +15,8 @@ %c2 = zext i16 %c1 to i32 ; [#uses=1] %Ret = zext i32 %c2 to i64 ; [#uses=1] ret i64 %Ret +; CHECK: %Ret = zext i8 %A to i64 +; CHECK: ret i64 %Ret } ; This function should just use bitwise AND @@ -21,6 +24,8 @@ %c1 = trunc i64 %A to i8 ; [#uses=1] %c2 = zext i8 %c1 to i64 ; [#uses=1] ret i64 %c2 +; CHECK: %c2 = and i64 %A, 255 +; CHECK: ret i64 %c2 } define i32 @test4(i32 %A, i32 %B) { @@ -30,6 +35,9 @@ ; for the cast elim purpose %result = zext i8 %c to i32 ; [#uses=1] ret i32 %result +; CHECK: %COND = icmp slt i32 %A, %B +; CHECK: %result = zext i1 %COND to i32 +; CHECK: ret i32 %result } define i32 @test5(i1 %B) { @@ -38,36 +46,46 @@ ; this cast %result = zext i8 %c to i32 ; [#uses=1] ret i32 %result +; CHECK: %result = zext i1 %B to i32 +; CHECK: ret i32 %result } define i32 @test6(i64 %A) { %c1 = trunc i64 %A to i32 ; [#uses=1] %res = bitcast i32 %c1 to i32 ; [#uses=1] ret i32 %res +; CHECK: %res = trunc i64 %A to i32 +; CHECK: ret i32 %res } define i64 @test7(i1 %A) { %c1 = zext i1 %A to i32 ; [#uses=1] %res = sext i32 %c1 to i64 ; [#uses=1] ret i64 %res +; CHECK: %res = zext i1 %A to i64 +; CHECK: ret i64 %res } define i64 @test8(i8 %A) { %c1 = sext i8 %A to i64 ; [#uses=1] %res = bitcast i64 %c1 to i64 ; [#uses=1] ret i64 %res +; CHECK: %res = sext i8 %A to i64 +; CHECK: ret i64 %res } define i16 @test9(i16 %A) { %c1 = sext i16 %A to i32 ; [#uses=1] %c2 = trunc i32 %c1 to i16 ; [#uses=1] ret i16 %c2 +; CHECK: ret i16 %A } define i16 @test10(i16 %A) { %c1 = sext i16 %A to i32 ; [#uses=1] %c2 = trunc i32 %c1 to i16 ; [#uses=1] ret i16 %c2 +; CHECK: ret i16 %A } declare void @varargs(i32, ...) @@ -76,22 +94,31 @@ %c = bitcast i32* %P to i16* ; [#uses=1] call void (i32, ...)* @varargs( i32 5, i16* %c ) ret void +; CHECK: call void (i32, ...)* @varargs(i32 5, i32* %P) +; CHECK: ret void } define i32* @test12() { %p = malloc [4 x i8] ; <[4 x i8]*> [#uses=1] %c = bitcast [4 x i8]* %p to i32* ; [#uses=1] ret i32* %c +; CHECK: %p = malloc i32 +; CHECK: ret i32* %p } + define i8* @test13(i64 %A) { %c = getelementptr [0 x i8]* bitcast ([32832 x i8]* @inbuf to [0 x i8]*), i64 0, i64 %A ; [#uses=1] ret i8* %c +; CHECK: %c = getelementptr [32832 x i8]* @inbuf, i64 0, i64 %A +; CHECK: ret i8* %c } define i1 @test14(i8 %A) { %c = bitcast i8 %A to i8 ; [#uses=1] %X = icmp ult i8 %c, -128 ; [#uses=1] ret i1 %X +; CHECK: %X = icmp sgt i8 %A, -1 +; CHECK: ret i1 %X } @@ -105,24 +132,32 @@ define i1 @test16(i32* %P) { %c = icmp ne i32* %P, null ; [#uses=1] ret i1 %c +; CHECK: %c = icmp ne i32* %P, null +; CHECK: ret i1 %c } define i16 @test17(i1 %tmp3) { %c = zext i1 %tmp3 to i32 ; [#uses=1] %t86 = trunc i32 %c to i16 ; [#uses=1] ret i16 %t86 +; CHECK: %t86 = zext i1 %tmp3 to i16 +; CHECK: ret i16 %t86 } define i16 @test18(i8 %tmp3) { %c = sext i8 %tmp3 to i32 ; [#uses=1] %t86 = trunc i32 %c to i16 ; [#uses=1] ret i16 %t86 +; CHECK: %t86 = sext i8 %tmp3 to i16 +; CHECK: ret i16 %t86 } define i1 @test19(i32 %X) { %c = sext i32 %X to i64 ; [#uses=1] %Z = icmp slt i64 %c, 12345 ; [#uses=1] ret i1 %Z +; CHECK: %Z = icmp slt i32 %X, 12345 +; CHECK: ret i1 %Z } define i1 @test20(i1 %B) { @@ -130,6 +165,7 @@ %D = icmp slt i32 %c, -1 ; [#uses=1] ;; false ret i1 %D +; CHECK: ret i1 false } define i32 @test21(i32 %X) { @@ -138,6 +174,8 @@ %c2 = sext i8 %c1 to i32 ; [#uses=1] %RV = and i32 %c2, 255 ; [#uses=1] ret i32 %RV +; CHECK: %c21 = and i32 %X, 255 +; CHECK: ret i32 %c21 } define i32 @test22(i32 %X) { @@ -146,6 +184,8 @@ %c2 = sext i8 %c1 to i32 ; [#uses=1] %RV = shl i32 %c2, 24 ; [#uses=1] ret i32 %RV +; CHECK: %RV = shl i32 %X, 24 +; CHECK: ret i32 %RV } define i32 @test23(i32 %X) { @@ -154,6 +194,8 @@ ;; and Z are signed. %c2 = zext i16 %c1 to i32 ; [#uses=1] ret i32 %c2 +; CHECK: %c2 = and i32 %X, 65535 +; CHECK: ret i32 %c2 } define i1 @test24(i1 %C) { @@ -161,6 +203,7 @@ ;; Fold cast into select %c = icmp ne i32 %X, 0 ; [#uses=1] ret i1 %c +; CHECK: ret i1 true } define void @test25(i32** %P) { @@ -168,6 +211,8 @@ ;; Fold cast into null store float* null, float** %c ret void +; CHECK: store i32* null, i32** %P +; CHECK: ret void } define i32 @test26(float %F) { @@ -175,16 +220,22 @@ %c = fpext float %F to double ; [#uses=1] %D = fptosi double %c to i32 ; [#uses=1] ret i32 %D +; CHECK: %D = fptosi float %F to i32 +; CHECK: ret i32 %D } define [4 x float]* @test27([9 x [4 x float]]* %A) { %c = bitcast [9 x [4 x float]]* %A to [4 x float]* ; <[4 x float]*> [#uses=1] ret [4 x float]* %c +; CHECK: %c = getelementptr inbounds [9 x [4 x float]]* %A, i64 0, i64 0 +; CHECK: ret [4 x float]* %c } define float* @test28([4 x float]* %A) { %c = bitcast [4 x float]* %A to float* ; [#uses=1] ret float* %c +; CHECK: %c = getelementptr inbounds [4 x float]* %A, i64 0, i64 0 +; CHECK: ret float* %c } define i32 @test29(i32 %c1, i32 %c2) { @@ -193,6 +244,9 @@ %tmp = or i8 %tmp4.mask, %tmp1 ; [#uses=1] %tmp10 = zext i8 %tmp to i32 ; [#uses=1] ret i32 %tmp10 +; CHECK: %tmp2 = or i32 %c2, %c1 +; CHECK: %tmp10 = and i32 %tmp2, 255 +; CHECK: ret i32 %tmp10 } define i32 @test30(i32 %c1) { @@ -200,6 +254,9 @@ %c3 = xor i8 %c2, 1 ; [#uses=1] %c4 = zext i8 %c3 to i32 ; [#uses=1] ret i32 %c4 +; CHECK: %c3 = and i32 %c1, 255 +; CHECK: %c4 = xor i32 %c3, 1 +; CHECK: ret i32 %c4 } define i1 @test31(i64 %A) { @@ -207,6 +264,9 @@ %C = and i32 %B, 42 ; [#uses=1] %D = icmp eq i32 %C, 10 ; [#uses=1] ret i1 %D +; CHECK: %C1 = and i64 %A, 42 +; CHECK: %D = icmp eq i64 %C1, 10 +; CHECK: ret i1 %D } define void @test32(double** %tmp) { @@ -214,12 +274,17 @@ %tmp8.upgrd.1 = bitcast [16 x i8]* %tmp8 to double* ; [#uses=1] store double* %tmp8.upgrd.1, double** %tmp ret void +; CHECK: %tmp81 = malloc [2 x double] +; CHECK: %tmp81.sub = getelementptr inbounds [2 x double]* %tmp81, i64 0, i64 0 +; CHECK: store double* %tmp81.sub, double** %tmp +; CHECK: ret void } define i32 @test33(i32 %c1) { %x = bitcast i32 %c1 to float ; [#uses=1] %y = bitcast float %x to i32 ; [#uses=1] ret i32 %y +; CHECK: ret i32 %c1 } define i16 @test34(i16 %a) { @@ -227,6 +292,8 @@ %tmp21 = lshr i32 %c1, 8 ; [#uses=1] %c2 = trunc i32 %tmp21 to i16 ; [#uses=1] ret i16 %c2 +; CHECK: %tmp21 = lshr i16 %a, 8 +; CHECK: ret i16 %tmp21 } define i16 @test35(i16 %a) { @@ -234,6 +301,8 @@ %tmp2 = lshr i16 %c1, 8 ; [#uses=1] %c2 = bitcast i16 %tmp2 to i16 ; [#uses=1] ret i16 %c2 +; CHECK: %tmp2 = lshr i16 %a, 8 +; CHECK: ret i16 %tmp2 } ; icmp sgt i32 %a, -1 @@ -243,6 +312,8 @@ %c = trunc i32 %b to i8 %d = icmp eq i8 %c, 0 ret i1 %d +; CHECK: %d = icmp sgt i32 %a, -1 +; CHECK: ret i1 %d } ; ret i1 false @@ -252,6 +323,7 @@ %d = trunc i32 %c to i8 %e = icmp eq i8 %d, 11 ret i1 %e +; CHECK: ret i1 false } define i64 @test38(i32 %a) { @@ -260,4 +332,7 @@ %3 = xor i8 %2, 1 %4 = zext i8 %3 to i64 ret i64 %4 +; CHECK: %1 = icmp ne i32 %a, -2 +; CHECK: %2 = zext i1 %1 to i64 +; CHECK: ret i64 %2 } Modified: llvm/trunk/test/Transforms/InstCombine/cast2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast2.ll?rev=83828&r1=83827&r2=83828&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast2.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast2.ll Mon Oct 12 02:18:14 2009 @@ -1,5 +1,5 @@ ; Tests to make sure elimination of casts is working correctly -; RUN: opt < %s -instcombine -S | notcast +; RUN: opt < %s -instcombine -S | FileCheck %s define i16 @test1(i16 %a) { %tmp = zext i16 %a to i32 ; [#uses=2] @@ -8,6 +8,8 @@ %tmp.upgrd.32 = or i32 %tmp21, %tmp5 ; [#uses=1] %tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16 ; [#uses=1] ret i16 %tmp.upgrd.3 +; CHECK: %tmp.upgrd.32 = call i16 @llvm.bswap.i16(i16 %a) +; CHECK: ret i16 %tmp.upgrd.32 } define i16 @test2(i16 %a) { @@ -17,6 +19,10 @@ %tmp.upgrd.32 = or i32 %tmp21, %tmp5 ; [#uses=1] %tmp.upgrd.3 = trunc i32 %tmp.upgrd.32 to i16 ; [#uses=1] ret i16 %tmp.upgrd.3 +; CHECK: %tmp21 = lshr i16 %a, 9 +; CHECK: %tmp5 = shl i16 %a, 8 +; CHECK: %tmp.upgrd.32 = or i16 %tmp21, %tmp5 +; CHECK: ret i16 %tmp.upgrd.32 } ; PR1263 @@ -24,6 +30,7 @@ %tmp64 = bitcast i32* %tmp1 to { i32 }* ; <{ i32 }*> [#uses=1] %tmp65 = getelementptr { i32 }* %tmp64, i32 0, i32 0 ; [#uses=1] ret i32* %tmp65 +; CHECK: ret i32* %tmp1 } Modified: llvm/trunk/test/Transforms/InstCombine/fpcast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fpcast.ll?rev=83828&r1=83827&r2=83828&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/fpcast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/fpcast.ll Mon Oct 12 02:18:14 2009 @@ -1,15 +1,15 @@ ; Test some floating point casting cases -; RUN: opt < %s -instcombine -S | notcast -; RUN: opt < %s -instcombine -S | \ -; RUN: egrep {ret i8 \(-1\)\|\(255\)} +; RUN: opt < %s -instcombine -S | FileCheck %s define i8 @test1() { %x = fptoui float 2.550000e+02 to i8 ; [#uses=1] ret i8 %x +; CHECK: ret i8 -1 } define i8 @test2() { %x = fptosi float -1.000000e+00 to i8 ; [#uses=1] ret i8 %x +; CHECK: ret i8 -1 } From anton at korobeynikov.info Mon Oct 12 03:08:02 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Mon, 12 Oct 2009 12:08:02 +0400 Subject: [llvm-commits] [llvm] r83823 - in /llvm/trunk: autoconf/configure.ac lib/System/Unix/Process.inc utils/unittest/googletest/include/gtest/internal/gtest-port.h In-Reply-To: <200910120457.n9C4vKCL002499@zion.cs.uiuc.edu> References: <200910120457.n9C4vKCL002499@zion.cs.uiuc.edu> Message-ID: > llvm/trunk/autoconf/configure.ac You need to regenerate configure. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From baldrick at free.fr Mon Oct 12 03:14:33 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 12 Oct 2009 08:14:33 -0000 Subject: [llvm-commits] [gcc-plugin] r83830 - /gcc-plugin/ Message-ID: <200910120814.n9C8EXQM023130@zion.cs.uiuc.edu> Author: baldrick Date: Mon Oct 12 03:14:33 2009 New Revision: 83830 URL: http://llvm.org/viewvc/llvm-project?rev=83830&view=rev Log: Rename gcc-plugin to dragonegg. Removed: gcc-plugin/ From baldrick at free.fr Mon Oct 12 03:19:49 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 12 Oct 2009 08:19:49 -0000 Subject: [llvm-commits] [gcc-plugin] r83831 - in /gcc-plugin: ./ trunk/ trunk/README Message-ID: <200910120819.n9C8JnN1023292@zion.cs.uiuc.edu> Author: baldrick Date: Mon Oct 12 03:19:49 2009 New Revision: 83831 URL: http://llvm.org/viewvc/llvm-project?rev=83831&view=rev Log: Add README explaining that the plugin moved to dragonegg/trunk. Added: gcc-plugin/ gcc-plugin/trunk/ gcc-plugin/trunk/README Added: gcc-plugin/trunk/README URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/README?rev=83831&view=auto ============================================================================== --- gcc-plugin/trunk/README (added) +++ gcc-plugin/trunk/README Mon Oct 12 03:19:49 2009 @@ -0,0 +1,2 @@ +The gcc plugin has been renamed DragonEgg. You can check it out by doing + svn co http://llvm.org/svn/llvm-project/dragonegg/trunk From eocallaghan at auroraux.org Mon Oct 12 03:46:47 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Mon, 12 Oct 2009 08:46:47 -0000 Subject: [llvm-commits] [llvm] r83833 - /llvm/trunk/test/Transforms/InstCombine/call.ll Message-ID: <200910120846.n9C8klCc024223@zion.cs.uiuc.edu> Author: evocallaghan Date: Mon Oct 12 03:46:47 2009 New Revision: 83833 URL: http://llvm.org/viewvc/llvm-project?rev=83833&view=rev Log: Convert InstCombine/call.ll to CheckFile. Modified: llvm/trunk/test/Transforms/InstCombine/call.ll Modified: llvm/trunk/test/Transforms/InstCombine/call.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/call.ll?rev=83833&r1=83832&r2=83833&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/call.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/call.ll Mon Oct 12 03:46:47 2009 @@ -1,7 +1,5 @@ ; Ignore stderr, we expect warnings there -; RUN: opt < %s -instcombine 2> /dev/null -S | \ -; RUN: grep call | notcast -; END. +; RUN: opt < %s -instcombine 2> /dev/null -S | CheckFile %s ; Simple case, argument translatable without changing the value @@ -10,17 +8,24 @@ define void @test1(i32* %A) { call void bitcast (void (i8*)* @test1a to void (i32*)*)( i32* %A ) ret void +; CHECK: %tmp = bitcast i32* %A to i8* +; CHECK: call void @test1a(i8* %tmp) +; CHECK: ret void } ; More complex case, translate argument because of resolution. This is safe ; because we have the body of the function define void @test2a(i8 %A) { ret void +; CHECK: ret void } define i32 @test2(i32 %A) { call void bitcast (void (i8)* @test2a to void (i32)*)( i32 %A ) ret i32 %A +; CHECK: %tmp = trunc i32 %A to i8 +; CHECK: call void @test2a(i8 %tmp) +; CHECK: ret i32 %A } @@ -32,17 +37,24 @@ call void bitcast (void (i8, ...)* @test3a to void (i8, i8)*)( i8 %A, i8 %B ) ret void +; CHECK: %tmp = zext i8 %B to i32 +; CHECK: call void (i8, ...)* @test3a(i8 %A, i32 %tmp) +; CHECK: ret void } ; test conversion of return value... define i8 @test4a() { ret i8 0 +; CHECK: ret i8 0 } define i32 @test4() { %X = call i32 bitcast (i8 ()* @test4a to i32 ()*)( ) ; [#uses=1] ret i32 %X +; CHECK: %X1 = call i8 @test4a() +%tmp = zext i8 %X1 to i32 +ret i32 %tmp } @@ -53,6 +65,8 @@ define i32 @test5() { %X = call i32 @test5a( ) ; [#uses=1] ret i32 %X +; CHECK: %X = call i32 @test5a() +; CHECK: ret i32 %X } @@ -62,17 +76,22 @@ define i32 @test6() { %X = call i32 bitcast (i32 (i32)* @test6a to i32 ()*)( ) ; [#uses=1] ret i32 %X +; CHECK: %X1 = call i32 @test6a(i32 0) +; CHECK: ret i32 %X1 } ; test removal of arguments, only can happen with a function body define void @test7a() { ret void +; CHECK: ret void } define void @test7() { call void bitcast (void ()* @test7a to void (i32)*)( i32 5 ) ret void +; CHECK: call void @test7a() +; CHECK: ret void } From eocallaghan at auroraux.org Mon Oct 12 03:51:28 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Mon, 12 Oct 2009 08:51:28 -0000 Subject: [llvm-commits] [llvm] r83834 - /llvm/trunk/test/Transforms/InstCombine/call.ll Message-ID: <200910120851.n9C8pTW4024386@zion.cs.uiuc.edu> Author: evocallaghan Date: Mon Oct 12 03:51:28 2009 New Revision: 83834 URL: http://llvm.org/viewvc/llvm-project?rev=83834&view=rev Log: FileCheck not CheckFile, oops. Modified: llvm/trunk/test/Transforms/InstCombine/call.ll Modified: llvm/trunk/test/Transforms/InstCombine/call.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/call.ll?rev=83834&r1=83833&r2=83834&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/call.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/call.ll Mon Oct 12 03:51:28 2009 @@ -1,5 +1,5 @@ ; Ignore stderr, we expect warnings there -; RUN: opt < %s -instcombine 2> /dev/null -S | CheckFile %s +; RUN: opt < %s -instcombine 2> /dev/null -S | FileCheck %s ; Simple case, argument translatable without changing the value From eocallaghan at auroraux.org Mon Oct 12 04:01:27 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Mon, 12 Oct 2009 09:01:27 -0000 Subject: [llvm-commits] [llvm] r83835 - /llvm/trunk/test/Transforms/InstCombine/call.ll Message-ID: <200910120901.n9C91RA3024770@zion.cs.uiuc.edu> Author: evocallaghan Date: Mon Oct 12 04:01:26 2009 New Revision: 83835 URL: http://llvm.org/viewvc/llvm-project?rev=83835&view=rev Log: Missing CHECK: lines makes test exit abnormally. Modified: llvm/trunk/test/Transforms/InstCombine/call.ll Modified: llvm/trunk/test/Transforms/InstCombine/call.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/call.ll?rev=83835&r1=83834&r2=83835&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/call.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/call.ll Mon Oct 12 04:01:26 2009 @@ -53,8 +53,8 @@ %X = call i32 bitcast (i8 ()* @test4a to i32 ()*)( ) ; [#uses=1] ret i32 %X ; CHECK: %X1 = call i8 @test4a() -%tmp = zext i8 %X1 to i32 -ret i32 %tmp +; CHECK: %tmp = zext i8 %X1 to i32 +; CHECK: ret i32 %tmp } From eocallaghan at auroraux.org Mon Oct 12 04:12:21 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Mon, 12 Oct 2009 10:12:21 +0100 Subject: [llvm-commits] [llvm] r83823 - in /llvm/trunk: autoconf/configure.ac lib/System/Unix/Process.inc utils/unittest/googletest/include/gtest/internal/gtest-port.h In-Reply-To: References: <200910120457.n9C4vKCL002499@zion.cs.uiuc.edu> Message-ID: <521640720910120212k507a4735geef739b277059f58@mail.gmail.com> Oh ! OK thanks, Do you do ./autogen.sh or something? Maybe quicker if you do it on Linux or what not, results could be not quite right on my platform? Cheers, Edward. 2009/10/12 Anton Korobeynikov : >> ? ?llvm/trunk/autoconf/configure.ac > You need to regenerate configure. > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University > -- -- Edward O'Callaghan http://www.auroraux.org/ eocallaghan at auroraux dot org From benny.kra at googlemail.com Mon Oct 12 04:31:55 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 12 Oct 2009 09:31:55 -0000 Subject: [llvm-commits] [llvm] r83837 - in /llvm/trunk/test/CodeGen: ARM/2009-09-01-PostRAProlog.ll MSP430/Inst16mi.ll MSP430/Inst16mm.ll MSP430/Inst16mr.ll MSP430/Inst16rm.ll MSP430/Inst16rr.ll MSP430/Inst8mi.ll MSP430/Inst8mm.ll MSP430/Inst8mr.ll MSP430/Inst8rm.ll MSP430/Inst8rr.ll SPARC/2009-08-28-PIC.ll SPARC/2009-08-28-WeakLinkage.ll Message-ID: <200910120931.n9C9VuPD030284@zion.cs.uiuc.edu> Author: d0k Date: Mon Oct 12 04:31:55 2009 New Revision: 83837 URL: http://llvm.org/viewvc/llvm-project?rev=83837&view=rev Log: Eliminate some redundant llvm-as calls. Modified: llvm/trunk/test/CodeGen/ARM/2009-09-01-PostRAProlog.ll llvm/trunk/test/CodeGen/MSP430/Inst16mi.ll llvm/trunk/test/CodeGen/MSP430/Inst16mm.ll llvm/trunk/test/CodeGen/MSP430/Inst16mr.ll llvm/trunk/test/CodeGen/MSP430/Inst16rm.ll llvm/trunk/test/CodeGen/MSP430/Inst16rr.ll llvm/trunk/test/CodeGen/MSP430/Inst8mi.ll llvm/trunk/test/CodeGen/MSP430/Inst8mm.ll llvm/trunk/test/CodeGen/MSP430/Inst8mr.ll llvm/trunk/test/CodeGen/MSP430/Inst8rm.ll llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll llvm/trunk/test/CodeGen/SPARC/2009-08-28-PIC.ll llvm/trunk/test/CodeGen/SPARC/2009-08-28-WeakLinkage.ll Modified: llvm/trunk/test/CodeGen/ARM/2009-09-01-PostRAProlog.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-09-01-PostRAProlog.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-09-01-PostRAProlog.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2009-09-01-PostRAProlog.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -asm-verbose=false -O3 -relocation-model=pic -disable-fp-elim -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 | FileCheck %s +; RUN: llc -asm-verbose=false -O3 -relocation-model=pic -disable-fp-elim -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 < %s | FileCheck %s target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:32" target triple = "thumbv7-apple-darwin9" Modified: llvm/trunk/test/CodeGen/MSP430/Inst16mi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst16mi.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst16mi.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst16mi.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; RUN: llc -march=msp430 < %s | FileCheck %s target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8" target triple = "msp430-generic-generic" Modified: llvm/trunk/test/CodeGen/MSP430/Inst16mm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst16mm.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst16mm.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst16mm.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; RUN: llc -march=msp430 < %s | FileCheck %s target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8" target triple = "msp430-generic-generic" @foo = common global i16 0, align 2 Modified: llvm/trunk/test/CodeGen/MSP430/Inst16mr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst16mr.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst16mr.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst16mr.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; RUN: llc -march=msp430 < %s | FileCheck %s target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8" target triple = "msp430-generic-generic" @foo = common global i16 0, align 2 Modified: llvm/trunk/test/CodeGen/MSP430/Inst16rm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst16rm.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst16rm.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst16rm.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; RUN: llc -march=msp430 < %s | FileCheck %s target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8" target triple = "msp430-generic-generic" @foo = common global i16 0, align 2 Modified: llvm/trunk/test/CodeGen/MSP430/Inst16rr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst16rr.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst16rr.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst16rr.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; RUN: llc -march=msp430 < %s | FileCheck %s target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8" target triple = "msp430-generic-generic" Modified: llvm/trunk/test/CodeGen/MSP430/Inst8mi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst8mi.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst8mi.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst8mi.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; RUN: llc -march=msp430 < %s | FileCheck %s target datalayout = "e-p:16:8:8-i8:8:8-i8:8:8-i32:8:8" target triple = "msp430-generic-generic" @foo = common global i8 0, align 1 Modified: llvm/trunk/test/CodeGen/MSP430/Inst8mm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst8mm.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst8mm.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst8mm.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; RUN: llc -march=msp430 < %s | FileCheck %s target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8" target triple = "msp430-generic-generic" Modified: llvm/trunk/test/CodeGen/MSP430/Inst8mr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst8mr.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst8mr.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst8mr.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; RUN: llc -march=msp430 < %s | FileCheck %s target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8" target triple = "msp430-generic-generic" @foo = common global i8 0, align 1 Modified: llvm/trunk/test/CodeGen/MSP430/Inst8rm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst8rm.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst8rm.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst8rm.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; RUN: llc -march=msp430 < %s | FileCheck %s target datalayout = "e-p:16:8:8-i8:8:8-i8:8:8-i32:8:8" target triple = "msp430-generic-generic" @foo = common global i8 0, align 1 Modified: llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=msp430 | FileCheck %s +; RUN: llc -march=msp430 < %s | FileCheck %s target datalayout = "e-p:16:8:8-i8:8:8-i8:8:8-i32:8:8" target triple = "msp430-generic-generic" Modified: llvm/trunk/test/CodeGen/SPARC/2009-08-28-PIC.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/2009-08-28-PIC.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/SPARC/2009-08-28-PIC.ll (original) +++ llvm/trunk/test/CodeGen/SPARC/2009-08-28-PIC.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=sparc --relocation-model=pic | grep _GLOBAL_OFFSET_TABLE_ +; RUN: llc -march=sparc --relocation-model=pic < %s | grep _GLOBAL_OFFSET_TABLE_ @foo = global i32 0 ; [#uses=1] Modified: llvm/trunk/test/CodeGen/SPARC/2009-08-28-WeakLinkage.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/2009-08-28-WeakLinkage.ll?rev=83837&r1=83836&r2=83837&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/SPARC/2009-08-28-WeakLinkage.ll (original) +++ llvm/trunk/test/CodeGen/SPARC/2009-08-28-WeakLinkage.ll Mon Oct 12 04:31:55 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=sparc | grep weak +; RUN: llc -march=sparc < %s | grep weak define weak i32 @func() nounwind { entry: From eocallaghan at auroraux.org Mon Oct 12 06:41:11 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Mon, 12 Oct 2009 12:41:11 +0100 Subject: [llvm-commits] building on haiku fixes In-Reply-To: <9430ad070909302334n6a5d76a5sbc675931d93c101d@mail.gmail.com> References: <9430ad070909302324g2b2acaccx3ed4e33769307c5d@mail.gmail.com> <9430ad070909302334n6a5d76a5sbc675931d93c101d@mail.gmail.com> Message-ID: <521640720910120441o61de3490we68f81c84d27f2c0@mail.gmail.com> Applied in Revision: 83823. In future send patches to the llvmdev mailing list please. Regards, Edward. 2009/10/1 Paul Davey : > this is a patch to make the configure script and a few source fixes to make > llvm configure and build on haiku > autoconf/configure.ac > lib/System/Unix/Process.inc > utils/unittest/googletest/include/gtest/internal/gtest-port.h > are the files that have changed, > it needs the configure script regenerated > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > -- -- Edward O'Callaghan http://www.auroraux.org/ eocallaghan at auroraux dot org From edwintorok at gmail.com Mon Oct 12 08:37:30 2009 From: edwintorok at gmail.com (Torok Edwin) Date: Mon, 12 Oct 2009 13:37:30 -0000 Subject: [llvm-commits] [llvm] r83848 - in /llvm/trunk/docs: ProgrammersManual.html WritingAnLLVMPass.html Message-ID: <200910121337.n9CDbU2e007164@zion.cs.uiuc.edu> Author: edwin Date: Mon Oct 12 08:37:29 2009 New Revision: 83848 URL: http://llvm.org/viewvc/llvm-project?rev=83848&view=rev Log: Fix typo, patch from Timo Juhani Lindfors. Modified: llvm/trunk/docs/ProgrammersManual.html llvm/trunk/docs/WritingAnLLVMPass.html Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=83848&r1=83847&r2=83848&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Mon Oct 12 08:37:29 2009 @@ -3543,7 +3543,7 @@ Value

The Function class represents a single procedure in LLVM. It is -actually one of the more complex classes in the LLVM heirarchy because it must +actually one of the more complex classes in the LLVM hierarchy because it must keep track of a large amount of data. The Function class keeps track of a list of BasicBlocks, a list of formal Arguments, and a Modified: llvm/trunk/docs/WritingAnLLVMPass.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/WritingAnLLVMPass.html?rev=83848&r1=83847&r2=83848&view=diff ============================================================================== --- llvm/trunk/docs/WritingAnLLVMPass.html (original) +++ llvm/trunk/docs/WritingAnLLVMPass.html Mon Oct 12 08:37:29 2009 @@ -179,7 +179,7 @@

 # Makefile for hello pass
 
-# Path to top level of LLVM heirarchy
+# Path to top level of LLVM hierarchy
 LEVEL = ../../..
 
 # Name of the library to build




From benny.kra at googlemail.com  Mon Oct 12 09:46:08 2009
From: benny.kra at googlemail.com (Benjamin Kramer)
Date: Mon, 12 Oct 2009 14:46:08 -0000
Subject: [llvm-commits] [llvm] r83849 - in /llvm/trunk/docs:
 BitCodeFormat.html CodingStandards.html CommandLine.html
 CompilerDriver.html FAQ.html GetElementPtr.html HowToReleaseLLVM.html
 HowToSubmitABug.html LangRef.html LinkTimeOptimization.html
 MakefileGuide.html Passes.html ProgrammersManual.html
 SourceLevelDebugging.html WritingAnLLVMPass.html tutorial/LangImpl3.html
 tutorial/LangImpl4.html tutorial/OCamlLangImpl3.html
 tutorial/OCamlLangImpl4.html
Message-ID: <200910121446.n9CEk9PF009954@zion.cs.uiuc.edu>

Author: d0k
Date: Mon Oct 12 09:46:08 2009
New Revision: 83849

URL: http://llvm.org/viewvc/llvm-project?rev=83849&view=rev
Log:
Documentation: Perform automated correction of common typos.

Modified:
    llvm/trunk/docs/BitCodeFormat.html
    llvm/trunk/docs/CodingStandards.html
    llvm/trunk/docs/CommandLine.html
    llvm/trunk/docs/CompilerDriver.html
    llvm/trunk/docs/FAQ.html
    llvm/trunk/docs/GetElementPtr.html
    llvm/trunk/docs/HowToReleaseLLVM.html
    llvm/trunk/docs/HowToSubmitABug.html
    llvm/trunk/docs/LangRef.html
    llvm/trunk/docs/LinkTimeOptimization.html
    llvm/trunk/docs/MakefileGuide.html
    llvm/trunk/docs/Passes.html
    llvm/trunk/docs/ProgrammersManual.html
    llvm/trunk/docs/SourceLevelDebugging.html
    llvm/trunk/docs/WritingAnLLVMPass.html
    llvm/trunk/docs/tutorial/LangImpl3.html
    llvm/trunk/docs/tutorial/LangImpl4.html
    llvm/trunk/docs/tutorial/OCamlLangImpl3.html
    llvm/trunk/docs/tutorial/OCamlLangImpl4.html

Modified: llvm/trunk/docs/BitCodeFormat.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/BitCodeFormat.html?rev=83849&r1=83848&r2=83849&view=diff

==============================================================================
--- llvm/trunk/docs/BitCodeFormat.html (original)
+++ llvm/trunk/docs/BitCodeFormat.html Mon Oct 12 09:46:08 2009
@@ -254,7 +254,7 @@
 a content-specific id number (for example, LLVM IR uses an ID of 12 to represent
 function bodies).  Block IDs 0-7 are reserved for standard blocks
 whose meaning is defined by Bitcode; block IDs 8 and greater are
-application specific. Nested blocks capture the hierachical structure of the data
+application specific. Nested blocks capture the hierarchical structure of the data
 encoded in it, and various properties are associated with blocks as the file is
 parsed.  Block definitions allow the reader to efficiently skip blocks
 in constant time if the reader wants a summary of blocks, or if it wants to

Modified: llvm/trunk/docs/CodingStandards.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CodingStandards.html?rev=83849&r1=83848&r2=83849&view=diff

==============================================================================
--- llvm/trunk/docs/CodingStandards.html (original)
+++ llvm/trunk/docs/CodingStandards.html Mon Oct 12 09:46:08 2009
@@ -303,7 +303,7 @@
 

In all cases, prefer spaces to tabs in source files. People have different -prefered indentation levels, and different styles of indentation that they +preferred indentation levels, and different styles of indentation that they like... this is fine. What isn't is that different editors/viewers expand tabs out to different tab stops. This can cause your code to look completely unreadable, and it is not worth dealing with.

@@ -491,7 +491,7 @@ must include all of the header files that you are using -- you can include them either directly or indirectly (through another header file). To make sure that you don't -accidently forget to include a header file in your module header, make sure to +accidentally forget to include a header file in your module header, make sure to include your module header first in the implementation file (as mentioned above). This way there won't be any hidden dependencies that you'll find out about later...

@@ -790,7 +790,7 @@

Use the "assert" function to its fullest. Check all of your -preconditions and assumptions, you never know when a bug (not neccesarily even +preconditions and assumptions, you never know when a bug (not necessarily even yours) might be caught early by an assertion, which reduces debugging time dramatically. The "<cassert>" header file is probably already included by the header files you are using, so it doesn't cost anything to use Modified: llvm/trunk/docs/CommandLine.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandLine.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/CommandLine.html (original) +++ llvm/trunk/docs/CommandLine.html Mon Oct 12 09:46:08 2009 @@ -1022,7 +1022,7 @@ code from the storage of the value parsed. For example, lets say that we have a '-debug' option that we would like to use to enable debug information across the entire body of our program. In this case, the boolean value -controlling the debug code should be globally accessable (in a header file, for +controlling the debug code should be globally accessible (in a header file, for example) yet the command line option processing code should not be exposed to all of these clients (requiring lots of .cpp files to #include CommandLine.h).

@@ -1107,7 +1107,7 @@ example.
  • The cl::init attribute specifies an -inital value for a scalar option. If this attribute is +initial value for a scalar option. If this attribute is not specified then the command line option value defaults to the value created by the default constructor for the type. Warning: If you specify both cl::init and cl::location for an option, @@ -1178,7 +1178,7 @@ tweak how options are parsed and how --help output is generated to fit your application well.

    -

    These options fall into five main catagories:

    +

    These options fall into five main categories:

    1. Hiding an option from --help output
    2. @@ -1190,9 +1190,9 @@
    3. Miscellaneous option modifiers
    -

    It is not possible to specify two options from the same catagory (you'll get +

    It is not possible to specify two options from the same category (you'll get a runtime error) to a single option, except for options in the miscellaneous -catagory. The CommandLine library specifies defaults for all of these settings +category. The CommandLine library specifies defaults for all of these settings that are the most useful in practice and the most common, which mean that you usually shouldn't have to worry about these.

    @@ -1536,7 +1536,7 @@ environment variable to examine, the optional additional extra text to emit when the --help option is invoked, and the boolean -switch that controls whether reponse files +switch that controls whether response files should be read.

    cl::ParseEnvironmentOptions will break the environment Modified: llvm/trunk/docs/CompilerDriver.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CompilerDriver.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/CompilerDriver.html (original) +++ llvm/trunk/docs/CompilerDriver.html Mon Oct 12 09:46:08 2009 @@ -307,13 +307,13 @@ -std=c99. It is also allowed to use spaces instead of the equality sign: -std c99. At most one occurrence is allowed.

  • parameter_list_option - same as the above, but more than one option -occurence is allowed.
  • +occurrence is allowed.
  • prefix_option - same as the parameter_option, but the option name and argument do not have to be separated. Example: -ofile. This can be also specified as -o file; however, -o=file will be parsed incorrectly (=file will be interpreted as option value). At most one occurrence is allowed.
  • -
  • prefix_list_option - same as the above, but more than one occurence of +
  • prefix_list_option - same as the above, but more than one occurrence of the option is allowed; example: -lm -lpthread.
  • alias_option - a special option type for creating aliases. Unlike other option types, aliases are not allowed to have any properties besides the @@ -682,7 +682,7 @@ Mikhail Glushenkov
    LLVM Compiler Infrastructure
    -Last modified: $Date: 2008-12-11 11:34:48 -0600 (Thu, 11 Dec 2008) $ +Last modified: $Date$
  • Modified: llvm/trunk/docs/FAQ.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/FAQ.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/FAQ.html (original) +++ llvm/trunk/docs/FAQ.html Mon Oct 12 09:46:08 2009 @@ -685,7 +685,7 @@

    Also, there are a number of other limitations of the C backend that cause it to produce code that does not fully conform to the C++ ABI on most platforms. Some of the C++ programs in LLVM's test suite are known to fail - when compiled with the C back end because of ABI incompatiblities with + when compiled with the C back end because of ABI incompatibilities with standard C++ libraries.

    @@ -700,7 +700,7 @@ portable is by using the preprocessor to include platform-specific code. In practice, information about other platforms is lost after preprocessing, so the result is inherently dependent on the platform that the preprocessing was - targetting.

    + targeting.

    Another example is sizeof. It's common for sizeof(long) to vary between platforms. In most C front-ends, sizeof is expanded to Modified: llvm/trunk/docs/GetElementPtr.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GetElementPtr.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/GetElementPtr.html (original) +++ llvm/trunk/docs/GetElementPtr.html Mon Oct 12 09:46:08 2009 @@ -40,7 +40,7 @@

    This document seeks to dispel the mystery and confusion surrounding LLVM's GetElementPtr (GEP) instruction. Questions about the wiley GEP instruction are - probably the most frequently occuring questions once a developer gets down to + probably the most frequently occurring questions once a developer gets down to coding with LLVM. Here we lay out the sources of confusion and show that the GEP instruction is really quite simple.

    Modified: llvm/trunk/docs/HowToReleaseLLVM.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/HowToReleaseLLVM.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/HowToReleaseLLVM.html (original) +++ llvm/trunk/docs/HowToReleaseLLVM.html Mon Oct 12 09:46:08 2009 @@ -40,7 +40,7 @@

    LLVM is released on a time based schedule (currently every 6 months). We do not have dot releases because of the nature of LLVM incremental - developement philosophy. The release schedule is roughly as follows: + development philosophy. The release schedule is roughly as follows:

    1. Set code freeze and branch creation date for 6 months after last code freeze @@ -499,7 +499,7 @@ release documentation.
    2. Finally, update the main page (index.html and sidebar) to point to the new release and release announcement. Make sure this all gets - commited back into Subversion.
    3. + committed back into Subversion.
    Modified: llvm/trunk/docs/HowToSubmitABug.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/HowToSubmitABug.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/HowToSubmitABug.html (original) +++ llvm/trunk/docs/HowToSubmitABug.html Mon Oct 12 09:46:08 2009 @@ -60,7 +60,7 @@

    Once you have a reduced test-case, go to the LLVM Bug Tracking System and fill out the form with the necessary details (note that you don't -need to pick a catagory, just use the "new-bugs" catagory if you're not sure). +need to pick a category, just use the "new-bugs" category if you're not sure). The bug description should contain the following information:

    Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Oct 12 09:46:08 2009 @@ -2019,7 +2019,7 @@

    The string 'undef' can be used anywhere a constant is expected, and - indicates that the user of the value may recieve an unspecified bit-pattern. + indicates that the user of the value may receive an unspecified bit-pattern. Undefined values may be of any type (other than label or void) and be used anywhere a constant is permitted.

    @@ -2118,7 +2118,7 @@ arbitrarily change its value over its "live range". This is true because the "variable" doesn't actually have a live range. Instead, the value is logically read from arbitrary registers that happen to be around when needed, -so the value is not neccesarily consistent over time. In fact, %A and %C need +so the value is not necessarily consistent over time. In fact, %A and %C need to have the same semantics or the core LLVM "replace all uses with" concept would not hold.

    @@ -2300,7 +2300,7 @@ the two digit hex code. For example: "!"test\00"".

    Metadata nodes are represented with notation similar to structure constants - (a comma separated list of elements, surrounded by braces and preceeded by an + (a comma separated list of elements, surrounded by braces and preceded by an exclamation point). For example: "!{ metadata !"test\00", i32 10}".

    @@ -2619,8 +2619,8 @@

    The switch instruction specifies a table of values and destinations. When the 'switch' instruction is executed, this table is searched for the given value. If the value is found, control flow is - transfered to the corresponding destination; otherwise, control flow is - transfered to the default destination.

    + transferred to the corresponding destination; otherwise, control flow is + transferred to the default destination.

    Implementation:

    Depending on properties of the target machine and the particular Modified: llvm/trunk/docs/LinkTimeOptimization.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LinkTimeOptimization.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/LinkTimeOptimization.html (original) +++ llvm/trunk/docs/LinkTimeOptimization.html Mon Oct 12 09:46:08 2009 @@ -166,7 +166,7 @@ provided by the linker on various platform are not unique. This means, this new tool needs to support all such features and platforms in one super tool or a separate tool per platform is required. This increases - maintance cost for link time optimizer significantly, which is not + maintenance cost for link time optimizer significantly, which is not necessary. This approach also requires staying synchronized with linker developements on various platforms, which is not the main focus of the link time optimizer. Finally, this approach increases end user's build time due @@ -189,7 +189,7 @@ user-supplied information, such as a list of exported symbols. LLVM optimizer collects control flow information, data flow information and knows much more about program structure from the optimizer's point of view. - Our goal is to take advantage of tight intergration between the linker and + Our goal is to take advantage of tight integration between the linker and the optimizer by sharing this information during various linking phases.

    Modified: llvm/trunk/docs/MakefileGuide.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/MakefileGuide.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/MakefileGuide.html (original) +++ llvm/trunk/docs/MakefileGuide.html Mon Oct 12 09:46:08 2009 @@ -261,7 +261,7 @@
    -

    In some situations, it is desireable to build a single bitcode module from +

    In some situations, it is desirable to build a single bitcode module from a variety of sources, instead of an archive, shared library, or bitcode library. Bitcode modules can be specified in addition to any of the other types of libraries by defining the MODULE_NAME Modified: llvm/trunk/docs/Passes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/Passes.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/Passes.html (original) +++ llvm/trunk/docs/Passes.html Mon Oct 12 09:46:08 2009 @@ -1544,7 +1544,7 @@

    This file demotes all registers to memory references. It is intented to be the inverse of -mem2reg. By converting to - load instructions, the only values live accross basic blocks are + load instructions, the only values live across basic blocks are alloca instructions and load instructions before phi nodes. It is intended that this should make CFG hacking much easier. To make later hacking easier, the entry block is split into two, such Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Mon Oct 12 09:46:08 2009 @@ -650,7 +650,7 @@

    The DEBUG_WITH_TYPE macro is also available for situations where you would like to set DEBUG_TYPE, but only for one specific DEBUG statement. It takes an additional first parameter, which is the type to use. For -example, the preceeding example could be written as:

    +example, the preceding example could be written as:

    @@ -2983,7 +2983,7 @@
    VectorType
    Subclass of SequentialType for vector types. A vector type is similar to an ArrayType but is distinguished because it is - a first class type wherease ArrayType is not. Vector types are used for + a first class type whereas ArrayType is not. Vector types are used for vector operations and are usually small vectors of of an integer or floating point type.
    StructType
    @@ -3552,7 +3552,7 @@

    The list of BasicBlocks is the most commonly used part of Function objects. The list imposes an implicit ordering of the blocks in the function, which indicate how the code will be -layed out by the backend. Additionally, the first BasicBlock is the implicit entry node for the Function. It is not legal in LLVM to explicitly branch to this initial block. There are no implicit exit nodes, and in fact there may be multiple exit @@ -3682,7 +3682,7 @@ User, Value

    -

    Global variables are represented with the (suprise suprise) +

    Global variables are represented with the (surprise surprise) GlobalVariable class. Like functions, GlobalVariables are also subclasses of GlobalValue, and as such are always referenced by their address (global values must live in memory, so their @@ -3732,7 +3732,7 @@

  • Constant *getInitializer() -

    Returns the intial value for a GlobalVariable. It is not legal +

    Returns the initial value for a GlobalVariable. It is not legal to call this method if there is no initializer.

  • Modified: llvm/trunk/docs/SourceLevelDebugging.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/SourceLevelDebugging.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/SourceLevelDebugging.html (original) +++ llvm/trunk/docs/SourceLevelDebugging.html Mon Oct 12 09:46:08 2009 @@ -288,7 +288,7 @@ way. Also, all debugging information objects start with a tag to indicate what type of object it is. The source-language is allowed to define its own objects, by using unreserved tag numbers. We recommend using with tags in - the range 0x1000 thru 0x2000 (there is a defined enum DW_TAG_user_base = + the range 0x1000 through 0x2000 (there is a defined enum DW_TAG_user_base = 0x1000.)

    The fields of debug descriptors used internally by LLVM Modified: llvm/trunk/docs/WritingAnLLVMPass.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/WritingAnLLVMPass.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/WritingAnLLVMPass.html (original) +++ llvm/trunk/docs/WritingAnLLVMPass.html Mon Oct 12 09:46:08 2009 @@ -453,7 +453,7 @@

    When choosing a superclass for your Pass, you should choose the most specific class possible, while still being able to meet the requirements listed. This gives the LLVM Pass Infrastructure information necessary to -optimize how passes are run, so that the resultant compiler isn't unneccesarily +optimize how passes are run, so that the resultant compiler isn't unnecessarily slow.

    @@ -492,7 +492,7 @@ href="http://llvm.org/doxygen/classllvm_1_1ModulePass.html">ModulePass" class is the most general of all superclasses that you can use. Deriving from ModulePass indicates that your pass uses the entire program as a unit, -refering to function bodies in no predictable order, or adding and removing +referring to function bodies in no predictable order, or adding and removing functions. Because nothing is known about the behavior of ModulePass subclasses, no optimization can be done for their execution.

    Modified: llvm/trunk/docs/tutorial/LangImpl3.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl3.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/LangImpl3.html (original) +++ llvm/trunk/docs/tutorial/LangImpl3.html Mon Oct 12 09:46:08 2009 @@ -183,7 +183,7 @@

    References to variables are also quite simple using LLVM. In the simple version -of Kaleidoscope, we assume that the variable has already been emited somewhere +of Kaleidoscope, we assume that the variable has already been emitted somewhere and its value is available. In practice, the only values that can be in the NamedValues map are function arguments. This code simply checks to see that the specified name is in the map (if not, an @@ -362,7 +362,7 @@ first, we want to allow 'extern'ing a function more than once, as long as the prototypes for the externs match (since all arguments have the same type, we just have to check that the number of arguments match). Second, we want to -allow 'extern'ing a function and then definining a body for it. This is useful +allow 'extern'ing a function and then defining a body for it. This is useful when defining mutually recursive functions.

    In order to implement this, the code above first checks to see if there is Modified: llvm/trunk/docs/tutorial/LangImpl4.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl4.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/LangImpl4.html (original) +++ llvm/trunk/docs/tutorial/LangImpl4.html Mon Oct 12 09:46:08 2009 @@ -209,7 +209,7 @@ to construct itself. Once it is set up, we use a series of "add" calls to add a bunch of LLVM passes. The first pass is basically boilerplate, it adds a pass so that later optimizations know how the data structures in the program are -layed out. The "TheExecutionEngine" variable is related to the JIT, +laid out. The "TheExecutionEngine" variable is related to the JIT, which we will get to in the next section.

    In this case, we choose to add 4 optimization passes. The passes we chose Modified: llvm/trunk/docs/tutorial/OCamlLangImpl3.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/OCamlLangImpl3.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/OCamlLangImpl3.html (original) +++ llvm/trunk/docs/tutorial/OCamlLangImpl3.html Mon Oct 12 09:46:08 2009 @@ -159,7 +159,7 @@

    References to variables are also quite simple using LLVM. In the simple -version of Kaleidoscope, we assume that the variable has already been emited +version of Kaleidoscope, we assume that the variable has already been emitted somewhere and its value is available. In practice, the only values that can be in the Codegen.named_values map are function arguments. This code simply checks to see that the specified name is in the map (if not, an unknown @@ -323,7 +323,7 @@ first, we want to allow 'extern'ing a function more than once, as long as the prototypes for the externs match (since all arguments have the same type, we just have to check that the number of arguments match). Second, we want to -allow 'extern'ing a function and then definining a body for it. This is useful +allow 'extern'ing a function and then defining a body for it. This is useful when defining mutually recursive functions.

    Modified: llvm/trunk/docs/tutorial/OCamlLangImpl4.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/OCamlLangImpl4.html?rev=83849&r1=83848&r2=83849&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/OCamlLangImpl4.html (original) +++ llvm/trunk/docs/tutorial/OCamlLangImpl4.html Mon Oct 12 09:46:08 2009 @@ -224,7 +224,7 @@ the_module_provider) to construct itself. Once it is set up, we use a series of "add" calls to add a bunch of LLVM passes. The first pass is basically boilerplate, it adds a pass so that later optimizations know how the -data structures in the program are layed out. The +data structures in the program are laid out. The "the_execution_engine" variable is related to the JIT, which we will get to in the next section.

    From ggreif at gmail.com Mon Oct 12 11:08:53 2009 From: ggreif at gmail.com (Gabor Greif) Date: Mon, 12 Oct 2009 16:08:53 -0000 Subject: [llvm-commits] [llvm] r83850 - /llvm/trunk/docs/ReleaseNotes-2.6.html Message-ID: <200910121608.n9CG8rBw012920@zion.cs.uiuc.edu> Author: ggreif Date: Mon Oct 12 11:08:52 2009 New Revision: 83850 URL: http://llvm.org/viewvc/llvm-project?rev=83850&view=rev Log: set some options in typewriter font Modified: llvm/trunk/docs/ReleaseNotes-2.6.html Modified: llvm/trunk/docs/ReleaseNotes-2.6.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes-2.6.html?rev=83850&r1=83849&r2=83850&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes-2.6.html (original) +++ llvm/trunk/docs/ReleaseNotes-2.6.html Mon Oct 12 11:08:52 2009 @@ -71,6 +71,7 @@ ELF Writer? How stable?
  • PostRA scheduler improvements, ARM adoption (David Goodwin).
  • 2.7 supports the GDB 7.0 jit interfaces for debug info. + 2.7 eliminates ADT/iterator.h -->
    -

    The Llvm.Linkage module is broken, and has incorrect values. Only -Llvm.Linkage.External, Llvm.Linkage.Available_externally, and -Llvm.Linkage.Link_once will be correct. If you need any of the other linkage +

    The Llvm.Linkage module is broken, and has incorrect values. Only +Llvm.Linkage.External, Llvm.Linkage.Available_externally, and +Llvm.Linkage.Link_once will be correct. If you need any of the other linkage modes, you'll have to write an external C library in order to expose the functionality. This has been fixed in the trunk.

    From gohman at apple.com Mon Oct 12 11:43:45 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 12 Oct 2009 16:43:45 -0000 Subject: [llvm-commits] [llvm] r83856 - /llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Message-ID: <200910121643.n9CGhj4p014161@zion.cs.uiuc.edu> Author: djg Date: Mon Oct 12 11:43:44 2009 New Revision: 83856 URL: http://llvm.org/viewvc/llvm-project?rev=83856&view=rev Log: Delete some obsolete declarations. Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=83856&r1=83855&r2=83856&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Mon Oct 12 11:43:44 2009 @@ -518,21 +518,6 @@ void EmitNoop(); void EmitPhysRegCopy(SUnit *SU, DenseMap &VRBaseMap); - - private: - /// EmitLiveInCopy - Emit a copy for a live in physical register. If the - /// physical register has only a single copy use, then coalesced the copy - /// if possible. - void EmitLiveInCopy(MachineBasicBlock *MBB, - MachineBasicBlock::iterator &InsertPos, - unsigned VirtReg, unsigned PhysReg, - const TargetRegisterClass *RC, - DenseMap &CopyRegMap); - - /// EmitLiveInCopies - If this is the first basic block in the function, - /// and if it has live ins that need to be copied into vregs, emit the - /// copies into the top of the block. - void EmitLiveInCopies(MachineBasicBlock *MBB); }; class SUnitIterator : public std::iterator Author: djg Date: Mon Oct 12 11:44:10 2009 New Revision: 83857 URL: http://llvm.org/viewvc/llvm-project?rev=83857&view=rev Log: Remove a redundant member variable. Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h?rev=83857&r1=83856&r2=83857&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h Mon Oct 12 11:44:10 2009 @@ -121,7 +121,6 @@ SmallSet LoopLiveInRegs; public: - MachineBasicBlock *BB; // Current basic block MachineBasicBlock::iterator Begin; // The beginning of the range to // be scheduled. The range extends // to InsertPos. From tonic at nondot.org Mon Oct 12 11:47:02 2009 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 12 Oct 2009 09:47:02 -0700 Subject: [llvm-commits] [llvm] r83417 - /llvm/trunk/lib/Support/Triple.cpp In-Reply-To: <933FB189-6510-469A-9BD9-7151AAD84830@apple.com> References: <200910062145.n96LjQsf011221@zion.cs.uiuc.edu> <933FB189-6510-469A-9BD9-7151AAD84830@apple.com> Message-ID: <645BEEDB-183E-44AB-9F74-48468499FB0A@nondot.org> Both are merged in. -Tanya On Oct 8, 2009, at 11:05 AM, Chris Lattner wrote: > > On Oct 8, 2009, at 11:02 AM, Tanya M. Lattner wrote: > >> >> Chris can you approve or deny this patch? >> >> Also, are both patches required or just the last one? > > yes approved, both patches are required. > > -Chris > >> >> Thanks, >> Tanya >> >> On Tue, 6 Oct 2009, Jeffrey Yasskin wrote: >> >>> Here's the real twine fix, in case you want it for the 2.6 branch. >>> >>> On Tue, Oct 6, 2009 at 2:45 PM, Jeffrey Yasskin >>> wrote: >>>> Author: jyasskin >>>> Date: Tue Oct 6 16:45:26 2009 >>>> New Revision: 83417 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=83417&view=rev >>>> Log: >>>> r83391 was completely broken since Twines keep references to >>>> their inputs, and >>>> some of the inputs were temporaries. Here's a real fix for the >>>> miscompilation. >>>> Thanks to sabre for pointing out the problem. >>>> >>>> Modified: >>>> llvm/trunk/lib/Support/Triple.cpp >>>> >>>> Modified: llvm/trunk/lib/Support/Triple.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=83417&r1=83416&r2=83417&view=diff >>>> >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> =================================================================== >>>> --- llvm/trunk/lib/Support/Triple.cpp (original) >>>> +++ llvm/trunk/lib/Support/Triple.cpp Tue Oct 6 16:45:26 2009 >>>> @@ -9,6 +9,7 @@ >>>> >>>> #include "llvm/ADT/Triple.h" >>>> >>>> +#include "llvm/ADT/SmallString.h" >>>> #include "llvm/ADT/Twine.h" >>>> #include >>>> #include >>>> @@ -390,10 +391,14 @@ >>>> } >>>> >>>> void Triple::setArchName(const StringRef &Str) { >>>> - // Work around a miscompilation bug in gcc 4.0.3. >>>> - Twine a = getVendorName() + "-" + getOSAndEnvironmentName(); >>>> - Twine b = Str + "-" + a; >>>> - setTriple(b); >>>> + // Work around a miscompilation bug for Twines in gcc 4.0.3. >>>> + SmallString<64> Triple; >>>> + Triple += Str; >>>> + Triple += "-"; >>>> + Triple += getVendorName(); >>>> + Triple += "-"; >>>> + Triple += getOSAndEnvironmentName(); >>>> + setTriple(Triple.str()); >>>> } >>>> >>>> void Triple::setVendorName(const StringRef &Str) { >>>> >>>> >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>>> >>> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From ggreif at gmail.com Mon Oct 12 11:50:26 2009 From: ggreif at gmail.com (Gabor Greif) Date: Mon, 12 Oct 2009 16:50:26 -0000 Subject: [llvm-commits] [llvm] r83860 - /llvm/trunk/docs/ReleaseNotes-2.6.html Message-ID: <200910121650.n9CGoQps014430@zion.cs.uiuc.edu> Author: ggreif Date: Mon Oct 12 11:50:25 2009 New Revision: 83860 URL: http://llvm.org/viewvc/llvm-project?rev=83860&view=rev Log: another bunch of s Modified: llvm/trunk/docs/ReleaseNotes-2.6.html Modified: llvm/trunk/docs/ReleaseNotes-2.6.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes-2.6.html?rev=83860&r1=83859&r2=83860&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes-2.6.html (original) +++ llvm/trunk/docs/ReleaseNotes-2.6.html Mon Oct 12 11:50:25 2009 @@ -796,7 +796,7 @@
    • New - PrettyStackTrace classes allows crashes of llvm tools (and applications + PrettyStackTrace class allows crashes of llvm tools (and applications that integrate them) to provide more detailed indication of what the compiler was doing at the time of the crash (e.g. running a pass). At the top level for each LLVM tool, it includes the command line arguments. @@ -804,8 +804,8 @@
    • New StringRef and Twine classes make operations on character ranges and - string concatenation to be more efficient. StringRef is just a const - char* with a length, Twine is a light-weight rope.
    • + string concatenation to be more efficient. StringRef is just a const + char* with a length, Twine is a light-weight rope.
    • LLVM has new WeakVH, AssertingVH and CallbackVH classes, which make it easier to write LLVM IR transformations. WeakVH is automatically drops to null when the referenced Value is deleted, @@ -889,12 +889,12 @@
    • The Itanium (IA64) backend has been removed. It was not actively supported and had bitrotted.
    • The BigBlock register allocator has been removed, it had also bitrotted.
    • -
    • The C Backend (-march=c) is no longer considered part of the LLVM release +
    • The C Backend (-march=c) is no longer considered part of the LLVM release criteria. We still want it to work, but no one is maintaining it and it lacks support for arbitrary precision integers and other important IR features.
    • All LLVM tools now default to overwriting their output file, behaving more - like standard unix tools. Previously, this only happened with the '-f' + like standard unix tools. Previously, this only happened with the '-f' option.
    • LLVM build now builds all libraries as .a files instead of some libraries as relinked .o files. This requires some APIs like @@ -907,11 +907,11 @@ API changes are:

        -
      • All uses of hash_set and hash_map have been removed from the LLVM tree and - the wrapper headers have been removed.
      • +
      • All uses of hash_set and hash_map have been removed from + the LLVM tree and the wrapper headers have been removed.
      • The llvm/Streams.h and DOUT member of Debug.h have been removed. The llvm::Ostream class has been completely removed and replaced with - uses of raw_ostream.
      • + uses of raw_ostream.
      • LLVM's global uniquing tables for Types and Constants have been privatized into members of an LLVMContext. A number of APIs now take an LLVMContext as a parameter. To smooth the transition From dpatel at apple.com Mon Oct 12 12:16:15 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 12 Oct 2009 10:16:15 -0700 Subject: [llvm-commits] [llvm] r83082 - /llvm/trunk/include/llvm/ADT/StringRef.h In-Reply-To: <08828162-224F-46F6-A00A-5C295D19BFE5@apple.com> References: <200909291839.n8TIdv0K005250@zion.cs.uiuc.edu> <5EAC33CE-F7F4-415E-AAE2-D3D090178ACB@apple.com> <9DA16CEF-67EF-449A-870E-9818DA3850CA@apple.com> <77942D29-5F7E-4AE6-B56B-2CE12FF05A02@apple.com> <08828162-224F-46F6-A00A-5C295D19BFE5@apple.com> Message-ID: <3754DE71-073E-4845-9A95-FFF65097080B@apple.com> OK. I'll update how DebugInfo uses StringRef. - Devang On Oct 12, 2009, at 7:02 AM, Daniel Dunbar wrote: > Yes, this isn't something that should be in StringRef, I would go so > far to say this is an invariant clients can rely on: > -- > StringRef(a).data() == a > -- > > As Chris mentions we want the StringRef constructors to be simple, > we use them a lot and rely on the optimizer to clean them up, for > example in default arguments. It's good to avoid any unnecessary > complexity. > > - Daniel > > On Sep 29, 2009, at 9:59 PM, Chris Lattner wrote: > >> On Sep 29, 2009, at 11:57 AM, Devang Patel wrote: >>> On Sep 29, 2009, at 11:53 AM, Chris Lattner wrote: >>>> On Sep 29, 2009, at 11:39 AM, Devang Patel wrote: >>>> Author: dpatel >>>>> Date: Tue Sep 29 13:39:56 2009 >>>>> New Revision: 83082 >>>>> >>>>> URL: http://llvm.org/viewvc/llvm-project?rev=83082&view=rev >>>>> Log: >>>>> Create empty StringRef is incoming cstring is NULL. >>>> >>>> I don't think this is correct, StringRef shouldn't allow null >>>> cstrings to be passed in. >>> >>> I'm using it to pass optional strings. For example, linkage name >>> in debug info. >>> Note, one can create empty StringRef by say >>> SringRef foo; >>> If this is not desirable then I'll update DebugInfo interface. >> >> The reason I mention that is that stringref is frequently used for >> const char*'s, and this adds an extra branch to the common case. >> Doing something like: >> >> return ptr != 0 : StringRef(ptr) : StringRef(); >> >> in the debug info stuff would make it pay the cost locally instead >> of making all clients of stringref pay it. >> >> What do you think Daniel? >> >> BTW, getting rid of std::string from debug info is really really >> awesome! >> >> -Chris >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091012/22234047/attachment.html From jyasskin at google.com Mon Oct 12 12:43:32 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Mon, 12 Oct 2009 17:43:32 -0000 Subject: [llvm-commits] [llvm] r83861 - in /llvm/trunk: include/llvm/Support/ValueHandle.h lib/VMCore/Value.cpp unittests/Support/ValueHandleTest.cpp Message-ID: <200910121743.n9CHhXUc016336@zion.cs.uiuc.edu> Author: jyasskin Date: Mon Oct 12 12:43:32 2009 New Revision: 83861 URL: http://llvm.org/viewvc/llvm-project?rev=83861&view=rev Log: Fix http://llvm.org/PR5160, to let CallbackVHs modify other ValueHandles on the same Value without breaking things. Modified: llvm/trunk/include/llvm/Support/ValueHandle.h llvm/trunk/lib/VMCore/Value.cpp llvm/trunk/unittests/Support/ValueHandleTest.cpp Modified: llvm/trunk/include/llvm/Support/ValueHandle.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ValueHandle.h?rev=83861&r1=83860&r2=83861&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ValueHandle.h (original) +++ llvm/trunk/include/llvm/Support/ValueHandle.h Mon Oct 12 12:43:32 2009 @@ -111,10 +111,15 @@ HandleBaseKind getKind() const { return PrevPair.getInt(); } void setPrevPtr(ValueHandleBase **Ptr) { PrevPair.setPointer(Ptr); } - /// AddToExistingUseList - Add this ValueHandle to the use list for VP, - /// where List is known to point into the existing use list. + /// AddToExistingUseList - Add this ValueHandle to the use list for VP, where + /// List is the address of either the head of the list or a Next node within + /// the existing use list. void AddToExistingUseList(ValueHandleBase **List); + /// AddToExistingUseListAfter - Add this ValueHandle to the use list after + /// Node. + void AddToExistingUseListAfter(ValueHandleBase *Node); + /// AddToUseList - Add this ValueHandle to the use list for VP. void AddToUseList(); /// RemoveFromUseList - Remove this ValueHandle from its current use list. Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=83861&r1=83860&r2=83861&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Mon Oct 12 12:43:32 2009 @@ -411,6 +411,16 @@ } } +void ValueHandleBase::AddToExistingUseListAfter(ValueHandleBase *List) { + assert(List && "Must insert after existing node"); + + Next = List->Next; + setPrevPtr(&List->Next); + List->Next = this; + if (Next) + Next->setPrevPtr(&Next); +} + /// AddToUseList - Add this ValueHandle to the use list for VP. void ValueHandleBase::AddToUseList() { assert(VP && "Null pointer doesn't have a use list!"); @@ -490,37 +500,46 @@ ValueHandleBase *Entry = pImpl->ValueHandles[V]; assert(Entry && "Value bit set but no entries exist"); - while (Entry) { - // Advance pointer to avoid invalidation. - ValueHandleBase *ThisNode = Entry; - Entry = Entry->Next; + // We use a local ValueHandleBase as an iterator so that + // ValueHandles can add and remove themselves from the list without + // breaking our iteration. This is not really an AssertingVH; we + // just have to give ValueHandleBase some kind. + for (ValueHandleBase Iterator(Assert, *Entry); Entry; Entry = Iterator.Next) { + Iterator.RemoveFromUseList(); + Iterator.AddToExistingUseListAfter(Entry); + assert(Entry->Next == &Iterator && "Loop invariant broken."); - switch (ThisNode->getKind()) { + switch (Entry->getKind()) { case Assert: -#ifndef NDEBUG // Only in -g mode... - errs() << "While deleting: " << *V->getType() << " %" << V->getNameStr() - << "\n"; -#endif - llvm_unreachable("An asserting value handle still pointed to this" - " value!"); + break; case Tracking: // Mark that this value has been deleted by setting it to an invalid Value // pointer. - ThisNode->operator=(DenseMapInfo::getTombstoneKey()); + Entry->operator=(DenseMapInfo::getTombstoneKey()); break; case Weak: // Weak just goes to null, which will unlink it from the list. - ThisNode->operator=(0); + Entry->operator=(0); break; case Callback: // Forward to the subclass's implementation. - static_cast(ThisNode)->deleted(); + static_cast(Entry)->deleted(); break; } } - // All callbacks and weak references should be dropped by now. - assert(!V->HasValueHandle && "All references to V were not removed?"); + // All callbacks, weak references, and assertingVHs should be dropped by now. + if (V->HasValueHandle) { +#ifndef NDEBUG // Only in +Asserts mode... + errs() << "While deleting: " << *V->getType() << " %" << V->getNameStr() + << "\n"; + if (pImpl->ValueHandles[V]->getKind() == Assert) + llvm_unreachable("An asserting value handle still pointed to this" + " value!"); + +#endif + llvm_unreachable("All references to V were not removed?"); + } } @@ -535,12 +554,16 @@ assert(Entry && "Value bit set but no entries exist"); - while (Entry) { - // Advance pointer to avoid invalidation. - ValueHandleBase *ThisNode = Entry; - Entry = Entry->Next; + // We use a local ValueHandleBase as an iterator so that + // ValueHandles can add and remove themselves from the list without + // breaking our iteration. This is not really an AssertingVH; we + // just have to give ValueHandleBase some kind. + for (ValueHandleBase Iterator(Assert, *Entry); Entry; Entry = Iterator.Next) { + Iterator.RemoveFromUseList(); + Iterator.AddToExistingUseListAfter(Entry); + assert(Entry->Next == &Iterator && "Loop invariant broken."); - switch (ThisNode->getKind()) { + switch (Entry->getKind()) { case Assert: // Asserting handle does not follow RAUW implicitly. break; @@ -553,11 +576,11 @@ // FALLTHROUGH case Weak: // Weak goes to the new value, which will unlink it from Old's list. - ThisNode->operator=(New); + Entry->operator=(New); break; case Callback: // Forward to the subclass's implementation. - static_cast(ThisNode)->allUsesReplacedWith(New); + static_cast(Entry)->allUsesReplacedWith(New); break; } } Modified: llvm/trunk/unittests/Support/ValueHandleTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ValueHandleTest.cpp?rev=83861&r1=83860&r2=83861&view=diff ============================================================================== --- llvm/trunk/unittests/Support/ValueHandleTest.cpp (original) +++ llvm/trunk/unittests/Support/ValueHandleTest.cpp Mon Oct 12 12:43:32 2009 @@ -11,6 +11,7 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" +#include "llvm/ADT/OwningPtr.h" #include "gtest/gtest.h" @@ -327,4 +328,84 @@ BitcastUser->getOperand(0)); } +TEST_F(ValueHandle, DestroyingOtherVHOnSameValueDoesntBreakIteration) { + // When a CallbackVH modifies other ValueHandles in its callbacks, + // that shouldn't interfere with non-modified ValueHandles receiving + // their appropriate callbacks. + // + // We create the active CallbackVH in the middle of a palindromic + // arrangement of other VHs so that the bad behavior would be + // triggered in whichever order callbacks run. + + class DestroyingVH : public CallbackVH { + public: + OwningPtr ToClear[2]; + DestroyingVH(Value *V) { + ToClear[0].reset(new WeakVH(V)); + setValPtr(V); + ToClear[1].reset(new WeakVH(V)); + } + virtual void deleted() { + ToClear[0].reset(); + ToClear[1].reset(); + CallbackVH::deleted(); + } + virtual void allUsesReplacedWith(Value *) { + ToClear[0].reset(); + ToClear[1].reset(); + } + }; + + { + WeakVH ShouldBeVisited1(BitcastV.get()); + DestroyingVH C(BitcastV.get()); + WeakVH ShouldBeVisited2(BitcastV.get()); + + BitcastV->replaceAllUsesWith(ConstantV); + EXPECT_EQ(ConstantV, static_cast(ShouldBeVisited1)); + EXPECT_EQ(ConstantV, static_cast(ShouldBeVisited2)); + } + + { + WeakVH ShouldBeVisited1(BitcastV.get()); + DestroyingVH C(BitcastV.get()); + WeakVH ShouldBeVisited2(BitcastV.get()); + + BitcastV.reset(); + EXPECT_EQ(NULL, static_cast(ShouldBeVisited1)); + EXPECT_EQ(NULL, static_cast(ShouldBeVisited2)); + } +} + +TEST_F(ValueHandle, AssertingVHCheckedLast) { + // If a CallbackVH exists to clear out a group of AssertingVHs on + // Value deletion, the CallbackVH should get a chance to do so + // before the AssertingVHs assert. + + class ClearingVH : public CallbackVH { + public: + AssertingVH *ToClear[2]; + ClearingVH(Value *V, + AssertingVH &A0, AssertingVH &A1) + : CallbackVH(V) { + ToClear[0] = &A0; + ToClear[1] = &A1; + } + + virtual void deleted() { + *ToClear[0] = 0; + *ToClear[1] = 0; + CallbackVH::deleted(); + } + }; + + AssertingVH A1, A2; + A1 = BitcastV.get(); + ClearingVH C(BitcastV.get(), A1, A2); + A2 = BitcastV.get(); + // C.deleted() should run first, clearing the two AssertingVHs, + // which should prevent them from asserting. + BitcastV.reset(); +} + } From natebegeman at mac.com Mon Oct 12 12:58:39 2009 From: natebegeman at mac.com (Nate Begeman) Date: Mon, 12 Oct 2009 17:58:39 -0000 Subject: [llvm-commits] [test-suite] r83863 - /test-suite/trunk/Makefile.programs Message-ID: <200910121758.n9CHwdlP016855@zion.cs.uiuc.edu> Author: sampo Date: Mon Oct 12 12:58:38 2009 New Revision: 83863 URL: http://llvm.org/viewvc/llvm-project?rev=83863&view=rev Log: Enable combiner-aa as LLCBETA on x86, x86-64 now that (hopefully) final heuristics are in place. Modified: test-suite/trunk/Makefile.programs Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=83863&r1=83862&r2=83863&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Mon Oct 12 12:58:38 2009 @@ -223,14 +223,14 @@ LLCBETAOPTION := -sched=simple endif ifeq ($(ARCH),x86_64) -LLCBETAOPTION := -remat-pic-stub-load +LLCBETAOPTION := -combiner-alias-analysis #-pre-alloc-split -#-combiner-alias-analysis +#-remat-pic-stub-load endif ifeq ($(ARCH),x86) -LLCBETAOPTION := -remat-pic-stub-load +LLCBETAOPTION := -combiner-alias-analysis #-pre-alloc-split -#-combiner-alias-analysis +#-remat-pic-stub-load #-combiner-global-alias-analysis #-fast-isel #-new-spilling-heuristic From sabre at nondot.org Mon Oct 12 13:12:47 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 12 Oct 2009 18:12:47 -0000 Subject: [llvm-commits] [llvm] r83865 - /llvm/trunk/docs/Bugpoint.html Message-ID: <200910121812.n9CIClmC017548@zion.cs.uiuc.edu> Author: lattner Date: Mon Oct 12 13:12:47 2009 New Revision: 83865 URL: http://llvm.org/viewvc/llvm-project?rev=83865&view=rev Log: Improve bugpoint doc, patch by Timo Lindfors! Modified: llvm/trunk/docs/Bugpoint.html Modified: llvm/trunk/docs/Bugpoint.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/Bugpoint.html?rev=83865&r1=83864&r2=83865&view=diff ============================================================================== --- llvm/trunk/docs/Bugpoint.html (original) +++ llvm/trunk/docs/Bugpoint.html Mon Oct 12 13:12:47 2009 @@ -216,6 +216,17 @@ the list of specified optimizations to be randomized and applied to the program. This process will repeat until a bug is found or the user kills bugpoint. + +
      • bugpoint does not understand the -O option + that is used to specify optimization level to opt. You + can use e.g.

        + +
        +

        opt -O2 -debug-pass=Arguments foo.bc -disable-output

        +
        + +

        to get a list of passes that are used with -O2 and + then pass this list to bugpoint.

        From sabre at nondot.org Mon Oct 12 13:33:33 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 12 Oct 2009 18:33:33 -0000 Subject: [llvm-commits] [llvm] r83868 - /llvm/trunk/docs/ReleaseNotes-2.6.html Message-ID: <200910121833.n9CIXX2K018483@zion.cs.uiuc.edu> Author: lattner Date: Mon Oct 12 13:33:33 2009 New Revision: 83868 URL: http://llvm.org/viewvc/llvm-project?rev=83868&view=rev Log: fix validation error pointed out by gabor (and the w3c :) Modified: llvm/trunk/docs/ReleaseNotes-2.6.html Modified: llvm/trunk/docs/ReleaseNotes-2.6.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes-2.6.html?rev=83868&r1=83867&r2=83868&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes-2.6.html (original) +++ llvm/trunk/docs/ReleaseNotes-2.6.html Mon Oct 12 13:33:33 2009 @@ -754,13 +754,13 @@
      • The ARM calling convention code is now tblgen generated instead of resorting to C++ code.
      • +

      These features are still somewhat experimental and subject to change. The Neon intrinsics, in particular, may change in future releases of LLVM. ARMv7 support has progressed a lot on top of tree since 2.6 branched.

      -
    From dalej at apple.com Mon Oct 12 13:33:50 2009 From: dalej at apple.com (Dale Johannesen) Date: Mon, 12 Oct 2009 11:33:50 -0700 Subject: [llvm-commits] [llvm] r83675 - in /llvm/trunk: include/llvm/Transforms/Utils/InlineCost.h lib/Transforms/IPO/Inliner.cpp lib/Transforms/Utils/InlineCost.cpp In-Reply-To: <6a8523d60910101242q478a1fcfl311f4a9d673495e0@mail.gmail.com> References: <200910092142.n99Lg3nh004433@zion.cs.uiuc.edu> <6a8523d60910101242q478a1fcfl311f4a9d673495e0@mail.gmail.com> Message-ID: On Oct 10, 2009, at 12:42 PMPDT, Daniel Dunbar wrote: >> >> + namespace InlineConstants { >> + // Various magic constants used to adjust heuristics. >> + const int CallPenalty = 5; >> + const int LastCallToStaticBonus = -15000; > > Seems strange to call this a "Bonus", but have a the negative value be > the "bonus". Wouldn't it make more sense to name it penalty as well? > Or perhaps replace {Penalty,Bonus} with a more neutral word like Cost? These numbers are used to compute a Cost. Penalties increase the cost. Bonuses decrease it. I do find it mildly confusing to have negative values mean more inlining; I wouldn't have done it that way, but I can live with it. From nlewycky at google.com Mon Oct 12 13:44:58 2009 From: nlewycky at google.com (Nick Lewycky) Date: Mon, 12 Oct 2009 11:44:58 -0700 Subject: [llvm-commits] patch: memory use markers In-Reply-To: <19D8DF80-620E-41D0-915D-A3D505766B00@apple.com> References: <4AD25B50.4000008@mxc.ca> <19D8DF80-620E-41D0-915D-A3D505766B00@apple.com> Message-ID: 2009/10/12 Dan Gohman > > On Oct 11, 2009, at 3:25 PM, Nick Lewycky wrote: > > > This patch adds memory use markers as described in > http://nondot.org/sabre/LLVMNotes/MemoryUseMarkers.txt > > . The bulk of the patch makes it possible to have intrinsics which > > return {}. > > Hi Nick, > > The use of {} here is clever, but I don't think it's correct. Since {} > has > no members, the set of values has exactly one element, which means > that all values of type {} can be assumed to be equivalent. Please use > something like opaque* instead. > I brought that up with Chris much earlier on (since I would've had this patch done a month ago were it not for the need to support {}) but he was adamant that {} was the correct type for these. I was suggesting metadata type though; opaque types require a name in the module. With @llvm.invariant.end being marked readonly and nounwind, and having > a void return type, it would seem to be trivially dead everywhere. > Should > the readonly be removed? > Good catch! Does this rule apply to intrinsics as well? How does @llvm.gcread work? I will check on it and make sure we're doing the right thing here. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091012/83a7a800/attachment.html From dalej at apple.com Mon Oct 12 13:45:32 2009 From: dalej at apple.com (Dale Johannesen) Date: Mon, 12 Oct 2009 18:45:32 -0000 Subject: [llvm-commits] [llvm] r83870 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200910121845.n9CIjXhD019004@zion.cs.uiuc.edu> Author: johannes Date: Mon Oct 12 13:45:32 2009 New Revision: 83870 URL: http://llvm.org/viewvc/llvm-project?rev=83870&view=rev Log: Fix warning. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=83870&r1=83869&r2=83870&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Oct 12 13:45:32 2009 @@ -2824,7 +2824,7 @@ // X * Y (where Y is 0 or 1) -> X & (0-Y) if (!isa(I.getType())) { // -2 is "-1 << 1" so it is all bits set except the low one. - APInt Negative2(I.getType()->getPrimitiveSizeInBits(), -2, true); + APInt Negative2(I.getType()->getPrimitiveSizeInBits(), (uint64_t)-2, true); Value *BoolCast = 0, *OtherOp = 0; if (MaskedValueIsZero(Op0, Negative2)) From dalej at apple.com Mon Oct 12 13:49:00 2009 From: dalej at apple.com (Dale Johannesen) Date: Mon, 12 Oct 2009 18:49:00 -0000 Subject: [llvm-commits] [llvm] r83871 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/CodeGen/TargetInstrInfoImpl.cpp lib/CodeGen/VirtRegRewriter.cpp lib/Target/PowerPC/PPCInstrInfo.h Message-ID: <200910121849.n9CIn0VK019156@zion.cs.uiuc.edu> Author: johannes Date: Mon Oct 12 13:49:00 2009 New Revision: 83871 URL: http://llvm.org/viewvc/llvm-project?rev=83871&view=rev Log: Revert the kludge in 76703. I got a clean bootstrap of FSF-style PPC, so there is some reason to believe the original bug (which was never analyzed) has been fixed, probably by 82266. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=83871&r1=83870&r2=83871&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Mon Oct 12 13:49:00 2009 @@ -449,10 +449,6 @@ return true; } - /// isDeadInstruction - Return true if the instruction is considered dead. - /// This allows some late codegen passes to delete them. - virtual bool isDeadInstruction(const MachineInstr *MI) const = 0; - /// GetInstSize - Returns the size of the specified Instruction. /// virtual unsigned GetInstSizeInBytes(const MachineInstr *MI) const { @@ -490,8 +486,6 @@ MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubReg, const MachineInstr *Orig) const; - virtual bool isDeadInstruction(const MachineInstr *MI) const; - virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const; }; Modified: llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp?rev=83871&r1=83870&r2=83871&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp Mon Oct 12 13:49:00 2009 @@ -143,27 +143,6 @@ MBB.insert(I, MI); } -bool TargetInstrInfoImpl::isDeadInstruction(const MachineInstr *MI) const { - const TargetInstrDesc &TID = MI->getDesc(); - if (TID.mayLoad() || TID.mayStore() || TID.isCall() || TID.isTerminator() || - TID.isCall() || TID.isBarrier() || TID.isReturn() || - TID.hasUnmodeledSideEffects()) - return false; - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = MI->getOperand(i); - if (!MO.isReg() || !MO.getReg()) - continue; - if (MO.isDef() && !MO.isDead()) - return false; - if (MO.isUse() && MO.isKill()) - // FIXME: We can't remove kill markers or else the scavenger will assert. - // An alternative is to add a ADD pseudo instruction to replace kill - // markers. - return false; - } - return true; -} - unsigned TargetInstrInfoImpl::GetFunctionSizeInBytes(const MachineFunction &MF) const { unsigned FnSize = 0; Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=83871&r1=83870&r2=83871&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Mon Oct 12 13:49:00 2009 @@ -1478,6 +1478,29 @@ ++NumStores; } + /// isSafeToDelete - Return true if this instruction doesn't produce any side + /// effect and all of its defs are dead. + static bool isSafeToDelete(MachineInstr &MI) { + const TargetInstrDesc &TID = MI.getDesc(); + if (TID.mayLoad() || TID.mayStore() || TID.isCall() || TID.isTerminator() || + TID.isCall() || TID.isBarrier() || TID.isReturn() || + TID.hasUnmodeledSideEffects()) + return false; + for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI.getOperand(i); + if (!MO.isReg() || !MO.getReg()) + continue; + if (MO.isDef() && !MO.isDead()) + return false; + if (MO.isUse() && MO.isKill()) + // FIXME: We can't remove kill markers or else the scavenger will assert. + // An alternative is to add a ADD pseudo instruction to replace kill + // markers. + return false; + } + return true; + } + /// TransferDeadness - A identity copy definition is dead and it's being /// removed. Find the last def or use and mark it as dead / kill. void TransferDeadness(MachineBasicBlock *MBB, unsigned CurDist, @@ -1519,7 +1542,7 @@ if (LastUD->isDef()) { // If the instruction has no side effect, delete it and propagate // backward further. Otherwise, mark is dead and we are done. - if (!TII->isDeadInstruction(LastUDMI)) { + if (!isSafeToDelete(*LastUDMI)) { LastUD->setIsDead(); break; } @@ -2340,7 +2363,7 @@ } ProcessNextInst: // Delete dead instructions without side effects. - if (!Erased && !BackTracked && TII->isDeadInstruction(&MI)) { + if (!Erased && !BackTracked && isSafeToDelete(MI)) { InvalidateKills(MI, TRI, RegKills, KillOps); VRM.RemoveMachineInstrFromMaps(&MI); MBB.erase(&MI); Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h?rev=83871&r1=83870&r2=83871&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h Mon Oct 12 13:49:00 2009 @@ -146,13 +146,6 @@ virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; virtual bool ReverseBranchCondition(SmallVectorImpl &Cond) const; - - virtual bool isDeadInstruction(const MachineInstr *MI) const { - // FIXME: Without this, ppc llvm-gcc doesn't bootstrap. That means some - // instruction definitions are not modeling side effects correctly. - // This is a workaround until we know the exact cause. - return false; - } /// GetInstSize - Return the number of bytes of code the specified /// instruction may be. This returns the maximum number of bytes. From bob.wilson at apple.com Mon Oct 12 13:52:13 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 12 Oct 2009 18:52:13 -0000 Subject: [llvm-commits] [llvm] r83872 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910121852.n9CIqDY3019356@zion.cs.uiuc.edu> Author: bwilson Date: Mon Oct 12 13:52:13 2009 New Revision: 83872 URL: http://llvm.org/viewvc/llvm-project?rev=83872&view=rev Log: Add a typedef for an iterator. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=83872&r1=83871&r2=83872&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Oct 12 13:52:13 2009 @@ -70,6 +70,8 @@ /// to a return, unreachable, or unconditional branch). std::vector WaterList; + typedef std::vector::iterator water_iterator; + /// CPUser - One user of a constant pool, keeping the machine instruction /// pointer, the constant pool being referenced, and the max displacement /// allowed from the instruction to the CP. @@ -164,7 +166,7 @@ bool LookForWater(CPUser&U, unsigned UserOffset, MachineBasicBlock** NewMBB); MachineBasicBlock* AcceptWater(MachineBasicBlock *WaterBB, - std::vector::iterator IP); + water_iterator IP); void CreateNewWater(unsigned CPUserIndex, unsigned UserOffset, MachineBasicBlock** NewMBB); bool HandleConstantPoolUser(MachineFunction &MF, unsigned CPUserIndex); @@ -608,7 +610,7 @@ // Next, update WaterList. Specifically, we need to add NewMBB as having // available water after it. - std::vector::iterator IP = + water_iterator IP = std::lower_bound(WaterList.begin(), WaterList.end(), NewBB, CompareMBBNumbers); WaterList.insert(IP, NewBB); @@ -670,7 +672,7 @@ // available water after it (but not if it's already there, which happens // when splitting before a conditional branch that is followed by an // unconditional branch - in that case we want to insert NewBB). - std::vector::iterator IP = + water_iterator IP = std::lower_bound(WaterList.begin(), WaterList.end(), OrigBB, CompareMBBNumbers); MachineBasicBlock* WaterBB = *IP; @@ -932,7 +934,7 @@ /// AcceptWater - Small amount of common code factored out of the following. MachineBasicBlock* ARMConstantIslands::AcceptWater(MachineBasicBlock *WaterBB, - std::vector::iterator IP) { + water_iterator IP) { DEBUG(errs() << "found water in range\n"); // Remove the original WaterList entry; we want subsequent // insertions in this vicinity to go after the one we're @@ -952,10 +954,10 @@ /// group, prefer the water that's farthest away. bool ARMConstantIslands::LookForWater(CPUser &U, unsigned UserOffset, MachineBasicBlock** NewMBB) { - std::vector::iterator IPThatWouldPad; + water_iterator IPThatWouldPad; MachineBasicBlock* WaterBBThatWouldPad = NULL; if (!WaterList.empty()) { - for (std::vector::iterator IP = prior(WaterList.end()), + for (water_iterator IP = prior(WaterList.end()), B = WaterList.begin();; --IP) { MachineBasicBlock* WaterBB = *IP; if (WaterIsInRange(UserOffset, WaterBB, U)) { From bob.wilson at apple.com Mon Oct 12 14:01:13 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 12 Oct 2009 19:01:13 -0000 Subject: [llvm-commits] [llvm] r83873 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910121901.n9CJ1Dib019874@zion.cs.uiuc.edu> Author: bwilson Date: Mon Oct 12 14:01:12 2009 New Revision: 83873 URL: http://llvm.org/viewvc/llvm-project?rev=83873&view=rev Log: Change to return a value by reference. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=83873&r1=83872&r2=83873&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Oct 12 14:01:12 2009 @@ -164,7 +164,7 @@ bool DecrementOldEntry(unsigned CPI, MachineInstr* CPEMI); int LookForExistingCPEntry(CPUser& U, unsigned UserOffset); bool LookForWater(CPUser&U, unsigned UserOffset, - MachineBasicBlock** NewMBB); + MachineBasicBlock *&NewMBB); MachineBasicBlock* AcceptWater(MachineBasicBlock *WaterBB, water_iterator IP); void CreateNewWater(unsigned CPUserIndex, unsigned UserOffset, @@ -947,13 +947,13 @@ /// LookForWater - look for an existing entry in the WaterList in which /// we can place the CPE referenced from U so it's within range of U's MI. -/// Returns true if found, false if not. If it returns true, *NewMBB +/// Returns true if found, false if not. If it returns true, NewMBB /// is set to the WaterList entry. /// For ARM, we prefer the water that's farthest away. For Thumb, prefer /// water that will not introduce padding to water that will; within each /// group, prefer the water that's farthest away. bool ARMConstantIslands::LookForWater(CPUser &U, unsigned UserOffset, - MachineBasicBlock** NewMBB) { + MachineBasicBlock *&NewMBB) { water_iterator IPThatWouldPad; MachineBasicBlock* WaterBBThatWouldPad = NULL; if (!WaterList.empty()) { @@ -971,7 +971,7 @@ IPThatWouldPad = IP; } } else { - *NewMBB = AcceptWater(WaterBB, IP); + NewMBB = AcceptWater(WaterBB, IP); return true; } } @@ -980,7 +980,7 @@ } } if (isThumb && WaterBBThatWouldPad) { - *NewMBB = AcceptWater(WaterBBThatWouldPad, IPThatWouldPad); + NewMBB = AcceptWater(WaterBBThatWouldPad, IPThatWouldPad); return true; } return false; @@ -1114,7 +1114,7 @@ // away that will work. Forward references only for now (although later // we might find some that are backwards). - if (!LookForWater(U, UserOffset, &NewMBB)) { + if (!LookForWater(U, UserOffset, NewMBB)) { // No water found. DEBUG(errs() << "No water found\n"); CreateNewWater(CPUserIndex, UserOffset, &NewMBB); From bob.wilson at apple.com Mon Oct 12 14:04:03 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 12 Oct 2009 19:04:03 -0000 Subject: [llvm-commits] [llvm] r83874 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910121904.n9CJ43OL020135@zion.cs.uiuc.edu> Author: bwilson Date: Mon Oct 12 14:04:03 2009 New Revision: 83874 URL: http://llvm.org/viewvc/llvm-project?rev=83874&view=rev Log: Use early exit to reduce indentation. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=83874&r1=83873&r2=83874&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Oct 12 14:04:03 2009 @@ -956,28 +956,29 @@ MachineBasicBlock *&NewMBB) { water_iterator IPThatWouldPad; MachineBasicBlock* WaterBBThatWouldPad = NULL; - if (!WaterList.empty()) { - for (water_iterator IP = prior(WaterList.end()), - B = WaterList.begin();; --IP) { - MachineBasicBlock* WaterBB = *IP; - if (WaterIsInRange(UserOffset, WaterBB, U)) { - unsigned WBBId = WaterBB->getNumber(); - if (isThumb && - (BBOffsets[WBBId] + BBSizes[WBBId])%4 != 0) { - // This is valid Water, but would introduce padding. Remember - // it in case we don't find any Water that doesn't do this. - if (!WaterBBThatWouldPad) { - WaterBBThatWouldPad = WaterBB; - IPThatWouldPad = IP; - } - } else { - NewMBB = AcceptWater(WaterBB, IP); - return true; + if (WaterList.empty()) + return false; + + for (water_iterator IP = prior(WaterList.end()), + B = WaterList.begin();; --IP) { + MachineBasicBlock* WaterBB = *IP; + if (WaterIsInRange(UserOffset, WaterBB, U)) { + unsigned WBBId = WaterBB->getNumber(); + if (isThumb && + (BBOffsets[WBBId] + BBSizes[WBBId])%4 != 0) { + // This is valid Water, but would introduce padding. Remember + // it in case we don't find any Water that doesn't do this. + if (!WaterBBThatWouldPad) { + WaterBBThatWouldPad = WaterBB; + IPThatWouldPad = IP; } + } else { + NewMBB = AcceptWater(WaterBB, IP); + return true; } - if (IP == B) - break; } + if (IP == B) + break; } if (isThumb && WaterBBThatWouldPad) { NewMBB = AcceptWater(WaterBBThatWouldPad, IPThatWouldPad); From baldrick at free.fr Mon Oct 12 14:31:15 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 12 Oct 2009 19:31:15 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r83875 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Message-ID: <200910121931.n9CJVFbP021229@zion.cs.uiuc.edu> Author: baldrick Date: Mon Oct 12 14:31:15 2009 New Revision: 83875 URL: http://llvm.org/viewvc/llvm-project?rev=83875&view=rev Log: Port of dragonegg commit 83637: Remove useless value names ("tmp") - these are not helpful, and they fatten the bitcode. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=83875&r1=83874&r2=83875&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Oct 12 14:31:15 2009 @@ -62,7 +62,7 @@ case IX86_BUILTIN_PADDW128: case IX86_BUILTIN_PADDD128: case IX86_BUILTIN_PADDQ128: - Result = Builder.CreateAdd(Ops[0], Ops[1], "tmp"); + Result = Builder.CreateAdd(Ops[0], Ops[1]); return true; case IX86_BUILTIN_SUBPS: case IX86_BUILTIN_SUBPD: @@ -74,34 +74,34 @@ case IX86_BUILTIN_PSUBW128: case IX86_BUILTIN_PSUBD128: case IX86_BUILTIN_PSUBQ128: - Result = Builder.CreateSub(Ops[0], Ops[1], "tmp"); + Result = Builder.CreateSub(Ops[0], Ops[1]); return true; case IX86_BUILTIN_MULPS: case IX86_BUILTIN_MULPD: case IX86_BUILTIN_PMULLW: case IX86_BUILTIN_PMULLW128: - Result = Builder.CreateMul(Ops[0], Ops[1], "tmp"); + Result = Builder.CreateMul(Ops[0], Ops[1]); return true; case IX86_BUILTIN_DIVPS: case IX86_BUILTIN_DIVPD: - Result = Builder.CreateFDiv(Ops[0], Ops[1], "tmp"); + Result = Builder.CreateFDiv(Ops[0], Ops[1]); return true; case IX86_BUILTIN_PAND: case IX86_BUILTIN_PAND128: - Result = Builder.CreateAnd(Ops[0], Ops[1], "tmp"); + Result = Builder.CreateAnd(Ops[0], Ops[1]); return true; case IX86_BUILTIN_PANDN: case IX86_BUILTIN_PANDN128: - Ops[0] = Builder.CreateNot(Ops[0], "tmp"); - Result = Builder.CreateAnd(Ops[0], Ops[1], "tmp"); + Ops[0] = Builder.CreateNot(Ops[0]); + Result = Builder.CreateAnd(Ops[0], Ops[1]); return true; case IX86_BUILTIN_POR: case IX86_BUILTIN_POR128: - Result = Builder.CreateOr(Ops[0], Ops[1], "tmp"); + Result = Builder.CreateOr(Ops[0], Ops[1]); return true; case IX86_BUILTIN_PXOR: case IX86_BUILTIN_PXOR128: - Result = Builder.CreateXor(Ops[0], Ops[1], "tmp"); + Result = Builder.CreateXor(Ops[0], Ops[1]); return true; case IX86_BUILTIN_ANDPS: case IX86_BUILTIN_ORPS: @@ -120,27 +120,27 @@ VectorType::get(Type::getInt64Ty(Context), 2), "tmp"); - Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "tmp"); + Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()); switch (FnCode) { case IX86_BUILTIN_ANDPS: case IX86_BUILTIN_ANDPD: - Result = Builder.CreateAnd(Ops[0], Ops[1], "tmp"); + Result = Builder.CreateAnd(Ops[0], Ops[1]); break; case IX86_BUILTIN_ORPS: case IX86_BUILTIN_ORPD: - Result = Builder.CreateOr (Ops[0], Ops[1], "tmp"); + Result = Builder.CreateOr (Ops[0], Ops[1]); break; case IX86_BUILTIN_XORPS: case IX86_BUILTIN_XORPD: - Result = Builder.CreateXor(Ops[0], Ops[1], "tmp"); + Result = Builder.CreateXor(Ops[0], Ops[1]); break; case IX86_BUILTIN_ANDNPS: case IX86_BUILTIN_ANDNPD: - Ops[0] = Builder.CreateNot(Ops[0], "tmp"); - Result = Builder.CreateAnd(Ops[0], Ops[1], "tmp"); + Ops[0] = Builder.CreateNot(Ops[0]); + Result = Builder.CreateAnd(Ops[0], Ops[1]); break; } - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); + Result = Builder.CreateBitCast(Result, ResultType); return true; case IX86_BUILTIN_SHUFPS: if (ConstantInt *Elt = dyn_cast(Ops[2])) { @@ -280,20 +280,20 @@ } case IX86_BUILTIN_LOADQ: { PointerType *i64Ptr = PointerType::getUnqual(Type::getInt64Ty(Context)); - Ops[0] = Builder.CreateBitCast(Ops[0], i64Ptr, "tmp"); - Ops[0] = Builder.CreateLoad(Ops[0], "tmp"); + Ops[0] = Builder.CreateBitCast(Ops[0], i64Ptr); + Ops[0] = Builder.CreateLoad(Ops[0]); Value *Zero = ConstantInt::get(Type::getInt64Ty(Context), 0); Result = BuildVector(Zero, Zero, NULL); Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), 0); - Result = Builder.CreateInsertElement(Result, Ops[0], Idx, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); + Result = Builder.CreateInsertElement(Result, Ops[0], Idx); + Result = Builder.CreateBitCast(Result, ResultType); return true; } case IX86_BUILTIN_LOADUPS: { VectorType *v4f32 = VectorType::get(Type::getFloatTy(Context), 4); PointerType *v4f32Ptr = PointerType::getUnqual(v4f32); - Value *BC = Builder.CreateBitCast(Ops[0], v4f32Ptr, "tmp"); - LoadInst *LI = Builder.CreateLoad(BC, "tmp"); + Value *BC = Builder.CreateBitCast(Ops[0], v4f32Ptr); + LoadInst *LI = Builder.CreateLoad(BC); LI->setAlignment(1); Result = LI; return true; @@ -301,8 +301,8 @@ case IX86_BUILTIN_LOADUPD: { VectorType *v2f64 = VectorType::get(Type::getDoubleTy(Context), 2); PointerType *v2f64Ptr = PointerType::getUnqual(v2f64); - Value *BC = Builder.CreateBitCast(Ops[0], v2f64Ptr, "tmp"); - LoadInst *LI = Builder.CreateLoad(BC, "tmp"); + Value *BC = Builder.CreateBitCast(Ops[0], v2f64Ptr); + LoadInst *LI = Builder.CreateLoad(BC); LI->setAlignment(1); Result = LI; return true; @@ -310,8 +310,8 @@ case IX86_BUILTIN_LOADDQU: { VectorType *v16i8 = VectorType::get(Type::getInt8Ty(Context), 16); PointerType *v16i8Ptr = PointerType::getUnqual(v16i8); - Value *BC = Builder.CreateBitCast(Ops[0], v16i8Ptr, "tmp"); - LoadInst *LI = Builder.CreateLoad(BC, "tmp"); + Value *BC = Builder.CreateBitCast(Ops[0], v16i8Ptr); + LoadInst *LI = Builder.CreateLoad(BC); LI->setAlignment(1); Result = LI; return true; @@ -319,7 +319,7 @@ case IX86_BUILTIN_STOREUPS: { VectorType *v4f32 = VectorType::get(Type::getFloatTy(Context), 4); PointerType *v4f32Ptr = PointerType::getUnqual(v4f32); - Value *BC = Builder.CreateBitCast(Ops[0], v4f32Ptr, "tmp"); + Value *BC = Builder.CreateBitCast(Ops[0], v4f32Ptr); StoreInst *SI = Builder.CreateStore(Ops[1], BC); SI->setAlignment(1); Result = SI; @@ -328,7 +328,7 @@ case IX86_BUILTIN_STOREUPD: { VectorType *v2f64 = VectorType::get(Type::getDoubleTy(Context), 2); PointerType *v2f64Ptr = PointerType::getUnqual(v2f64); - Value *BC = Builder.CreateBitCast(Ops[0], v2f64Ptr, "tmp"); + Value *BC = Builder.CreateBitCast(Ops[0], v2f64Ptr); StoreInst *SI = Builder.CreateStore(Ops[1], BC); SI->setAlignment(1); Result = SI; @@ -337,7 +337,7 @@ case IX86_BUILTIN_STOREDQU: { VectorType *v16i8 = VectorType::get(Type::getInt8Ty(Context), 16); PointerType *v16i8Ptr = PointerType::getUnqual(v16i8); - Value *BC = Builder.CreateBitCast(Ops[0], v16i8Ptr, "tmp"); + Value *BC = Builder.CreateBitCast(Ops[0], v16i8Ptr); StoreInst *SI = Builder.CreateStore(Ops[1], BC); SI->setAlignment(1); Result = SI; @@ -345,57 +345,57 @@ } case IX86_BUILTIN_LOADHPS: { PointerType *f64Ptr = PointerType::getUnqual(Type::getDoubleTy(Context)); - Ops[1] = Builder.CreateBitCast(Ops[1], f64Ptr, "tmp"); - Value *Load = Builder.CreateLoad(Ops[1], "tmp"); + Ops[1] = Builder.CreateBitCast(Ops[1], f64Ptr); + Value *Load = Builder.CreateLoad(Ops[1]); Ops[1] = BuildVector(Load, UndefValue::get(Type::getDoubleTy(Context)), NULL); - Ops[1] = Builder.CreateBitCast(Ops[1], ResultType, "tmp"); + Ops[1] = Builder.CreateBitCast(Ops[1], ResultType); Result = BuildVectorShuffle(Ops[0], Ops[1], 0, 1, 4, 5); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); + Result = Builder.CreateBitCast(Result, ResultType); return true; } case IX86_BUILTIN_LOADLPS: { PointerType *f64Ptr = PointerType::getUnqual(Type::getDoubleTy(Context)); - Ops[1] = Builder.CreateBitCast(Ops[1], f64Ptr, "tmp"); - Value *Load = Builder.CreateLoad(Ops[1], "tmp"); + Ops[1] = Builder.CreateBitCast(Ops[1], f64Ptr); + Value *Load = Builder.CreateLoad(Ops[1]); Ops[1] = BuildVector(Load, UndefValue::get(Type::getDoubleTy(Context)), NULL); - Ops[1] = Builder.CreateBitCast(Ops[1], ResultType, "tmp"); + Ops[1] = Builder.CreateBitCast(Ops[1], ResultType); Result = BuildVectorShuffle(Ops[0], Ops[1], 4, 5, 2, 3); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); + Result = Builder.CreateBitCast(Result, ResultType); return true; } case IX86_BUILTIN_LOADHPD: { - Value *Load = Builder.CreateLoad(Ops[1], "tmp"); + Value *Load = Builder.CreateLoad(Ops[1]); Ops[1] = BuildVector(Load, UndefValue::get(Type::getDoubleTy(Context)), NULL); - Ops[1] = Builder.CreateBitCast(Ops[1], ResultType, "tmp"); + Ops[1] = Builder.CreateBitCast(Ops[1], ResultType); Result = BuildVectorShuffle(Ops[0], Ops[1], 0, 2); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); + Result = Builder.CreateBitCast(Result, ResultType); return true; } case IX86_BUILTIN_LOADLPD: { - Value *Load = Builder.CreateLoad(Ops[1], "tmp"); + Value *Load = Builder.CreateLoad(Ops[1]); Ops[1] = BuildVector(Load, UndefValue::get(Type::getDoubleTy(Context)), NULL); - Ops[1] = Builder.CreateBitCast(Ops[1], ResultType, "tmp"); + Ops[1] = Builder.CreateBitCast(Ops[1], ResultType); Result = BuildVectorShuffle(Ops[0], Ops[1], 2, 1); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); + Result = Builder.CreateBitCast(Result, ResultType); return true; } case IX86_BUILTIN_STOREHPS: { VectorType *v2f64 = VectorType::get(Type::getDoubleTy(Context), 2); PointerType *f64Ptr = PointerType::getUnqual(Type::getDoubleTy(Context)); - Ops[0] = Builder.CreateBitCast(Ops[0], f64Ptr, "tmp"); + Ops[0] = Builder.CreateBitCast(Ops[0], f64Ptr); Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), 1); - Ops[1] = Builder.CreateBitCast(Ops[1], v2f64, "tmp"); - Ops[1] = Builder.CreateExtractElement(Ops[1], Idx, "tmp"); + Ops[1] = Builder.CreateBitCast(Ops[1], v2f64); + Ops[1] = Builder.CreateExtractElement(Ops[1], Idx); Result = Builder.CreateStore(Ops[1], Ops[0]); return true; } case IX86_BUILTIN_STORELPS: { VectorType *v2f64 = VectorType::get(Type::getDoubleTy(Context), 2); PointerType *f64Ptr = PointerType::getUnqual(Type::getDoubleTy(Context)); - Ops[0] = Builder.CreateBitCast(Ops[0], f64Ptr, "tmp"); + Ops[0] = Builder.CreateBitCast(Ops[0], f64Ptr); Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), 0); - Ops[1] = Builder.CreateBitCast(Ops[1], v2f64, "tmp"); - Ops[1] = Builder.CreateExtractElement(Ops[1], Idx, "tmp"); + Ops[1] = Builder.CreateBitCast(Ops[1], v2f64); + Ops[1] = Builder.CreateExtractElement(Ops[1], Idx); Result = Builder.CreateStore(Ops[1], Ops[0]); return true; } @@ -411,13 +411,13 @@ case IX86_BUILTIN_VEC_INIT_V4HI: // Sometimes G++ promotes arguments to int. for (unsigned i = 0; i != 4; ++i) - Ops[i] = Builder.CreateIntCast(Ops[i], Type::getInt16Ty(Context), false, "tmp"); + Ops[i] = Builder.CreateIntCast(Ops[i], Type::getInt16Ty(Context), false); Result = BuildVector(Ops[0], Ops[1], Ops[2], Ops[3], NULL); return true; case IX86_BUILTIN_VEC_INIT_V8QI: // Sometimes G++ promotes arguments to int. for (unsigned i = 0; i != 8; ++i) - Ops[i] = Builder.CreateIntCast(Ops[i], Type::getInt8Ty(Context), false, "tmp"); + Ops[i] = Builder.CreateIntCast(Ops[i], Type::getInt8Ty(Context), false); Result = BuildVector(Ops[0], Ops[1], Ops[2], Ops[3], Ops[4], Ops[5], Ops[6], Ops[7], NULL); return true; @@ -429,24 +429,24 @@ case IX86_BUILTIN_VEC_EXT_V4SF: case IX86_BUILTIN_VEC_EXT_V8HI: case IX86_BUILTIN_VEC_EXT_V16QI: - Result = Builder.CreateExtractElement(Ops[0], Ops[1], "tmp"); + Result = Builder.CreateExtractElement(Ops[0], Ops[1]); return true; case IX86_BUILTIN_VEC_SET_V16QI: // Sometimes G++ promotes arguments to int. - Ops[1] = Builder.CreateIntCast(Ops[1], Type::getInt8Ty(Context), false, "tmp"); - Result = Builder.CreateInsertElement(Ops[0], Ops[1], Ops[2], "tmp"); + Ops[1] = Builder.CreateIntCast(Ops[1], Type::getInt8Ty(Context), false); + Result = Builder.CreateInsertElement(Ops[0], Ops[1], Ops[2]); return true; case IX86_BUILTIN_VEC_SET_V4HI: case IX86_BUILTIN_VEC_SET_V8HI: // GCC sometimes doesn't produce the right element type. - Ops[1] = Builder.CreateIntCast(Ops[1], Type::getInt16Ty(Context), false, "tmp"); - Result = Builder.CreateInsertElement(Ops[0], Ops[1], Ops[2], "tmp"); + Ops[1] = Builder.CreateIntCast(Ops[1], Type::getInt16Ty(Context), false); + Result = Builder.CreateInsertElement(Ops[0], Ops[1], Ops[2]); return true; case IX86_BUILTIN_VEC_SET_V4SI: - Result = Builder.CreateInsertElement(Ops[0], Ops[1], Ops[2], "tmp"); + Result = Builder.CreateInsertElement(Ops[0], Ops[1], Ops[2]); return true; case IX86_BUILTIN_VEC_SET_V2DI: - Result = Builder.CreateInsertElement(Ops[0], Ops[1], Ops[2], "tmp"); + Result = Builder.CreateInsertElement(Ops[0], Ops[1], Ops[2]); return true; case IX86_BUILTIN_CMPEQPS: case IX86_BUILTIN_CMPLTPS: @@ -484,8 +484,8 @@ Value *Arg1 = Ops[1]; if (flip) std::swap(Arg0, Arg1); Value *CallOps[3] = { Arg0, Arg1, Pred }; - Result = Builder.CreateCall(cmpps, CallOps, CallOps+3, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); + Result = Builder.CreateCall(cmpps, CallOps, CallOps+3); + Result = Builder.CreateBitCast(Result, ResultType); return true; } case IX86_BUILTIN_CMPEQSS: @@ -514,8 +514,8 @@ } Value *Pred = ConstantInt::get(Type::getInt8Ty(Context), PredCode); Value *CallOps[3] = { Ops[0], Ops[1], Pred }; - Result = Builder.CreateCall(cmpss, CallOps, CallOps+3, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); + Result = Builder.CreateCall(cmpss, CallOps, CallOps+3); + Result = Builder.CreateBitCast(Result, ResultType); return true; } case IX86_BUILTIN_CMPEQPD: @@ -555,8 +555,8 @@ if (flip) std::swap(Arg0, Arg1); Value *CallOps[3] = { Arg0, Arg1, Pred }; - Result = Builder.CreateCall(cmppd, CallOps, CallOps+3, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); + Result = Builder.CreateCall(cmppd, CallOps, CallOps+3); + Result = Builder.CreateBitCast(Result, ResultType); return true; } case IX86_BUILTIN_CMPEQSD: @@ -583,8 +583,8 @@ } Value *Pred = ConstantInt::get(Type::getInt8Ty(Context), PredCode); Value *CallOps[3] = { Ops[0], Ops[1], Pred }; - Result = Builder.CreateCall(cmpsd, CallOps, CallOps+3, "tmp"); - Result = Builder.CreateBitCast(Result, ResultType, "tmp"); + Result = Builder.CreateCall(cmpsd, CallOps, CallOps+3); + Result = Builder.CreateBitCast(Result, ResultType); return true; } case IX86_BUILTIN_LDMXCSR: { @@ -593,7 +593,7 @@ Value *Ptr = CreateTemporary(Type::getInt32Ty(Context)); Builder.CreateStore(Ops[0], Ptr); Ptr = Builder.CreateBitCast(Ptr, - PointerType::getUnqual(Type::getInt8Ty(Context)), "tmp"); + PointerType::getUnqual(Type::getInt8Ty(Context))); Result = Builder.CreateCall(ldmxcsr, Ptr); return true; } @@ -602,10 +602,10 @@ Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse_stmxcsr); Value *Ptr = CreateTemporary(Type::getInt32Ty(Context)); Value *BPtr = Builder.CreateBitCast(Ptr, - PointerType::getUnqual(Type::getInt8Ty(Context)), "tmp"); + PointerType::getUnqual(Type::getInt8Ty(Context))); Builder.CreateCall(stmxcsr, BPtr); - Result = Builder.CreateLoad(Ptr, "tmp"); + Result = Builder.CreateLoad(Ptr); return true; } } From baldrick at free.fr Mon Oct 12 14:35:13 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 12 Oct 2009 19:35:13 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r83876 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386.cpp llvm-abi.h llvm-backend.cpp llvm-convert.cpp llvm-types.cpp Message-ID: <200910121935.n9CJZE6h021494@zion.cs.uiuc.edu> Author: baldrick Date: Mon Oct 12 14:35:13 2009 New Revision: 83876 URL: http://llvm.org/viewvc/llvm-project?rev=83876&view=rev Log: Port of dragonegg commit 83402: Simplify the creation of pointer types. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi.h llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=83876&r1=83875&r2=83876&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Oct 12 14:35:13 2009 @@ -279,7 +279,7 @@ return true; } case IX86_BUILTIN_LOADQ: { - PointerType *i64Ptr = PointerType::getUnqual(Type::getInt64Ty(Context)); + const PointerType *i64Ptr = Type::getInt64PtrTy(Context); Ops[0] = Builder.CreateBitCast(Ops[0], i64Ptr); Ops[0] = Builder.CreateLoad(Ops[0]); Value *Zero = ConstantInt::get(Type::getInt64Ty(Context), 0); @@ -291,7 +291,7 @@ } case IX86_BUILTIN_LOADUPS: { VectorType *v4f32 = VectorType::get(Type::getFloatTy(Context), 4); - PointerType *v4f32Ptr = PointerType::getUnqual(v4f32); + const PointerType *v4f32Ptr = v4f32->getPointerTo(); Value *BC = Builder.CreateBitCast(Ops[0], v4f32Ptr); LoadInst *LI = Builder.CreateLoad(BC); LI->setAlignment(1); @@ -300,7 +300,7 @@ } case IX86_BUILTIN_LOADUPD: { VectorType *v2f64 = VectorType::get(Type::getDoubleTy(Context), 2); - PointerType *v2f64Ptr = PointerType::getUnqual(v2f64); + const PointerType *v2f64Ptr = v2f64->getPointerTo(); Value *BC = Builder.CreateBitCast(Ops[0], v2f64Ptr); LoadInst *LI = Builder.CreateLoad(BC); LI->setAlignment(1); @@ -309,7 +309,7 @@ } case IX86_BUILTIN_LOADDQU: { VectorType *v16i8 = VectorType::get(Type::getInt8Ty(Context), 16); - PointerType *v16i8Ptr = PointerType::getUnqual(v16i8); + const PointerType *v16i8Ptr = v16i8->getPointerTo(); Value *BC = Builder.CreateBitCast(Ops[0], v16i8Ptr); LoadInst *LI = Builder.CreateLoad(BC); LI->setAlignment(1); @@ -318,7 +318,7 @@ } case IX86_BUILTIN_STOREUPS: { VectorType *v4f32 = VectorType::get(Type::getFloatTy(Context), 4); - PointerType *v4f32Ptr = PointerType::getUnqual(v4f32); + const PointerType *v4f32Ptr = v4f32->getPointerTo(); Value *BC = Builder.CreateBitCast(Ops[0], v4f32Ptr); StoreInst *SI = Builder.CreateStore(Ops[1], BC); SI->setAlignment(1); @@ -327,7 +327,7 @@ } case IX86_BUILTIN_STOREUPD: { VectorType *v2f64 = VectorType::get(Type::getDoubleTy(Context), 2); - PointerType *v2f64Ptr = PointerType::getUnqual(v2f64); + const PointerType *v2f64Ptr = v2f64->getPointerTo(); Value *BC = Builder.CreateBitCast(Ops[0], v2f64Ptr); StoreInst *SI = Builder.CreateStore(Ops[1], BC); SI->setAlignment(1); @@ -336,7 +336,7 @@ } case IX86_BUILTIN_STOREDQU: { VectorType *v16i8 = VectorType::get(Type::getInt8Ty(Context), 16); - PointerType *v16i8Ptr = PointerType::getUnqual(v16i8); + const PointerType *v16i8Ptr = v16i8->getPointerTo(); Value *BC = Builder.CreateBitCast(Ops[0], v16i8Ptr); StoreInst *SI = Builder.CreateStore(Ops[1], BC); SI->setAlignment(1); @@ -344,7 +344,7 @@ return true; } case IX86_BUILTIN_LOADHPS: { - PointerType *f64Ptr = PointerType::getUnqual(Type::getDoubleTy(Context)); + const PointerType *f64Ptr = Type::getDoublePtrTy(Context); Ops[1] = Builder.CreateBitCast(Ops[1], f64Ptr); Value *Load = Builder.CreateLoad(Ops[1]); Ops[1] = BuildVector(Load, UndefValue::get(Type::getDoubleTy(Context)), NULL); @@ -354,7 +354,7 @@ return true; } case IX86_BUILTIN_LOADLPS: { - PointerType *f64Ptr = PointerType::getUnqual(Type::getDoubleTy(Context)); + const PointerType *f64Ptr = Type::getDoublePtrTy(Context); Ops[1] = Builder.CreateBitCast(Ops[1], f64Ptr); Value *Load = Builder.CreateLoad(Ops[1]); Ops[1] = BuildVector(Load, UndefValue::get(Type::getDoubleTy(Context)), NULL); @@ -381,7 +381,7 @@ } case IX86_BUILTIN_STOREHPS: { VectorType *v2f64 = VectorType::get(Type::getDoubleTy(Context), 2); - PointerType *f64Ptr = PointerType::getUnqual(Type::getDoubleTy(Context)); + const PointerType *f64Ptr = Type::getDoublePtrTy(Context); Ops[0] = Builder.CreateBitCast(Ops[0], f64Ptr); Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), 1); Ops[1] = Builder.CreateBitCast(Ops[1], v2f64); @@ -391,7 +391,7 @@ } case IX86_BUILTIN_STORELPS: { VectorType *v2f64 = VectorType::get(Type::getDoubleTy(Context), 2); - PointerType *f64Ptr = PointerType::getUnqual(Type::getDoubleTy(Context)); + const PointerType *f64Ptr = Type::getDoublePtrTy(Context); Ops[0] = Builder.CreateBitCast(Ops[0], f64Ptr); Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), 0); Ops[1] = Builder.CreateBitCast(Ops[1], v2f64); @@ -592,8 +592,7 @@ Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse_ldmxcsr); Value *Ptr = CreateTemporary(Type::getInt32Ty(Context)); Builder.CreateStore(Ops[0], Ptr); - Ptr = Builder.CreateBitCast(Ptr, - PointerType::getUnqual(Type::getInt8Ty(Context))); + Ptr = Builder.CreateBitCast(Ptr, Type::getInt8PtrTy(Context)); Result = Builder.CreateCall(ldmxcsr, Ptr); return true; } @@ -601,8 +600,7 @@ Function *stmxcsr = Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse_stmxcsr); Value *Ptr = CreateTemporary(Type::getInt32Ty(Context)); - Value *BPtr = Builder.CreateBitCast(Ptr, - PointerType::getUnqual(Type::getInt8Ty(Context))); + Value *BPtr = Builder.CreateBitCast(Ptr, Type::getInt8PtrTy(Context)); Builder.CreateCall(stmxcsr, BPtr); Result = Builder.CreateLoad(Ptr); Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=83876&r1=83875&r2=83876&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Mon Oct 12 14:35:13 2009 @@ -390,7 +390,7 @@ if (ScalarType) C.HandleAggregateResultAsScalar(ConvertType(ScalarType)); else if (LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(type, isBuiltin)) - C.HandleScalarShadowResult(PointerType::getUnqual(Ty), false); + C.HandleScalarShadowResult(Ty->getPointerTo(), false); else C.HandleScalarResult(Ty); } else if (Ty->isSingleValueType() || Ty == Type::getVoidTy(getGlobalContext())) { @@ -422,7 +422,7 @@ // FIXME: should return the hidden first argument for some targets // (e.g. ELF i386). - C.HandleAggregateShadowResult(PointerType::getUnqual(Ty), false); + C.HandleAggregateShadowResult(Ty->getPointerTo(), false); } } @@ -445,7 +445,7 @@ C.HandleScalarArgument(OpTy, type); ScalarElts.push_back(OpTy); } else if (isPassedByInvisibleReference(type)) { // variable size -> by-ref. - const Type *PtrTy = PointerType::getUnqual(Ty); + const Type *PtrTy = Ty->getPointerTo(); C.HandleByInvisibleReferenceArgument(PtrTy, type); ScalarElts.push_back(PtrTy); } else if (isa(Ty)) { @@ -746,7 +746,7 @@ if (ScalarType) C.HandleAggregateResultAsScalar(ConvertType(ScalarType)); else if (LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(type, isBuiltin)) - C.HandleScalarShadowResult(PointerType::getUnqual(Ty), false); + C.HandleScalarShadowResult(Ty->getPointerTo(), false); else C.HandleScalarResult(Ty); } else if (Ty->isSingleValueType() || Ty == Type::getVoidTy(getGlobalContext())) { @@ -778,7 +778,7 @@ // FIXME: should return the hidden first argument for some targets // (e.g. ELF i386). - C.HandleAggregateShadowResult(PointerType::getUnqual(Ty), false); + C.HandleAggregateShadowResult(Ty->getPointerTo(), false); } } @@ -812,7 +812,7 @@ // not include variable sized fields here. std::vector Elts; if (isPassedByInvisibleReference(type)) { // variable size -> by-ref. - const Type *PtrTy = PointerType::getUnqual(Ty); + const Type *PtrTy = Ty->getPointerTo(); C.HandleByInvisibleReferenceArgument(PtrTy, type); ScalarElts.push_back(PtrTy); Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=83876&r1=83875&r2=83876&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Oct 12 14:35:13 2009 @@ -822,7 +822,7 @@ const Type *FPTy = FunctionType::get(Type::getVoidTy(Context), std::vector(), false); - FPTy = PointerType::getUnqual(FPTy); + FPTy = FPTy->getPointerTo(); for (unsigned i = 0, e = Tors.size(); i != e; ++i) { StructInit[0] = ConstantInt::get(Type::getInt32Ty(Context), Tors[i].second); @@ -861,7 +861,7 @@ if (!AttributeUsedGlobals.empty()) { std::vector AUGs; - const Type *SBP= PointerType::getUnqual(Type::getInt8Ty(Context)); + const Type *SBP= Type::getInt8PtrTy(Context); for (SmallSetVector::iterator AI = AttributeUsedGlobals.begin(), AE = AttributeUsedGlobals.end(); AI != AE; ++AI) { @@ -880,7 +880,7 @@ if (!AttributeCompilerUsedGlobals.empty()) { std::vector ACUGs; - const Type *SBP= PointerType::getUnqual(Type::getInt8Ty(Context)); + const Type *SBP= Type::getInt8PtrTy(Context); for (SmallSetVector::iterator AI = AttributeCompilerUsedGlobals.begin(), AE = AttributeCompilerUsedGlobals.end(); AI != AE; ++AI) { @@ -1158,7 +1158,7 @@ Constant *lineNo = ConstantInt::get(Type::getInt32Ty(Context), DECL_SOURCE_LINE(decl)); Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl)); - const Type *SBP= PointerType::getUnqual(Type::getInt8Ty(Context)); + const Type *SBP= Type::getInt8PtrTy(Context); file = TheFolder->CreateBitCast(file, SBP); // There may be multiple annotate attributes. Pass return of lookup_attr Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=83876&r1=83875&r2=83876&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Oct 12 14:35:13 2009 @@ -229,7 +229,7 @@ Builder.CreateStore(ArgVal, Loc); } else { // This cast only involves pointers, therefore BitCast. - Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(LLVMTy)); + Loc = Builder.CreateBitCast(Loc, LLVMTy->getPointerTo()); Builder.CreateStore(ArgVal, Loc); } } @@ -374,7 +374,7 @@ Value *Loc = LocStack.back(); // This cast only involves pointers, therefore BitCast. - Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(StructTy)); + Loc = Builder.CreateBitCast(Loc, StructTy->getPointerTo()); Loc = Builder.CreateStructGEP(Loc, FieldNo); LocStack.push_back(Loc); @@ -665,7 +665,7 @@ } else { Value *RetVal = DECL_LLVM(DECL_RESULT(FnDecl)); if (const StructType *STy = dyn_cast(Fn->getReturnType())) { - Value *R1 = BitCastToType(RetVal, PointerType::getUnqual(STy)); + Value *R1 = BitCastToType(RetVal, STy->getPointerTo()); llvm::Value *Idxs[2]; Idxs[0] = ConstantInt::get(llvm::Type::getInt32Ty(Context), 0); @@ -683,12 +683,11 @@ // beginning of the aggregate (x86-64). if (ReturnOffset) { RetVal = BitCastToType(RetVal, - PointerType::getUnqual(Type::getInt8Ty(Context))); + Type::getInt8PtrTy(Context)); RetVal = Builder.CreateGEP(RetVal, ConstantInt::get(TD.getIntPtrType(Context), ReturnOffset)); } - RetVal = BitCastToType(RetVal, - PointerType::getUnqual(Fn->getReturnType())); + RetVal = BitCastToType(RetVal, Fn->getReturnType()->getPointerTo()); RetVal = Builder.CreateLoad(RetVal, "retval"); RetVals.push_back(RetVal); } @@ -1340,9 +1339,9 @@ // Don't copy tons of tiny elements. NumElts <= 8) { DestLoc.Ptr = BitCastToType(DestLoc.Ptr, - PointerType::getUnqual(LLVMTy)); + LLVMTy->getPointerTo()); SrcLoc.Ptr = BitCastToType(SrcLoc.Ptr, - PointerType::getUnqual(LLVMTy)); + LLVMTy->getPointerTo()); CopyAggregate(DestLoc, SrcLoc, Builder, type); return; } @@ -1395,7 +1394,7 @@ // Don't zero tons of tiny elements. CountAggregateElements(LLVMTy) <= 8) { DestLoc.Ptr = BitCastToType(DestLoc.Ptr, - PointerType::getUnqual(LLVMTy)); + LLVMTy->getPointerTo()); ZeroAggregate(DestLoc, Builder); return; } @@ -1407,7 +1406,7 @@ Value *TreeToLLVM::EmitMemCpy(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align) { - const Type *SBP = PointerType::getUnqual(Type::getInt8Ty(Context)); + const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); Value *Ops[4] = { BitCastToType(DestPtr, SBP), @@ -1423,7 +1422,7 @@ Value *TreeToLLVM::EmitMemMove(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align) { - const Type *SBP = PointerType::getUnqual(Type::getInt8Ty(Context)); + const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); Value *Ops[4] = { BitCastToType(DestPtr, SBP), @@ -1439,7 +1438,7 @@ Value *TreeToLLVM::EmitMemSet(Value *DestPtr, Value *SrcVal, Value *Size, unsigned Align) { - const Type *SBP = PointerType::getUnqual(Type::getInt8Ty(Context)); + const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); Value *Ops[4] = { BitCastToType(DestPtr, SBP), @@ -1464,8 +1463,8 @@ // The idea is that it's a pointer to type "Value" // which is opaque* but the routine expects i8** and i8*. - const PointerType *Ty = PointerType::getUnqual(Type::getInt8Ty(Context)); - V = Builder.CreateBitCast(V, PointerType::getUnqual(Ty)); + const PointerType *Ty = Type::getInt8PtrTy(Context); + V = Builder.CreateBitCast(V, Ty->getPointerTo()); Value *Ops[2] = { V, @@ -1491,7 +1490,7 @@ Constant *lineNo = ConstantInt::get(Type::getInt32Ty(Context), DECL_SOURCE_LINE(decl)); Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl)); - const Type *SBP= PointerType::getUnqual(Type::getInt8Ty(Context)); + const Type *SBP= Type::getInt8PtrTy(Context); file = Builder.getFolder().CreateBitCast(file, SBP); // There may be multiple annotate attributes. Pass return of lookup_attr @@ -1511,7 +1510,7 @@ // Assert its a string, and then get that string. assert(TREE_CODE(val) == STRING_CST && "Annotate attribute arg should always be a string"); - const Type *SBP = PointerType::getUnqual(Type::getInt8Ty(Context)); + const Type *SBP = Type::getInt8PtrTy(Context); Constant *strGV = TreeConstantToLLVM::EmitLV_STRING_CST(val); Value *Ops[4] = { BitCastToType(V, SBP), @@ -1919,7 +1918,7 @@ const Type *IntPtr = TD.getIntPtrType(Context); - ExceptionValue = CreateTemporary(PointerType::getUnqual(Type::getInt8Ty(Context))); + ExceptionValue = CreateTemporary(Type::getInt8PtrTy(Context)); ExceptionValue->setName("eh_exception"); ExceptionSelectorValue = CreateTemporary(IntPtr); @@ -1981,7 +1980,7 @@ assert(llvm_eh_personality_libfunc && "no exception handling personality function!"); Args.push_back(BitCastToType(DECL_LLVM(llvm_eh_personality_libfunc), - PointerType::getUnqual(Type::getInt8Ty(Context)))); + Type::getInt8PtrTy(Context))); // Add selections for each handler. foreach_reachable_handler(i, false, AddHandler, &Handlers); @@ -2013,7 +2012,7 @@ if (!TypeList) { // Catch-all - push a null pointer. Args.push_back( - Constant::getNullValue(PointerType::getUnqual(Type::getInt8Ty(Context))) + Constant::getNullValue(Type::getInt8PtrTy(Context)) ); } else { // Add the type infos. @@ -2040,7 +2039,7 @@ if (catch_all_type == NULL_TREE) // Use a C++ style null catch-all object. CatchAll = Constant::getNullValue( - PointerType::getUnqual(Type::getInt8Ty(Context))); + Type::getInt8PtrTy(Context)); else // This language has a type that catches all others. CatchAll = Emit(catch_all_type, 0); @@ -2104,7 +2103,7 @@ for (; TypeList; TypeList = TREE_CHAIN (TypeList)) { Value *TType = Emit(lookup_type_for_runtime(TREE_VALUE(TypeList)), 0); TType = BitCastToType(TType, - PointerType::getUnqual(Type::getInt8Ty(Context))); + Type::getInt8PtrTy(Context)); // Call get eh type id. Value *TypeID = Builder.CreateCall(FuncEHGetTypeID, TType, "eh_typeid"); @@ -2262,7 +2261,7 @@ if (!LV.isBitfield()) { if (!DestLoc) { // Scalar value: emit a load. - Value *Ptr = BitCastToType(LV.Ptr, PointerType::getUnqual(Ty)); + Value *Ptr = BitCastToType(LV.Ptr, Ty->getPointerTo()); LoadInst *LI = Builder.CreateLoad(Ptr, isVolatile); LI->setAlignment(Alignment); return LI; @@ -2391,7 +2390,7 @@ // If this is a direct call to a function using a static chain then we need // to ensure the function type is the one just calculated: it has an extra // parameter for the chain. - Callee = BitCastToType(Callee, PointerType::getUnqual(Ty)); + Callee = BitCastToType(Callee, Ty->getPointerTo()); // EmitCall(exp, DestLoc); Value *Result = EmitCallOf(Callee, exp, DestLoc, PAL); @@ -2496,7 +2495,7 @@ Value *Loc = LocStack.back(); if (Loc) { // An address. Convert to the right type and load the value out. - Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(Ty)); + Loc = Builder.CreateBitCast(Loc, Ty->getPointerTo()); return Builder.CreateLoad(Loc, "val"); } else { // A value - just return it. @@ -2639,7 +2638,7 @@ /// reference with an additional parameter attribute "ByVal". void HandleByValArgument(const llvm::Type *LLVMTy, tree type) { Value *Loc = getAddress(); - assert(PointerType::getUnqual(LLVMTy) == Loc->getType()); + assert(LLVMTy->getPointerTo() == Loc->getType()); CallOperands.push_back(Loc); } @@ -2647,7 +2646,7 @@ /// argument is passed as a first class aggregate. void HandleFCAArgument(const llvm::Type *LLVMTy, tree type) { Value *Loc = getAddress(); - assert(PointerType::getUnqual(LLVMTy) == Loc->getType()); + assert(LLVMTy->getPointerTo() == Loc->getType()); CallOperands.push_back(Builder.CreateLoad(Loc)); } @@ -2656,7 +2655,7 @@ /// LLVM Struct, StructTy is the LLVM type of the struct we are entering. void EnterField(unsigned FieldNo, const llvm::Type *StructTy) { Value *Loc = getAddress(); - Loc = Builder.CreateBitCast(Loc, PointerType::getUnqual(StructTy)); + Loc = Builder.CreateBitCast(Loc, StructTy->getPointerTo()); pushAddress(Builder.CreateStructGEP(Loc, FieldNo, "elt")); } void ExitField() { @@ -2816,8 +2815,7 @@ return 0; if (Client.isAggrReturn()) { - Value *Dest = BitCastToType(DestLoc->Ptr, - PointerType::getUnqual(Call->getType())); + Value *Dest = BitCastToType(DestLoc->Ptr, Call->getType()->getPointerTo()); LLVM_EXTRACT_MULTIPLE_RETURN_VALUE(Call,Dest,DestLoc->Volatile,Builder); return 0; } @@ -2833,11 +2831,11 @@ Value *Ptr = DestLoc->Ptr; if (Client.Offset) { - Ptr = BitCastToType(Ptr, PointerType::getUnqual(Type::getInt8Ty(Context))); + Ptr = BitCastToType(Ptr, Type::getInt8PtrTy(Context)); Ptr = Builder.CreateGEP(Ptr, ConstantInt::get(TD.getIntPtrType(Context), Client.Offset)); } - Ptr = BitCastToType(Ptr, PointerType::getUnqual(Call->getType())); + Ptr = BitCastToType(Ptr, Call->getType()->getPointerTo()); StoreInst *St = Builder.CreateStore(Call, Ptr, DestLoc->Volatile); St->setAlignment(DestLoc->getAlignment()); return 0; @@ -2967,8 +2965,7 @@ if (PT->getElementType()->canLosslesslyBitCastTo(RHS->getType())) RHS = CastToAnyType(RHS, RHSSigned, PT->getElementType(), LHSSigned); else - LV.Ptr = BitCastToType(LV.Ptr, - PointerType::getUnqual(RHS->getType())); + LV.Ptr = BitCastToType(LV.Ptr, RHS->getType()->getPointerTo()); StoreInst *SI = Builder.CreateStore(RHS, LV.Ptr, isVolatile); SI->setAlignment(Alignment); return RHS; @@ -3080,7 +3077,7 @@ } else if (isAggregateTreeType(TREE_TYPE(Op))) { // Aggregate to aggregate copy. MemRef NewLoc = *DestLoc; - NewLoc.Ptr = BitCastToType(DestLoc->Ptr, PointerType::getUnqual(Ty)); + NewLoc.Ptr = BitCastToType(DestLoc->Ptr, Ty->getPointerTo()); Value *OpVal = Emit(Op, &NewLoc); assert(OpVal == 0 && "Shouldn't cast scalar to aggregate!"); return 0; @@ -3088,8 +3085,7 @@ // Scalar to aggregate copy. Value *OpVal = Emit(Op, 0); - Value *Ptr = BitCastToType(DestLoc->Ptr, - PointerType::getUnqual(OpVal->getType())); + Value *Ptr = BitCastToType(DestLoc->Ptr, OpVal->getType()->getPointerTo()); StoreInst *St = Builder.CreateStore(OpVal, Ptr, DestLoc->Volatile); St->setAlignment(DestLoc->getAlignment()); return 0; @@ -3117,7 +3113,7 @@ // Make the destination look like the source type. const Type *OpTy = ConvertType(TREE_TYPE(Op)); - Target.Ptr = BitCastToType(Target.Ptr, PointerType::getUnqual(OpTy)); + Target.Ptr = BitCastToType(Target.Ptr, OpTy->getPointerTo()); // Needs to be in sync with EmitLV. switch (TREE_CODE(Op)) { @@ -3157,7 +3153,7 @@ // Target holds the temporary created above. const Type *ExpTy = ConvertType(TREE_TYPE(exp)); return Builder.CreateLoad(BitCastToType(Target.Ptr, - PointerType::getUnqual(ExpTy))); + ExpTy->getPointerTo())); } if (DestLoc) { @@ -3165,8 +3161,7 @@ // then store into DestLoc. Value *OpVal = Emit(Op, 0); assert(OpVal && "Expected a scalar result!"); - Value *Ptr = BitCastToType(DestLoc->Ptr, - PointerType::getUnqual(OpVal->getType())); + Value *Ptr = BitCastToType(DestLoc->Ptr, OpVal->getType()->getPointerTo()); StoreInst *St = Builder.CreateStore(OpVal, Ptr, DestLoc->Volatile); St->setAlignment(DestLoc->getAlignment()); return 0; @@ -4478,7 +4473,7 @@ TySize == 32 || TySize == 64) { LLVMTy = IntegerType::get(Context, TySize); Op = Builder.CreateLoad(BitCastToType(LV.Ptr, - PointerType::getUnqual(LLVMTy))); + LLVMTy->getPointerTo())); } else { // Otherwise, emit our value as a lvalue and let the codegen deal with // it. @@ -4811,7 +4806,7 @@ }; const Type* Ty[2]; Ty[0] = ResultTy; - Ty[1] = PointerType::getUnqual(ResultTy); + Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); // The gcc builtins are also full memory barriers. @@ -4836,7 +4831,7 @@ }; const Type* Ty[2]; Ty[0] = ResultTy; - Ty[1] = PointerType::getUnqual(ResultTy); + Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); C[2] = Builder.CreateIntCast(C[2], Ty[0], "cast"); @@ -5145,7 +5140,7 @@ location_t locus = EXPR_LOCATION (exp); Constant *lineNo = ConstantInt::get(Type::getInt32Ty(Context), locus.line); Constant *file = ConvertMetadataStringToGV(locus.file); - const Type *SBP= PointerType::getUnqual(Type::getInt8Ty(Context)); + const Type *SBP= Type::getInt8PtrTy(Context); file = Builder.getFolder().CreateBitCast(file, SBP); // Get arguments. @@ -5318,7 +5313,7 @@ }; const Type* Ty[2]; Ty[0] = ResultTy; - Ty[1] = PointerType::getUnqual(ResultTy); + Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); @@ -5356,7 +5351,7 @@ }; const Type* Ty[2]; Ty[0] = ResultTy; - Ty[1] = PointerType::getUnqual(ResultTy); + Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); @@ -5394,7 +5389,7 @@ }; const Type* Ty[2]; Ty[0] = ResultTy; - Ty[1] = PointerType::getUnqual(ResultTy); + Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); @@ -5432,7 +5427,7 @@ }; const Type* Ty[2]; Ty[0] = ResultTy; - Ty[1] = PointerType::getUnqual(ResultTy); + Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); @@ -5470,7 +5465,7 @@ }; const Type* Ty[2]; Ty[0] = ResultTy; - Ty[1] = PointerType::getUnqual(ResultTy); + Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); @@ -5508,7 +5503,7 @@ }; const Type* Ty[2]; Ty[0] = ResultTy; - Ty[1] = PointerType::getUnqual(ResultTy); + Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); C[1] = Builder.CreateIntCast(C[1], Ty[0], "cast"); @@ -5828,7 +5823,7 @@ if (Locality == 0) Locality = ConstantInt::get(Type::getInt32Ty(Context), 3); - Ptr = BitCastToType(Ptr, PointerType::getUnqual(Type::getInt8Ty(Context))); + Ptr = BitCastToType(Ptr, Type::getInt8PtrTy(Context)); Value *Ops[3] = { Ptr, ReadWrite, Locality }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::prefetch), @@ -5871,7 +5866,7 @@ // Unfortunately, these constants are defined as RTL expressions and // should be handled separately. - Result = BitCastToType(Ptr, PointerType::getUnqual(Type::getInt8Ty(Context))); + Result = BitCastToType(Ptr, Type::getInt8PtrTy(Context)); return true; } @@ -5887,7 +5882,7 @@ // needed for: MIPS, Sparc. Unfortunately, these constants are defined // as RTL expressions and should be handled separately. - Result = BitCastToType(Ptr, PointerType::getUnqual(Type::getInt8Ty(Context))); + Result = BitCastToType(Ptr, Type::getInt8PtrTy(Context)); return true; } @@ -5995,7 +5990,7 @@ Intrinsic::eh_return_i32 : Intrinsic::eh_return_i64); Offset = Builder.CreateIntCast(Offset, IntPtr, true); - Handler = BitCastToType(Handler, PointerType::getUnqual(Type::getInt8Ty(Context))); + Handler = BitCastToType(Handler, Type::getInt8PtrTy(Context)); SmallVector Args; Args.push_back(Offset); @@ -6024,7 +6019,7 @@ } Value *Addr = BitCastToType(Emit(TREE_VALUE(arglist), 0), - PointerType::getUnqual(Type::getInt8Ty(Context))); + Type::getInt8PtrTy(Context)); Constant *Size, *Idx; for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) { @@ -6086,7 +6081,7 @@ return false; Value *Ptr = Emit(TREE_VALUE(arglist), 0); - Ptr = BitCastToType(Ptr, PointerType::getUnqual(Type::getInt8Ty(Context))); + Ptr = BitCastToType(Ptr, Type::getInt8PtrTy(Context)); Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::stackrestore), Ptr); @@ -6135,14 +6130,14 @@ Constant *llvm_va_start_fn = Intrinsic::getDeclaration(TheModule, Intrinsic::vastart); - ArgVal = BitCastToType(ArgVal, PointerType::getUnqual(Type::getInt8Ty(Context))); + ArgVal = BitCastToType(ArgVal, Type::getInt8PtrTy(Context)); Builder.CreateCall(llvm_va_start_fn, ArgVal); return true; } bool TreeToLLVM::EmitBuiltinVAEnd(tree exp) { Value *Arg = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0); - Arg = BitCastToType(Arg, PointerType::getUnqual(Type::getInt8Ty(Context))); + Arg = BitCastToType(Arg, Type::getInt8PtrTy(Context)); Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::vaend), Arg); return true; @@ -6167,7 +6162,7 @@ Arg2 = Emit(Arg2T, 0); } - static const Type *VPTy = PointerType::getUnqual(Type::getInt8Ty(Context)); + static const Type *VPTy = Type::getInt8PtrTy(Context); // FIXME: This ignores alignment and volatility of the arguments. SmallVector Args; @@ -6185,7 +6180,7 @@ VOID_TYPE)) return false; - static const Type *VPTy = PointerType::getUnqual(Type::getInt8Ty(Context)); + static const Type *VPTy = Type::getInt8PtrTy(Context); Value *Tramp = Emit(TREE_VALUE(arglist), 0); Tramp = BitCastToType(Tramp, VPTy); @@ -6379,7 +6374,7 @@ Value *TreeToLLVM::EmitFieldAnnotation(Value *FieldPtr, tree FieldDecl) { tree AnnotateAttr = lookup_attribute("annotate", DECL_ATTRIBUTES(FieldDecl)); - const Type *SBP = PointerType::getUnqual(Type::getInt8Ty(Context)); + const Type *SBP = Type::getInt8PtrTy(Context); Function *Fn = Intrinsic::getDeclaration(TheModule, Intrinsic::ptr_annotation, @@ -6500,7 +6495,7 @@ const Type *ElementTy = ConvertType(ElementType); unsigned Alignment = MinAlign(ArrayAlign, TD.getABITypeAlignment(ElementTy)); return LValue(BitCastToType(Ptr, - PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))), + ConvertType(TREE_TYPE(exp))->getPointerTo()), Alignment); } @@ -6509,7 +6504,7 @@ // float foo(int w, float A[][w], int g) { return A[g][0]; } ArrayAddr = BitCastToType(ArrayAddr, - PointerType::getUnqual(Type::getInt8Ty(Context))); + Type::getInt8PtrTy(Context)); if (VOID_TYPE_P(TREE_TYPE(ArrayTreeType))) return LValue(Builder.CreateGEP(ArrayAddr, IndexVal), 1); @@ -6523,8 +6518,7 @@ Value *Ptr = flag_wrapv ? Builder.CreateGEP(ArrayAddr, IndexVal) : Builder.CreateInBoundsGEP(ArrayAddr, IndexVal); - return LValue(BitCastToType(Ptr, - PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))), + return LValue(BitCastToType(Ptr, ConvertType(TREE_TYPE(exp))->getPointerTo()), Alignment); } @@ -6550,7 +6544,7 @@ if (unsigned UnitOffset = BitStart / ValueSizeInBits) { // TODO: If Ptr.Ptr is a struct type or something, we can do much better // than this. e.g. check out when compiling unwind-dw2-fde-darwin.c. - Ptr.Ptr = BitCastToType(Ptr.Ptr, PointerType::getUnqual(ValTy)); + Ptr.Ptr = BitCastToType(Ptr.Ptr, ValTy->getPointerTo()); Ptr.Ptr = Builder.CreateGEP(Ptr.Ptr, ConstantInt::get(Type::getInt32Ty(Context), UnitOffset)); BitStart -= UnitOffset*ValueSizeInBits; @@ -6558,11 +6552,11 @@ // If this is referring to the whole field, return the whole thing. if (BitStart == 0 && BitSize == ValueSizeInBits) { - return LValue(BitCastToType(Ptr.Ptr, PointerType::getUnqual(ValTy)), + return LValue(BitCastToType(Ptr.Ptr, ValTy->getPointerTo()), Ptr.getAlignment()); } - return LValue(BitCastToType(Ptr.Ptr, PointerType::getUnqual(ValTy)), 1, + return LValue(BitCastToType(Ptr.Ptr, ValTy->getPointerTo()), 1, BitStart, BitSize); } @@ -6585,7 +6579,7 @@ StructAddrLV.BitStart == 0) && "structs cannot be bitfields!"); StructAddrLV.Ptr = BitCastToType(StructAddrLV.Ptr, - PointerType::getUnqual(StructTy)); + StructTy->getPointerTo()); const Type *FieldTy = ConvertType(getDeclaredType(FieldDecl)); // BitStart - This is the actual offset of the field from the start of the @@ -6662,7 +6656,7 @@ Offset->getType()); Ptr = Builder.CreateAdd(Ptr, Offset); FieldPtr = CastToType(Instruction::IntToPtr, Ptr, - PointerType::getUnqual(FieldTy)); + FieldTy->getPointerTo()); } if (isBitfield(FieldDecl)) { @@ -6702,7 +6696,7 @@ // If this is a bitfield, the field may span multiple fields in the LLVM // type. As such, cast the pointer to be a pointer to the declared type. - FieldPtr = BitCastToType(FieldPtr, PointerType::getUnqual(FieldTy)); + FieldPtr = BitCastToType(FieldPtr, FieldTy->getPointerTo()); unsigned LLVMValueBitSize = FieldTy->getPrimitiveSizeInBits(); // Finally, because bitfields can span LLVM fields, and because the start @@ -6734,7 +6728,7 @@ Offset->getType()); FieldPtr = Builder.CreateAdd(FieldPtr, Offset); FieldPtr = CastToType(Instruction::IntToPtr, FieldPtr, - PointerType::getUnqual(FieldTy)); + FieldTy->getPointerTo()); // Adjust bitstart to account for the pointer movement. BitStart -= ByteOffset*8; @@ -6755,7 +6749,7 @@ } else { // Make sure we return a pointer to the right type. const Type *EltTy = ConvertType(TREE_TYPE(exp)); - FieldPtr = BitCastToType(FieldPtr, PointerType::getUnqual(EltTy)); + FieldPtr = BitCastToType(FieldPtr, EltTy->getPointerTo()); } assert(BitStart == 0 && @@ -6796,7 +6790,7 @@ if (Decl == 0) { if (errorcount || sorrycount) { const Type *Ty = ConvertType(TREE_TYPE(exp)); - const PointerType *PTy = PointerType::getUnqual(Ty); + const PointerType *PTy = Ty->getPointerTo(); LValue LV(ConstantPointerNull::get(PTy), 1); return LV; } @@ -6834,7 +6828,7 @@ // If we have "extern void foo", make the global have type {} instead of // type void. if (Ty == Type::getVoidTy(Context)) Ty = StructType::get(Context); - const PointerType *PTy = PointerType::getUnqual(Ty); + const PointerType *PTy = Ty->getPointerTo(); unsigned Alignment = Ty->isSized() ? TD.getABITypeAlignment(Ty) : 1; if (DECL_ALIGN(exp)) { if (DECL_USER_ALIGN(exp) || 8 * Alignment < (unsigned)DECL_ALIGN(exp)) @@ -6850,7 +6844,7 @@ unsigned Alignment = TD.getABITypeAlignment(cast(ExceptionValue-> getType())->getElementType()); return LValue(BitCastToType(ExceptionValue, - PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))), + ConvertType(TREE_TYPE(exp))->getPointerTo()), Alignment); } @@ -6878,16 +6872,14 @@ // If the input is an aggregate, the address is the address of the operand. LValue LV = EmitLV(Op); // The type is the type of the expression. - LV.Ptr = BitCastToType(LV.Ptr, - PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))); + LV.Ptr = BitCastToType(LV.Ptr, ConvertType(TREE_TYPE(exp))->getPointerTo()); return LV; } else { // If the input is a scalar, emit to a temporary. Value *Dest = CreateTemporary(ConvertType(TREE_TYPE(Op))); Builder.CreateStore(Emit(Op, 0), Dest); // The type is the type of the expression. - Dest = BitCastToType(Dest, - PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))); + Dest = BitCastToType(Dest, ConvertType(TREE_TYPE(exp))->getPointerTo()); return LValue(Dest, 1); } } @@ -6981,8 +6973,7 @@ } else { // Scalar value. Evaluate to a register, then do the store. Value *V = Emit(tree_value, 0); - Value *Ptr = BitCastToType(DestLoc->Ptr, - PointerType::getUnqual(V->getType())); + Value *Ptr = BitCastToType(DestLoc->Ptr, V->getType()->getPointerTo()); StoreInst *St = Builder.CreateStore(V, Ptr, DestLoc->Volatile); St->setAlignment(DestLoc->getAlignment()); } @@ -7990,7 +7981,7 @@ BasicBlock *BB = getLabelDeclBlock(exp); Constant *C = TheTreeToLLVM->getIndirectGotoBlockNumber(BB); return - TheFolder->CreateIntToPtr(C, PointerType::getUnqual(Type::getInt8Ty(Context))); + TheFolder->CreateIntToPtr(C, Type::getInt8PtrTy(Context)); } Constant *TreeConstantToLLVM::EmitLV_COMPLEX_CST(tree exp) { @@ -8089,7 +8080,7 @@ tree FieldDecl = TREE_OPERAND(exp, 1); StructAddrLV = TheFolder->CreateBitCast(StructAddrLV, - PointerType::getUnqual(StructTy)); + StructTy->getPointerTo()); const Type *FieldTy = ConvertType(getDeclaredType(FieldDecl)); // BitStart - This is the actual offset of the field from the start of the @@ -8126,13 +8117,12 @@ Constant *Ptr = TheFolder->CreatePtrToInt(StructAddrLV, Offset->getType()); Ptr = TheFolder->CreateAdd(Ptr, Offset); FieldPtr = TheFolder->CreateIntToPtr(Ptr, - PointerType::getUnqual(FieldTy)); + FieldTy->getPointerTo()); } // Make sure we return a result of the right type. - if (PointerType::getUnqual(FieldTy) != FieldPtr->getType()) - FieldPtr = TheFolder->CreateBitCast(FieldPtr, - PointerType::getUnqual(FieldTy)); + if (FieldTy->getPointerTo() != FieldPtr->getType()) + FieldPtr = TheFolder->CreateBitCast(FieldPtr, FieldTy->getPointerTo()); assert(BitStart == 0 && "It's a bitfield reference or we didn't get to the field!"); Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=83876&r1=83875&r2=83876&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Oct 12 14:35:13 2009 @@ -822,8 +822,7 @@ Ty = GET_TYPE_LLVM(TYPE_MAIN_VARIANT(TREE_TYPE(type))); if (Ty == 0) { PointersToReresolve.push_back(type); - return TypeDB.setType(type, - PointerType::getUnqual(OpaqueType::get(Context))); + return TypeDB.setType(type, OpaqueType::get(Context)->getPointerTo()); } // A type has already been computed. However, this may be some sort of @@ -841,7 +840,7 @@ if (Ty == Type::getVoidTy(Context)) Ty = Type::getInt8Ty(Context); // void* -> sbyte* - return TypeDB.setType(type, PointerType::getUnqual(Ty)); + return TypeDB.setType(type, Ty->getPointerTo()); } case METHOD_TYPE: @@ -1014,7 +1013,7 @@ /// argument is passed by value. It is lowered to a parameter passed by /// reference with an additional parameter attribute "ByVal". void HandleByValArgument(const llvm::Type *LLVMTy, tree type) { - HandleScalarArgument(PointerType::getUnqual(LLVMTy), type); + HandleScalarArgument(LLVMTy->getPointerTo(), type); } /// HandleFCAArgument - This callback is invoked if the aggregate function From baldrick at free.fr Mon Oct 12 14:36:17 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 12 Oct 2009 19:36:17 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r83877 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200910121936.n9CJaHo3021624@zion.cs.uiuc.edu> Author: baldrick Date: Mon Oct 12 14:36:16 2009 New Revision: 83877 URL: http://llvm.org/viewvc/llvm-project?rev=83877&view=rev Log: Port of dragonegg commit 83374: Map GCC's -fverbose-asm to --asm-verbose, rather than mapping -dA as now, since this seems more logical. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=83877&r1=83876&r2=83877&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Oct 12 14:36:16 2009 @@ -396,7 +396,7 @@ Args.push_back("--disable-fp-elim"); if (!flag_zero_initialized_in_bss) Args.push_back("--nozero-initialized-in-bss"); - if (flag_debug_asm) + if (flag_verbose_asm) Args.push_back("--asm-verbose"); if (flag_debug_pass_structure) Args.push_back("--debug-pass=Structure"); From baldrick at free.fr Mon Oct 12 14:37:58 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 12 Oct 2009 19:37:58 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r83878 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386.cpp llvm-abi.h llvm-backend.cpp llvm-convert.cpp llvm-types.cpp Message-ID: <200910121937.n9CJbwAs021751@zion.cs.uiuc.edu> Author: baldrick Date: Mon Oct 12 14:37:58 2009 New Revision: 83878 URL: http://llvm.org/viewvc/llvm-project?rev=83878&view=rev Log: Port of dragonegg commit 83301: Use new predicates to test whether a type is void, float etc. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi.h llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=83878&r1=83877&r2=83878&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Oct 12 14:37:58 2009 @@ -672,8 +672,8 @@ // as loads and stores of it get only 10 bytes. if (EltTy == Type::getInt32Ty(Context) || EltTy == Type::getInt64Ty(Context) || - EltTy == Type::getFloatTy(Context) || - EltTy == Type::getDoubleTy(Context) || + EltTy->isFloatTy() || + EltTy->isDoubleTy() || isa(EltTy)) { Elts.push_back(EltTy); continue; @@ -702,8 +702,8 @@ // short in 32-bit. const Type *EltTy = STy->getElementType(0); return !((TARGET_64BIT && (EltTy->isInteger() || - EltTy == Type::getFloatTy(Context) || - EltTy == Type::getDoubleTy(Context))) || + EltTy->isFloatTy() || + EltTy->isDoubleTy())) || EltTy == Type::getInt16Ty(Context) || EltTy == Type::getInt8Ty(Context)); } @@ -746,7 +746,7 @@ ++NumXMMs; } else if (Ty->isInteger() || isa(Ty)) { ++NumGPRs; - } else if (Ty==Type::getVoidTy(Context)) { + } else if (Ty->isVoidTy()) { // Padding bytes that are not passed anywhere ; } else { Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=83878&r1=83877&r2=83878&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Mon Oct 12 14:37:58 2009 @@ -393,7 +393,7 @@ C.HandleScalarShadowResult(Ty->getPointerTo(), false); else C.HandleScalarResult(Ty); - } else if (Ty->isSingleValueType() || Ty == Type::getVoidTy(getGlobalContext())) { + } else if (Ty->isSingleValueType() || Ty->isVoidTy()) { // Return scalar values normally. C.HandleScalarResult(Ty); } else if (doNotUseShadowReturn(type, fn)) { @@ -439,7 +439,7 @@ // Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do // not include variable sized fields here. std::vector Elts; - if (Ty == Type::getVoidTy(getGlobalContext())) { + if (Ty->isVoidTy()) { // Handle void explicitly as an opaque type. const Type *OpTy = OpaqueType::get(getGlobalContext()); C.HandleScalarArgument(OpTy, type); @@ -667,7 +667,7 @@ const Type* wordType = getTargetData().getPointerSize() == 4 ? Type::getInt32Ty(getGlobalContext()) : Type::getInt64Ty(getGlobalContext()); for (unsigned i=0, e=Elts.size(); i!=e; ++i) - if (OrigElts[i]==Type::getVoidTy(getGlobalContext())) + if (OrigElts[i]->isVoidTy()) Elts[i] = wordType; const StructType *STy = StructType::get(getGlobalContext(), Elts, false); @@ -749,7 +749,7 @@ C.HandleScalarShadowResult(Ty->getPointerTo(), false); else C.HandleScalarResult(Ty); - } else if (Ty->isSingleValueType() || Ty == Type::getVoidTy(getGlobalContext())) { + } else if (Ty->isSingleValueType() || Ty->isVoidTy()) { // Return scalar values normally. C.HandleScalarResult(Ty); } else if (doNotUseShadowReturn(type, fn)) { @@ -1112,7 +1112,7 @@ const Type* wordType = getTargetData().getPointerSize() == 4 ? Type::getInt32Ty(getGlobalContext()) : Type::getInt64Ty(getGlobalContext()); for (unsigned i=0, e=Elts.size(); i!=e; ++i) - if (OrigElts[i]==Type::getVoidTy(getGlobalContext())) + if (OrigElts[i]->isVoidTy()) Elts[i] = wordType; const StructType *STy = StructType::get(getGlobalContext(), Elts, false); Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=83878&r1=83877&r2=83878&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Oct 12 14:37:58 2009 @@ -1622,7 +1622,7 @@ // If we have "extern void foo", make the global have type {} instead of // type void. - if (Ty == Type::getVoidTy(Context)) + if (Ty->isVoidTy()) Ty = StructType::get(Context); if (Name[0] == 0) { // Global has no name. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=83878&r1=83877&r2=83878&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Oct 12 14:37:58 2009 @@ -329,7 +329,7 @@ // If this is GCC being sloppy about pointer types, insert a bitcast. // See PR1083 for an example. ArgVal = Builder.CreateBitCast(ArgVal, LLVMTy); - } else if (ArgVal->getType() == Type::getDoubleTy(Context)) { + } else if (ArgVal->getType()->isDoubleTy()) { // If this is a K&R float parameter, it got promoted to double. Insert // the truncation to float now. ArgVal = Builder.CreateFPTrunc(ArgVal, LLVMTy, @@ -2811,7 +2811,7 @@ if (Client.isShadowReturn()) return Client.EmitShadowResult(TREE_TYPE(exp), DestLoc); - if (Call->getType() == Type::getVoidTy(Context)) + if (Call->getType()->isVoidTy()) return 0; if (Client.isAggrReturn()) { @@ -3072,7 +3072,7 @@ assert(!isAggregateTreeType(TREE_TYPE(Op)) && "Aggregate to scalar nop_expr!"); Value *OpVal = Emit(Op, DestLoc); - if (Ty == Type::getVoidTy(Context)) return 0; + if (Ty->isVoidTy()) return 0; return CastToAnyType(OpVal, OpIsSigned, Ty, ExpIsSigned); } else if (isAggregateTreeType(TREE_TYPE(Op))) { // Aggregate to aggregate copy. @@ -6827,7 +6827,7 @@ const Type *Ty = ConvertType(TREE_TYPE(exp)); // If we have "extern void foo", make the global have type {} instead of // type void. - if (Ty == Type::getVoidTy(Context)) Ty = StructType::get(Context); + if (Ty->isVoidTy()) Ty = StructType::get(Context); const PointerType *PTy = Ty->getPointerTo(); unsigned Alignment = Ty->isSized() ? TD.getABITypeAlignment(Ty) : 1; if (DECL_ALIGN(exp)) { @@ -7046,7 +7046,7 @@ int UArr[2]; double V; }; - if (Ty==Type::getFloatTy(Context) || Ty==Type::getDoubleTy(Context)) { + if (Ty->isFloatTy() || Ty->isDoubleTy()) { REAL_VALUE_TO_TARGET_DOUBLE(TREE_REAL_CST(exp), RealArr); // Here's how this works: @@ -7072,9 +7072,9 @@ std::swap(UArr[0], UArr[1]); return - ConstantFP::get(Context, Ty==Type::getFloatTy(Context) ? + ConstantFP::get(Context, Ty->isFloatTy() ? APFloat((float)V) : APFloat(V)); - } else if (Ty==Type::getX86_FP80Ty(Context)) { + } else if (Ty->isX86_FP80Ty()) { long RealArr[4]; uint64_t UArr[2]; REAL_VALUE_TO_TARGET_LONG_DOUBLE(TREE_REAL_CST(exp), RealArr); @@ -7082,8 +7082,8 @@ ((uint64_t)((uint32_t)RealArr[1]) << 32); UArr[1] = (uint16_t)RealArr[2]; return ConstantFP::get(Context, APFloat(APInt(80, 2, UArr))); - } else if (Ty==Type::getPPC_FP128Ty(Context) || - Ty==Type::getFP128Ty(Context)) { + } else if (Ty->isPPC_FP128Ty() || + Ty->isFP128Ty()) { long RealArr[4]; uint64_t UArr[2]; REAL_VALUE_TO_TARGET_LONG_DOUBLE(TREE_REAL_CST(exp), RealArr); @@ -7094,7 +7094,7 @@ ((uint64_t)((uint32_t)RealArr[3])); return ConstantFP::get(Context, APFloat(APInt(128, 2, UArr), - /*isIEEE*/ Ty==Type::getFP128Ty(Context))); + /*isIEEE*/ Ty->isFP128Ty())); } assert(0 && "Floating point type not handled yet"); return 0; // outwit compiler warning @@ -7960,7 +7960,7 @@ // itself (allowed in GCC but not in LLVM) then the global is changed to have // the type of the initializer. Correct for this now. const Type *Ty = ConvertType(TREE_TYPE(exp)); - if (Ty == Type::getVoidTy(Context)) Ty = Type::getInt8Ty(Context); // void* -> i8*. + if (Ty->isVoidTy()) Ty = Type::getInt8Ty(Context); // void* -> i8*. return TheFolder->CreateBitCast(Val, Ty->getPointerTo()); } Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=83878&r1=83877&r2=83878&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Oct 12 14:37:58 2009 @@ -804,7 +804,7 @@ // Restore ConvertingStruct for the caller. ConvertingStruct = false; - if (Actual == Type::getVoidTy(Context)) + if (Actual->isVoidTy()) Actual = Type::getInt8Ty(Context); // void* -> sbyte* // Update the type, potentially updating TYPE_LLVM(type). @@ -838,7 +838,7 @@ Ty = ConvertType(TREE_TYPE(type)); } - if (Ty == Type::getVoidTy(Context)) + if (Ty->isVoidTy()) Ty = Type::getInt8Ty(Context); // void* -> sbyte* return TypeDB.setType(type, Ty->getPointerTo()); } From clattner at apple.com Mon Oct 12 14:40:07 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 12 Oct 2009 12:40:07 -0700 Subject: [llvm-commits] patch: memory use markers In-Reply-To: References: <4AD25B50.4000008@mxc.ca> <19D8DF80-620E-41D0-915D-A3D505766B00@apple.com> Message-ID: On Oct 12, 2009, at 11:44 AM, Nick Lewycky wrote: > 2009/10/12 Dan Gohman > > On Oct 11, 2009, at 3:25 PM, Nick Lewycky wrote: > > > This patch adds memory use markers as described in http://nondot.org/sabre/LLVMNotes/MemoryUseMarkers.txt > > . The bulk of the patch makes it possible to have intrinsics which > > return {}. > > Hi Nick, > > The use of {} here is clever, but I don't think it's correct. Since {} > has > no members, the set of values has exactly one element, which means > that all values of type {} can be assumed to be equivalent. Please use > something like opaque* instead. > > I brought that up with Chris much earlier on (since I would've had > this patch done a month ago were it not for the need to support {}) > but he was adamant that {} was the correct type for these. I was > suggesting metadata type though; opaque types require a name in the > module. Dan convinced me that {} was a bad way to go, lets use "{}*" instead, does that work for you? -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091012/b9e2c293/attachment.html From baldrick at free.fr Mon Oct 12 14:40:31 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 12 Oct 2009 19:40:31 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r83879 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200910121940.n9CJeV6t021901@zion.cs.uiuc.edu> Author: baldrick Date: Mon Oct 12 14:40:30 2009 New Revision: 83879 URL: http://llvm.org/viewvc/llvm-project?rev=83879&view=rev Log: Port of dragonegg commit 82041: Remove an incorrect assertion. This fires when adding (for example) an i1 field. Adding an i1 field does not mean adding a bitfield, it means adding a byte of which only the first bit is used. Since all the logic uses the AllocSize, which is 1 byte for an i1, as far as I can see everything should work correctly in this case. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=83879&r1=83878&r2=83879&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Oct 12 14:40:30 2009 @@ -7473,9 +7473,6 @@ /// void ConstantLayoutInfo:: AddFieldToRecordConstant(Constant *Val, uint64_t GCCFieldOffsetInBits) { - assert((TD.getTypeSizeInBits(Val->getType()) & 7) == 0 && - "Cannot handle non-byte sized values"); - // Figure out how to add this non-bitfield value to our constant struct so // that it ends up at the right offset. There are four cases we have to // think about: From clattner at apple.com Mon Oct 12 14:41:28 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 12 Oct 2009 12:41:28 -0700 Subject: [llvm-commits] patch: memory use markers In-Reply-To: References: <4AD25B50.4000008@mxc.ca> <19D8DF80-620E-41D0-915D-A3D505766B00@apple.com> Message-ID: On Oct 12, 2009, at 11:44 AM, Nick Lewycky wrote: > 2009/10/12 Dan Gohman > > With @llvm.invariant.end being marked readonly and nounwind, and > having > a void return type, it would seem to be trivially dead everywhere. > Should > the readonly be removed? > > Good catch! Does this rule apply to intrinsics as well? How does > @llvm.gcread work? gcread should be deleted when dead. Basicaa should special case these new intrinsics to say that they always have an empty mod/ref set. -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091012/c6ff592d/attachment.html From bob.wilson at apple.com Mon Oct 12 15:37:23 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 12 Oct 2009 20:37:23 -0000 Subject: [llvm-commits] [llvm] r83894 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910122037.n9CKbOuQ024747@zion.cs.uiuc.edu> Author: bwilson Date: Mon Oct 12 15:37:23 2009 New Revision: 83894 URL: http://llvm.org/viewvc/llvm-project?rev=83894&view=rev Log: Remove redundant parameter. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=83894&r1=83893&r2=83894&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Oct 12 15:37:23 2009 @@ -165,8 +165,7 @@ int LookForExistingCPEntry(CPUser& U, unsigned UserOffset); bool LookForWater(CPUser&U, unsigned UserOffset, MachineBasicBlock *&NewMBB); - MachineBasicBlock* AcceptWater(MachineBasicBlock *WaterBB, - water_iterator IP); + MachineBasicBlock *AcceptWater(water_iterator IP); void CreateNewWater(unsigned CPUserIndex, unsigned UserOffset, MachineBasicBlock** NewMBB); bool HandleConstantPoolUser(MachineFunction &MF, unsigned CPUserIndex); @@ -932,9 +931,8 @@ } /// AcceptWater - Small amount of common code factored out of the following. - -MachineBasicBlock* ARMConstantIslands::AcceptWater(MachineBasicBlock *WaterBB, - water_iterator IP) { +/// +MachineBasicBlock *ARMConstantIslands::AcceptWater(water_iterator IP) { DEBUG(errs() << "found water in range\n"); // Remove the original WaterList entry; we want subsequent // insertions in this vicinity to go after the one we're @@ -942,7 +940,7 @@ // of times we have to move the same CPE more than once. WaterList.erase(IP); // CPE goes before following block (NewMBB). - return next(MachineFunction::iterator(WaterBB)); + return next(MachineFunction::iterator(*IP)); } /// LookForWater - look for an existing entry in the WaterList in which @@ -973,7 +971,7 @@ IPThatWouldPad = IP; } } else { - NewMBB = AcceptWater(WaterBB, IP); + NewMBB = AcceptWater(IP); return true; } } @@ -981,7 +979,7 @@ break; } if (isThumb && WaterBBThatWouldPad) { - NewMBB = AcceptWater(WaterBBThatWouldPad, IPThatWouldPad); + NewMBB = AcceptWater(IPThatWouldPad); return true; } return false; From sabre at nondot.org Mon Oct 12 15:42:36 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 12 Oct 2009 20:42:36 -0000 Subject: [llvm-commits] [llvm] r83895 - /llvm/trunk/test/FrontendC/2008-03-24-BitField-And-Alloca.c Message-ID: <200910122042.n9CKgarv025039@zion.cs.uiuc.edu> Author: lattner Date: Mon Oct 12 15:42:35 2009 New Revision: 83895 URL: http://llvm.org/viewvc/llvm-project?rev=83895&view=rev Log: allow this testcase to pass with recent changes. The test hasn't been producing any stores at all for a long time, but ".store." was in some IR instruction names until recently. This removal caused the test to start failing. Just make it reject any stores. Modified: llvm/trunk/test/FrontendC/2008-03-24-BitField-And-Alloca.c Modified: llvm/trunk/test/FrontendC/2008-03-24-BitField-And-Alloca.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2008-03-24-BitField-And-Alloca.c?rev=83895&r1=83894&r2=83895&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2008-03-24-BitField-And-Alloca.c (original) +++ llvm/trunk/test/FrontendC/2008-03-24-BitField-And-Alloca.c Mon Oct 12 15:42:35 2009 @@ -1,5 +1,5 @@ // RUN: %llvmgcc -O2 -S %s -o - | not grep alloca -// RUN: %llvmgcc -m32 -O2 -S %s -o - | grep store | not grep {align 8} +// RUN: %llvmgcc -m32 -O2 -S %s -o - | not grep store enum { PP_C, From bob.wilson at apple.com Mon Oct 12 15:45:53 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 12 Oct 2009 20:45:53 -0000 Subject: [llvm-commits] [llvm] r83897 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910122045.n9CKjrcw025232@zion.cs.uiuc.edu> Author: bwilson Date: Mon Oct 12 15:45:53 2009 New Revision: 83897 URL: http://llvm.org/viewvc/llvm-project?rev=83897&view=rev Log: Another minor clean-up. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=83897&r1=83896&r2=83897&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Oct 12 15:45:53 2009 @@ -952,11 +952,11 @@ /// group, prefer the water that's farthest away. bool ARMConstantIslands::LookForWater(CPUser &U, unsigned UserOffset, MachineBasicBlock *&NewMBB) { - water_iterator IPThatWouldPad; - MachineBasicBlock* WaterBBThatWouldPad = NULL; if (WaterList.empty()) return false; + bool FoundWaterThatWouldPad = false; + water_iterator IPThatWouldPad; for (water_iterator IP = prior(WaterList.end()), B = WaterList.begin();; --IP) { MachineBasicBlock* WaterBB = *IP; @@ -966,8 +966,8 @@ (BBOffsets[WBBId] + BBSizes[WBBId])%4 != 0) { // This is valid Water, but would introduce padding. Remember // it in case we don't find any Water that doesn't do this. - if (!WaterBBThatWouldPad) { - WaterBBThatWouldPad = WaterBB; + if (!FoundWaterThatWouldPad) { + FoundWaterThatWouldPad = true; IPThatWouldPad = IP; } } else { @@ -978,7 +978,7 @@ if (IP == B) break; } - if (isThumb && WaterBBThatWouldPad) { + if (FoundWaterThatWouldPad) { NewMBB = AcceptWater(IPThatWouldPad); return true; } From bob.wilson at apple.com Mon Oct 12 16:23:15 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 12 Oct 2009 21:23:15 -0000 Subject: [llvm-commits] [llvm] r83902 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910122123.n9CLNGLs026827@zion.cs.uiuc.edu> Author: bwilson Date: Mon Oct 12 16:23:15 2009 New Revision: 83902 URL: http://llvm.org/viewvc/llvm-project?rev=83902&view=rev Log: Last week, ARMConstantIslandPass was failing to converge for the MultiSource/Benchmarks/MiBench/automotive-susan test. The failure has since been masked by an unrelated change (just randomly), so I don't have a testcase for this now. Radar 7291928. The situation where this happened is that a constant pool entry (CPE) was placed at a lower address than the load that referenced it. There were in fact 2 CPEs placed at adjacent addresses and referenced by 2 loads that were close together in the code. The distance from the loads to the CPEs was right at the limit of what they could handle, so that only one of the CPEs could be placed within range. On every iteration, the first CPE was found to be out of range, causing a new CPE to be inserted. The second CPE had been in range but the newly inserted entry pushed it too far away. Thus the second CPE was also replaced by a new entry, which in turn pushed the first CPE out of range. Etc. Judging from some comments in the code, the initial implementation of this pass did not support CPEs placed _before_ their references. In the case where the CPE is placed at a higher address, the key to making the algorithm terminate is that new CPEs are only inserted at the end of a group of adjacent CPEs. This is implemented by removing a basic block from the "WaterList" once it has been used, and then adding the newly inserted CPE block to the list so that the next insertion will come after it. This avoids the ping-pong effect where CPEs are repeatedly moved to the beginning of a group of adjacent CPEs. This does not work when going backwards, however, because the entries at the end of an adjacent group of CPEs are closer than the CPEs earlier in the group. To make this pass terminate, we need to maintain a property that changes can only happen in some sort of monotonic fashion. The fix used here is to require that the CPE for a particular constant pool load can only move to lower addresses. This is a very simple change to the code and should not cause any significant degradation in the results. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=83902&r1=83901&r2=83902&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Oct 12 16:23:15 2009 @@ -946,10 +946,11 @@ /// LookForWater - look for an existing entry in the WaterList in which /// we can place the CPE referenced from U so it's within range of U's MI. /// Returns true if found, false if not. If it returns true, NewMBB -/// is set to the WaterList entry. -/// For ARM, we prefer the water that's farthest away. For Thumb, prefer -/// water that will not introduce padding to water that will; within each -/// group, prefer the water that's farthest away. +/// is set to the WaterList entry. For Thumb, prefer water that will not +/// introduce padding to water that will. To ensure that this pass +/// terminates, the CPE location for a particular CPUser is only allowed to +/// move to a lower address, so search backward from the end of the list and +/// prefer the first water that is in range. bool ARMConstantIslands::LookForWater(CPUser &U, unsigned UserOffset, MachineBasicBlock *&NewMBB) { if (WaterList.empty()) @@ -960,7 +961,9 @@ for (water_iterator IP = prior(WaterList.end()), B = WaterList.begin();; --IP) { MachineBasicBlock* WaterBB = *IP; - if (WaterIsInRange(UserOffset, WaterBB, U)) { + // Check if water is in range and at a lower address than the current one. + if (WaterIsInRange(UserOffset, WaterBB, U) && + WaterBB->getNumber() < U.CPEMI->getParent()->getNumber()) { unsigned WBBId = WaterBB->getNumber(); if (isThumb && (BBOffsets[WBBId] + BBSizes[WBBId])%4 != 0) { @@ -1109,10 +1112,7 @@ // We will be generating a new clone. Get a UID for it. unsigned ID = AFI->createConstPoolEntryUId(); - // Look for water where we can place this CPE. We look for the farthest one - // away that will work. Forward references only for now (although later - // we might find some that are backwards). - + // Look for water where we can place this CPE. if (!LookForWater(U, UserOffset, NewMBB)) { // No water found. DEBUG(errs() << "No water found\n"); From bob.wilson at apple.com Mon Oct 12 16:39:43 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 12 Oct 2009 21:39:43 -0000 Subject: [llvm-commits] [llvm] r83905 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910122139.n9CLdikP027662@zion.cs.uiuc.edu> Author: bwilson Date: Mon Oct 12 16:39:43 2009 New Revision: 83905 URL: http://llvm.org/viewvc/llvm-project?rev=83905&view=rev Log: Change CreateNewWater method to return NewMBB by reference. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=83905&r1=83904&r2=83905&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Oct 12 16:39:43 2009 @@ -167,7 +167,7 @@ MachineBasicBlock *&NewMBB); MachineBasicBlock *AcceptWater(water_iterator IP); void CreateNewWater(unsigned CPUserIndex, unsigned UserOffset, - MachineBasicBlock** NewMBB); + MachineBasicBlock *&NewMBB); bool HandleConstantPoolUser(MachineFunction &MF, unsigned CPUserIndex); void RemoveDeadCPEMI(MachineInstr *CPEMI); bool RemoveUnusedCPEntries(); @@ -992,12 +992,12 @@ /// CPUsers[CPUserIndex], so create a place to put the CPE. The end of the /// block is used if in range, and the conditional branch munged so control /// flow is correct. Otherwise the block is split to create a hole with an -/// unconditional branch around it. In either case *NewMBB is set to a +/// unconditional branch around it. In either case NewMBB is set to a /// block following which the new island can be inserted (the WaterList /// is not adjusted). - void ARMConstantIslands::CreateNewWater(unsigned CPUserIndex, - unsigned UserOffset, MachineBasicBlock** NewMBB) { + unsigned UserOffset, + MachineBasicBlock *&NewMBB) { CPUser &U = CPUsers[CPUserIndex]; MachineInstr *UserMI = U.MI; MachineInstr *CPEMI = U.CPEMI; @@ -1019,7 +1019,7 @@ DEBUG(errs() << "Split at end of block\n"); if (&UserMBB->back() == UserMI) assert(BBHasFallthrough(UserMBB) && "Expected a fallthrough BB!"); - *NewMBB = next(MachineFunction::iterator(UserMBB)); + NewMBB = next(MachineFunction::iterator(UserMBB)); // Add an unconditional branch from UserMBB to fallthrough block. // Record it for branch lengthening; this new branch will not get out of // range, but if the preceding conditional branch is out of range, the @@ -1027,7 +1027,7 @@ // range, so the machinery has to know about it. int UncondBr = isThumb ? ((isThumb2) ? ARM::t2B : ARM::tB) : ARM::B; BuildMI(UserMBB, DebugLoc::getUnknownLoc(), - TII->get(UncondBr)).addMBB(*NewMBB); + TII->get(UncondBr)).addMBB(NewMBB); unsigned MaxDisp = getUnconditionalBrDisp(UncondBr); ImmBranches.push_back(ImmBranch(&UserMBB->back(), MaxDisp, false, UncondBr)); @@ -1082,7 +1082,7 @@ } } DEBUG(errs() << "Split in middle of big block\n"); - *NewMBB = SplitBlockBeforeInstr(prior(MI)); + NewMBB = SplitBlockBeforeInstr(prior(MI)); } } @@ -1116,7 +1116,7 @@ if (!LookForWater(U, UserOffset, NewMBB)) { // No water found. DEBUG(errs() << "No water found\n"); - CreateNewWater(CPUserIndex, UserOffset, &NewMBB); + CreateNewWater(CPUserIndex, UserOffset, NewMBB); } // Okay, we know we can put an island before NewMBB now, do it! From tonic at nondot.org Mon Oct 12 16:53:27 2009 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 12 Oct 2009 16:53:27 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/Cifuentes_ParfaitBugChecker.pdf Geoffray_GarbageCollectionVMKit.pdf Grover_PLANG.pdf Korobeynikov_BackendTutorial.pdf Nagarakatte_SoftBound.pdf Osborne_TargetingXCoreResources.pdf Sands_LLVMGCCPlugin.pdf Winter_UnladenSwallowLLVM.pdf Zaks_CoVaC.pdf index.html Message-ID: <200910122153.n9CLrRaO028279@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: Cifuentes_ParfaitBugChecker.pdf added (r1.1) Geoffray_GarbageCollectionVMKit.pdf added (r1.1) Grover_PLANG.pdf added (r1.1) Korobeynikov_BackendTutorial.pdf added (r1.1) Nagarakatte_SoftBound.pdf added (r1.1) Osborne_TargetingXCoreResources.pdf added (r1.1) Sands_LLVMGCCPlugin.pdf added (r1.1) Winter_UnladenSwallowLLVM.pdf added (r1.1) Zaks_CoVaC.pdf added (r1.1) index.html updated: 1.1 -> 1.2 --- Log message: Starting to add slides to the website. --- Diffs of the changes: (+254 -5) Cifuentes_ParfaitBugChecker.pdf | 0 Geoffray_GarbageCollectionVMKit.pdf | 0 Grover_PLANG.pdf | 0 Korobeynikov_BackendTutorial.pdf | 0 Nagarakatte_SoftBound.pdf | 0 Osborne_TargetingXCoreResources.pdf | 0 Sands_LLVMGCCPlugin.pdf | 0 Winter_UnladenSwallowLLVM.pdf | 0 Zaks_CoVaC.pdf | 0 index.html | 259 +++++++++++++++++++++++++++++++++++- 10 files changed, 254 insertions(+), 5 deletions(-) Index: llvm-www/devmtg/2009-10/Cifuentes_ParfaitBugChecker.pdf Index: llvm-www/devmtg/2009-10/Geoffray_GarbageCollectionVMKit.pdf Index: llvm-www/devmtg/2009-10/Grover_PLANG.pdf Index: llvm-www/devmtg/2009-10/Korobeynikov_BackendTutorial.pdf Index: llvm-www/devmtg/2009-10/Nagarakatte_SoftBound.pdf Index: llvm-www/devmtg/2009-10/Osborne_TargetingXCoreResources.pdf Index: llvm-www/devmtg/2009-10/Sands_LLVMGCCPlugin.pdf Index: llvm-www/devmtg/2009-10/Winter_UnladenSwallowLLVM.pdf Index: llvm-www/devmtg/2009-10/Zaks_CoVaC.pdf Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.1 llvm-www/devmtg/2009-10/index.html:1.2 --- llvm-www/devmtg/2009-10/index.html:1.1 Thu Jul 9 13:48:42 2009 +++ llvm-www/devmtg/2009-10/index.html Mon Oct 12 16:52:21 2009 @@ -1,5 +1,254 @@ - - -LLVM Developers' Meeting - - + + +
    2009 LLVM Developers' Meeting
    + +
    +
      +
    1. Proceedings
    2. +
    3. Attendees
    4. +
    +
    +
      +
    • What: The third general meeting of LLVM Developers and Users. +
    • +
    • Why: To get acquainted, learn how LLVM is used, and exchange + ideas.
    • +
    • When: October 2, 2009
    • +
    +
    + +

    SPONSORED BY: Apple, Google, Adobe, Qualcomm Incorporated

    + +

    The meeting serves as a forum for both LLVM +and Clang developers and users to get acquainted, lea +rn how LLVM is used, and +exchange ideas about LLVM and its (potential) applications. More broadly, we +believe the event will be of particular interest to the following people:

    + +
      +
    • Active LLVM and Clang developers and users.
    • +
    • Anyone interested in using LLVM or Clang.
    • +
    • Compiler, programming language, and runtime enthusiasts.
    • +
    • Those interested in using compiler technology in novel and interesting ways.
    • +
    + + +
    Proceedings
    + +

    The day was structured to have general overview/introduction talks about some +major LLVM subsystems and talks on applications of LLVM for various +specific projects.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MediaWhoDescription
    + [No Slides]
    + [No Video] +
    Chris Lattner
    LLVM Foundation
    + Welcome +
    + [No Slides]
    + [No Video] +
    Doug Gregor, Chris Lattner, Ted Kremenek
    + State of Clang +
    + [Slides] + Anton Korobeynikov
    Saint Petersburg State University
    + Tutorial: Building backend in 24 hours - A step by step tutorial to + build a backend. +
    + [Slides] + Nicolas Geoffray
    Universite Pierre et Marie Curie
    Precise and efficient garbage collection in VMKit with MMTk - + This talk will describe how we have added precise garbage collection in VMKit, both in the JVM and .Net runtime. The work continues in the spirit of VMKit, in that the garbage collector is an external library provided by others. We have used MMTk, a garbage collector written in Java to provide efficient and precise garbage collection. The talk will give a step by step explanation on how the new system was implemented (using LLVM as an ahead of time compiler for Java, using the LLVM GC framework, creating stack maps at runtime, etc), and provide a tutorial on how this can be adopted by other kinds of VMs implemented with LLVM. Additionally, I will show the new performance results with the new garbage collector. The new system continues to support big applications (eclipse, tomcat, DaCapo benchmarks), and provides way better performance than before. +
    + [Slides] + Colin Winter
    Google
    Unladen Swallow: Python on LLVM - + This talk will go into detail about Unladen Swallow, a Google-sponsored branch of CPython based on LLVM. The talk will describe the architecture of Python-on-LLVM, why we chose LLVM, how we're exploiting LLVM to increase performance, challenges we face in optimizing Python, and future direction for our work. +
    + [Slides] + Duncan Sands
    Deep Blue Capital
    Reimplementing llvm-gcc as a gcc plugin - + Mainline gcc is now able to load additional logic and passes at run-time via a plugin mechanism. It may be possible to replace gcc's optimizers and code generators with those of LLVM via a plugin without needing to modify gcc at all. The goal is to obtain an equivalent of llvm-gcc in this way. I will describe the current status of this project. +
    + [No Slides]
    + [No Video] +
    Dan Gohman
    ScalarEvolution and Loop Optimization - LLVM's ScalarEvolution framework has undergone some major changes and now sports some cool new features. I'll give an overview of what ScalarEvolution can do, illustrate the new features, and discuss the infrastructure behind the functionality. +
    + + Bruno Cardoso Lopes
    University of Campinas
    Object Code Emission and llvm-mc - + A high level overview of the LLVM Machine Code Emitter, with a specific focus on the emission of object files: the design and current implementation status. +
    + + David Greene
    Cray
    LLVM on 180k Cores - + In this talk we'll see how Cray incorporated LLVM into an existing highly optimizing, vectorizing and parallelizing compiler. Attendees will learn about the pitfalls encountered as well as the benefits of using an Open Source codegen solution. We will also discuss various modifications to LLVM that Cray is currently in the process of integrating back into the community repository. +
    + [Slides] + Cristina Cifuentes
    Sun Microsystems
    The Parfait Bug-Checker - + Parfait is a research bug-checking project for C built on top of LLVM. Parfait is being used internally within Sun to find bugs in various applications including the Solaris(TM) operating system. Externally, Parfait is being tested in the OS community with the OpenBSD, Linux and FreeBSD kernels. In this talk we explain Parfait's design for scalability and precision, explain some of the internals of the tool and how it is built on top of LLVM, and give a demo against open source code bases. +
    + [Slides] + Scott Petersen
    Adobe Systems, Inc.
    Optimizing ActionScript Bytecode using LLVM - + LLVM has state-of-the-art optimization capabilities that can operate against LLVM bitcode. But many of these optimizations are not intrinsically specific to LLVM's representation of programs. Adobe has built a proof-of-concept implementation of an ActionScript Bytecode optimizer using LLVM. This talk will discuss the implementation of the optimizer and possible future directions for this type of technology. +
    + [Slides] + Richard Osborne
    XMOS
    Targeting XCore resources from LLVM - + The XCore is an event driven multi-threaded processor. It provides direct hardware support for interprocess communication using channels and precise timing of inputs and outputs on I/O pins using ports. This talks looks at using LLVM to compile an version of C extended with support for explicit parallelism and I/O to the XCore. +
    + [No Slides]
    + [No Videos]
    +
    Lang Hames
    Future Works in LLVM Register Allocation - About the future of register allocation in LLVM. +
    + [Slides] + Anna Zaks
    New York University
    CoVaC: Compiler Validation by Program Analysis of the Cross-Product - I + n this talk, I am going to present CoVaC, which is a framework for formal verification of the compiler optimization phase, and give a brief overview of the prototype tool, which has been developed on top of LLVM 2.0. The CoVaC framework checks that optimization passes preserve semantics of the program being compiled by proving that the unoptimized program is equivalent to the optimized one. To leverage existing program analysis techniques, we reduce the equivalence checking problem to analysis of one system - a cross-product of the two input programs. Unlike existing frameworks, CoVaC accommodates absence of compiler annotations and handles most of the classical intraprocedural optimizations such as constant folding, reassociation, common subexpression elimination, code motion, dead code elimination, branch optimizations, and others. The talk is based on the following paper: Compiler Validation by Program Analysis of the Cross-Product, Anna Zaks and Amir Pnueli, FM'08 +
    + [No Slides]
    + [No Videos]
    +
    Nate Begeman
    OpenCL
    + [Slides] + [PPT Slides] + Santosh Nagarakatte
    University of Pennsylvania
    ftBound: Highly Compatible and Complete Spatial Memory Safety for C - + The serious bugs and security vulnerabilities facilitated by C/C++???s lack of bounds checking are well known, yet C and C++ remain in widespread use. Unfortunately, C???s arbitrary pointer arithmetic, conflation of pointers and arrays, and programmer-visible memory layout make retrofitting C/C++ with spatial safety guarantees extremely challenging. Existing approaches suffer from incompleteness, have high runtime overhead, or require non-trivial changes to the C source code. Thus far, these deficiencies have prevented widespread adoption of such techniques. In this talk, I will present SoftBound, a compile-time transformation for enforcing spatial safety of C. SoftBound records base and bound information for every pointer as disjoint metadata. This decoupling enables SoftBound to provide spatial safety without requiring changes to C source code. SoftBound is a software-only approach and performs metadata manipulation only when loading or storing pointer values. I will ! also provide a brief description of the formal proof and llvm implementation. SoftBound???s full checking mode provides complete spatial violation detection with 67% runtime overhead on average. To further reduce overheads, SoftBound has a store-only checking mode that successfully detects all the security vulnerabilities in a test suite at the cost of only 22% runtime overhead on average. +
    + [Slides] + Vinod Grover
    NVIDIA
    PLANG: Translating NVIDIA PTX language to LLVM IR + Machine - + PTX is an abstract ISA, for NVIDIA GPUs, targeted by CUDA and several other tools. PTX is jitted or compiled to a supported GPU for execution. We describe PLANG, a new front-end for PTX that emits LLVM and leverages its analysis, transformation and code generation infrastructure for PTX. Based on PLANG we have built several analysis and translation tools for PTX, e.g. synchronization analysis, visualization and targeting execution of PTX on x86 processors. In this talk we will describe PLANG, and our experiences in building tools based on LLVM. +
    + +
    Accelerating Ruby with LLVM + - + Rubinius is a ruby VM that strives to write as much of the system in ruby itself as it can. To make this practical, we're using LLVM to JIT frequently used methods. I'll cover briefly the architecture of Rubinius, spending most of the time discussing the integration points. These include: Background compilation, runtime profile guide optimization, efficient IR generation, etc. +
    + + +
    +

    Insert blurb about attendees. +

    + +
    + + +
    +
    + Valid CSS! + Valid HTML 4.01! +
    Last modified: $Date: 2009/10/12 21:52:21 $ +
    + + From tbrethou at cs.uiuc.edu Mon Oct 12 16:53:35 2009 From: tbrethou at cs.uiuc.edu (Tanya Lattner) Date: Mon, 12 Oct 2009 16:53:35 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.php Message-ID: <200910122153.n9CLrZm0028305@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.php (r1.40) removed --- Log message: Remove old page and replace with static one. --- Diffs of the changes: (+0 -0) 0 files changed From dalej at apple.com Mon Oct 12 16:54:01 2009 From: dalej at apple.com (Dale Johannesen) Date: Mon, 12 Oct 2009 14:54:01 -0700 Subject: [llvm-commits] [llvm] r83902 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp In-Reply-To: <200910122123.n9CLNGLs026827@zion.cs.uiuc.edu> References: <200910122123.n9CLNGLs026827@zion.cs.uiuc.edu> Message-ID: <5435A54B-30DB-43F9-BBB4-81DA4DED3CCB@apple.com> On Oct 12, 2009, at 2:23 PMPDT, Bob Wilson wrote: > Author: bwilson > Date: Mon Oct 12 16:23:15 2009 > New Revision: 83902 > > URL: http://llvm.org/viewvc/llvm-project?rev=83902&view=rev > Log: > Last week, ARMConstantIslandPass was failing to converge for the > MultiSource/Benchmarks/MiBench/automotive-susan test. The failure has > since been masked by an unrelated change (just randomly), so I don't > have > a testcase for this now. Radar 7291928. Thanks for tracking this down and fixing it. The last person to hit it was not so brave; can we get rid of 78377 now? From tonic at nondot.org Mon Oct 12 16:55:37 2009 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 12 Oct 2009 16:55:37 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910122155.n9CLtbNa028404@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.2 -> 1.3 --- Log message: Be patient for videos. --- Diffs of the changes: (+2 -1) index.html | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.2 llvm-www/devmtg/2009-10/index.html:1.3 --- llvm-www/devmtg/2009-10/index.html:1.2 Mon Oct 12 16:52:21 2009 +++ llvm-www/devmtg/2009-10/index.html Mon Oct 12 16:55:20 2009 @@ -41,6 +41,7 @@ major LLVM subsystems and talks on applications of LLVM for various specific projects.

    +

    Videos will take 2-4 weeks from the meeting to appear. Please be patient.

    @@ -248,7 +249,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
    Last modified: $Date: 2009/10/12 21:52:21 $ +
    Last modified: $Date: 2009/10/12 21:55:20 $ From tonic at nondot.org Mon Oct 12 16:57:25 2009 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 12 Oct 2009 16:57:25 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910122157.n9CLvPlI028496@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.3 -> 1.4 --- Log message: Non breaking space. --- Diffs of the changes: (+2 -2) index.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.3 llvm-www/devmtg/2009-10/index.html:1.4 --- llvm-www/devmtg/2009-10/index.html:1.3 Mon Oct 12 16:55:20 2009 +++ llvm-www/devmtg/2009-10/index.html Mon Oct 12 16:57:09 2009 @@ -204,7 +204,7 @@ [Slides] - [PPT Slides] + [PPT Slides] Santosh Nagarakatte
    University of Pennsylvania ftBound: Highly Compatible and Complete Spatial Memory Safety for C - @@ -249,7 +249,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
    Last modified: $Date: 2009/10/12 21:55:20 $ +
    Last modified: $Date: 2009/10/12 21:57:09 $ From tonic at nondot.org Mon Oct 12 16:59:40 2009 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 12 Oct 2009 16:59:40 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/Petersen_OptimizingActionScriptBytecode.pdf Message-ID: <200910122159.n9CLxeKw028669@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: Petersen_OptimizingActionScriptBytecode.pdf added (r1.1) --- Log message: Add Petersen talk. --- Diffs of the changes: (+0 -0) Petersen_OptimizingActionScriptBytecode.pdf | 0 1 files changed Index: llvm-www/devmtg/2009-10/Petersen_OptimizingActionScriptBytecode.pdf From tonic at nondot.org Mon Oct 12 17:02:52 2009 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 12 Oct 2009 17:02:52 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/talkInfo.php Message-ID: <200910122202.n9CM2quL028851@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg: talkInfo.php updated: 1.1 -> 1.2 --- Log message: Its an int. --- Diffs of the changes: (+1 -1) talkInfo.php | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-www/devmtg/talkInfo.php diff -u llvm-www/devmtg/talkInfo.php:1.1 llvm-www/devmtg/talkInfo.php:1.2 --- llvm-www/devmtg/talkInfo.php:1.1 Thu Oct 1 21:16:05 2009 +++ llvm-www/devmtg/talkInfo.php Mon Oct 12 17:02:37 2009 @@ -8,7 +8,7 @@ virtual("../header.incl"); ?> References: <200910122123.n9CLNGLs026827@zion.cs.uiuc.edu> <5435A54B-30DB-43F9-BBB4-81DA4DED3CCB@apple.com> Message-ID: <33316BD2-5E02-4864-B981-16FE9C130585@apple.com> On Oct 12, 2009, at 2:54 PM, Dale Johannesen wrote: > > On Oct 12, 2009, at 2:23 PMPDT, Bob Wilson wrote: > >> Author: bwilson >> Date: Mon Oct 12 16:23:15 2009 >> New Revision: 83902 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=83902&view=rev >> Log: >> Last week, ARMConstantIslandPass was failing to converge for the >> MultiSource/Benchmarks/MiBench/automotive-susan test. The failure has >> since been masked by an unrelated change (just randomly), so I don't >> have >> a testcase for this now. Radar 7291928. > > Thanks for tracking this down and fixing it. The last person to hit > it was not so brave; can we get rid of 78377 now? Why do we want to get rid of 78377? Error out is always better than infinite looping. It's still theoretically possible there is another bug that can cause it not to converge. Evan > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From tonic at nondot.org Mon Oct 12 17:04:03 2009 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 12 Oct 2009 17:04:03 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910122204.n9CM436V028943@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.4 -> 1.5 --- Log message: Fix title. --- Diffs of the changes: (+2 -2) index.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.4 llvm-www/devmtg/2009-10/index.html:1.5 --- llvm-www/devmtg/2009-10/index.html:1.4 Mon Oct 12 16:57:09 2009 +++ llvm-www/devmtg/2009-10/index.html Mon Oct 12 17:03:46 2009 @@ -207,7 +207,7 @@ [PPT Slides] Santosh Nagarakatte
    University of Pennsylvania - ftBound: Highly Compatible and Complete Spatial Memory Safety for C - + SoftBound: Highly Compatible and Complete Spatial Memory Safety for C - The serious bugs and security vulnerabilities facilitated by C/C++???s lack of bounds checking are well known, yet C and C++ remain in widespread use. Unfortunately, C???s arbitrary pointer arithmetic, conflation of pointers and arrays, and programmer-visible memory layout make retrofitting C/C++ with spatial safety guarantees extremely challenging. Existing approaches suffer from incompleteness, have high runtime overhead, or require non-trivial changes to the C source code. Thus far, these deficiencies have prevented widespread adoption of such techniques. In this talk, I will present SoftBound, a compile-time transformation for enforcing spatial safety of C. SoftBound records base and bound information for every pointer as disjoint metadata. This decoupling enables SoftBound to provide spatial safety without requiring changes to C source code. SoftBound is a software-only approach and performs metadata manipulation only when loading or storing pointer values. I will ! also provide a brief description of the formal proof and llvm implementation. SoftBound???s full checking mode provides complete spatial violation detection with 67% runtime overhead on average. To further reduce overheads, SoftBound has a store-only checking mode that successfully detects all the security vulnerabilities in a test suite at the cost of only 22% runtime overhead on average. @@ -249,7 +249,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
    Last modified: $Date: 2009/10/12 21:57:09 $ +
    Last modified: $Date: 2009/10/12 22:03:46 $ From bob.wilson at apple.com Mon Oct 12 17:01:58 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 12 Oct 2009 15:01:58 -0700 Subject: [llvm-commits] [llvm] r83902 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp In-Reply-To: <5435A54B-30DB-43F9-BBB4-81DA4DED3CCB@apple.com> References: <200910122123.n9CLNGLs026827@zion.cs.uiuc.edu> <5435A54B-30DB-43F9-BBB4-81DA4DED3CCB@apple.com> Message-ID: On Oct 12, 2009, at 2:54 PM, Dale Johannesen wrote: > > On Oct 12, 2009, at 2:23 PMPDT, Bob Wilson wrote: > >> Author: bwilson >> Date: Mon Oct 12 16:23:15 2009 >> New Revision: 83902 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=83902&view=rev >> Log: >> Last week, ARMConstantIslandPass was failing to converge for the >> MultiSource/Benchmarks/MiBench/automotive-susan test. The failure >> has >> since been masked by an unrelated change (just randomly), so I >> don't have >> a testcase for this now. Radar 7291928. > > Thanks for tracking this down and fixing it. The last person to hit > it was not so brave; can we get rid of 78377 now? > You're welcome. I'm a big fan of 78377 (the patch that causes the compiler to fail instead of running forever when the pass doesn't converge). It should hopefully not matter but there's always a chance that new bugs will creep in.... If (or maybe I should say "when") that happens, it's very bad for the compiler to hang. From tonic at nondot.org Mon Oct 12 17:08:55 2009 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 12 Oct 2009 17:08:55 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910122208.n9CM8t3V029150@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.5 -> 1.6 --- Log message: Shorten descriptions. --- Diffs of the changes: (+6 -5) index.html | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.5 llvm-www/devmtg/2009-10/index.html:1.6 --- llvm-www/devmtg/2009-10/index.html:1.5 Mon Oct 12 17:03:46 2009 +++ llvm-www/devmtg/2009-10/index.html Mon Oct 12 17:08:39 2009 @@ -88,7 +88,7 @@ Nicolas Geoffray
    Universite Pierre et Marie Curie Precise and efficient garbage collection in VMKit with MMTk - - This talk will describe how we have added precise garbage collection in VMKit, both in the JVM and .Net runtime. The work continues in the spirit of VMKit, in that the garbage collector is an external library provided by others. We have used MMTk, a garbage collector written in Java to provide efficient and precise garbage collection. The talk will give a step by step explanation on how the new system was implemented (using LLVM as an ahead of time compiler for Java, using the LLVM GC framework, creating stack maps at runtime, etc), and provide a tutorial on how this can be adopted by other kinds of VMs implemented with LLVM. Additionally, I will show the new performance results with the new garbage collector. The new system continues to support big applications (eclipse, tomcat, DaCapo benchmarks), and provides way better performance than before. + This talk will describe how we have added precise garbage collection in VMKit, both in the JVM and .Net runtime. The work continues in the spirit of VMKit, in that the garbage collector is an external library provided by others. We have used MMTk, a garbage collector written in Java to provide efficient and precise garbage collection. The talk will give a step by step explanation on how the new system was implemented and provide a tutorial on how this can be adopted by other kinds of VMs implemented with LLVM. Additionally, I will show the new performance results with the new garbage collector. @@ -187,8 +187,9 @@ [Slides] Anna Zaks
    New York University - CoVaC: Compiler Validation by Program Analysis of the Cross-Product - I - n this talk, I am going to present CoVaC, which is a framework for formal verification of the compiler optimization phase, and give a brief overview of the prototype tool, which has been developed on top of LLVM 2.0. The CoVaC framework checks that optimization passes preserve semantics of the program being compiled by proving that the unoptimized program is equivalent to the optimized one. To leverage existing program analysis techniques, we reduce the equivalence checking problem to analysis of one system - a cross-product of the two input programs. Unlike existing frameworks, CoVaC accommodates absence of compiler annotations and handles most of the classical intraprocedural optimizations such as constant folding, reassociation, common subexpression elimination, code motion, dead code elimination, branch optimizations, and others. The talk is based on the following paper: Compiler Validation by Program Analysis of the Cross-Product, Anna Zaks and Amir Pnueli, FM'08 + CoVaC: Compiler Validation by Program Analysis of the Cross-Product - + CoVaC is a framework for formal verification of the compiler optimization phase. This talk gives a brief overview of the prototype tool, which has been developed on top of LLVM 2.0. The CoVaC framework checks that optimization passes preserve semantics of the program being compiled by proving that the unoptimized program is equivalent to the optimized one. To leverage existing program analysis techniques, we reduce the equivalence checking problem to analysis of one system - a cross-product of the two input programs. +The talk is based on the following paper: Compiler Validation by Program Analysis of the Cross-Product, Anna Zaks and Amir Pnueli, FM'08 @@ -208,7 +209,7 @@ Santosh Nagarakatte
    University of Pennsylvania SoftBound: Highly Compatible and Complete Spatial Memory Safety for C - - The serious bugs and security vulnerabilities facilitated by C/C++???s lack of bounds checking are well known, yet C and C++ remain in widespread use. Unfortunately, C???s arbitrary pointer arithmetic, conflation of pointers and arrays, and programmer-visible memory layout make retrofitting C/C++ with spatial safety guarantees extremely challenging. Existing approaches suffer from incompleteness, have high runtime overhead, or require non-trivial changes to the C source code. Thus far, these deficiencies have prevented widespread adoption of such techniques. In this talk, I will present SoftBound, a compile-time transformation for enforcing spatial safety of C. SoftBound records base and bound information for every pointer as disjoint metadata. This decoupling enables SoftBound to provide spatial safety without requiring changes to C source code. SoftBound is a software-only approach and performs metadata manipulation only when loading or storing pointer values. I will ! also provide a brief description of the formal proof and llvm implementation. SoftBound???s full checking mode provides complete spatial violation detection with 67% runtime overhead on average. To further reduce overheads, SoftBound has a store-only checking mode that successfully detects all the security vulnerabilities in a test suite at the cost of only 22% runtime overhead on average. +SoftBound is a compile-time transformation for enforcing spatial safety of C. SoftBound records base and bound information for every pointer as disjoint metadata. This decoupling enables SoftBound to provide spatial safety without requiring changes to C source code. SoftBound is a software-only approach and performs metadata manipulation only when loading or storing pointer values. This talk provides a brief description of the formal proof and llvm implementation. @@ -249,7 +250,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
    Last modified: $Date: 2009/10/12 22:03:46 $ +
    Last modified: $Date: 2009/10/12 22:08:39 $ From evan.cheng at apple.com Mon Oct 12 17:25:23 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 12 Oct 2009 22:25:23 -0000 Subject: [llvm-commits] [llvm] r83908 - /llvm/trunk/lib/Transforms/Scalar/LICM.cpp Message-ID: <200910122225.n9CMPN5e029827@zion.cs.uiuc.edu> Author: evancheng Date: Mon Oct 12 17:25:23 2009 New Revision: 83908 URL: http://llvm.org/viewvc/llvm-project?rev=83908&view=rev Log: Make licm debug message readable. Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=83908&r1=83907&r2=83908&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Mon Oct 12 17:25:23 2009 @@ -605,7 +605,8 @@ /// that is safe to hoist, this instruction is called to do the dirty work. /// void LICM::hoist(Instruction &I) { - DEBUG(errs() << "LICM hoisting to " << Preheader->getName() << ": " << I); + DEBUG(errs() << "LICM hoisting to " << Preheader->getName() << ": " + << I << "\n"); // Remove the instruction from its current basic block... but don't delete the // instruction. From enderby at apple.com Mon Oct 12 17:39:55 2009 From: enderby at apple.com (Kevin Enderby) Date: Mon, 12 Oct 2009 22:39:55 -0000 Subject: [llvm-commits] [llvm] r83915 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <200910122239.n9CMdtSt030481@zion.cs.uiuc.edu> Author: enderby Date: Mon Oct 12 17:39:54 2009 New Revision: 83915 URL: http://llvm.org/viewvc/llvm-project?rev=83915&view=rev Log: Fix a problem in the code where ARMAsmParser::ParseShift() second argument should have been a pointer to a reference. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=83915&r1=83914&r2=83915&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Mon Oct 12 17:39:54 2009 @@ -50,7 +50,7 @@ bool ParseMemory(ARMOperand &Op); - bool ParseShift(enum ShiftType *St, const MCExpr *ShiftAmount); + bool ParseShift(enum ShiftType *St, const MCExpr *&ShiftAmount); bool ParseOperand(ARMOperand &Op); @@ -414,7 +414,7 @@ /// ( lsl | lsr | asr | ror ) , # shift_amount /// rrx /// and returns true if it parses a shift otherwise it returns false. -bool ARMAsmParser::ParseShift(ShiftType *St, const MCExpr *ShiftAmount) { +bool ARMAsmParser::ParseShift(ShiftType *St, const MCExpr *&ShiftAmount) { const AsmToken &Tok = getLexer().getTok(); if (Tok.isNot(AsmToken::Identifier)) return true; From bob.wilson at apple.com Mon Oct 12 17:49:05 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 12 Oct 2009 22:49:05 -0000 Subject: [llvm-commits] [llvm] r83916 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910122249.n9CMn5sW030870@zion.cs.uiuc.edu> Author: bwilson Date: Mon Oct 12 17:49:05 2009 New Revision: 83916 URL: http://llvm.org/viewvc/llvm-project?rev=83916&view=rev Log: Delete a comment that makes no sense to me. The statement that moving a CPE before its reference is only supported on ARM has not been true for a while. In fact, until recently, that was only supported for Thumb. Besides that, CPEs are always a multiple of 4 bytes in size, so inserting a CPE should have no effect on Thumb alignment. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=83916&r1=83915&r2=83916&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Oct 12 17:49:05 2009 @@ -757,8 +757,7 @@ BBSizes[Water->getNumber()]; // If the CPE is to be inserted before the instruction, that will raise - // the offset of the instruction. (Currently applies only to ARM, so - // no alignment compensation attempted here.) + // the offset of the instruction. if (CPEOffset < UserOffset) UserOffset += U.CPEMI->getOperand(2).getImm(); From enderby at apple.com Mon Oct 12 17:51:50 2009 From: enderby at apple.com (Kevin Enderby) Date: Mon, 12 Oct 2009 22:51:50 -0000 Subject: [llvm-commits] [llvm] r83917 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <200910122251.n9CMpobJ030971@zion.cs.uiuc.edu> Author: enderby Date: Mon Oct 12 17:51:49 2009 New Revision: 83917 URL: http://llvm.org/viewvc/llvm-project?rev=83917&view=rev Log: Fix two warnings about unused variables that are only used in assert() calls. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=83917&r1=83916&r2=83917&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Mon Oct 12 17:51:49 2009 @@ -216,8 +216,8 @@ // Try to parse a register list. The first token must be a '{' when called // for now. bool ARMAsmParser::ParseRegisterList(ARMOperand &Op) { - const AsmToken &LCurlyTok = getLexer().getTok(); - assert(LCurlyTok.is(AsmToken::LCurly) && "Token is not an Left Curly Brace"); + assert(getLexer().getTok().is(AsmToken::LCurly) && + "Token is not an Left Curly Brace"); getLexer().Lex(); // Eat left curly brace token. const AsmToken &RegTok = getLexer().getTok(); @@ -264,8 +264,8 @@ // TODO Only preindexing and postindexing addressing are started, unindexed // with option, etc are still to do. bool ARMAsmParser::ParseMemory(ARMOperand &Op) { - const AsmToken &LBracTok = getLexer().getTok(); - assert(LBracTok.is(AsmToken::LBrac) && "Token is not an Left Bracket"); + assert(getLexer().getTok().is(AsmToken::LBrac) && + "Token is not an Left Bracket"); getLexer().Lex(); // Eat left bracket token. const AsmToken &BaseRegTok = getLexer().getTok(); From dpatel at apple.com Mon Oct 12 18:10:55 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 12 Oct 2009 23:10:55 -0000 Subject: [llvm-commits] [llvm] r83921 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200910122310.n9CNAtpH031737@zion.cs.uiuc.edu> Author: dpatel Date: Mon Oct 12 18:10:55 2009 New Revision: 83921 URL: http://llvm.org/viewvc/llvm-project?rev=83921&view=rev Log: Set default location for a function if it is not set. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=83921&r1=83920&r2=83921&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Oct 12 18:10:55 2009 @@ -385,6 +385,8 @@ DILocation DILoc(Dbg); DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo()); SDL->setCurDebugLoc(Loc); + if (MF->getDefaultDebugLoc().isUnknown()) + MF->setDefaultDebugLoc(Loc); } } if (!isa(I)) From dpatel at apple.com Mon Oct 12 18:11:24 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 12 Oct 2009 23:11:24 -0000 Subject: [llvm-commits] [llvm] r83922 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200910122311.n9CNBOAZ031772@zion.cs.uiuc.edu> Author: dpatel Date: Mon Oct 12 18:11:24 2009 New Revision: 83922 URL: http://llvm.org/viewvc/llvm-project?rev=83922&view=rev Log: Find enclosing subprogram info. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=83922&r1=83921&r2=83922&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Oct 12 18:11:24 2009 @@ -1894,6 +1894,24 @@ return !DbgScopeMap.empty(); } +static DISubprogram getDISubprogram(MDNode *N) { + + DIDescriptor D(N); + if (D.isNull()) + return DISubprogram(); + + if (D.isCompileUnit()) + return DISubprogram(); + + if (D.isSubprogram()) + return DISubprogram(N); + + if (D.isLexicalBlock()) + return getDISubprogram(DILexicalBlock(N).getContext().getNode()); + + assert (0 && "Unexpected Descriptor!"); +} + /// BeginFunction - Gather pre-function debug information. Assumes being /// emitted immediately after the function entry point. void DwarfDebug::BeginFunction(MachineFunction *MF) { @@ -1923,7 +1941,7 @@ if (!FDL.isUnknown()) { DebugLocTuple DLT = MF->getDebugLocTuple(FDL); unsigned LabelID = 0; - DISubprogram SP(DLT.CompileUnit); + DISubprogram SP = getDISubprogram(DLT.CompileUnit); if (!SP.isNull()) LabelID = RecordSourceLine(SP.getLineNumber(), 0, DLT.CompileUnit); else From dpatel at apple.com Mon Oct 12 18:22:09 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 12 Oct 2009 23:22:09 -0000 Subject: [llvm-commits] [llvm] r83925 - in /llvm/trunk/include/llvm: Analysis/DebugInfo.h CodeGen/MachineModuleInfo.h Message-ID: <200910122322.n9CNMAUI032304@zion.cs.uiuc.edu> Author: dpatel Date: Mon Oct 12 18:22:09 2009 New Revision: 83925 URL: http://llvm.org/viewvc/llvm-project?rev=83925&view=rev Log: Enable "debug info attached to an instruction" mode. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=83925&r1=83924&r2=83925&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Mon Oct 12 18:22:09 2009 @@ -26,6 +26,8 @@ #include "llvm/Support/Dwarf.h" #include "llvm/Support/ValueHandle.h" +#define ATTACH_DEBUG_INFO_TO_AN_INSN 1 + namespace llvm { class BasicBlock; class Constant; Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=83925&r1=83924&r2=83925&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Mon Oct 12 18:22:09 2009 @@ -44,6 +44,8 @@ #include "llvm/Pass.h" #include "llvm/Metadata.h" +#define ATTACH_DEBUG_INFO_TO_AN_INSN 1 + namespace llvm { //===----------------------------------------------------------------------===// From sabre at nondot.org Mon Oct 12 18:56:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 12 Oct 2009 18:56:32 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/index.html Message-ID: <200910122356.n9CNuW2J001154@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg: index.html updated: 1.6 -> 1.7 --- Log message: fix link, the meeting already happened. --- Diffs of the changes: (+5 -6) index.html | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) Index: llvm-www/devmtg/index.html diff -u llvm-www/devmtg/index.html:1.6 llvm-www/devmtg/index.html:1.7 --- llvm-www/devmtg/index.html:1.6 Fri Jul 10 12:45:18 2009 +++ llvm-www/devmtg/index.html Mon Oct 12 18:55:33 2009 @@ -2,14 +2,13 @@
    LLVM Developers' Meeting
    -Upcoming Developers' Meeting: October 2, 2009 - Cupertino, CA, USA -

    We have had these meetings so far:

    @@ -21,7 +20,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
    Last modified: $Date: 2009/07/10 17:45:18 $ +
    Last modified: $Date: 2009/10/12 23:55:33 $ From eocallaghan at auroraux.org Mon Oct 12 20:01:38 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Tue, 13 Oct 2009 01:01:38 -0000 Subject: [llvm-commits] [llvm] r83930 - in /llvm/trunk: configure include/llvm/Config/config.h.in Message-ID: <200910130101.n9D11doq003791@zion.cs.uiuc.edu> Author: evocallaghan Date: Mon Oct 12 20:01:38 2009 New Revision: 83930 URL: http://llvm.org/viewvc/llvm-project?rev=83930&view=rev Log: Regenerate configure for rev. 83823 putback. Modified: llvm/trunk/configure llvm/trunk/include/llvm/Config/config.h.in Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=83930&r1=83929&r2=83930&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Mon Oct 12 20:01:38 2009 @@ -2348,6 +2348,11 @@ llvm_cv_no_link_all_option="-Wl,--no-whole-archive" llvm_cv_os_type="MingW" llvm_cv_platform_type="Win32" ;; + *-*-haiku*) + llvm_cv_link_all_option="-Wl,--whole-archive" + llvm_cv_no_link_all_option="-Wl,--no-whole-archive" + llvm_cv_os_type="Haiku" + llvm_cv_platform_type="Unix" ;; *-unknown-eabi*) llvm_cv_link_all_option="-Wl,--whole-archive" llvm_cv_no_link_all_option="-Wl,--no-whole-archive" @@ -2402,6 +2407,8 @@ llvm_cv_target_os_type="Win32" ;; *-*-mingw*) llvm_cv_target_os_type="MingW" ;; + *-*-haiku*) + llvm_cv_target_os_type="Haiku" ;; *-unknown-eabi*) llvm_cv_target_os_type="Freestanding" ;; *) @@ -10994,7 +11001,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 13148 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14856,11 +14863,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14859: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14866: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14863: \$? = $ac_status" >&5 + echo "$as_me:14870: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15124,11 +15131,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15127: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15134: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15131: \$? = $ac_status" >&5 + echo "$as_me:15138: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15228,11 +15235,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15231: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15238: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15235: \$? = $ac_status" >&5 + echo "$as_me:15242: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17680,7 +17687,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:20158: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:20155: \$? = $ac_status" >&5 + echo "$as_me:20162: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -20252,11 +20259,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:20255: $lt_compile\"" >&5) + (eval echo "\"\$as_me:20262: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:20259: \$? = $ac_status" >&5 + echo "$as_me:20266: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21822,11 +21829,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21825: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21832: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21829: \$? = $ac_status" >&5 + echo "$as_me:21836: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21926,11 +21933,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21929: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21936: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21933: \$? = $ac_status" >&5 + echo "$as_me:21940: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -24161,11 +24168,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24164: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24171: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24168: \$? = $ac_status" >&5 + echo "$as_me:24175: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24429,11 +24436,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24432: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24439: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24436: \$? = $ac_status" >&5 + echo "$as_me:24443: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24533,11 +24540,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24536: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24543: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24540: \$? = $ac_status" >&5 + echo "$as_me:24547: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -28019,14 +28026,12 @@ if test "$ENABLE_THREADS" -eq 1 ; then - -{ echo "$as_me:$LINENO: checking for pthread_mutex_init in -lpthread" >&5 -echo $ECHO_N "checking for pthread_mutex_init in -lpthread... $ECHO_C" >&6; } -if test "${ac_cv_lib_pthread_pthread_mutex_init+set}" = set; then + { echo "$as_me:$LINENO: checking for library containing pthread_mutex_init" >&5 +echo $ECHO_N "checking for library containing pthread_mutex_init... $ECHO_C" >&6; } +if test "${ac_cv_search_pthread_mutex_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpthread $LIBS" + ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -28049,7 +28054,14 @@ return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext +for ac_lib in '' pthread; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; @@ -28083,26 +28095,37 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lib_pthread_pthread_mutex_init=yes + ac_cv_search_pthread_mutex_init=$ac_res else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_lib_pthread_pthread_mutex_init=no + fi rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + conftest$ac_exeext + if test "${ac_cv_search_pthread_mutex_init+set}" = set; then + break fi -{ echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_mutex_init" >&5 -echo "${ECHO_T}$ac_cv_lib_pthread_pthread_mutex_init" >&6; } -if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBPTHREAD 1 -_ACEOF +done +if test "${ac_cv_search_pthread_mutex_init+set}" = set; then + : +else + ac_cv_search_pthread_mutex_init=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_pthread_mutex_init" >&5 +echo "${ECHO_T}$ac_cv_search_pthread_mutex_init" >&6; } +ac_res=$ac_cv_search_pthread_mutex_init +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - LIBS="-lpthread $LIBS" +cat >>confdefs.h <<\_ACEOF +#define HAVE_PTHREAD 1 +_ACEOF fi Modified: llvm/trunk/include/llvm/Config/config.h.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.in?rev=83930&r1=83929&r2=83930&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.in (original) +++ llvm/trunk/include/llvm/Config/config.h.in Mon Oct 12 20:01:38 2009 @@ -193,9 +193,6 @@ /* Define to 1 if you have the `psapi' library (-lpsapi). */ #undef HAVE_LIBPSAPI -/* Define to 1 if you have the `pthread' library (-lpthread). */ -#undef HAVE_LIBPTHREAD - /* Define to 1 if you have the `udis86' library (-ludis86). */ #undef HAVE_LIBUDIS86 @@ -285,6 +282,9 @@ /* Define to have the %a format string */ #undef HAVE_PRINTF_A +/* Have pthread */ +#undef HAVE_PTHREAD + /* Have pthread_getspecific */ #undef HAVE_PTHREAD_GETSPECIFIC From eocallaghan at auroraux.org Mon Oct 12 20:02:33 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Tue, 13 Oct 2009 02:02:33 +0100 Subject: [llvm-commits] [llvm] r83823 - in /llvm/trunk: autoconf/configure.ac lib/System/Unix/Process.inc utils/unittest/googletest/include/gtest/internal/gtest-port.h In-Reply-To: <521640720910120212k507a4735geef739b277059f58@mail.gmail.com> References: <200910120457.n9C4vKCL002499@zion.cs.uiuc.edu> <521640720910120212k507a4735geef739b277059f58@mail.gmail.com> Message-ID: <521640720910121802r6055c982r364f0fcf74bd80@mail.gmail.com> Commited in rev. 83930. From: http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-October/026424.html Sorry about that, Thanks. 2009/10/12 Edward O'Callaghan : > Oh ! OK thanks, Do you do ./autogen.sh or something? > Maybe quicker if you do it on Linux or what not, results could be not > quite right on my platform? > > Cheers, > Edward. > > 2009/10/12 Anton Korobeynikov : >>> ? ?llvm/trunk/autoconf/configure.ac >> You need to regenerate configure. >> >> -- >> With best regards, Anton Korobeynikov >> Faculty of Mathematics and Mechanics, Saint Petersburg State University >> > > > > -- > -- > Edward O'Callaghan > http://www.auroraux.org/ > eocallaghan at auroraux dot org > -- -- Edward O'Callaghan http://www.auroraux.org/ eocallaghan at auroraux dot org From vhernandez at apple.com Mon Oct 12 20:42:54 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Tue, 13 Oct 2009 01:42:54 -0000 Subject: [llvm-commits] [llvm] r83931 - in /llvm/trunk: lib/Analysis/MemoryDependenceAnalysis.cpp test/Transforms/GVN/2009-11-12-MemDepMallocBitCast.ll Message-ID: <200910130142.n9D1gsZR005354@zion.cs.uiuc.edu> Author: hernande Date: Mon Oct 12 20:42:53 2009 New Revision: 83931 URL: http://llvm.org/viewvc/llvm-project?rev=83931&view=rev Log: Memory dependence analysis was incorrectly stopping to scan for stores to a pointer at bitcast uses of a malloc call. It should continue scanning until the malloc call, and this patch fixes that. Added: llvm/trunk/test/Transforms/GVN/2009-11-12-MemDepMallocBitCast.ll Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=83931&r1=83930&r2=83931&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Mon Oct 12 20:42:53 2009 @@ -225,16 +225,11 @@ // the allocation, return Def. This means that there is no dependence and // the access can be optimized based on that. For example, a load could // turn into undef. - if (AllocationInst *AI = dyn_cast(Inst)) { - Value *AccessPtr = MemPtr->getUnderlyingObject(); - - if (AccessPtr == AI || - AA->alias(AI, 1, AccessPtr, 1) == AliasAnalysis::MustAlias) - return MemDepResult::getDef(AI); - continue; - } - - if (isMalloc(Inst)) { + // Note: Only determine this to be a malloc if Inst is the malloc call, not + // a subsequent bitcast of the malloc call result. There can be stores to + // the malloced memory between the malloc call and its bitcast uses, and we + // need to continue scanning until the malloc call. + if (isa(Inst) || extractMallocCall(Inst)) { Value *AccessPtr = MemPtr->getUnderlyingObject(); if (AccessPtr == Inst || Added: llvm/trunk/test/Transforms/GVN/2009-11-12-MemDepMallocBitCast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/2009-11-12-MemDepMallocBitCast.ll?rev=83931&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/2009-11-12-MemDepMallocBitCast.ll (added) +++ llvm/trunk/test/Transforms/GVN/2009-11-12-MemDepMallocBitCast.ll Mon Oct 12 20:42:53 2009 @@ -0,0 +1,15 @@ +; Test to make sure malloc's bitcast does not block detection of a store +; to aliased memory; GVN should not optimize away the load in this program. +; RUN: opt < %s -gvn -S | FileCheck %s + +define i64 @test() { + %1 = tail call i8* @malloc(i64 mul (i64 4, i64 ptrtoint (i64* getelementptr (i64* null, i64 1) to i64))) ; [#uses=2] + store i8 42, i8* %1 + %X = bitcast i8* %1 to i64* ; [#uses=1] + %Y = load i64* %X ; [#uses=1] + ret i64 %Y +; CHECK: %Y = load i64* %X +; CHECK: ret i64 %Y +} + +declare noalias i8* @malloc(i64) From gohman at apple.com Mon Oct 12 20:49:02 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 13 Oct 2009 01:49:02 -0000 Subject: [llvm-commits] [llvm] r83932 - in /llvm/trunk: include/llvm/ADT/APInt.h unittests/ADT/APIntTest.cpp Message-ID: <200910130149.n9D1n3VL005523@zion.cs.uiuc.edu> Author: djg Date: Mon Oct 12 20:49:02 2009 New Revision: 83932 URL: http://llvm.org/viewvc/llvm-project?rev=83932&view=rev Log: Add a ceilLogBase2 function to APInt. Modified: llvm/trunk/include/llvm/ADT/APInt.h llvm/trunk/unittests/ADT/APIntTest.cpp Modified: llvm/trunk/include/llvm/ADT/APInt.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=83932&r1=83931&r2=83932&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/APInt.h (original) +++ llvm/trunk/include/llvm/ADT/APInt.h Mon Oct 12 20:49:02 2009 @@ -1234,6 +1234,11 @@ return BitWidth - 1 - countLeadingZeros(); } + /// @returns the ceil log base 2 of this APInt. + unsigned ceilLogBase2() const { + return BitWidth - (*this - 1).countLeadingZeros(); + } + /// @returns the log base 2 of this APInt if its an exact power of two, -1 /// otherwise int32_t exactLogBase2() const { Modified: llvm/trunk/unittests/ADT/APIntTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/APIntTest.cpp?rev=83932&r1=83931&r2=83932&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/APIntTest.cpp (original) +++ llvm/trunk/unittests/ADT/APIntTest.cpp Mon Oct 12 20:49:02 2009 @@ -315,6 +315,17 @@ EXPECT_EQ(9U, APInt::getBitsNeeded("-20", 16)); } +TEST(APIntTest, Log2) { + EXPECT_EQ(APInt(15, 7).logBase2(), 2); + EXPECT_EQ(APInt(15, 7).ceilLogBase2(), 3); + EXPECT_EQ(APInt(15, 7).exactLogBase2(), -1); + EXPECT_EQ(APInt(15, 8).logBase2(), 3); + EXPECT_EQ(APInt(15, 8).ceilLogBase2(), 3); + EXPECT_EQ(APInt(15, 8).exactLogBase2(), 3); + EXPECT_EQ(APInt(15, 9).logBase2(), 3); + EXPECT_EQ(APInt(15, 9).ceilLogBase2(), 4); + EXPECT_EQ(APInt(15, 9).exactLogBase2(), -1); +} #ifdef GTEST_HAS_DEATH_TEST TEST(APIntTest, StringDeath) { From dpatel at apple.com Mon Oct 12 20:51:29 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 01:51:29 -0000 Subject: [llvm-commits] [llvm] r83933 - in /llvm/trunk/test: FrontendC++/2006-11-06-StackTrace.cpp FrontendC/2005-12-04-DeclarationLineNumbers.c FrontendC/2006-01-13-Includes.c FrontendC/2009-02-17-BitField-dbg.c FrontendObjC/2009-08-17-DebugInfo.m Message-ID: <200910130151.n9D1pTO0005602@zion.cs.uiuc.edu> Author: dpatel Date: Mon Oct 12 20:51:29 2009 New Revision: 83933 URL: http://llvm.org/viewvc/llvm-project?rev=83933&view=rev Log: XFAIL these tests for now. Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp llvm/trunk/test/FrontendC/2005-12-04-DeclarationLineNumbers.c llvm/trunk/test/FrontendC/2006-01-13-Includes.c llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-06-StackTrace.cpp?rev=83933&r1=83932&r2=83933&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp Mon Oct 12 20:51:29 2009 @@ -13,6 +13,7 @@ // Only works on ppc (but not apple-darwin9), x86 and x86_64. Should // generalize? // XFAIL: alpha|arm|powerpc-apple-darwin9 +// XFAIL: * #include Modified: llvm/trunk/test/FrontendC/2005-12-04-DeclarationLineNumbers.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2005-12-04-DeclarationLineNumbers.c?rev=83933&r1=83932&r2=83933&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2005-12-04-DeclarationLineNumbers.c (original) +++ llvm/trunk/test/FrontendC/2005-12-04-DeclarationLineNumbers.c Mon Oct 12 20:51:29 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc %s -S -g -o - | grep {llvm.dbg.stoppoint.*i32 14} +// RUN: %llvmgcc %s -S -g -o - | grep DW_TAG_compile_unit | count 1 // PR664: ensure that line #'s are emitted for declarations Modified: llvm/trunk/test/FrontendC/2006-01-13-Includes.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2006-01-13-Includes.c?rev=83933&r1=83932&r2=83933&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2006-01-13-Includes.c (original) +++ llvm/trunk/test/FrontendC/2006-01-13-Includes.c Mon Oct 12 20:51:29 2009 @@ -1,6 +1,7 @@ // RUN: %llvmgcc %s -g -S -o - | llvm-as | opt -std-compile-opts | \ // RUN: llvm-dis | grep {test/FrontendC} // PR676 +// XFAIL: * #include Modified: llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c?rev=83933&r1=83932&r2=83933&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c (original) +++ llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c Mon Oct 12 20:51:29 2009 @@ -5,6 +5,7 @@ // RUN: echo {ptype mystruct} > %t2 // RUN: gdb -q -batch -n -x %t2 2009-02-17-BitField-dbg.o | \ // RUN: tee 2009-02-17-BitField-dbg.out | grep "int a : 4" +// XFAIL: * struct { int a:4; Modified: llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m?rev=83933&r1=83932&r2=83933&view=diff ============================================================================== --- llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m (original) +++ llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m Mon Oct 12 20:51:29 2009 @@ -7,6 +7,7 @@ // RUN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | \ // RUN: grep {Breakpoint 1 at 0x.*: file 2009-08-17-DebugInfo.m, line 21} // XTARGET: darwin +// XFAIL: * @interface MyClass { int my; From daniel_dunbar at apple.com Mon Oct 12 09:02:36 2009 From: daniel_dunbar at apple.com (Daniel Dunbar) Date: Mon, 12 Oct 2009 17:02:36 +0300 Subject: [llvm-commits] [llvm] r83082 - /llvm/trunk/include/llvm/ADT/StringRef.h In-Reply-To: <77942D29-5F7E-4AE6-B56B-2CE12FF05A02@apple.com> References: <200909291839.n8TIdv0K005250@zion.cs.uiuc.edu> <5EAC33CE-F7F4-415E-AAE2-D3D090178ACB@apple.com> <9DA16CEF-67EF-449A-870E-9818DA3850CA@apple.com> <77942D29-5F7E-4AE6-B56B-2CE12FF05A02@apple.com> Message-ID: <08828162-224F-46F6-A00A-5C295D19BFE5@apple.com> Yes, this isn't something that should be in StringRef, I would go so far to say this is an invariant clients can rely on: -- StringRef(a).data() == a -- As Chris mentions we want the StringRef constructors to be simple, we use them a lot and rely on the optimizer to clean them up, for example in default arguments. It's good to avoid any unnecessary complexity. - Daniel On Sep 29, 2009, at 9:59 PM, Chris Lattner wrote: > On Sep 29, 2009, at 11:57 AM, Devang Patel wrote: >> On Sep 29, 2009, at 11:53 AM, Chris Lattner wrote: >>> On Sep 29, 2009, at 11:39 AM, Devang Patel wrote: >>> Author: dpatel >>>> Date: Tue Sep 29 13:39:56 2009 >>>> New Revision: 83082 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=83082&view=rev >>>> Log: >>>> Create empty StringRef is incoming cstring is NULL. >>> >>> I don't think this is correct, StringRef shouldn't allow null >>> cstrings to be passed in. >> >> I'm using it to pass optional strings. For example, linkage name in >> debug info. >> Note, one can create empty StringRef by say >> SringRef foo; >> If this is not desirable then I'll update DebugInfo interface. > > The reason I mention that is that stringref is frequently used for > const char*'s, and this adds an extra branch to the common case. > Doing something like: > > return ptr != 0 : StringRef(ptr) : StringRef(); > > in the debug info stuff would make it pay the cost locally instead > of making all clients of stringref pay it. > > What do you think Daniel? > > BTW, getting rid of std::string from debug info is really really > awesome! > > -Chris > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091012/40c3e90d/attachment.html From jyasskin at gmail.com Mon Oct 12 19:43:30 2009 From: jyasskin at gmail.com (jyasskin at gmail.com) Date: Tue, 13 Oct 2009 00:43:30 +0000 Subject: [llvm-commits] [PATCH] Make ExecutionEngine automatically remove global mappings on GlobalValue destruction Message-ID: <0016363b7bded75fc30475c6559a@google.com> Reviewers: , Message: http://codereview.appspot.com/download/issue129074_5.diff This doesn't make the ExecutionEngine do everything perfectly on GlobalValue destruction (stubs still crash and machine code still leaks), but it's progress. Please review this at http://codereview.appspot.com/129074 Affected files: M include/llvm/ExecutionEngine/ExecutionEngine.h M lib/ExecutionEngine/ExecutionEngine.cpp M unittests/ExecutionEngine/ExecutionEngineTest.cpp From sabre at nondot.org Mon Oct 12 23:25:24 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 13 Oct 2009 04:25:24 -0000 Subject: [llvm-commits] [llvm] r83937 - in /llvm/trunk/test/FrontendC++: 2003-11-09-ConstructorTypeSafety.cpp 2003-11-18-MemberInitializationCasting.cpp Message-ID: <200910130425.n9D4PPj3023491@zion.cs.uiuc.edu> Author: lattner Date: Mon Oct 12 23:25:24 2009 New Revision: 83937 URL: http://llvm.org/viewvc/llvm-project?rev=83937&view=rev Log: remove two old and nearly useless tests. Removed: llvm/trunk/test/FrontendC++/2003-11-09-ConstructorTypeSafety.cpp llvm/trunk/test/FrontendC++/2003-11-18-MemberInitializationCasting.cpp Removed: llvm/trunk/test/FrontendC++/2003-11-09-ConstructorTypeSafety.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2003-11-09-ConstructorTypeSafety.cpp?rev=83936&view=auto ============================================================================== --- llvm/trunk/test/FrontendC++/2003-11-09-ConstructorTypeSafety.cpp (original) +++ llvm/trunk/test/FrontendC++/2003-11-09-ConstructorTypeSafety.cpp (removed) @@ -1,21 +0,0 @@ -// The code generated for this testcase should be completely typesafe! -// RUN: %llvmgcc -xc++ -S -o - %s | llvm-as | opt -die | llvm-dis | \ -// RUN: notcast - -struct contained { - unsigned X; - contained(); -}; - -struct base { - unsigned A, B; -}; - -struct derived : public base { - contained _M_value_field; -}; - -int test() { - derived X; -} - Removed: llvm/trunk/test/FrontendC++/2003-11-18-MemberInitializationCasting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2003-11-18-MemberInitializationCasting.cpp?rev=83936&view=auto ============================================================================== --- llvm/trunk/test/FrontendC++/2003-11-18-MemberInitializationCasting.cpp (original) +++ llvm/trunk/test/FrontendC++/2003-11-18-MemberInitializationCasting.cpp (removed) @@ -1,13 +0,0 @@ -// RUN: %llvmgcc -xc++ -S -o - %s | llvm-as | opt -die | llvm-dis | notcast - -struct A { - A() : i(0) {} - int getI() {return i;} - int i; -}; - -int f(int j) -{ - A a; - return j+a.getI(); -} From sabre at nondot.org Mon Oct 12 23:27:03 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 13 Oct 2009 04:27:03 -0000 Subject: [llvm-commits] [llvm] r83938 - /llvm/trunk/test/Scripts/notcast Message-ID: <200910130427.n9D4R33m023694@zion.cs.uiuc.edu> Author: lattner Date: Mon Oct 12 23:27:02 2009 New Revision: 83938 URL: http://llvm.org/viewvc/llvm-project?rev=83938&view=rev Log: remove notcast, it is now dead! Removed: llvm/trunk/test/Scripts/notcast Removed: llvm/trunk/test/Scripts/notcast URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Scripts/notcast?rev=83937&view=auto ============================================================================== --- llvm/trunk/test/Scripts/notcast (original) +++ llvm/trunk/test/Scripts/notcast (removed) @@ -1,16 +0,0 @@ -#!/bin/sh -# -# Program: notcast -# -# Synopsis: Returns 0 if the input does not contain a cast operator -# -# Syntax: notcast tailexpr -# -# postpat - optionally allows a regular expression to go at the end -# prepat - optionally allow a regular expression to go at the start -# - -if grep "$2"'\(\([sz]ext\)\|\(trunc\)\|\(fpto[us]i\)\|\([us]itofp\)\|\(bitcast\)\|\(fpext\)\|\(fptrunc\)\|\(ptrtoint\)\|\(inttoptr\)\|\(cast\)\)'"$1" -then exit 1 -else exit 0 -fi From sabre at nondot.org Tue Oct 13 00:33:26 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 13 Oct 2009 05:33:26 -0000 Subject: [llvm-commits] [llvm] r83943 - /llvm/trunk/include/llvm/ADT/HashExtras.h Message-ID: <200910130533.n9D5XQbI003612@zion.cs.uiuc.edu> Author: lattner Date: Tue Oct 13 00:33:26 2009 New Revision: 83943 URL: http://llvm.org/viewvc/llvm-project?rev=83943&view=rev Log: remove dead header. Removed: llvm/trunk/include/llvm/ADT/HashExtras.h Removed: llvm/trunk/include/llvm/ADT/HashExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/HashExtras.h?rev=83942&view=auto ============================================================================== --- llvm/trunk/include/llvm/ADT/HashExtras.h (original) +++ llvm/trunk/include/llvm/ADT/HashExtras.h (removed) @@ -1,40 +0,0 @@ -//===-- llvm/ADT/HashExtras.h - Useful functions for STL hash ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains some templates that are useful if you are working with the -// STL Hashed containers. -// -// No library is required when using these functions. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ADT_HASHEXTRAS_H -#define LLVM_ADT_HASHEXTRAS_H - -#include - -// Cannot specialize hash template from outside of the std namespace. -namespace HASH_NAMESPACE { - -// Provide a hash function for arbitrary pointers... -template struct hash { - inline size_t operator()(const T *Val) const { - return reinterpret_cast(Val); - } -}; - -template <> struct hash { - size_t operator()(std::string const &str) const { - return hash()(str.c_str()); - } -}; - -} // End namespace std - -#endif From sabre at nondot.org Tue Oct 13 00:37:17 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 13 Oct 2009 05:37:17 -0000 Subject: [llvm-commits] [test-suite] r83944 - /test-suite/trunk/MultiSource/Benchmarks/MiBench/office-ispell/term.c Message-ID: <200910130537.n9D5bH1a003763@zion.cs.uiuc.edu> Author: lattner Date: Tue Oct 13 00:37:17 2009 New Revision: 83944 URL: http://llvm.org/viewvc/llvm-project?rev=83944&view=rev Log: FIX PR5170 "Fix build of MultiSource/Benchmarks/MiBench/office-ispell on FreeBSD", patch by Pawel Worach! Modified: test-suite/trunk/MultiSource/Benchmarks/MiBench/office-ispell/term.c Modified: test-suite/trunk/MultiSource/Benchmarks/MiBench/office-ispell/term.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/MiBench/office-ispell/term.c?rev=83944&r1=83943&r2=83944&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Benchmarks/MiBench/office-ispell/term.c (original) +++ test-suite/trunk/MultiSource/Benchmarks/MiBench/office-ispell/term.c Tue Oct 13 00:37:17 2009 @@ -72,7 +72,7 @@ #include "msgs.h" #include -#ifdef __GLIBC__ +#if defined(__GLIBC__) || defined(__FreeBSD__) /* Use termios under at least glibc */ #include #define USE_TERMIOS From daniel at zuster.org Tue Oct 13 01:47:08 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 13 Oct 2009 06:47:08 -0000 Subject: [llvm-commits] [llvm] r83950 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200910130647.n9D6l8ov006445@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Oct 13 01:47:08 2009 New Revision: 83950 URL: http://llvm.org/viewvc/llvm-project?rev=83950&view=rev Log: Fix a -Asserts warning. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=83950&r1=83949&r2=83950&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Oct 13 01:47:08 2009 @@ -23,9 +23,10 @@ #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/Timer.h" -#include "llvm/Support/Debug.h" #include "llvm/System/Path.h" using namespace llvm; @@ -1909,7 +1910,7 @@ if (D.isLexicalBlock()) return getDISubprogram(DILexicalBlock(N).getContext().getNode()); - assert (0 && "Unexpected Descriptor!"); + llvm_unreachable("Unexpected Descriptor!"); } /// BeginFunction - Gather pre-function debug information. Assumes being From nicholas at mxc.ca Tue Oct 13 02:03:23 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 13 Oct 2009 07:03:23 -0000 Subject: [llvm-commits] [llvm] r83953 - in /llvm/trunk: docs/LangRef.html include/llvm/Intrinsics.td test/Feature/memorymarkers.ll Message-ID: <200910130703.n9D73NSw007024@zion.cs.uiuc.edu> Author: nicholas Date: Tue Oct 13 02:03:23 2009 New Revision: 83953 URL: http://llvm.org/viewvc/llvm-project?rev=83953&view=rev Log: Add new "memory use marker" intrinsics. These indicate lifetimes and invariant sections of memory objects. Added: llvm/trunk/test/Feature/memorymarkers.ll Modified: llvm/trunk/docs/LangRef.html llvm/trunk/include/llvm/Intrinsics.td Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=83953&r1=83952&r2=83953&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Tue Oct 13 02:03:23 2009 @@ -273,6 +273,14 @@
  • llvm.atomic.load.umin
  • +
  • Memory Use Markers +
      +
    1. llvm.lifetime.start
    2. +
    3. llvm.lifetime.end
    4. +
    5. llvm.invariant.start
    6. +
    7. llvm.invariant.end
    8. +
    +
  • General intrinsics
    1. @@ -6980,6 +6988,129 @@ + + + + +
      + +

      This class of intrinsics exists to information about the lifetime of memory + objects and ranges where variables are immutable.

      + +
      + + + + +
      + +
      Syntax:
      +
      +  declare void @llvm.lifetime.start(i64 <size>, i8* nocapture <ptr>)
      +
      + +
      Overview:
      +

      The 'llvm.lifetime.start' intrinsic specifies the start of a memory + object's lifetime.

      + +
      Arguments:
      +

      The first argument is a the size of the object, or -1 if it is variable + sized. The second argument is a pointer to the object.

      + +
      Semantics:
      +

      This intrinsic indicates that before this point in the code, the value of the + memory pointed to by ptr is dead. This means that it is known to + never be used and has an undefined value. A load from the pointer that is + preceded by this intrinsic can be replaced with + 'undef'.

      + +
      + + + + +
      + +
      Syntax:
      +
      +  declare void @llvm.lifetime.end(i64 <size>, i8* nocapture <ptr>)
      +
      + +
      Overview:
      +

      The 'llvm.lifetime.end' intrinsic specifies the end of a memory + object's lifetime.

      + +
      Arguments:
      +

      The first argument is a the size of the object, or -1 if it is variable + sized. The second argument is a pointer to the object.

      + +
      Semantics:
      +

      This intrinsic indicates that after this point in the code, the value of the + memory pointed to by ptr is dead. This means that it is known to + never be used and has an undefined value. Any stores into the memory object + following this intrinsic may be removed as dead. + +

      + + + + +
      + +
      Syntax:
      +
      +  declare {}* @llvm.invariant.start(i64 <size>, i8* nocapture <ptr>) readonly
      +
      + +
      Overview:
      +

      The 'llvm.invariant.start' intrinsic specifies that the contents of + a memory object will not change.

      + +
      Arguments:
      +

      The first argument is a the size of the object, or -1 if it is variable + sized. The second argument is a pointer to the object.

      + +
      Semantics:
      +

      This intrinsic indicates that until an llvm.invariant.end that uses + the return value, the referenced memory location is constant and + unchanging.

      + +
      + + + + +
      + +
      Syntax:
      +
      +  declare void @llvm.invariant.end({}* <start>, i64 <size>, i8* nocapture <ptr>)
      +
      + +
      Overview:
      +

      The 'llvm.invariant.end' intrinsic specifies that the contents of + a memory object are mutable.

      + +
      Arguments:
      +

      The first argument is the matching llvm.invariant.start intrinsic. + The second argument is a the size of the object, or -1 if it is variable + sized and the third argument is a pointer to the object.

      + +
      Semantics:
      +

      This intrinsic indicates that the memory is mutable again.

      + +
      +
      General Intrinsics Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=83953&r1=83952&r2=83953&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Tue Oct 13 02:03:23 2009 @@ -421,6 +421,22 @@ [IntrWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_umax">; +//===------------------------- Memory Use Markers -------------------------===// +// +def int_lifetime_start : Intrinsic<[llvm_void_ty], + [llvm_i64_ty, llvm_ptr_ty], + [IntrWriteArgMem, NoCapture<1>]>; +def int_lifetime_end : Intrinsic<[llvm_void_ty], + [llvm_i64_ty, llvm_ptr_ty], + [IntrWriteArgMem, NoCapture<1>]>; +def int_invariant_start : Intrinsic<[llvm_descriptor_ty], + [llvm_i64_ty, llvm_ptr_ty], + [IntrReadArgMem, NoCapture<1>]>; +def int_invariant_end : Intrinsic<[llvm_void_ty], + [llvm_descriptor_ty, llvm_i64_ty, + llvm_ptr_ty], + [IntrWriteArgMem, NoCapture<2>]>; + //===-------------------------- Other Intrinsics --------------------------===// // def int_flt_rounds : Intrinsic<[llvm_i32_ty]>, Added: llvm/trunk/test/Feature/memorymarkers.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/memorymarkers.ll?rev=83953&view=auto ============================================================================== --- llvm/trunk/test/Feature/memorymarkers.ll (added) +++ llvm/trunk/test/Feature/memorymarkers.ll Tue Oct 13 02:03:23 2009 @@ -0,0 +1,36 @@ +; RUN: llvm-as -disable-output < %s + +%"struct.std::pair" = type { i32, i32 } + +declare void @_Z3barRKi(i32*) + +declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind +declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind +declare {}* @llvm.invariant.start(i64, i8* nocapture) readonly nounwind +declare void @llvm.invariant.end({}*, i64, i8* nocapture) nounwind + +define i32 @_Z4foo2v() nounwind { +entry: + %x = alloca %"struct.std::pair" + %y = bitcast %"struct.std::pair"* %x to i8* + + ;; Constructor starts here (this isn't needed since it is immediately + ;; preceded by an alloca, but shown for completeness). + call void @llvm.lifetime.start(i64 8, i8* %y) + + %0 = getelementptr %"struct.std::pair"* %x, i32 0, i32 0 + store i32 4, i32* %0, align 8 + %1 = getelementptr %"struct.std::pair"* %x, i32 0, i32 1 + store i32 5, i32* %1, align 4 + + ;; Constructor has finished here. + %inv = call {}* @llvm.invariant.start(i64 8, i8* %y) + call void @_Z3barRKi(i32* %0) nounwind + %2 = load i32* %0, align 8 + + ;; Destructor is run here. + call void @llvm.invariant.end({}* %inv, i64 8, i8* %y) + ;; Destructor is done here. + call void @llvm.lifetime.end(i64 8, i8* %y) + ret i32 %2 +} From astifter-llvm at gmx.at Tue Oct 13 02:39:29 2009 From: astifter-llvm at gmx.at (Andreas Neustifter) Date: Tue, 13 Oct 2009 09:39:29 +0200 Subject: [llvm-commits] Static Profile Patch In-Reply-To: References: <030E9AA3-1AF1-433F-8807-9628E7155939@apple.com> <98736D45-B8BE-4616-82EC-EECE7A25AE40@apple.com> Message-ID: <4AD42EB1.7020305@gmx.at> Hi Andrei! Sorry, took me a while to get to this. The implementation looks good and solid, I haven't had time for an in-depth review, but from what I gather the Wu's algorithm is properly implemented. The patch does not build against revision 83533 (2009-10-08 09:01:46) with the build complaining about cyclic dependencies between libLLVMAnalysis.a and libLLVMipa.a. Any ideas about this? Andi From nicholas at mxc.ca Tue Oct 13 02:48:39 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 13 Oct 2009 07:48:39 -0000 Subject: [llvm-commits] [llvm] r83959 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll Message-ID: <200910130748.n9D7mdF0014001@zion.cs.uiuc.edu> Author: nicholas Date: Tue Oct 13 02:48:38 2009 New Revision: 83959 URL: http://llvm.org/viewvc/llvm-project?rev=83959&view=rev Log: Teach BasicAA a little something about the atomic intrinsics: they can only modify through the pointer they're given. Added: llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=83959&r1=83958&r2=83959&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Tue Oct 13 02:48:38 2009 @@ -284,6 +284,27 @@ if (!passedAsArg) return NoModRef; } + + if (IntrinsicInst *II = dyn_cast(CS.getInstruction())) { + switch (II->getIntrinsicID()) { + default: break; + case Intrinsic::atomic_cmp_swap: + case Intrinsic::atomic_swap: + case Intrinsic::atomic_load_add: + case Intrinsic::atomic_load_sub: + case Intrinsic::atomic_load_and: + case Intrinsic::atomic_load_nand: + case Intrinsic::atomic_load_or: + case Intrinsic::atomic_load_xor: + case Intrinsic::atomic_load_max: + case Intrinsic::atomic_load_min: + case Intrinsic::atomic_load_umax: + case Intrinsic::atomic_load_umin: + if (alias(II->getOperand(1), Size, P, Size) == NoAlias) + return NoModRef; + break; + } + } } // The AliasAnalysis base class has some smarts, lets use them. Added: llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll?rev=83959&view=auto ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll (added) +++ llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll Tue Oct 13 02:48:38 2009 @@ -0,0 +1,16 @@ +; RUN: opt -gvn -S < %s | FileCheck %s + +declare i8 @llvm.atomic.load.add.i8.p0i8(i8*, i8) + +define void @foo(i8* %ptr) { + %P = getelementptr i8* %ptr, i32 0 + %Q = getelementptr i8* %ptr, i32 1 +; CHECK: getelementptr + %X = load i8* %P +; CHECK: = load + %Y = call i8 @llvm.atomic.load.add.i8.p0i8(i8* %Q, i8 1) + %Z = load i8* %P +; CHECK-NOT: = load + ret void +; CHECK: ret void +} From baldrick at free.fr Tue Oct 13 02:51:31 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 13 Oct 2009 09:51:31 +0200 Subject: [llvm-commits] [llvm] r83953 - in /llvm/trunk: docs/LangRef.html include/llvm/Intrinsics.td test/Feature/memorymarkers.ll In-Reply-To: <200910130703.n9D73NSw007024@zion.cs.uiuc.edu> References: <200910130703.n9D73NSw007024@zion.cs.uiuc.edu> Message-ID: <4AD43183.7000906@free.fr> Hi Nick, > +

      The first argument is the matching llvm.invariant.start intrinsic. > + The second argument is a the size of the object, or -1 if it is variable a the -> the > + sized and the third argument is a pointer to the object.

      sized and the -> size. The Ciao, Duncan. From baldrick at free.fr Tue Oct 13 02:54:08 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 13 Oct 2009 09:54:08 +0200 Subject: [llvm-commits] [llvm] r83953 - in /llvm/trunk: docs/LangRef.html include/llvm/Intrinsics.td test/Feature/memorymarkers.ll In-Reply-To: <200910130703.n9D73NSw007024@zion.cs.uiuc.edu> References: <200910130703.n9D73NSw007024@zion.cs.uiuc.edu> Message-ID: <4AD43220.90901@free.fr> Hi Nick, probably it doesn't matter but the first argument here is also not captured (the "descriptor"). > +def int_invariant_end : Intrinsic<[llvm_void_ty], > + [llvm_descriptor_ty, llvm_i64_ty, > + llvm_ptr_ty], > + [IntrWriteArgMem, NoCapture<2>]>; Ciao, Duncan. From baldrick at free.fr Tue Oct 13 02:56:19 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 13 Oct 2009 09:56:19 +0200 Subject: [llvm-commits] [llvm] r83959 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll In-Reply-To: <200910130748.n9D7mdF0014001@zion.cs.uiuc.edu> References: <200910130748.n9D7mdF0014001@zion.cs.uiuc.edu> Message-ID: <4AD432A3.9010602@free.fr> Hi Nick, > Teach BasicAA a little something about the atomic intrinsics: they can only > modify through the pointer they're given. how does that differ from IntrWriteArgMem? I thought the AA core already had some logic for this. Ciao, Duncan. From nicholas at mxc.ca Tue Oct 13 02:57:34 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 13 Oct 2009 07:57:34 -0000 Subject: [llvm-commits] [llvm] r83960 - in /llvm/trunk: docs/LangRef.html lib/VMCore/Verifier.cpp Message-ID: <200910130757.n9D7vYDI017071@zion.cs.uiuc.edu> Author: nicholas Date: Tue Oct 13 02:57:33 2009 New Revision: 83960 URL: http://llvm.org/viewvc/llvm-project?rev=83960&view=rev Log: Force memory use markers to have a ConstantInt for the size argument. Modified: llvm/trunk/docs/LangRef.html llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=83960&r1=83959&r2=83960&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Tue Oct 13 02:57:33 2009 @@ -7018,8 +7018,9 @@ object's lifetime.

      Arguments:
      -

      The first argument is a the size of the object, or -1 if it is variable - sized. The second argument is a pointer to the object.

      +

      The first argument is a constant integer representing the size of the + object, or -1 if it is variable sized. The second argument is a pointer to + the object.

      Semantics:

      This intrinsic indicates that before this point in the code, the value of the @@ -7047,8 +7048,9 @@ object's lifetime.

      Arguments:
      -

      The first argument is a the size of the object, or -1 if it is variable - sized. The second argument is a pointer to the object.

      +

      The first argument is a constant integer representing the size of the + object, or -1 if it is variable sized. The second argument is a pointer to + the object.

      Semantics:

      This intrinsic indicates that after this point in the code, the value of the @@ -7075,8 +7077,9 @@ a memory object will not change.

      Arguments:
      -

      The first argument is a the size of the object, or -1 if it is variable - sized. The second argument is a pointer to the object.

      +

      The first argument is a constant integer representing the size of the + object, or -1 if it is variable sized. The second argument is a pointer to + the object.

      Semantics:

      This intrinsic indicates that until an llvm.invariant.end that uses @@ -7103,8 +7106,9 @@

      Arguments:

      The first argument is the matching llvm.invariant.start intrinsic. - The second argument is a the size of the object, or -1 if it is variable - sized and the third argument is a pointer to the object.

      + The second argument is a constant integer representing the size of the + object, or -1 if it is variable sized and the third argument is a pointer + to the object.

      Semantics:

      This intrinsic indicates that the memory is mutable again.

      Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=83960&r1=83959&r2=83960&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Tue Oct 13 02:57:33 2009 @@ -1578,6 +1578,17 @@ "llvm.stackprotector parameter #2 must resolve to an alloca.", &CI); break; + case Intrinsic::lifetime_start: + case Intrinsic::lifetime_end: + case Intrinsic::invariant_start: + Assert1(isa(CI.getOperand(1)), + "size argument of memory use markers must be a constant integer", + &CI); + break; + case Intrinsic::invariant_end: + Assert1(isa(CI.getOperand(2)), + "llvm.invariant.end parameter #2 must be a constant integer", &CI); + break; } } From evan.cheng at apple.com Tue Oct 13 04:01:15 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 13 Oct 2009 02:01:15 -0700 Subject: [llvm-commits] [PATCH] Make ExecutionEngine automatically remove global mappings on GlobalValue destruction In-Reply-To: <0016363b7bded75fc30475c6559a@google.com> References: <0016363b7bded75fc30475c6559a@google.com> Message-ID: <6F95F744-B216-4EB0-9A6C-14ECF07FFB5E@apple.com> Looks good to me. I'd preferred if "state" can be renamed to something like EEState though. Evan On Oct 12, 2009, at 5:43 PM, jyasskin at gmail.com wrote: > Reviewers: , > > Message: > http://codereview.appspot.com/download/issue129074_5.diff > > This doesn't make the ExecutionEngine do everything perfectly on > GlobalValue destruction (stubs still crash and machine code still > leaks), but it's progress. > > > > Please review this at http://codereview.appspot.com/129074 > > Affected files: > M include/llvm/ExecutionEngine/ExecutionEngine.h > M lib/ExecutionEngine/ExecutionEngine.cpp > M unittests/ExecutionEngine/ExecutionEngineTest.cpp > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From baldrick at free.fr Tue Oct 13 04:23:12 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 13 Oct 2009 09:23:12 -0000 Subject: [llvm-commits] [llvm] r83962 - /llvm/trunk/unittests/ADT/APIntTest.cpp Message-ID: <200910130923.n9D9NCsU025903@zion.cs.uiuc.edu> Author: baldrick Date: Tue Oct 13 04:23:11 2009 New Revision: 83962 URL: http://llvm.org/viewvc/llvm-project?rev=83962&view=rev Log: Pacify the compiler (signed with unsigned comparison) by making these constants unsigned. Modified: llvm/trunk/unittests/ADT/APIntTest.cpp Modified: llvm/trunk/unittests/ADT/APIntTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/APIntTest.cpp?rev=83962&r1=83961&r2=83962&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/APIntTest.cpp (original) +++ llvm/trunk/unittests/ADT/APIntTest.cpp Tue Oct 13 04:23:11 2009 @@ -316,14 +316,14 @@ } TEST(APIntTest, Log2) { - EXPECT_EQ(APInt(15, 7).logBase2(), 2); - EXPECT_EQ(APInt(15, 7).ceilLogBase2(), 3); + EXPECT_EQ(APInt(15, 7).logBase2(), 2U); + EXPECT_EQ(APInt(15, 7).ceilLogBase2(), 3U); EXPECT_EQ(APInt(15, 7).exactLogBase2(), -1); - EXPECT_EQ(APInt(15, 8).logBase2(), 3); - EXPECT_EQ(APInt(15, 8).ceilLogBase2(), 3); + EXPECT_EQ(APInt(15, 8).logBase2(), 3U); + EXPECT_EQ(APInt(15, 8).ceilLogBase2(), 3U); EXPECT_EQ(APInt(15, 8).exactLogBase2(), 3); - EXPECT_EQ(APInt(15, 9).logBase2(), 3); - EXPECT_EQ(APInt(15, 9).ceilLogBase2(), 4); + EXPECT_EQ(APInt(15, 9).logBase2(), 3U); + EXPECT_EQ(APInt(15, 9).ceilLogBase2(), 4U); EXPECT_EQ(APInt(15, 9).exactLogBase2(), -1); } From baldrick at free.fr Tue Oct 13 04:24:02 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 13 Oct 2009 09:24:02 -0000 Subject: [llvm-commits] [llvm] r83963 - /llvm/trunk/include/llvm/Intrinsics.td Message-ID: <200910130924.n9D9O2Uf025965@zion.cs.uiuc.edu> Author: baldrick Date: Tue Oct 13 04:24:02 2009 New Revision: 83963 URL: http://llvm.org/viewvc/llvm-project?rev=83963&view=rev Log: The eh.exception intrinsic only reads from memory, it doesn't write to it. Modified: llvm/trunk/include/llvm/Intrinsics.td Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=83963&r1=83962&r2=83963&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Tue Oct 13 04:24:02 2009 @@ -289,7 +289,7 @@ //===------------------ Exception Handling Intrinsics----------------------===// // -def int_eh_exception : Intrinsic<[llvm_ptr_ty]>; +def int_eh_exception : Intrinsic<[llvm_ptr_ty], [], [IntrReadMem]>; def int_eh_selector_i32 : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty]>; def int_eh_selector_i64 : Intrinsic<[llvm_i64_ty], From bob.wilson at apple.com Tue Oct 13 10:27:23 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 13 Oct 2009 15:27:23 -0000 Subject: [llvm-commits] [llvm] r83973 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <200910131527.n9DFRNfB006079@zion.cs.uiuc.edu> Author: bwilson Date: Tue Oct 13 10:27:23 2009 New Revision: 83973 URL: http://llvm.org/viewvc/llvm-project?rev=83973&view=rev Log: Fix a tab. Thanks to Johnny Chen for pointing it out. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=83973&r1=83972&r2=83973&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Oct 13 10:27:23 2009 @@ -397,7 +397,7 @@ IIC_iALUr, opc, "s $dst, $a, $b", [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> { let isCommutable = Commutable; - let Inst{25} = 0; + let Inst{25} = 0; } def rs : AI1 Changes in directory llvm-www/ProjectsWithLLVM: index.html updated: 1.51 -> 1.52 --- Log message: xps is dead and x-p-s.org is a domain squatter now. --- Diffs of the changes: (+0 -48) index.html | 48 ------------------------------------------------ 1 files changed, 48 deletions(-) Index: llvm-www/ProjectsWithLLVM/index.html diff -u llvm-www/ProjectsWithLLVM/index.html:1.51 llvm-www/ProjectsWithLLVM/index.html:1.52 --- llvm-www/ProjectsWithLLVM/index.html:1.51 Wed Sep 30 01:25:42 2009 +++ llvm-www/ProjectsWithLLVM/index.html Tue Oct 13 11:24:04 2009 @@ -57,7 +57,6 @@
    2. LLVM Visualization Tool
    3. Improvements to Linear Scan register allocation
    4. -
    5. XPS - eXtensible Programming System
    6. LLVA-emu project
    7. SPEDI: Static Patch Extraction and Dynamic Insertion
    8. @@ -670,53 +669,6 @@ - - - -
      By eXtensible Systems, Inc.
      - -
      - -

      The XPS project's purpose is to making programming computers easier by -raising the level of abstraction in programming languages beyond the current -practice. By using XML as a means for extensibility, XPS will support both -meta-programming and domain engineering. In particular, it will make the -creation of new Domain-Specific Languages very easy. By moving the programming -abstraction into to the problem domain, the "impedance mis-match" between the -problem domain and the solution domain is all but eliminated.

      - -

      XPS combines an XML-based programming language, XPL, with a robust virtual -machine making it easier to develop applications by hiding all the "computer -science" and increasing the level of abstraction without losing performance. -True to its name, XPL is highly extensible. It permits extension of -both the programming language and the virtual machine with relative ease. -Somewhat counter-intuitively, XPL is not a particularly programmer friendly -language. It is designed to be fast, efficient, and easily compilable. It is -expected that higher level (e.g. domain specific) languages will be designed -that translate into XPL. These facilities support meta-programming and domain -engineering so that software can be written using domain-specific -vocabularies. The goal is to make it possible for the lay person to program -computers without having to learn complicated programming languages or -understand the tenets of computer science.

      - -

      Currently, XPS is under development. It has just completed its 0.2.0 release -which includes a basic XPL compiler that can reproduce its XPL input. The next -release, 0.3.0 (Summer 2005) will compile XPL to executable code via LLVM's -facilities. The decision to use LLVM was made in November, 2003 as it provides -a much simpler and more modern compiler infrastructure than the other open -source alternatives. Using LLVM for the "back end" of XPS will accelerate the -development of XPS because many of the compilation and execution details are -taken care of by LLVM.

      - -

      Further information about XPS can be obtained at -http://x-p-s.org/.

      - -
      - - - From dpatel at apple.com Tue Oct 13 11:32:09 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 16:32:09 -0000 Subject: [llvm-commits] [llvm] r83975 - /llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m Message-ID: <200910131632.n9DGW9aT009042@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 11:32:09 2009 New Revision: 83975 URL: http://llvm.org/viewvc/llvm-project?rev=83975&view=rev Log: Disable this test for now. Modified: llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m Modified: llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m?rev=83975&r1=83974&r2=83975&view=diff ============================================================================== --- llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m (original) +++ llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m Tue Oct 13 11:32:09 2009 @@ -6,7 +6,6 @@ // RUN: echo {break randomFunc\n} > %t.in // RUN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | \ // RUN: grep {Breakpoint 1 at 0x.*: file 2009-08-17-DebugInfo.m, line 21} -// XTARGET: darwin // XFAIL: * @interface MyClass { From resistor at mac.com Tue Oct 13 11:59:21 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 13 Oct 2009 09:59:21 -0700 Subject: [llvm-commits] [llvm] r83959 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll In-Reply-To: <200910130748.n9D7mdF0014001@zion.cs.uiuc.edu> References: <200910130748.n9D7mdF0014001@zion.cs.uiuc.edu> Message-ID: Nick, This shouldn't be necessary. Duncan and I did the same things back in r63900 andr64551. --Owen On Oct 13, 2009, at 12:48 AM, Nick Lewycky wrote: > Author: nicholas > Date: Tue Oct 13 02:48:38 2009 > New Revision: 83959 > > URL: http://llvm.org/viewvc/llvm-project?rev=83959&view=rev > Log: > Teach BasicAA a little something about the atomic intrinsics: they > can only > modify through the pointer they're given. > > Added: > llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll > Modified: > llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp > > Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=83959&r1=83958&r2=83959&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) > +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Tue Oct 13 > 02:48:38 2009 > @@ -284,6 +284,27 @@ > if (!passedAsArg) > return NoModRef; > } > + > + if (IntrinsicInst *II = dyn_cast > (CS.getInstruction())) { > + switch (II->getIntrinsicID()) { > + default: break; > + case Intrinsic::atomic_cmp_swap: > + case Intrinsic::atomic_swap: > + case Intrinsic::atomic_load_add: > + case Intrinsic::atomic_load_sub: > + case Intrinsic::atomic_load_and: > + case Intrinsic::atomic_load_nand: > + case Intrinsic::atomic_load_or: > + case Intrinsic::atomic_load_xor: > + case Intrinsic::atomic_load_max: > + case Intrinsic::atomic_load_min: > + case Intrinsic::atomic_load_umax: > + case Intrinsic::atomic_load_umin: > + if (alias(II->getOperand(1), Size, P, Size) == NoAlias) > + return NoModRef; > + break; > + } > + } > } > > // The AliasAnalysis base class has some smarts, lets use them. > > Added: llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll?rev=83959&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll > (added) > +++ llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll Tue > Oct 13 02:48:38 2009 > @@ -0,0 +1,16 @@ > +; RUN: opt -gvn -S < %s | FileCheck %s > + > +declare i8 @llvm.atomic.load.add.i8.p0i8(i8*, i8) > + > +define void @foo(i8* %ptr) { > + %P = getelementptr i8* %ptr, i32 0 > + %Q = getelementptr i8* %ptr, i32 1 > +; CHECK: getelementptr > + %X = load i8* %P > +; CHECK: = load > + %Y = call i8 @llvm.atomic.load.add.i8.p0i8(i8* %Q, i8 1) > + %Z = load i8* %P > +; CHECK-NOT: = load > + ret void > +; CHECK: ret void > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2620 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091013/6918eef0/attachment.bin From dpatel at apple.com Tue Oct 13 12:00:54 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 17:00:54 -0000 Subject: [llvm-commits] [llvm] r83977 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp lib/VMCore/Value.cpp Message-ID: <200910131700.n9DH0sGT010067@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 12:00:54 2009 New Revision: 83977 URL: http://llvm.org/viewvc/llvm-project?rev=83977&view=rev Log: Copy metadata when value is RAUW'd. It is debatable whether this is the right approach for custom metadata data in general. However, right now the only custom data user, "dbg", expects this behavior while FE is constructing llvm IR with debug info. Modified: llvm/trunk/include/llvm/Metadata.h llvm/trunk/lib/VMCore/Metadata.cpp llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=83977&r1=83976&r2=83977&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Tue Oct 13 12:00:54 2009 @@ -361,6 +361,7 @@ void ValueIsDeleted(const Instruction *Inst) { removeMDs(Inst); } + void ValueIsRAUWd(Value *V1, Value *V2); /// ValueIsCloned - This handler is used to update metadata store /// when In1 is cloned to create In2. Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=83977&r1=83976&r2=83977&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Tue Oct 13 12:00:54 2009 @@ -404,3 +404,15 @@ if (MDNode *MD = dyn_cast_or_null(I->second)) addMD(I->first, MD, In2); } + +/// ValueIsRAUWd - This handler is used when V1's all uses are replaced by +/// V2. +void MetadataContext::ValueIsRAUWd(Value *V1, Value *V2) { + Instruction *I1 = dyn_cast(V1); + Instruction *I2 = dyn_cast(V2); + if (!I1 || !I2) + return; + + // FIXME : Give custom handlers a chance to override this. + ValueIsCloned(I1, I2); +} Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=83977&r1=83976&r2=83977&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Tue Oct 13 12:00:54 2009 @@ -309,6 +309,10 @@ // Notify all ValueHandles (if present) that this value is going away. if (HasValueHandle) ValueHandleBase::ValueIsRAUWd(this, New); + if (HasMetadata) { + LLVMContext &Context = getContext(); + Context.pImpl->TheMetadata.ValueIsRAUWd(this, New); + } while (!use_empty()) { Use &U = *UseList; From jyasskin at google.com Tue Oct 13 12:16:06 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Tue, 13 Oct 2009 10:16:06 -0700 Subject: [llvm-commits] [PATCH] Make ExecutionEngine automatically remove global mappings on GlobalValue destruction In-Reply-To: <6F95F744-B216-4EB0-9A6C-14ECF07FFB5E@apple.com> References: <0016363b7bded75fc30475c6559a@google.com> <6F95F744-B216-4EB0-9A6C-14ECF07FFB5E@apple.com> Message-ID: Done and committing. Thanks for the review! On Tue, Oct 13, 2009 at 2:01 AM, Evan Cheng wrote: > Looks good to me. I'd preferred if "state" can be renamed to something > like EEState though. > > Evan > > On Oct 12, 2009, at 5:43 PM, jyasskin at gmail.com wrote: > >> Reviewers: , >> >> Message: >> http://codereview.appspot.com/download/issue129074_5.diff >> >> This doesn't make the ExecutionEngine do everything perfectly on >> GlobalValue destruction (stubs still crash and machine code still >> leaks), but it's progress. >> >> >> >> Please review this at http://codereview.appspot.com/129074 >> >> Affected files: >> ? M include/llvm/ExecutionEngine/ExecutionEngine.h >> ? M lib/ExecutionEngine/ExecutionEngine.cpp >> ? M unittests/ExecutionEngine/ExecutionEngineTest.cpp >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From devang.patel at gmail.com Tue Oct 13 12:16:17 2009 From: devang.patel at gmail.com (Devang Patel) Date: Tue, 13 Oct 2009 10:16:17 -0700 Subject: [llvm-commits] [PATCH] Preserve DebugInfo during LICM In-Reply-To: <4AD22FBF.3060607@gmail.com> References: <4ACDAF90.1040202@gmail.com> <4AD22FBF.3060607@gmail.com> Message-ID: <352a1fb20910131016g41abc9e0v3ff54f001324075c@mail.gmail.com> 2009/10/11 T?r?k Edwin : >>> I think that we'd need another TEST.dbgquality that tests whether each >>> basicblock has at least one stoppoint (if original did), >>> and also outputs how many instructions have a stoppoint in same BB, how >>> many have a stoppoint >>> foundable by findStopPointInst, and how many don't have at all. The test >>> would pass if each BB has at least one stoppoint, >> >> I'm not sure what the right approach is here. ?When stoppoints move to >> being on the instructions, we won't really need this. > > We'd need something else: ?check that each insn has a debug info, some > optimizers may create new instructions and forget > to set debug info. > > But you're right, there is no point working on this now, since the debug > info is about to undergo a major change. > Now, debug info (location info) is attached to an instruction. There is a way to check this. MetadataContext &TheMetadata = ...getContext().getMetadata(); unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, I)) { Here Dbg is non-null if debug info is attached with instruction I. - Devang From edwintorok at gmail.com Tue Oct 13 12:26:26 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Tue, 13 Oct 2009 20:26:26 +0300 Subject: [llvm-commits] [PATCH] Preserve DebugInfo during LICM In-Reply-To: <352a1fb20910131016g41abc9e0v3ff54f001324075c@mail.gmail.com> References: <4ACDAF90.1040202@gmail.com> <4AD22FBF.3060607@gmail.com> <352a1fb20910131016g41abc9e0v3ff54f001324075c@mail.gmail.com> Message-ID: <4AD4B842.10703@gmail.com> On 2009-10-13 20:16, Devang Patel wrote: > 2009/10/11 T?r?k Edwin : > >>>> I think that we'd need another TEST.dbgquality that tests whether each >>>> basicblock has at least one stoppoint (if original did), >>>> and also outputs how many instructions have a stoppoint in same BB, how >>>> many have a stoppoint >>>> foundable by findStopPointInst, and how many don't have at all. The test >>>> would pass if each BB has at least one stoppoint, >>>> >>> I'm not sure what the right approach is here. When stoppoints move to >>> being on the instructions, we won't really need this. >>> >> We'd need something else: check that each insn has a debug info, some >> optimizers may create new instructions and forget >> to set debug info. >> >> But you're right, there is no point working on this now, since the debug >> info is about to undergo a major change. >> >> > > Now, debug info (location info) is attached to an instruction. There > is a way to check this. > > MetadataContext &TheMetadata = ...getContext().getMetadata(); > unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); > if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, I)) { > Maybe I should update findStopPoint to return dbg metadata instead of a stoppoint, if stoppoints are going away? If stoppoints are going away please let me know so I can update Analysis/DbgInfoPrinter.cpp too. > Here Dbg is non-null if debug info is attached with instruction I. > Does llvm-gcc and clang support emitting dbgmetadata on instructions? If yes I'll start working on something that measures quality of dbginfo in the testsuite, and maybe do some checks too. Also does this move to metadata on instructions fix the linker/inliner(?) bug where the line number was greater than the total lines in the file? And the bug that you can't link together multiple files with debug info due to multiple main compilation units? Best regards, --Edwin From bob.wilson at apple.com Tue Oct 13 12:29:13 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 13 Oct 2009 17:29:13 -0000 Subject: [llvm-commits] [llvm] r83982 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910131729.n9DHTDc5011331@zion.cs.uiuc.edu> Author: bwilson Date: Tue Oct 13 12:29:13 2009 New Revision: 83982 URL: http://llvm.org/viewvc/llvm-project?rev=83982&view=rev Log: Fix regression introduced by r83894. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=83982&r1=83981&r2=83982&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Tue Oct 13 12:29:13 2009 @@ -933,13 +933,14 @@ /// MachineBasicBlock *ARMConstantIslands::AcceptWater(water_iterator IP) { DEBUG(errs() << "found water in range\n"); + MachineBasicBlock *WaterBB = *IP; // Remove the original WaterList entry; we want subsequent // insertions in this vicinity to go after the one we're // about to insert. This considerably reduces the number // of times we have to move the same CPE more than once. WaterList.erase(IP); // CPE goes before following block (NewMBB). - return next(MachineFunction::iterator(*IP)); + return next(MachineFunction::iterator(WaterBB)); } /// LookForWater - look for an existing entry in the WaterList in which From clattner at apple.com Tue Oct 13 12:34:09 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 13 Oct 2009 10:34:09 -0700 Subject: [llvm-commits] [llvm] r83959 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll In-Reply-To: <200910130748.n9D7mdF0014001@zion.cs.uiuc.edu> References: <200910130748.n9D7mdF0014001@zion.cs.uiuc.edu> Message-ID: <33FD0425-F50F-48AE-B06B-9CEC9ECC9BF9@apple.com> On Oct 13, 2009, at 12:48 AM, Nick Lewycky wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=83959&view=rev > Log: > Teach BasicAA a little something about the atomic intrinsics: they > can only > modify through the pointer they're given. Thanks Nick, > + > +define void @foo(i8* %ptr) { > + %P = getelementptr i8* %ptr, i32 0 > + %Q = getelementptr i8* %ptr, i32 1 > +; CHECK: getelementptr > + %X = load i8* %P > +; CHECK: = load > + %Y = call i8 @llvm.atomic.load.add.i8.p0i8(i8* %Q, i8 1) > + %Z = load i8* %P > +; CHECK-NOT: = load > + ret void > +; CHECK: ret void > +} Please add some uses of the loads: do: "ret sub X,Z", and FileCheck that GVN+instcombine turn it into "ret i32 0" -Chris From bob.wilson at apple.com Tue Oct 13 12:35:30 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 13 Oct 2009 17:35:30 -0000 Subject: [llvm-commits] [llvm] r83983 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <200910131735.n9DHZVfS011591@zion.cs.uiuc.edu> Author: bwilson Date: Tue Oct 13 12:35:30 2009 New Revision: 83983 URL: http://llvm.org/viewvc/llvm-project?rev=83983&view=rev Log: Add some ARM instruction encoding bits. Patch by Johnny Chen. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=83983&r1=83982&r2=83983&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Oct 13 12:35:30 2009 @@ -416,17 +416,20 @@ def ri : AI1 { + let Inst{20} = 1; let Inst{25} = 1; } def rr : AI1 { + let Inst{20} = 1; let Inst{25} = 0; let isCommutable = Commutable; } def rs : AI1 { + let Inst{20} = 1; let Inst{25} = 0; } } @@ -934,6 +937,7 @@ "movw", " $dst, $src", [(set GPR:$dst, imm0_65535:$src)]>, Requires<[IsARM, HasV6T2]> { + let Inst{20} = 0; let Inst{25} = 1; } @@ -945,6 +949,7 @@ (or (and GPR:$src, 0xffff), lo16AllZero:$imm))]>, UnaryDP, Requires<[IsARM, HasV6T2]> { + let Inst{20} = 0; let Inst{25} = 1; } From dpatel at apple.com Tue Oct 13 12:35:35 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 17:35:35 -0000 Subject: [llvm-commits] [llvm] r83984 - /llvm/trunk/lib/Analysis/DebugInfo.cpp Message-ID: <200910131735.n9DHZZg2011605@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 12:35:35 2009 New Revision: 83984 URL: http://llvm.org/viewvc/llvm-project?rev=83984&view=rev Log: "there is not any instruction with attached debug info in this module" does not mean "there is no debug info in this module". :) Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=83984&r1=83983&r2=83984&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Oct 13 12:35:35 2009 @@ -969,8 +969,6 @@ #ifdef ATTACH_DEBUG_INFO_TO_AN_INSN MetadataContext &TheMetadata = M.getContext().getMetadata(); unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); - if (!MDDbgKind) - return; #endif for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) for (Function::iterator FI = (*I).begin(), FE = (*I).end(); FI != FE; ++FI) @@ -987,15 +985,17 @@ else if (DbgDeclareInst *DDI = dyn_cast(BI)) processDeclare(DDI); #ifdef ATTACH_DEBUG_INFO_TO_AN_INSN - else if (MDNode *L = TheMetadata.getMD(MDDbgKind, BI)) { - DILocation Loc(L); - DIScope S(Loc.getScope().getNode()); - if (S.isCompileUnit()) - addCompileUnit(DICompileUnit(S.getNode())); - else if (S.isSubprogram()) - processSubprogram(DISubprogram(S.getNode())); - else if (S.isLexicalBlock()) - processLexicalBlock(DILexicalBlock(S.getNode())); + else if (MDDbgKind) { + if (MDNode *L = TheMetadata.getMD(MDDbgKind, BI)) { + DILocation Loc(L); + DIScope S(Loc.getScope().getNode()); + if (S.isCompileUnit()) + addCompileUnit(DICompileUnit(S.getNode())); + else if (S.isSubprogram()) + processSubprogram(DISubprogram(S.getNode())); + else if (S.isLexicalBlock()) + processLexicalBlock(DILexicalBlock(S.getNode())); + } } #endif } From devang.patel at gmail.com Tue Oct 13 12:40:01 2009 From: devang.patel at gmail.com (Devang Patel) Date: Tue, 13 Oct 2009 10:40:01 -0700 Subject: [llvm-commits] [PATCH] Preserve DebugInfo during LICM In-Reply-To: <4AD4B842.10703@gmail.com> References: <4ACDAF90.1040202@gmail.com> <4AD22FBF.3060607@gmail.com> <352a1fb20910131016g41abc9e0v3ff54f001324075c@mail.gmail.com> <4AD4B842.10703@gmail.com> Message-ID: <352a1fb20910131040k40fd72eag829f499a6a04f0e4@mail.gmail.com> 2009/10/13 T?r?k Edwin : > On 2009-10-13 20:16, Devang Patel wrote: >> 2009/10/11 T?r?k Edwin : >> >>>>> I think that we'd need another TEST.dbgquality that tests whether each >>>>> basicblock has at least one stoppoint (if original did), >>>>> and also outputs how many instructions have a stoppoint in same BB, how >>>>> many have a stoppoint >>>>> foundable by findStopPointInst, and how many don't have at all. The test >>>>> would pass if each BB has at least one stoppoint, >>>>> >>>> I'm not sure what the right approach is here. ?When stoppoints move to >>>> being on the instructions, we won't really need this. >>>> >>> We'd need something else: ?check that each insn has a debug info, some >>> optimizers may create new instructions and forget >>> to set debug info. >>> >>> But you're right, there is no point working on this now, since the debug >>> info is about to undergo a major change. >>> >>> >> >> Now, debug info (location info) is attached to an instruction. There >> is a way to check this. >> >> ? MetadataContext &TheMetadata = ...getContext().getMetadata(); >> ? unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); >> ? if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, I)) { >> > > Maybe I should update findStopPoint to return dbg metadata instead of a > stoppoint, if stoppoints are going away? Eventually yes. I'll wait for things to settle down before completely removing this. > > If stoppoints are going away please let me know so I can update > Analysis/DbgInfoPrinter.cpp too. >> Here Dbg is non-null if debug info is attached with instruction I. >> > > Does llvm-gcc and clang support emitting dbgmetadata on instructions? Yes, I flipped the switch yesterday. > If yes I'll start working on something that measures quality of dbginfo > in the testsuite, and maybe do some checks too. That'd be very useful. > Also does this move to metadata on instructions fix the > linker/inliner(?) bug where the line number was greater than the total > lines in the file? Not yet. > And the bug that you can't link together multiple files with debug info > due to multiple main compilation units? Not yet. - Devang From sabre at nondot.org Tue Oct 13 12:39:30 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 13 Oct 2009 17:39:30 -0000 Subject: [llvm-commits] [llvm] r83985 - /llvm/trunk/test/Analysis/BasicAA/cas.ll Message-ID: <200910131739.n9DHdUp0011769@zion.cs.uiuc.edu> Author: lattner Date: Tue Oct 13 12:39:29 2009 New Revision: 83985 URL: http://llvm.org/viewvc/llvm-project?rev=83985&view=rev Log: don't use dead loads as tests. Modified: llvm/trunk/test/Analysis/BasicAA/cas.ll Modified: llvm/trunk/test/Analysis/BasicAA/cas.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/cas.ll?rev=83985&r1=83984&r2=83985&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/cas.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/cas.ll Tue Oct 13 12:39:29 2009 @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | grep load | count 1 +; RUN: opt < %s -basicaa -gvn -instcombine -S | grep {ret i32 0} @flag0 = internal global i32 zeroinitializer @turn = internal global i32 zeroinitializer @@ -6,9 +6,10 @@ define i32 @main() { %a = load i32* @flag0 - %b = tail call i32 @llvm.atomic.swap.i32.p0i32(i32* @turn, i32 1) + %b = tail call i32 @llvm.atomic.swap.i32.p0i32(i32* @turn, i32 1) %c = load i32* @flag0 - ret i32 %c + %d = sub i32 %a, %c + ret i32 %d } declare i32 @llvm.atomic.swap.i32.p0i32(i32*, i32) nounwind \ No newline at end of file From jyasskin at google.com Tue Oct 13 12:42:08 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Tue, 13 Oct 2009 17:42:08 -0000 Subject: [llvm-commits] [llvm] r83987 - in /llvm/trunk: include/llvm/ExecutionEngine/ExecutionEngine.h lib/ExecutionEngine/ExecutionEngine.cpp unittests/ExecutionEngine/ExecutionEngineTest.cpp Message-ID: <200910131742.n9DHg9cD011982@zion.cs.uiuc.edu> Author: jyasskin Date: Tue Oct 13 12:42:08 2009 New Revision: 83987 URL: http://llvm.org/viewvc/llvm-project?rev=83987&view=rev Log: Make the ExecutionEngine automatically remove global mappings on when their GlobalValue is destroyed. Function destruction still leaks machine code and can crash on leaked stubs, but this is some progress. Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=83987&r1=83986&r2=83987&view=diff ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original) +++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Tue Oct 13 12:42:08 2009 @@ -19,6 +19,7 @@ #include #include #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/ValueHandle.h" #include "llvm/System/Mutex.h" #include "llvm/Target/TargetMachine.h" @@ -26,6 +27,7 @@ struct GenericValue; class Constant; +class ExecutionEngine; class Function; class GlobalVariable; class GlobalValue; @@ -37,13 +39,29 @@ class MutexGuard; class TargetData; class Type; -template class AssertingVH; class ExecutionEngineState { +public: + class MapUpdatingCVH : public CallbackVH { + ExecutionEngineState &EES; + + public: + MapUpdatingCVH(ExecutionEngineState &EES, const GlobalValue *GV); + + operator const GlobalValue*() const { + return cast(getValPtr()); + } + + virtual void deleted(); + virtual void allUsesReplacedWith(Value *new_value); + }; + private: + ExecutionEngine &EE; + /// GlobalAddressMap - A mapping between LLVM global values and their /// actualized version... - std::map, void *> GlobalAddressMap; + std::map GlobalAddressMap; /// GlobalAddressReverseMap - This is the reverse mapping of GlobalAddressMap, /// used to convert raw addresses into the LLVM global value that is emitted @@ -52,7 +70,13 @@ std::map > GlobalAddressReverseMap; public: - std::map, void *> & + ExecutionEngineState(ExecutionEngine &EE) : EE(EE) {} + + MapUpdatingCVH getVH(const GlobalValue *GV) { + return MapUpdatingCVH(*this, GV); + } + + std::map & getGlobalAddressMap(const MutexGuard &) { return GlobalAddressMap; } @@ -69,7 +93,7 @@ class ExecutionEngine { const TargetData *TD; - ExecutionEngineState state; + ExecutionEngineState EEState; bool LazyCompilationDisabled; bool GVCompilationDisabled; bool SymbolSearchingDisabled; @@ -213,8 +237,8 @@ /// at the specified location. This is used internally as functions are JIT'd /// and as global variables are laid out in memory. It can and should also be /// used by clients of the EE that want to have an LLVM global overlay - /// existing data in memory. After adding a mapping for GV, you must not - /// destroy it until you've removed the mapping. + /// existing data in memory. Mappings are automatically removed when their + /// GlobalValue is destroyed. void addGlobalMapping(const GlobalValue *GV, void *Addr); /// clearAllGlobalMappings - Clear all global mappings and start over again @@ -238,29 +262,23 @@ void *getPointerToGlobalIfAvailable(const GlobalValue *GV); /// getPointerToGlobal - This returns the address of the specified global - /// value. This may involve code generation if it's a function. After - /// getting a pointer to GV, it and all globals it transitively refers to have - /// been passed to addGlobalMapping. You must clear the mapping for each - /// referred-to global before destroying it. If a referred-to global RTG is a - /// function and this ExecutionEngine is a JIT compiler, calling - /// updateGlobalMapping(RTG, 0) will leak the function's machine code, so you - /// should call freeMachineCodeForFunction(RTG) instead. Note that - /// optimizations can move and delete non-external GlobalValues without - /// notifying the ExecutionEngine. + /// value. This may involve code generation if it's a function. /// void *getPointerToGlobal(const GlobalValue *GV); /// getPointerToFunction - The different EE's represent function bodies in /// different ways. They should each implement this to say what a function - /// pointer should look like. See getPointerToGlobal for the requirements on - /// destroying F and any GlobalValues it refers to. + /// pointer should look like. When F is destroyed, the ExecutionEngine will + /// remove its global mapping but will not yet free its machine code. Call + /// freeMachineCodeForFunction(F) explicitly to do that. Note that global + /// optimizations can destroy Functions without notifying the ExecutionEngine. /// virtual void *getPointerToFunction(Function *F) = 0; /// getPointerToFunctionOrStub - If the specified function has been /// code-gen'd, return a pointer to the function. If not, compile it, or use - /// a stub to implement lazy compilation if available. See getPointerToGlobal - /// for the requirements on destroying F and any GlobalValues it refers to. + /// a stub to implement lazy compilation if available. See + /// getPointerToFunction for the requirements on destroying F. /// virtual void *getPointerToFunctionOrStub(Function *F) { // Default implementation, just codegen the function. @@ -296,8 +314,7 @@ /// getOrEmitGlobalVariable - Return the address of the specified global /// variable, possibly emitting it to memory if needed. This is used by the - /// Emitter. See getPointerToGlobal for the requirements on destroying GV and - /// any GlobalValues it refers to. + /// Emitter. virtual void *getOrEmitGlobalVariable(const GlobalVariable *GV) { return getPointerToGlobal((GlobalValue*)GV); } @@ -471,6 +488,12 @@ }; +inline bool operator<(const ExecutionEngineState::MapUpdatingCVH& lhs, + const ExecutionEngineState::MapUpdatingCVH& rhs) { + return static_cast(lhs) < + static_cast(rhs); +} + } // End llvm namespace #endif Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=83987&r1=83986&r2=83987&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Tue Oct 13 12:42:08 2009 @@ -46,7 +46,9 @@ ExecutionEngine::EERegisterFn ExecutionEngine::ExceptionTableRegister = 0; -ExecutionEngine::ExecutionEngine(ModuleProvider *P) : LazyFunctionCreator(0) { +ExecutionEngine::ExecutionEngine(ModuleProvider *P) + : EEState(*this), + LazyFunctionCreator(0) { LazyCompilationDisabled = false; GVCompilationDisabled = false; SymbolSearchingDisabled = false; @@ -115,8 +117,8 @@ void *ExecutionEngineState::RemoveMapping( const MutexGuard &, const GlobalValue *ToUnmap) { - std::map, void *>::iterator I = - GlobalAddressMap.find(ToUnmap); + std::map::iterator I = + GlobalAddressMap.find(getVH(ToUnmap)); void *OldVal; if (I == GlobalAddressMap.end()) OldVal = 0; @@ -139,14 +141,14 @@ DEBUG(errs() << "JIT: Map \'" << GV->getName() << "\' to [" << Addr << "]\n";); - void *&CurVal = state.getGlobalAddressMap(locked)[GV]; + void *&CurVal = EEState.getGlobalAddressMap(locked)[EEState.getVH(GV)]; assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!"); CurVal = Addr; // If we are using the reverse mapping, add it too - if (!state.getGlobalAddressReverseMap(locked).empty()) { + if (!EEState.getGlobalAddressReverseMap(locked).empty()) { AssertingVH &V = - state.getGlobalAddressReverseMap(locked)[Addr]; + EEState.getGlobalAddressReverseMap(locked)[Addr]; assert((V == 0 || GV == 0) && "GlobalMapping already established!"); V = GV; } @@ -157,8 +159,8 @@ void ExecutionEngine::clearAllGlobalMappings() { MutexGuard locked(lock); - state.getGlobalAddressMap(locked).clear(); - state.getGlobalAddressReverseMap(locked).clear(); + EEState.getGlobalAddressMap(locked).clear(); + EEState.getGlobalAddressReverseMap(locked).clear(); } /// clearGlobalMappingsFromModule - Clear all global mappings that came from a @@ -167,11 +169,11 @@ MutexGuard locked(lock); for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI) { - state.RemoveMapping(locked, FI); + EEState.RemoveMapping(locked, FI); } for (Module::global_iterator GI = M->global_begin(), GE = M->global_end(); GI != GE; ++GI) { - state.RemoveMapping(locked, GI); + EEState.RemoveMapping(locked, GI); } } @@ -181,25 +183,25 @@ void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) { MutexGuard locked(lock); - std::map, void *> &Map = - state.getGlobalAddressMap(locked); + std::map &Map = + EEState.getGlobalAddressMap(locked); // Deleting from the mapping? if (Addr == 0) { - return state.RemoveMapping(locked, GV); + return EEState.RemoveMapping(locked, GV); } - void *&CurVal = Map[GV]; + void *&CurVal = Map[EEState.getVH(GV)]; void *OldVal = CurVal; - if (CurVal && !state.getGlobalAddressReverseMap(locked).empty()) - state.getGlobalAddressReverseMap(locked).erase(CurVal); + if (CurVal && !EEState.getGlobalAddressReverseMap(locked).empty()) + EEState.getGlobalAddressReverseMap(locked).erase(CurVal); CurVal = Addr; // If we are using the reverse mapping, add it too - if (!state.getGlobalAddressReverseMap(locked).empty()) { + if (!EEState.getGlobalAddressReverseMap(locked).empty()) { AssertingVH &V = - state.getGlobalAddressReverseMap(locked)[Addr]; + EEState.getGlobalAddressReverseMap(locked)[Addr]; assert((V == 0 || GV == 0) && "GlobalMapping already established!"); V = GV; } @@ -212,9 +214,9 @@ void *ExecutionEngine::getPointerToGlobalIfAvailable(const GlobalValue *GV) { MutexGuard locked(lock); - std::map, void*>::iterator I = - state.getGlobalAddressMap(locked).find(GV); - return I != state.getGlobalAddressMap(locked).end() ? I->second : 0; + std::map::iterator I = + EEState.getGlobalAddressMap(locked).find(EEState.getVH(GV)); + return I != EEState.getGlobalAddressMap(locked).end() ? I->second : 0; } /// getGlobalValueAtAddress - Return the LLVM global value object that starts @@ -224,17 +226,17 @@ MutexGuard locked(lock); // If we haven't computed the reverse mapping yet, do so first. - if (state.getGlobalAddressReverseMap(locked).empty()) { - for (std::map, void *>::iterator - I = state.getGlobalAddressMap(locked).begin(), - E = state.getGlobalAddressMap(locked).end(); I != E; ++I) - state.getGlobalAddressReverseMap(locked).insert(std::make_pair(I->second, + if (EEState.getGlobalAddressReverseMap(locked).empty()) { + for (std::map::iterator + I = EEState.getGlobalAddressMap(locked).begin(), + E = EEState.getGlobalAddressMap(locked).end(); I != E; ++I) + EEState.getGlobalAddressReverseMap(locked).insert(std::make_pair(I->second, I->first)); } std::map >::iterator I = - state.getGlobalAddressReverseMap(locked).find(Addr); - return I != state.getGlobalAddressReverseMap(locked).end() ? I->second : 0; + EEState.getGlobalAddressReverseMap(locked).find(Addr); + return I != EEState.getGlobalAddressReverseMap(locked).end() ? I->second : 0; } // CreateArgv - Turn a vector of strings into a nice argv style array of @@ -474,7 +476,7 @@ return getPointerToFunction(F); MutexGuard locked(lock); - void *p = state.getGlobalAddressMap(locked)[GV]; + void *p = EEState.getGlobalAddressMap(locked)[EEState.getVH(GV)]; if (p) return p; @@ -484,7 +486,7 @@ EmitGlobalVariable(GVar); else llvm_unreachable("Global hasn't had an address allocated yet!"); - return state.getGlobalAddressMap(locked)[GV]; + return EEState.getGlobalAddressMap(locked)[EEState.getVH(GV)]; } /// This function converts a Constant* into a GenericValue. The interesting @@ -1069,3 +1071,18 @@ NumInitBytes += (unsigned)GVSize; ++NumGlobals; } + +ExecutionEngineState::MapUpdatingCVH::MapUpdatingCVH( + ExecutionEngineState &EES, const GlobalValue *GV) + : CallbackVH(const_cast(GV)), EES(EES) {} + +void ExecutionEngineState::MapUpdatingCVH::deleted() { + MutexGuard locked(EES.EE.lock); + EES.RemoveMapping(locked, *this); // Destroys *this. +} + +void ExecutionEngineState::MapUpdatingCVH::allUsesReplacedWith( + Value *new_value) { + assert(false && "The ExecutionEngine doesn't know how to handle a" + " RAUW on a value it has a global mapping for."); +} Modified: llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp?rev=83987&r1=83986&r2=83987&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp Tue Oct 13 12:42:08 2009 @@ -113,4 +113,17 @@ EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1)); } +TEST_F(ExecutionEngineTest, DestructionRemovesGlobalMapping) { + GlobalVariable *G1 = + NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1"); + int32_t Mem1 = 3; + Engine->addGlobalMapping(G1, &Mem1); + // Make sure the reverse mapping is enabled. + EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem1)); + // When the GV goes away, the ExecutionEngine should remove any + // mappings that refer to it. + G1->eraseFromParent(); + EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1)); +} + } From sabre at nondot.org Tue Oct 13 12:47:07 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 13 Oct 2009 17:47:07 -0000 Subject: [llvm-commits] [llvm] r83988 - /llvm/trunk/docs/ReleaseNotes-2.6.html Message-ID: <200910131747.n9DHl7YM012460@zion.cs.uiuc.edu> Author: lattner Date: Tue Oct 13 12:47:06 2009 New Revision: 83988 URL: http://llvm.org/viewvc/llvm-project?rev=83988&view=rev Log: add Zero Modified: llvm/trunk/docs/ReleaseNotes-2.6.html Modified: llvm/trunk/docs/ReleaseNotes-2.6.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes-2.6.html?rev=83988&r1=83987&r2=83988&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes-2.6.html (original) +++ llvm/trunk/docs/ReleaseNotes-2.6.html Tue Oct 13 12:47:06 2009 @@ -305,7 +305,7 @@ @@ -437,6 +437,23 @@ code.

      + + + +
      +

      +IcedTea provides a +harness to build OpenJDK using only free software build tools and to provide +replacements for the not-yet free parts of OpenJDK. One of the extensions that +IcedTea provides is a new JIT compiler named Shark which uses LLVM +to provide native code generation without introducing processor-dependent +code. +

      +
      + From sabre at nondot.org Tue Oct 13 12:48:04 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 13 Oct 2009 17:48:04 -0000 Subject: [llvm-commits] [llvm] r83990 - in /llvm/trunk/docs: ReleaseNotes-2.6.html ReleaseNotes.html Message-ID: <200910131748.n9DHm5cC012539@zion.cs.uiuc.edu> Author: lattner Date: Tue Oct 13 12:48:04 2009 New Revision: 83990 URL: http://llvm.org/viewvc/llvm-project?rev=83990&view=rev Log: rename ReleaseNotes-2.6.html -> ReleaseNotes.html Removed: llvm/trunk/docs/ReleaseNotes-2.6.html Modified: llvm/trunk/docs/ReleaseNotes.html Removed: llvm/trunk/docs/ReleaseNotes-2.6.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes-2.6.html?rev=83989&view=auto ============================================================================== --- llvm/trunk/docs/ReleaseNotes-2.6.html (original) +++ llvm/trunk/docs/ReleaseNotes-2.6.html (removed) @@ -1,1355 +0,0 @@ - - - - - - LLVM 2.6 Release Notes - - - -
      LLVM 2.6 Release Notes
      - -
        -
      1. Introduction
      2. -
      3. Sub-project Status Update
      4. -
      5. External Projects Using LLVM 2.6
      6. -
      7. What's New in LLVM 2.6?
      8. -
      9. Installation Instructions
      10. -
      11. Portability and Supported Platforms
      12. -
      13. Known Problems
      14. -
      15. Additional Information
      16. -
      - -
      -

      Written by the LLVM Team

      -
      - - - - - -
      - -

      This document contains the release notes for the LLVM Compiler -Infrastructure, release 2.6. Here we describe the status of LLVM, including -major improvements from the previous release and significant known problems. -All LLVM releases may be downloaded from the LLVM releases web site.

      - -

      For more information about LLVM, including information about the latest -release, please check out the main LLVM -web site. If you have questions or comments, the LLVM Developer's Mailing -List is a good place to send them.

      - -

      Note that if you are reading this file from a Subversion checkout or the -main LLVM web page, this document applies to the next release, not the -current one. To see the release notes for a specific release, please see the -releases page.

      - -
      - - - - - - - - - - - - - -
      -

      -The LLVM 2.6 distribution currently consists of code from the core LLVM -repository (which roughly includes the LLVM optimizers, code generators -and supporting tools), the Clang repository and the llvm-gcc repository. In -addition to this code, the LLVM Project includes other sub-projects that are in -development. Here we include updates on these subprojects. -

      - -
      - - - - - -
      - -

      The Clang project is an effort to build -a set of new 'LLVM native' front-end technologies for the C family of languages. -LLVM 2.6 is the first release to officially include Clang, and it provides a -production quality C and Objective-C compiler. If you are interested in fast compiles and -good diagnostics, we -encourage you to try it out. Clang currently compiles typical Objective-C code -3x faster than GCC and compiles C code about 30% faster than GCC at -O0 -g -(which is when the most pressure is on the frontend).

      - -

      In addition to supporting these languages, C++ support is also well under way, and mainline -Clang is able to parse the libstdc++ 4.2 headers and even codegen simple apps. -If you are interested in Clang C++ support or any other Clang feature, we -strongly encourage you to get involved on the Clang front-end mailing -list.

      - -

      In the LLVM 2.6 time-frame, the Clang team has made many improvements:

      - -
        -
      • C and Objective-C support are now considered production quality.
      • -
      • AuroraUX, FreeBSD and OpenBSD are now supported.
      • -
      • Most of Objective-C 2.0 is now supported with the GNU runtime.
      • -
      • Many many bugs are fixed and lots of features have been added.
      • -
      -
      - - - - -
      - -

      Previously announced in the 2.4 and 2.5 LLVM releases, the Clang project also -includes an early stage static source code analysis tool for automatically finding bugs -in C and Objective-C programs. The tool performs checks to find -bugs that occur on a specific path within a program.

      - -

      In the LLVM 2.6 time-frame, the analyzer core has undergone several important -improvements and cleanups and now includes a new Checker interface that -is intended to eventually serve as a basis for domain-specific checks. Further, -in addition to generating HTML files for reporting analysis results, the -analyzer can now also emit bug reports in a structured XML format that is -intended to be easily readable by other programs.

      - -

      The set of checks performed by the static analyzer continues to expand, and -future plans for the tool include full source-level inter-procedural analysis -and deeper checks such as buffer overrun detection. There are many opportunities -to extend and enhance the static analyzer, and anyone interested in working on -this project is encouraged to get involved!

      - -
      - - - - -
      -

      -The VMKit project is an implementation of -a JVM and a CLI Virtual Machine (Microsoft .NET is an -implementation of the CLI) using LLVM for static and just-in-time -compilation.

      - -

      -VMKit version 0.26 builds with LLVM 2.6 and you can find it on its -web page. The release includes -bug fixes, cleanup and new features. The major changes are:

      - -
        - -
      • A new llcj tool to generate shared libraries or executables of Java - files.
      • -
      • Cooperative garbage collection.
      • -
      • Fast subtype checking (paper from Click et al [JGI'02]).
      • -
      • Implementation of a two-word header for Java objects instead of the original - three-word header.
      • -
      • Better Java specification-compliance: division by zero checks, stack - overflow checks, finalization and references support.
      • - -
      -
      - - - - - -
      -

      -The new LLVM compiler-rt project -is a simple library that provides an implementation of the low-level -target-specific hooks required by code generation and other runtime components. -For example, when compiling for a 32-bit target, converting a double to a 64-bit -unsigned integer is compiled into a runtime call to the "__fixunsdfdi" -function. The compiler-rt library provides highly optimized implementations of -this and other low-level routines (some are 3x faster than the equivalent -libgcc routines).

      - -

      -All of the code in the compiler-rt project is available under the standard LLVM -License, a "BSD-style" license.

      - -
      - - - - -
      -

      -The new LLVM KLEE project is a symbolic -execution framework for programs in LLVM bitcode form. KLEE tries to -symbolically evaluate "all" paths through the application and records state -transitions that lead to fault states. This allows it to construct testcases -that lead to faults and can even be used to verify algorithms. For more -details, please see the OSDI 2008 paper about -KLEE.

      - -
      - - - - -
      -

      -The goal of DragonEgg is to make -gcc-4.5 act like llvm-gcc without requiring any gcc modifications whatsoever. -DragonEgg is a shared library (llvm.so) -that is loaded by gcc at runtime. It uses the new gcc plugin architecture to -disable the GCC optimizers and code generators, and schedule the LLVM optimizers -and code generators (or direct output of LLVM IR) instead. Currently only Linux -and Darwin are supported, and only on x86-32 and x86-64. It should be easy to -add additional unix-like architectures and other processor families. In theory -it should be possible to use DragonEgg -with any language supported by gcc, however only C and Fortran work well for the -moment. Ada and C++ work to some extent, while Java, Obj-C and Obj-C++ are so -far entirely untested. Since gcc-4.5 has not yet been released, neither has -DragonEgg. To build -DragonEgg you will need to check out the -development versions of gcc, -llvm and -DragonEgg from their respective -subversion repositories, and follow the instructions in the -DragonEgg README. -

      - -
      - - - - - -
      -

      -The LLVM Machine Code (MC) Toolkit project is a (very early) effort to build -better tools for dealing with machine code, object file formats, etc. The idea -is to be able to generate most of the target specific details of assemblers and -disassemblers from existing LLVM target .td files (with suitable enhancements), -and to build infrastructure for reading and writing common object file formats. -One of the first deliverables is to build a full assembler and integrate it into -the compiler, which is predicted to substantially reduce compile time in some -scenarios. -

      - -

      In the LLVM 2.6 timeframe, the MC framework has grown to the point where it -can reliably parse and pretty print (with some encoding information) a -darwin/x86 .s file successfully, and has the very early phases of a Mach-O -assembler in progress. Beyond the MC framework itself, major refactoring of the -LLVM code generator has started. The idea is to make the code generator reason -about the code it is producing in a much more semantic way, rather than a -textual way. For example, the code generator now uses MCSection objects to -represent section assignments, instead of text strings that print to .section -directives.

      - -

      MC is an early and ongoing project that will hopefully continue to lead to -many improvements in the code generator and build infrastructure useful for many -other situations. -

      - -
      - - - - - - -
      - -

      An exciting aspect of LLVM is that it is used as an enabling technology for - a lot of other language and tools projects. This section lists some of the - projects that have already been updated to work with LLVM 2.6.

      -
      - - - - - -
      -

      Rubinius is an environment -for running Ruby code which strives to write as much of the core class -implementation in Ruby as possible. Combined with a bytecode interpreting VM, it -uses LLVM to optimize and compile ruby code down to machine code. Techniques -such as type feedback, method inlining, and uncommon traps are all used to -remove dynamism from ruby execution and increase performance.

      - -

      Since LLVM 2.5, Rubinius has made several major leaps forward, implementing -a counter based JIT, type feedback and speculative method inlining. -

      - -
      - - - - -
      - -

      -MacRuby is an implementation of Ruby on top of -core Mac OS X technologies, such as the Objective-C common runtime and garbage -collector and the CoreFoundation framework. It is principally developed by -Apple and aims at enabling the creation of full-fledged Mac OS X applications. -

      - -

      -MacRuby uses LLVM for optimization passes, JIT and AOT compilation of Ruby -expressions. It also uses zero-cost DWARF exceptions to implement Ruby exception -handling.

      - -
      - - - -
      -Pure -
      - -
      -

      -Pure -is an algebraic/functional programming language based on term rewriting. -Programs are collections of equations which are used to evaluate expressions in -a symbolic fashion. Pure offers dynamic typing, eager and lazy evaluation, -lexical closures, a hygienic macro system (also based on term rewriting), -built-in list and matrix support (including list and matrix comprehensions) and -an easy-to-use C interface. The interpreter uses LLVM as a backend to - JIT-compile Pure programs to fast native code.

      - -

      Pure versions 0.31 and later have been tested and are known to work with -LLVM 2.6 (and continue to work with older LLVM releases >= 2.3 as well). -

      -
      - - - - - -
      -

      -LDC is an implementation of -the D Programming Language using the LLVM optimizer and code generator. -The LDC project works great with the LLVM 2.6 release. General improvements in -this -cycle have included new inline asm constraint handling, better debug info -support, general bug fixes and better x86-64 support. This has allowed -some major improvements in LDC, getting it much closer to being as -fully featured as the original DMD compiler from DigitalMars. -

      -
      - - - - -
      -

      -Roadsend PHP (rphp) is an open -source implementation of the PHP programming -language that uses LLVM for its optimizer, JIT and static compiler. This is a -reimplementation of an earlier project that is now based on LLVM.

      -
      - - - - -
      -

      -Unladen Swallow is a -branch of Python intended to be fully -compatible and significantly faster. It uses LLVM's optimization passes and JIT -compiler.

      -
      - - - - -
      -

      -LLVM-Lua uses LLVM to add JIT -and static compiling support to the Lua VM. Lua bytecode is analyzed to -remove type checks, then LLVM is used to compile the bytecode down to machine -code.

      -
      - - - - -
      -

      -IcedTea provides a -harness to build OpenJDK using only free software build tools and to provide -replacements for the not-yet free parts of OpenJDK. One of the extensions that -IcedTea provides is a new JIT compiler named Shark which uses LLVM -to provide native code generation without introducing processor-dependent -code. -

      -
      - - - - - - - -
      - -

      This release includes a huge number of bug fixes, performance tweaks and -minor improvements. Some of the major improvements and new features are listed -in this section. -

      - -
      - - - - -
      - -

      LLVM 2.6 includes several major new capabilities:

      - -
        -
      • New compiler-rt, KLEE - and machine code toolkit sub-projects.
      • -
      • Debug information now includes line numbers when optimizations are enabled. - This allows statistical sampling tools like OProfile and Shark to map - samples back to source lines.
      • -
      • LLVM now includes new experimental backends to support the MSP430, SystemZ - and BlackFin architectures.
      • -
      • LLVM supports a new Gold Linker Plugin which - enables support for transparent - link-time optimization on ELF targets when used with the Gold binutils - linker.
      • -
      • LLVM now supports doing optimization and code generation on multiple - threads. Please see the LLVM - Programmer's Manual for more information.
      • -
      • LLVM now has experimental support for embedded - metadata in LLVM IR, though the implementation is not guaranteed to be - final and the .bc file format may change in future releases. Debug info - does not yet use this format in LLVM 2.6.
      • -
      - -
      - - - - -
      -

      LLVM IR has several new features for better support of new targets and that -expose new optimization opportunities:

      - -
        -
      • The add, sub and mul - instructions have been split into integer and floating point versions (like - divide and remainder), introducing new fadd, fsub, - and fmul instructions.
      • -
      • The add, sub and mul - instructions now support optional "nsw" and "nuw" bits which indicate that - the operation is guaranteed to not overflow (in the signed or - unsigned case, respectively). This gives the optimizer more information and - can be used for things like C signed integer values, which are undefined on - overflow.
      • -
      • The sdiv instruction now supports an - optional "exact" flag which indicates that the result of the division is - guaranteed to have a remainder of zero. This is useful for optimizing pointer - subtraction in C.
      • -
      • The getelementptr instruction now - supports arbitrary integer index values for array/pointer indices. This - allows for better code generation on 16-bit pointer targets like PIC16.
      • -
      • The getelementptr instruction now - supports an "inbounds" optimization hint that tells the optimizer that the - pointer is guaranteed to be within its allocated object.
      • -
      • LLVM now support a series of new linkage types for global values which allow - for better optimization and new capabilities: -
          -
        • linkonce_odr and - weak_odr have the same linkage - semantics as the non-"odr" linkage types. The difference is that these - linkage types indicate that all definitions of the specified function - are guaranteed to have the same semantics. This allows inlining - templates functions in C++ but not inlining weak functions in C, - which previously both got the same linkage type.
        • -
        • available_externally - is a new linkage type that gives the optimizer visibility into the - definition of a function (allowing inlining and side effect analysis) - but that does not cause code to be generated. This allows better - optimization of "GNU inline" functions, extern templates, etc.
        • -
        • linker_private is a - new linkage type (which is only useful on Mac OS X) that is used for - some metadata generation and other obscure things.
        • -
      • -
      • Finally, target-specific intrinsics can now return multiple values, which - is useful for modeling target operations with multiple results.
      • -
      - -
      - - - - -
      - -

      In addition to a large array of minor performance tweaks and bug fixes, this -release includes a few major enhancements and additions to the optimizers:

      - -
        - -
      • The Scalar Replacement of Aggregates - pass has many improvements that allow it to better promote vector unions, - variables which are memset, and much more strange code that can happen to - do bitfield accesses to register operations. An interesting change is that - it now produces "unusual" integer sizes (like i1704) in some cases and lets - other optimizers clean things up.
      • -
      • The Loop Strength Reduction pass now - promotes small integer induction variables to 64-bit on 64-bit targets, - which provides a major performance boost for much numerical code. It also - promotes shorts to int on 32-bit hosts, etc. LSR now also analyzes pointer - expressions (e.g. getelementptrs), as well as integers.
      • -
      • The GVN pass now eliminates partial - redundancies of loads in simple cases.
      • -
      • The Inliner now reuses stack space when - inlining similar arrays from multiple callees into one caller.
      • -
      • LLVM includes a new experimental Static Single Information (SSI) - construction pass.
      • - -
      - -
      - - - - - -
      - -
        -
      • LLVM has a new "EngineBuilder" class which makes it more obvious how to - set up and configure an ExecutionEngine (a JIT or interpreter).
      • -
      • The JIT now supports generating more than 16M of code.
      • -
      • When configured with --with-oprofile, the JIT can now inform - OProfile about JIT'd code, allowing OProfile to get line number and function - name information for JIT'd functions.
      • -
      • When "libffi" is available, the LLVM interpreter now uses it, which supports - calling almost arbitrary external (natively compiled) functions.
      • -
      • Clients of the JIT can now register a 'JITEventListener' object to receive - callbacks when the JIT emits or frees machine code. The OProfile support - uses this mechanism.
      • -
      - -
      - - - - -
      - -

      We have put a significant amount of work into the code generator -infrastructure, which allows us to implement more aggressive algorithms and make -it run faster:

      - -
        - -
      • The llc -asm-verbose option (exposed from llvm-gcc as -dA - and clang as -fverbose-asm or -dA) now adds a lot of - useful information in comments to - the generated .s file. This information includes location information (if - built with -g) and loop nest information.
      • -
      • The code generator now supports a new MachineVerifier pass which is useful - for finding bugs in targets and codegen passes.
      • -
      • The Machine LICM is now enabled by default. It hoists instructions out of - loops (such as constant pool loads, loads from read-only stubs, vector - constant synthesization code, etc.) and is currently configured to only do - so when the hoisted operation can be rematerialized.
      • -
      • The Machine Sinking pass is now enabled by default. This pass moves - side-effect free operations down the CFG so that they are executed on fewer - paths through a function.
      • -
      • The code generator now performs "stack slot coloring" of register spills, - which allows spill slots to be reused. This leads to smaller stack frames - in cases where there are lots of register spills.
      • -
      • The register allocator has many improvements to take better advantage of - commutable operations, various spiller peephole optimizations, and can now - coalesce cross-register-class copies.
      • -
      • Tblgen now supports multiclass inheritance and a number of new string and - list operations like !(subst), !(foreach), !car, - !cdr, !null, !if, !cast. - These make the .td files more expressive and allow more aggressive factoring - of duplication across instruction patterns.
      • -
      • Target-specific intrinsics can now be added without having to hack VMCore to - add them. This makes it easier to maintain out-of-tree targets.
      • -
      • The instruction selector is better at propagating information about values - (such as whether they are sign/zero extended etc.) across basic block - boundaries.
      • -
      • The SelectionDAG datastructure has new nodes for representing buildvector - and vector shuffle operations. This - makes operations and pattern matching more efficient and easier to get - right.
      • -
      • The Prolog/Epilog Insertion Pass now has experimental support for performing - the "shrink wrapping" optimization, which moves spills and reloads around in - the CFG to avoid doing saves on paths that don't need them.
      • -
      • LLVM includes new experimental support for writing ELF .o files directly - from the compiler. It works well for many simple C testcases, but doesn't - support exception handling, debug info, inline assembly, etc.
      • -
      • Targets can now specify register allocation hints through - MachineRegisterInfo::setRegAllocationHint. A regalloc hint consists - of hint type and physical register number. A hint type of zero specifies a - register allocation preference. Other hint type values are target specific - which are resolved by TargetRegisterInfo::ResolveRegAllocHint. An - example is the ARM target which uses register hints to request that the - register allocator provide an even / odd register pair to two virtual - registers.
      • -
      -
      - - - - -
      -

      New features of the X86 target include: -

      - -
        - -
      • SSE 4.2 builtins are now supported.
      • -
      • GCC-compatible soft float modes are now supported, which are typically used - by OS kernels.
      • -
      • X86-64 now models implicit zero extensions better, which allows the code - generator to remove a lot of redundant zexts. It also models the 8-bit "H" - registers as subregs, which allows them to be used in some tricky - situations.
      • -
      • X86-64 now supports the "local exec" and "initial exec" thread local storage - model.
      • -
      • The vector forms of the icmp and fcmp instructions now select to efficient - SSE operations.
      • -
      • Support for the win64 calling conventions have improved. The primary - missing feature is support for varargs function definitions. It seems to - work well for many win64 JIT purposes.
      • -
      • The X86 backend has preliminary support for mapping address spaces to segment - register references. This allows you to write GS or FS relative memory - accesses directly in LLVM IR for cases where you know exactly what you're - doing (such as in an OS kernel). There are some known problems with this - support, but it works in simple cases.
      • -
      • The X86 code generator has been refactored to move all global variable - reference logic to one place - (X86Subtarget::ClassifyGlobalReference) which - makes it easier to reason about.
      • - -
      - -
      - - - - -
      -

      New features of the PIC16 target include: -

      - -
        -
      • Support for floating-point, indirect function calls, and - passing/returning aggregate types to functions. -
      • The code generator is able to generate debug info into output COFF files. -
      • Support for placing an object into a specific section or at a specific - address in memory.
      • -
      - -

      Things not yet supported:

      - -
        -
      • Variable arguments.
      • -
      • Interrupts/programs.
      • -
      - -
      - - - - -
      -

      New features of the ARM target include: -

      - -
        - -
      • Preliminary support for processors, such as the Cortex-A8 and Cortex-A9, -that implement version v7-A of the ARM architecture. The ARM backend now -supports both the Thumb2 and Advanced SIMD (Neon) instruction sets.
      • - -
      • The AAPCS-VFP "hard float" calling conventions are also supported with the --float-abi=hard flag.
      • - -
      • The ARM calling convention code is now tblgen generated instead of resorting - to C++ code.
      • -
      - -

      These features are still somewhat experimental -and subject to change. The Neon intrinsics, in particular, may change in future -releases of LLVM. ARMv7 support has progressed a lot on top of tree since 2.6 -branched.

      - - -
      - - - - -
      -

      New features of other targets include: -

      - -
        -
      • Mips now supports O32 Calling Convention.
      • -
      • Many improvements to the 32-bit PowerPC SVR4 ABI (used on powerpc-linux) - support, lots of bugs fixed.
      • -
      • Added support for the 64-bit PowerPC SVR4 ABI (used on powerpc64-linux). - Needs more testing.
      • -
      - -
      - - - - -
      - -

      This release includes a number of new APIs that are used internally, which - may also be useful for external clients. -

      - -
        -
      • New - PrettyStackTrace class allows crashes of llvm tools (and applications - that integrate them) to provide more detailed indication of what the - compiler was doing at the time of the crash (e.g. running a pass). - At the top level for each LLVM tool, it includes the command line arguments. -
      • -
      • New StringRef - and Twine classes - make operations on character ranges and - string concatenation to be more efficient. StringRef is just a const - char* with a length, Twine is a light-weight rope.
      • -
      • LLVM has new WeakVH, AssertingVH and CallbackVH - classes, which make it easier to write LLVM IR transformations. WeakVH - is automatically drops to null when the referenced Value is deleted, - and is updated across a replaceAllUsesWith operation. - AssertingVH aborts the program if the - referenced value is destroyed while it is being referenced. CallbackVH - is a customizable class for handling value references. See ValueHandle.h - for more information.
      • -
      • The new 'Triple - ' class centralizes a lot of logic that reasons about target - triples.
      • -
      • The new ' - llvm_report_error()' set of APIs allows tools to embed the LLVM - optimizer and backend and recover from previously unrecoverable errors.
      • -
      • LLVM has new abstractions for atomic operations - and reader/writer - locks.
      • -
      • LLVM has new - SourceMgr and SMLoc classes which implement caret - diagnostics and basic include stack processing for simple parsers. It is - used by tablegen, llvm-mc, the .ll parser and FileCheck.
      • -
      - - -
      - - - - -
      -

      Other miscellaneous features include:

      - -
        -
      • LLVM now includes a new internal 'FileCheck' tool which allows - writing much more accurate regression tests that run faster. Please see the - FileCheck section of the Testing - Guide for more information.
      • -
      • LLVM profile information support has been significantly improved to produce -correct use counts, and has support for edge profiling with reduced runtime -overhead. Combined, the generated profile information is both more correct and -imposes about half as much overhead (2.6. from 12% to 6% overhead on SPEC -CPU2000).
      • -
      • The C bindings (in the llvm/include/llvm-c directory) include many newly - supported APIs.
      • -
      • LLVM 2.6 includes a brand new experimental LLVM bindings to the Ada2005 - programming language.
      • - -
      • The LLVMC driver has several new features: -
          -
        • Dynamic plugins now work on Windows.
        • -
        • New option property: init. Makes possible to provide default values for - options defined in plugins (interface to cl::init).
        • -
        • New example: Skeleton, shows how to create a standalone LLVMC-based - driver.
        • -
        • New example: mcc16, a driver for the PIC16 toolchain.
        • -
        -
      • - -
      - -
      - - - - - -
      - -

      If you're already an LLVM user or developer with out-of-tree changes based -on LLVM 2.5, this section lists some "gotchas" that you may run into upgrading -from the previous release.

      - -
        -
      • The Itanium (IA64) backend has been removed. It was not actively supported - and had bitrotted.
      • -
      • The BigBlock register allocator has been removed, it had also bitrotted.
      • -
      • The C Backend (-march=c) is no longer considered part of the LLVM release -criteria. We still want it to work, but no one is maintaining it and it lacks -support for arbitrary precision integers and other important IR features.
      • - -
      • All LLVM tools now default to overwriting their output file, behaving more - like standard unix tools. Previously, this only happened with the '-f' - option.
      • -
      • LLVM build now builds all libraries as .a files instead of some - libraries as relinked .o files. This requires some APIs like - InitializeAllTargets.h. -
      • -
      - - -

      In addition, many APIs have changed in this release. Some of the major LLVM -API changes are:

      - -
        -
      • All uses of hash_set and hash_map have been removed from - the LLVM tree and the wrapper headers have been removed.
      • -
      • The llvm/Streams.h and DOUT member of Debug.h have been removed. The - llvm::Ostream class has been completely removed and replaced with - uses of raw_ostream.
      • -
      • LLVM's global uniquing tables for Types and Constants have - been privatized into members of an LLVMContext. A number of APIs - now take an LLVMContext as a parameter. To smooth the transition - for clients that will only ever use a single context, the new - getGlobalContext() API can be used to access a default global - context which can be passed in any and all cases where a context is - required. -
      • The getABITypeSize methods are now called getAllocSize.
      • -
      • The Add, Sub and Mul operators are no longer - overloaded for floating-point types. Floating-point addition, subtraction - and multiplication are now represented with new operators FAdd, - FSub and FMul. In the IRBuilder API, - CreateAdd, CreateSub, CreateMul and - CreateNeg should only be used for integer arithmetic now; - CreateFAdd, CreateFSub, CreateFMul and - CreateFNeg should now be used for floating-point arithmetic.
      • -
      • The DynamicLibrary class can no longer be constructed, its functionality has - moved to static member functions.
      • -
      • raw_fd_ostream's constructor for opening a given filename now - takes an extra Force argument. If Force is set to - false, an error will be reported if a file with the given name - already exists. If Force is set to true, the file will - be silently truncated (which is the behavior before this flag was - added).
      • -
      • SCEVHandle no longer exists, because reference counting is no - longer done for SCEV* objects, instead const SCEV* - should be used.
      • - -
      • Many APIs, notably llvm::Value, now use the StringRef -and Twine classes instead of passing const char* -or std::string, as described in -the Programmer's Manual. Most -clients should be unaffected by this transition, unless they are used to -Value::getName() returning a string. Here are some tips on updating to -2.6: -
          -
        • getNameStr() is still available, and matches the old - behavior. Replacing getName() calls with this is an safe option, - although more efficient alternatives are now possible.
        • - -
        • If you were just relying on getName() being able to be sent to - a std::ostream, consider migrating - to llvm::raw_ostream.
        • - -
        • If you were using getName().c_str() to get a const - char* pointer to the name, you can use getName().data(). - Note that this string (as before), may not be the entire name if the - name contains embedded null characters.
        • - -
        • If you were using operator + on the result of getName() and - treating the result as an std::string, you can either - use Twine::str to get the result as an std::string, or - could move to a Twine based design.
        • - -
        • isName() should be replaced with comparison - against getName() (this is now efficient). -
        -
      • - -
      • The registration interfaces for backend Targets has changed (what was -previously TargetMachineRegistry). For backend authors, see the Writing An LLVM Backend -guide. For clients, the notable API changes are: -
          -
        • TargetMachineRegistry has been renamed - to TargetRegistry.
        • - -
        • Clients should move to using the TargetRegistry::lookupTarget() - function to find targets.
        • -
        -
      • -
      - -
      - - - - - - - -
      - -

      LLVM is known to work on the following platforms:

      - -
        -
      • Intel and AMD machines (IA32, X86-64, AMD64, EMT-64) running Red Hat - Linux, Fedora Core, FreeBSD and AuroraUX (and probably other unix-like - systems).
      • -
      • PowerPC and X86-based Mac OS X systems, running 10.3 and above in 32-bit - and 64-bit modes.
      • -
      • Intel and AMD machines running on Win32 using MinGW libraries (native).
      • -
      • Intel and AMD machines running on Win32 with the Cygwin libraries (limited - support is available for native builds with Visual C++).
      • -
      • Sun UltraSPARC workstations running Solaris 10.
      • -
      • Alpha-based machines running Debian GNU/Linux.
      • -
      - -

      The core LLVM infrastructure uses GNU autoconf to adapt itself -to the machine and operating system on which it is built. However, minor -porting may be required to get LLVM to work on new platforms. We welcome your -portability patches and reports of successful builds or error messages.

      - -
      - - - - - -
      - -

      This section contains significant known problems with the LLVM system, -listed by component. If you run into a problem, please check the LLVM bug database and submit a bug if -there isn't already one.

      - -
        -
      • The llvm-gcc bootstrap will fail with some versions of binutils (e.g. 2.15) - with a message of "Error: can not do 8 - byte pc-relative relocation" when building C++ code. We intend to - fix this on mainline, but a workaround for 2.6 is to upgrade to binutils - 2.17 or later.
      • - -
      • LLVM will not correctly compile on Solaris and/or OpenSolaris -using the stock GCC 3.x.x series 'out the box', -See: Broken versions of GCC and other tools. -However, A Modern GCC Build -for x86/x86-64 has been made available from the third party AuroraUX Project -that has been meticulously tested for bootstrapping LLVM & Clang.
      • -
      - -
      - - - - -
      - -

      The following components of this LLVM release are either untested, known to -be broken or unreliable, or are in early development. These components should -not be relied on, and bugs should not be filed against them, but they may be -useful to some people. In particular, if you would like to work on one of these -components, please contact us on the LLVMdev list.

      - -
        -
      • The MSIL, Alpha, SPU, MIPS, PIC16, Blackfin, MSP430 and SystemZ backends are - experimental.
      • -
      • The llc "-filetype=asm" (the default) is the only - supported value for this option. The ELF writer is experimental.
      • -
      • The implementation of Andersen's Alias Analysis has many known bugs.
      • -
      - -
      - - - - -
      - -
        -
      • The X86 backend does not yet support - all inline assembly that uses the X86 - floating point stack. It supports the 'f' and 't' constraints, but not - 'u'.
      • -
      • The X86 backend generates inefficient floating point code when configured - to generate code for systems that don't have SSE2.
      • -
      • Win64 code generation wasn't widely tested. Everything should work, but we - expect small issues to happen. Also, llvm-gcc cannot build the mingw64 - runtime currently due - to several - bugs and due to lack of support for - the - 'u' inline assembly constraint and for X87 floating point inline assembly.
      • -
      • The X86-64 backend does not yet support the LLVM IR instruction - va_arg. Currently, the llvm-gcc and front-ends support variadic - argument constructs on X86-64 by lowering them manually.
      • -
      - -
      - - - - -
      - -
        -
      • The Linux PPC32/ABI support needs testing for the interpreter and static -compilation, and lacks support for debug information.
      • -
      - -
      - - - - -
      - -
        -
      • Support for the Advanced SIMD (Neon) instruction set is still incomplete -and not well tested. Some features may not work at all, and the code quality -may be poor in some cases.
      • -
      • Thumb mode works only on ARMv6 or higher processors. On sub-ARMv6 -processors, thumb programs can crash or produce wrong -results (PR1388).
      • -
      • Compilation for ARM Linux OABI (old ABI) is supported but not fully tested. -
      • -
      - -
      - - - - -
      - -
        -
      • The SPARC backend only supports the 32-bit SPARC ABI (-m32); it does not - support the 64-bit SPARC ABI (-m64).
      • -
      - -
      - - - - -
      - -
        -
      • 64-bit MIPS targets are not supported yet.
      • -
      - -
      - - - - -
      - -
        - -
      • On 21164s, some rare FP arithmetic sequences which may trap do not have the -appropriate nops inserted to ensure restartability.
      • - -
      -
      - - - - -
      - - - -
      - - - - - -
      - -

      The only major language feature of GCC not supported by llvm-gcc is - the __builtin_apply family of builtins. However, some extensions - are only supported on some targets. For example, trampolines are only - supported on some targets (these are used when you take the address of a - nested function).

      - -

      If you run into GCC extensions which are not supported, please let us know. -

      - -
      - - - - -
      - -

      The C++ front-end is considered to be fully -tested and works for a number of non-trivial programs, including LLVM -itself, Qt, Mozilla, etc.

      - -
        -
      • Exception handling works well on the X86 and PowerPC targets. Currently - only Linux and Darwin targets are supported (both 32 and 64 bit).
      • -
      - -
      - - - - -
      -
        -
      • Fortran support generally works, but there are still several unresolved bugs - in Bugzilla. Please see the - tools/gfortran component for details.
      • -
      -
      - - - - -
      -The llvm-gcc 4.2 Ada compiler works fairly well; however, this is not a mature -technology, and problems should be expected. -
        -
      • The Ada front-end currently only builds on X86-32. This is mainly due -to lack of trampoline support (pointers to nested functions) on other platforms. -However, it also fails to build on X86-64 -which does support trampolines.
      • -
      • The Ada front-end fails to bootstrap. -This is due to lack of LLVM support for setjmp/longjmp style -exception handling, which is used internally by the compiler. -Workaround: configure with --disable-bootstrap.
      • -
      • The c380004, c393010 -and cxg2021 ACATS tests fail -(c380004 also fails with gcc-4.2 mainline). -If the compiler is built with checks disabled then c393010 -causes the compiler to go into an infinite loop, using up all system memory.
      • -
      • Some GCC specific Ada tests continue to crash the compiler.
      • -
      • The -E binder option (exception backtraces) -does not work and will result in programs -crashing if an exception is raised. Workaround: do not use -E.
      • -
      • Only discrete types are allowed to start -or finish at a non-byte offset in a record. Workaround: do not pack records -or use representation clauses that result in a field of a non-discrete type -starting or finishing in the middle of a byte.
      • -
      • The lli interpreter considers -'main' as generated by the Ada binder to be invalid. -Workaround: hand edit the file to use pointers for argv and -envp rather than integers.
      • -
      • The -fstack-check option is -ignored.
      • -
      -
      - - - - -
      - -

      The Llvm.Linkage module is broken, and has incorrect values. Only -Llvm.Linkage.External, Llvm.Linkage.Available_externally, and -Llvm.Linkage.Link_once will be correct. If you need any of the other linkage -modes, you'll have to write an external C library in order to expose the -functionality. This has been fixed in the trunk.

      -
      - - - - - -
      - -

      A wide variety of additional information is available on the LLVM web page, in particular in the documentation section. The web page also -contains versions of the API documentation which is up-to-date with the -Subversion version of the source code. -You can access versions of these documents specific to this release by going -into the "llvm/doc/" directory in the LLVM tree.

      - -

      If you have any questions or comments about LLVM, please feel free to contact -us via the mailing -lists.

      - -
      - - - -
      -
      - Valid CSS - Valid HTML 4.01 - - LLVM Compiler Infrastructure
      - Last modified: $Date$ -
      - - - Modified: llvm/trunk/docs/ReleaseNotes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=83990&r1=83989&r2=83990&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes.html (original) +++ llvm/trunk/docs/ReleaseNotes.html Tue Oct 13 12:48:04 2009 @@ -4,17 +4,17 @@ - LLVM 2.5 Release Notes + LLVM 2.6 Release Notes -
      LLVM 2.5 Release Notes
      +
      LLVM 2.6 Release Notes
      1. Introduction
      2. Sub-project Status Update
      3. -
      4. External Projects Using LLVM 2.5
      5. -
      6. What's New in LLVM 2.5?
      7. +
      8. External Projects Using LLVM 2.6
      9. +
      10. What's New in LLVM 2.6?
      11. Installation Instructions
      12. Portability and Supported Platforms
      13. Known Problems
      14. @@ -34,7 +34,7 @@

        This document contains the release notes for the LLVM Compiler -Infrastructure, release 2.5. Here we describe the status of LLVM, including +Infrastructure, release 2.6. Here we describe the status of LLVM, including major improvements from the previous release and significant known problems. All LLVM releases may be downloaded from the LLVM releases web site.

        @@ -51,25 +51,37 @@ releases page.

        + - + + + @@ -80,12 +92,11 @@

        -The LLVM 2.5 distribution currently consists of code from the core LLVM -repository —which roughly includes the LLVM optimizers, code generators -and supporting tools — and the llvm-gcc repository. In addition to this -code, the LLVM Project includes other sub-projects that are in development. The -two which are the most actively developed are the Clang -Project and the VMKit Project. +The LLVM 2.6 distribution currently consists of code from the core LLVM +repository (which roughly includes the LLVM optimizers, code generators +and supporting tools), the Clang repository and the llvm-gcc repository. In +addition to this code, the LLVM Project includes other sub-projects that are in +development. Here we include updates on these subprojects.

        @@ -99,37 +110,30 @@

        The Clang project is an effort to build -a set of new 'LLVM native' front-end technologies for the LLVM optimizer and -code generator. While Clang is not included in the LLVM 2.5 release, it is -continuing to make major strides forward in all areas. Its C and Objective-C -parsing and code generation support is now very solid. For example, it is -capable of successfully building many real-world applications for X86-32 -and X86-64, -including the FreeBSD -kernel and gcc 4.2. C++ is also -making incredible progress, -and work on templates has recently started. If you are -interested in fast compiles and good diagnostics, we encourage you to try it out -by building from mainline -and reporting any issues you hit to the fast compiles and +good diagnostics, we +encourage you to try it out. Clang currently compiles typical Objective-C code +3x faster than GCC and compiles C code about 30% faster than GCC at -O0 -g +(which is when the most pressure is on the frontend).

        + +

        In addition to supporting these languages, C++ support is also well under way, and mainline +Clang is able to parse the libstdc++ 4.2 headers and even codegen simple apps. +If you are interested in Clang C++ support or any other Clang feature, we +strongly encourage you to get involved on the Clang front-end mailing list.

        -

        In the LLVM 2.5 time-frame, the Clang team has made many improvements:

        +

        In the LLVM 2.6 time-frame, the Clang team has made many improvements:

          -
        • Clang now has a new driver, which is focused on providing a GCC-compatible - interface.
        • -
        • The X86-64 ABI is now supported, including support for the Apple - 64-bit Objective-C runtime and zero cost exception handling.
        • -
        • Precompiled header support is now implemented.
        • -
        • Objective-C support is significantly improved beyond LLVM 2.4, supporting - many features, such as Objective-C Garbage Collection.
        • -
        • Variable length arrays are now fully supported.
        • -
        • C99 designated initializers are now fully supported.
        • -
        • Clang now includes all major compiler headers, including a - redesigned tgmath.h and several more intrinsic headers.
        • -
        • Many many bugs are fixed and many features have been added.
        • +
        • C and Objective-C support are now considered production quality.
        • +
        • AuroraUX, FreeBSD and OpenBSD are now supported.
        • +
        • Most of Objective-C 2.0 is now supported with the GNU runtime.
        • +
        • Many many bugs are fixed and lots of features have been added.
        @@ -140,19 +144,18 @@
        -

        Previously announced in the last LLVM release, the Clang project also +

        Previously announced in the 2.4 and 2.5 LLVM releases, the Clang project also includes an early stage static source code analysis tool for automatically finding bugs -in C and Objective-C programs. The tool performs a growing set of checks to find +in C and Objective-C programs. The tool performs checks to find bugs that occur on a specific path within a program.

        -

        In the LLVM 2.5 time-frame there have been many significant improvements to -the analyzer's core path simulation engine and machinery for generating -path-based bug reports to end-users. Particularly noteworthy improvements -include experimental support for full field-sensitivity and reasoning about heap -objects as well as an improved value-constraints subengine that does a much -better job of reasoning about inequality relationships (e.g., x > 2) -between variables and constants. +

        In the LLVM 2.6 time-frame, the analyzer core has undergone several important +improvements and cleanups and now includes a new Checker interface that +is intended to eventually serve as a basis for domain-specific checks. Further, +in addition to generating HTML files for reporting analysis results, the +analyzer can now also emit bug reports in a structured XML format that is +intended to be easily readable by other programs.

        The set of checks performed by the static analyzer continues to expand, and future plans for the tool include full source-level inter-procedural analysis @@ -170,44 +173,191 @@

        The VMKit project is an implementation of -a JVM and a CLI Virtual Machines (Microsoft .NET is an -implementation of the CLI) using the Just-In-Time compiler of LLVM.

        +a JVM and a CLI Virtual Machine (Microsoft .NET is an +implementation of the CLI) using LLVM for static and just-in-time +compilation.

        -

        Following LLVM 2.5, VMKit has its second release that you can find on its -webpage. The release includes +

        +VMKit version 0.26 builds with LLVM 2.6 and you can find it on its +web page. The release includes bug fixes, cleanup and new features. The major changes are:

          -
        • Ahead of Time compiler: compiles .class files to llvm .bc. VMKit uses this -functionality to native compile the standard classes (e.g. java.lang.String). -Users can compile AoT .class files into dynamic libraries and run them with the -help of VMKit.
        • - -
        • New exception model: the dwarf exception model is very slow for -exception-intensive applications, so the JVM has had a new implementation of -exceptions which check at each function call if an exception happened. There is -a low performance penalty on applications without exceptions, but it is a big -gain for exception-intensive applications. For example the jack benchmark in -Spec JVM98 is 6x faster (performance gain of 83%).
        • +
        • A new llcj tool to generate shared libraries or executables of Java + files.
        • +
        • Cooperative garbage collection.
        • +
        • Fast subtype checking (paper from Click et al [JGI'02]).
        • +
        • Implementation of a two-word header for Java objects instead of the original + three-word header.
        • +
        • Better Java specification-compliance: division by zero checks, stack + overflow checks, finalization and references support.
        • -
        • User-level management of thread stacks, so that thread local data access -at runtime is fast and portable.
        • +
        +
        -
      15. Implementation of biased locking for faster object synchronizations at -runtime.
      16. -
      17. New support for OSX/X64, Linux/X64 (with the Boehm GC) and Linux/ppc32.
      18. + + + +
        +

        +The new LLVM compiler-rt project +is a simple library that provides an implementation of the low-level +target-specific hooks required by code generation and other runtime components. +For example, when compiling for a 32-bit target, converting a double to a 64-bit +unsigned integer is compiled into a runtime call to the "__fixunsdfdi" +function. The compiler-rt library provides highly optimized implementations of +this and other low-level routines (some are 3x faster than the equivalent +libgcc routines).

        + +

        +All of the code in the compiler-rt project is available under the standard LLVM +License, a "BSD-style" license.

        + +
        + + + + +
        +

        +The new LLVM KLEE project is a symbolic +execution framework for programs in LLVM bitcode form. KLEE tries to +symbolically evaluate "all" paths through the application and records state +transitions that lead to fault states. This allows it to construct testcases +that lead to faults and can even be used to verify algorithms. For more +details, please see the OSDI 2008 paper about +KLEE.

        -
        + + + +
        +

        +The goal of DragonEgg is to make +gcc-4.5 act like llvm-gcc without requiring any gcc modifications whatsoever. +DragonEgg is a shared library (llvm.so) +that is loaded by gcc at runtime. It uses the new gcc plugin architecture to +disable the GCC optimizers and code generators, and schedule the LLVM optimizers +and code generators (or direct output of LLVM IR) instead. Currently only Linux +and Darwin are supported, and only on x86-32 and x86-64. It should be easy to +add additional unix-like architectures and other processor families. In theory +it should be possible to use DragonEgg +with any language supported by gcc, however only C and Fortran work well for the +moment. Ada and C++ work to some extent, while Java, Obj-C and Obj-C++ are so +far entirely untested. Since gcc-4.5 has not yet been released, neither has +DragonEgg. To build +DragonEgg you will need to check out the +development versions of gcc, +llvm and +DragonEgg from their respective +subversion repositories, and follow the instructions in the +DragonEgg README. +

        + +
        + + + + + +
        +

        +The LLVM Machine Code (MC) Toolkit project is a (very early) effort to build +better tools for dealing with machine code, object file formats, etc. The idea +is to be able to generate most of the target specific details of assemblers and +disassemblers from existing LLVM target .td files (with suitable enhancements), +and to build infrastructure for reading and writing common object file formats. +One of the first deliverables is to build a full assembler and integrate it into +the compiler, which is predicted to substantially reduce compile time in some +scenarios. +

        + +

        In the LLVM 2.6 timeframe, the MC framework has grown to the point where it +can reliably parse and pretty print (with some encoding information) a +darwin/x86 .s file successfully, and has the very early phases of a Mach-O +assembler in progress. Beyond the MC framework itself, major refactoring of the +LLVM code generator has started. The idea is to make the code generator reason +about the code it is producing in a much more semantic way, rather than a +textual way. For example, the code generator now uses MCSection objects to +represent section assignments, instead of text strings that print to .section +directives.

        + +

        MC is an early and ongoing project that will hopefully continue to lead to +many improvements in the code generator and build infrastructure useful for many +other situations. +

        + +
        + + +
        + +

        An exciting aspect of LLVM is that it is used as an enabling technology for + a lot of other language and tools projects. This section lists some of the + projects that have already been updated to work with LLVM 2.6.

        +
        + + + + + +
        +

        Rubinius is an environment +for running Ruby code which strives to write as much of the core class +implementation in Ruby as possible. Combined with a bytecode interpreting VM, it +uses LLVM to optimize and compile ruby code down to machine code. Techniques +such as type feedback, method inlining, and uncommon traps are all used to +remove dynamism from ruby execution and increase performance.

        + +

        Since LLVM 2.5, Rubinius has made several major leaps forward, implementing +a counter based JIT, type feedback and speculative method inlining. +

        + +
        + + + + +
        + +

        +MacRuby is an implementation of Ruby on top of +core Mac OS X technologies, such as the Objective-C common runtime and garbage +collector and the CoreFoundation framework. It is principally developed by +Apple and aims at enabling the creation of full-fledged Mac OS X applications. +

        + +

        +MacRuby uses LLVM for optimization passes, JIT and AOT compilation of Ruby +expressions. It also uses zero-cost DWARF exceptions to implement Ruby exception +handling.

        + +
        + +
        Pure @@ -224,12 +374,8 @@ an easy-to-use C interface. The interpreter uses LLVM as a backend to JIT-compile Pure programs to fast native code.

        -

        In addition to the usual algebraic data structures, Pure also has -MATLAB-style matrices in order to support numeric computations and signal -processing in an efficient way. Pure is mainly aimed at mathematical -applications right now, but it has been designed as a general purpose language. -The dynamic interpreter environment and the C interface make it possible to use -it as a kind of functional scripting language for many application areas. +

        Pure versions 0.31 and later have been tested and are known to work with +LLVM 2.6 (and continue to work with older LLVM releases >= 2.3 as well).

        @@ -243,11 +389,11 @@

        LDC is an implementation of the D Programming Language using the LLVM optimizer and code generator. -The LDC project works great with the LLVM 2.5 release. General improvements in +The LDC project works great with the LLVM 2.6 release. General improvements in this cycle have included new inline asm constraint handling, better debug info -support, general bugfixes, and better x86-64 support. This has allowed -some major improvements in LDC, getting us much closer to being as +support, general bug fixes and better x86-64 support. This has allowed +some major improvements in LDC, getting it much closer to being as fully featured as the original DMD compiler from DigitalMars.

        @@ -258,142 +404,160 @@
        -

        Roadsend PHP (rphp) is an open +

        +Roadsend PHP (rphp) is an open source implementation of the PHP programming -language that uses LLVM for its optimizer, JIT, and static compiler. This is a +language that uses LLVM for its optimizer, JIT and static compiler. This is a reimplementation of an earlier project that is now based on LLVM.

        - - -
        - What's New in LLVM 2.5? + + -
        - -

        This release includes a huge number of bug fixes, performance tweaks, and -minor improvements. Some of the major improvements and new features are listed -in this section. -

        +

        +Unladen Swallow is a +branch of Python intended to be fully +compatible and significantly faster. It uses LLVM's optimization passes and JIT +compiler.

        +

        +LLVM-Lua uses LLVM to add JIT +and static compiling support to the Lua VM. Lua bytecode is analyzed to +remove type checks, then LLVM is used to compile the bytecode down to machine +code.

        +
        -

        LLVM 2.5 includes several major new capabilities:

        + + -
          -
        • LLVM 2.5 includes a brand new XCore backend.
        • +
          +

          +IcedTea provides a +harness to build OpenJDK using only free software build tools and to provide +replacements for the not-yet free parts of OpenJDK. One of the extensions that +IcedTea provides is a new JIT compiler named Shark which uses LLVM +to provide native code generation without introducing processor-dependent +code. +

          +
          -
        • llvm-gcc now generally supports the GFortran front-end, and the precompiled -release binaries now support Fortran, even on Mac OS/X.
        • -
        • CMake is now used by the LLVM build process -on Windows. It automatically generates Visual Studio project files (and -more) from a set of simple text files. This makes it much easier to -maintain. In time, we'd like to standardize on CMake for everything.
        • -
        • LLVM 2.5 now uses (and includes) Google Test for unit testing.
        • + + + -
        • The LLVM native code generator now supports arbitrary precision integers. -Types like i33 have long been valid in the LLVM IR, but were previously -only supported by the interpreter. Note that the C backend still does not -support these.
        • +
          -
        • LLVM 2.5 no longer uses 'bison,' so it is easier to build on Windows.
        • -
        +

        This release includes a huge number of bug fixes, performance tweaks and +minor improvements. Some of the major improvements and new features are listed +in this section. +

        -
        -

        LLVM fully supports the llvm-gcc 4.2 front-end, which marries the GCC -front-ends and driver with the LLVM optimizer and code generator. It currently -includes support for the C, C++, Objective-C, Ada, and Fortran front-ends.

        +

        LLVM 2.6 includes several major new capabilities:

          -
        • In this release, the GCC inliner is completely disabled. Previously the GCC -inliner was used to handle always-inline functions and other cases. This caused -problems with code size growth, and it is completely disabled in this -release.
        • - -
        • llvm-gcc (and LLVM in general) now support code generation for stack -canaries, which is an effective form of buffer overflow -protection. llvm-gcc supports this with the -fstack-protector -command line option (just like GCC). In LLVM IR, you can request code -generation for stack canaries with function attributes. -
        • +
        • New compiler-rt, KLEE + and machine code toolkit sub-projects.
        • +
        • Debug information now includes line numbers when optimizations are enabled. + This allows statistical sampling tools like OProfile and Shark to map + samples back to source lines.
        • +
        • LLVM now includes new experimental backends to support the MSP430, SystemZ + and BlackFin architectures.
        • +
        • LLVM supports a new Gold Linker Plugin which + enables support for transparent + link-time optimization on ELF targets when used with the Gold binutils + linker.
        • +
        • LLVM now supports doing optimization and code generation on multiple + threads. Please see the LLVM + Programmer's Manual for more information.
        • +
        • LLVM now has experimental support for embedded + metadata in LLVM IR, though the implementation is not guaranteed to be + final and the .bc file format may change in future releases. Debug info + does not yet use this format in LLVM 2.6.
        -
        -

        LLVM IR has several new features that are used by our existing front-ends and -can be useful if you are writing a front-end for LLVM:

        +

        LLVM IR has several new features for better support of new targets and that +expose new optimization opportunities:

          -
        • The shufflevector instruction -has been generalized to allow different shuffle mask width than its input -vectors. This allows you to use shufflevector to combine two -"<4 x float>" vectors into a "<8 x float>" for example.
        • - -
        • LLVM IR now supports new intrinsics for computing and acting on overflow of integer operations. This allows -efficient code generation for languages that must trap or throw an exception on -overflow. While these intrinsics work on all targets, they only generate -efficient code on X86 so far.
        • - -
        • LLVM IR now supports a new private -linkage type to produce labels that are stripped by the assembler before it -produces a .o file (thus they are invisible to the linker).
        • - -
        • LLVM IR supports two new attributes for better alias analysis. The noalias attribute can now be used on the -return value of a function to indicate that it returns new memory (e.g. -'malloc', 'calloc', etc). -The new nocapture attribute can be used -on pointer arguments to indicate that the function does not return the pointer, -store it in an object that outlives the call, or let the value of the pointer -escape from the function in any other way. -Note that it is the pointer itself that must not escape, not the value it -points to: loading a value out of the pointer is perfectly fine. -Many standard library functions (e.g. 'strlen', 'memcpy') have this property. - -
        • - -
        • The parser for ".ll" files in lib/AsmParser is now completely rewritten as a -recursive descent parser. This parser produces better error messages (including -caret diagnostics), is less fragile (less likely to crash on strange things), -does not leak memory, is more efficient, and eliminates LLVM's last use of the -'bison' tool.
        • - -
        • Debug information representation and manipulation internals have been - consolidated to use a new set of classes in - llvm/Analysis/DebugInfo.h. These routines are more - efficient, robust, and extensible and replace the older mechanisms. - llvm-gcc, clang, and the code generator now use them to create and process - debug information.
        • - +
        • The add, sub and mul + instructions have been split into integer and floating point versions (like + divide and remainder), introducing new fadd, fsub, + and fmul instructions.
        • +
        • The add, sub and mul + instructions now support optional "nsw" and "nuw" bits which indicate that + the operation is guaranteed to not overflow (in the signed or + unsigned case, respectively). This gives the optimizer more information and + can be used for things like C signed integer values, which are undefined on + overflow.
        • +
        • The sdiv instruction now supports an + optional "exact" flag which indicates that the result of the division is + guaranteed to have a remainder of zero. This is useful for optimizing pointer + subtraction in C.
        • +
        • The getelementptr instruction now + supports arbitrary integer index values for array/pointer indices. This + allows for better code generation on 16-bit pointer targets like PIC16.
        • +
        • The getelementptr instruction now + supports an "inbounds" optimization hint that tells the optimizer that the + pointer is guaranteed to be within its allocated object.
        • +
        • LLVM now support a series of new linkage types for global values which allow + for better optimization and new capabilities: +
            +
          • linkonce_odr and + weak_odr have the same linkage + semantics as the non-"odr" linkage types. The difference is that these + linkage types indicate that all definitions of the specified function + are guaranteed to have the same semantics. This allows inlining + templates functions in C++ but not inlining weak functions in C, + which previously both got the same linkage type.
          • +
          • available_externally + is a new linkage type that gives the optimizer visibility into the + definition of a function (allowing inlining and side effect analysis) + but that does not cause code to be generated. This allows better + optimization of "GNU inline" functions, extern templates, etc.
          • +
          • linker_private is a + new linkage type (which is only useful on Mac OS X) that is used for + some metadata generation and other obscure things.
          • +
        • +
        • Finally, target-specific intrinsics can now return multiple values, which + is useful for modeling target operations with multiple results.
        @@ -405,27 +569,53 @@
        -

        In addition to a large array of bug fixes and minor performance tweaks, this +

        In addition to a large array of minor performance tweaks and bug fixes, this release includes a few major enhancements and additions to the optimizers:

          -
        • The loop optimizer now improves floating point induction variables in -several ways, including adding shadow induction variables to avoid -"integer <-> floating point" conversions in loops when safe.
        • +
        • The Scalar Replacement of Aggregates + pass has many improvements that allow it to better promote vector unions, + variables which are memset, and much more strange code that can happen to + do bitfield accesses to register operations. An interesting change is that + it now produces "unusual" integer sizes (like i1704) in some cases and lets + other optimizers clean things up.
        • +
        • The Loop Strength Reduction pass now + promotes small integer induction variables to 64-bit on 64-bit targets, + which provides a major performance boost for much numerical code. It also + promotes shorts to int on 32-bit hosts, etc. LSR now also analyzes pointer + expressions (e.g. getelementptrs), as well as integers.
        • +
        • The GVN pass now eliminates partial + redundancies of loads in simple cases.
        • +
        • The Inliner now reuses stack space when + inlining similar arrays from multiple callees into one caller.
        • +
        • LLVM includes a new experimental Static Single Information (SSI) + construction pass.
        • + +
        -
      19. The "-mem2reg" pass is now much faster on code with large basic blocks.
      20. +
        -
      21. The "-jump-threading" pass is more powerful: it is iterative - and handles threading based on values with fully and partially redundant - loads.
      22. -
      23. The "-memdep" memory dependence analysis pass (used by GVN and memcpyopt) is - both faster and more aggressive.
      24. + + -
      25. The "-scalarrepl" scalar replacement of aggregates pass is more aggressive - about promoting unions to registers.
      26. +
        +
          +
        • LLVM has a new "EngineBuilder" class which makes it more obvious how to + set up and configure an ExecutionEngine (a JIT or interpreter).
        • +
        • The JIT now supports generating more than 16M of code.
        • +
        • When configured with --with-oprofile, the JIT can now inform + OProfile about JIT'd code, allowing OProfile to get line number and function + name information for JIT'd functions.
        • +
        • When "libffi" is available, the LLVM interpreter now uses it, which supports + calling almost arbitrary external (natively compiled) functions.
        • +
        • Clients of the JIT can now register a 'JITEventListener' object to receive + callbacks when the JIT emits or frees machine code. The OProfile support + uses this mechanism.
        @@ -442,33 +632,55 @@ it run faster:

          -
        • The Writing an LLVM Compiler -Backend document has been greatly expanded and is substantially more -complete.
        • - -
        • The SelectionDAG type legalization logic has been completely rewritten, is -now more powerful (it supports arbitrary precision integer types for example), -and is more correct in several corner cases. The type legalizer converts -operations on types that are not natively supported by the target machine into -equivalent code sequences that only use natively supported types. The old type -legalizer is still available (for now) and will be used if --disable-legalize-types is passed to the code generator. -
        • -
        • The code generator now supports widening illegal vectors to larger legal -ones (for example, converting operations on <3 x float> to work on -<4 x float>) which is very important for common graphics -applications.
        • - -
        • The assembly printers for each target are now split out into their own -libraries that are separate from the main code generation logic. This reduces -the code size of JIT compilers by not requiring them to be linked in.
        • - -
        • The 'fast' instruction selection path (used at -O0 and for fast JIT - compilers) now supports accelerating codegen for code that uses exception - handling constructs.
        • - -
        • The optional PBQP register allocator now supports register coalescing.
        • +
        • The llc -asm-verbose option (exposed from llvm-gcc as -dA + and clang as -fverbose-asm or -dA) now adds a lot of + useful information in comments to + the generated .s file. This information includes location information (if + built with -g) and loop nest information.
        • +
        • The code generator now supports a new MachineVerifier pass which is useful + for finding bugs in targets and codegen passes.
        • +
        • The Machine LICM is now enabled by default. It hoists instructions out of + loops (such as constant pool loads, loads from read-only stubs, vector + constant synthesization code, etc.) and is currently configured to only do + so when the hoisted operation can be rematerialized.
        • +
        • The Machine Sinking pass is now enabled by default. This pass moves + side-effect free operations down the CFG so that they are executed on fewer + paths through a function.
        • +
        • The code generator now performs "stack slot coloring" of register spills, + which allows spill slots to be reused. This leads to smaller stack frames + in cases where there are lots of register spills.
        • +
        • The register allocator has many improvements to take better advantage of + commutable operations, various spiller peephole optimizations, and can now + coalesce cross-register-class copies.
        • +
        • Tblgen now supports multiclass inheritance and a number of new string and + list operations like !(subst), !(foreach), !car, + !cdr, !null, !if, !cast. + These make the .td files more expressive and allow more aggressive factoring + of duplication across instruction patterns.
        • +
        • Target-specific intrinsics can now be added without having to hack VMCore to + add them. This makes it easier to maintain out-of-tree targets.
        • +
        • The instruction selector is better at propagating information about values + (such as whether they are sign/zero extended etc.) across basic block + boundaries.
        • +
        • The SelectionDAG datastructure has new nodes for representing buildvector + and vector shuffle operations. This + makes operations and pattern matching more efficient and easier to get + right.
        • +
        • The Prolog/Epilog Insertion Pass now has experimental support for performing + the "shrink wrapping" optimization, which moves spills and reloads around in + the CFG to avoid doing saves on paths that don't need them.
        • +
        • LLVM includes new experimental support for writing ELF .o files directly + from the compiler. It works well for many simple C testcases, but doesn't + support exception handling, debug info, inline assembly, etc.
        • +
        • Targets can now specify register allocation hints through + MachineRegisterInfo::setRegAllocationHint. A regalloc hint consists + of hint type and physical register number. A hint type of zero specifies a + register allocation preference. Other hint type values are target specific + which are resolved by TargetRegisterInfo::ResolveRegAllocHint. An + example is the ARM target which uses register hints to request that the + register allocator provide an even / odd register pair to two virtual + registers.
        @@ -482,37 +694,33 @@

          -
        • The llvm.returnaddress -intrinsic (which is used to implement __builtin_return_address) now -supports non-zero stack depths on X86.
        • - -
        • The X86 backend now supports code generation of vector shift operations -using SSE instructions.
        • - -
        • X86-64 code generation now takes advantage of red zone, unless the --mno-red-zone option is specified.
        • - -
        • The X86 backend now supports using address space #256 in LLVM IR as a way of -performing memory references off the GS segment register. This allows a -front-end to take advantage of very low-level programming techniques when -targeting X86 CPUs. See test/CodeGen/X86/movgs.ll for a simple -example.
        • - -
        • The X86 backend now supports a -disable-mmx command line option to - prevent use of MMX even on chips that support it. This is important for cases - where code does not contain the proper llvm.x86.mmx.emms - intrinsics.
        • - -
        • The X86 JIT now detects the new Intel Core i7 and Atom chips and - auto-configures itself appropriately for the features of these chips.
        • - -
        • The JIT now supports exception handling constructs on Linux/X86-64 and - Darwin/x86-64.
        • -
        • The JIT supports Thread Local Storage (TLS) on Linux/X86-32 but not yet on - X86-64.
        • +
        • SSE 4.2 builtins are now supported.
        • +
        • GCC-compatible soft float modes are now supported, which are typically used + by OS kernels.
        • +
        • X86-64 now models implicit zero extensions better, which allows the code + generator to remove a lot of redundant zexts. It also models the 8-bit "H" + registers as subregs, which allows them to be used in some tricky + situations.
        • +
        • X86-64 now supports the "local exec" and "initial exec" thread local storage + model.
        • +
        • The vector forms of the icmp and fcmp instructions now select to efficient + SSE operations.
        • +
        • Support for the win64 calling conventions have improved. The primary + missing feature is support for varargs function definitions. It seems to + work well for many win64 JIT purposes.
        • +
        • The X86 backend has preliminary support for mapping address spaces to segment + register references. This allows you to write GS or FS relative memory + accesses directly in LLVM IR for cases where you know exactly what you're + doing (such as in an OS kernel). There are some known problems with this + support, but it works in simple cases.
        • +
        • The X86 code generator has been refactored to move all global variable + reference logic to one place + (X86Subtarget::ClassifyGlobalReference) which + makes it easier to reason about.
        • +
        @@ -527,70 +735,156 @@

          -
        • Both direct and indirect load/stores work now.
        • -
        • Logical, bitwise and conditional operations now work for integer data -types.
        • -
        • Function calls involving basic types work now.
        • -
        • Support for integer arrays.
        • -
        • The compiler can now emit libcalls for operations not supported by m/c -instructions.
        • -
        • Support for both data and ROM address spaces.
        • +
        • Support for floating-point, indirect function calls, and + passing/returning aggregate types to functions. +
        • The code generator is able to generate debug info into output COFF files. +
        • Support for placing an object into a specific section or at a specific + address in memory.

        Things not yet supported:

          -
        • Floating point.
        • -
        • Passing/returning aggregate types to and from functions.
        • Variable arguments.
        • -
        • Indirect function calls.
        • Interrupts/programs.
        • -
        • Debug info.
        + + + +
        +

        New features of the ARM target include: +

        + +
          + +
        • Preliminary support for processors, such as the Cortex-A8 and Cortex-A9, +that implement version v7-A of the ARM architecture. The ARM backend now +supports both the Thumb2 and Advanced SIMD (Neon) instruction sets.
        • + +
        • The AAPCS-VFP "hard float" calling conventions are also supported with the +-float-abi=hard flag.
        • + +
        • The ARM calling convention code is now tblgen generated instead of resorting + to C++ code.
        • +
        + +

        These features are still somewhat experimental +and subject to change. The Neon intrinsics, in particular, may change in future +releases of LLVM. ARMv7 support has progressed a lot on top of tree since 2.6 +branched.

        + + +
        -

        New features include:

        +

        New features of other targets include: +

          -
        • Beginning with LLVM 2.5, llvmc2 is known as - just llvmc. The old llvmc driver was removed.
        • +
        • Mips now supports O32 Calling Convention.
        • +
        • Many improvements to the 32-bit PowerPC SVR4 ABI (used on powerpc-linux) + support, lots of bugs fixed.
        • +
        • Added support for the 64-bit PowerPC SVR4 ABI (used on powerpc64-linux). + Needs more testing.
        • +
        + +
        + + + -
      27. The Clang plugin was substantially improved and is now enabled - by default. The command llvmc --clang can be now used as a - synonym to ccc.
      28. +
        -
      29. There is now a --check-graph option, which is supposed to catch - common errors like multiple default edges, mismatched output/input language - names and cycles. In general, these checks can't be done at compile-time - because of the need to support plugins.
      30. +

        This release includes a number of new APIs that are used internally, which + may also be useful for external clients. +

        -
      31. Plugins are now more flexible and can refer to compilation graph nodes and - options defined in other plugins. To manage dependencies, a priority-sorting - mechanism was introduced. This change affects the TableGen file syntax. See the - documentation for details.
      32. +
          +
        • New + PrettyStackTrace class allows crashes of llvm tools (and applications + that integrate them) to provide more detailed indication of what the + compiler was doing at the time of the crash (e.g. running a pass). + At the top level for each LLVM tool, it includes the command line arguments. +
        • +
        • New StringRef + and Twine classes + make operations on character ranges and + string concatenation to be more efficient. StringRef is just a const + char* with a length, Twine is a light-weight rope.
        • +
        • LLVM has new WeakVH, AssertingVH and CallbackVH + classes, which make it easier to write LLVM IR transformations. WeakVH + is automatically drops to null when the referenced Value is deleted, + and is updated across a replaceAllUsesWith operation. + AssertingVH aborts the program if the + referenced value is destroyed while it is being referenced. CallbackVH + is a customizable class for handling value references. See ValueHandle.h + for more information.
        • +
        • The new 'Triple + ' class centralizes a lot of logic that reasons about target + triples.
        • +
        • The new ' + llvm_report_error()' set of APIs allows tools to embed the LLVM + optimizer and backend and recover from previously unrecoverable errors.
        • +
        • LLVM has new abstractions for atomic operations + and reader/writer + locks.
        • +
        • LLVM has new + SourceMgr and SMLoc classes which implement caret + diagnostics and basic include stack processing for simple parsers. It is + used by tablegen, llvm-mc, the .ll parser and FileCheck.
        • +
        -
      33. Hooks can now be provided with arguments. The syntax is "$CALL(MyHook, - 'Arg1', 'Arg2', 'Arg3')".
      34. -
      35. A new option type: multi-valued option, for options that take more than one - argument (for example, "-foo a b c").
      36. +
        -
      37. New option properties: 'one_or_more', 'zero_or_more', -'hidden' and 'really_hidden'.
      38. + + -
      39. The 'case' expression gained an 'error' action and - an 'empty' test (equivalent to "(not (not_empty ...))").
      40. +
        +

        Other miscellaneous features include:

        -
      41. Documentation now looks more consistent to the rest of the LLVM - docs. There is also a man page now.
      42. +
          +
        • LLVM now includes a new internal 'FileCheck' tool which allows + writing much more accurate regression tests that run faster. Please see the + FileCheck section of the Testing + Guide for more information.
        • +
        • LLVM profile information support has been significantly improved to produce +correct use counts, and has support for edge profiling with reduced runtime +overhead. Combined, the generated profile information is both more correct and +imposes about half as much overhead (2.6. from 12% to 6% overhead on SPEC +CPU2000).
        • +
        • The C bindings (in the llvm/include/llvm-c directory) include many newly + supported APIs.
        • +
        • LLVM 2.6 includes a brand new experimental LLVM bindings to the Ada2005 + programming language.
        • + +
        • The LLVMC driver has several new features: +
            +
          • Dynamic plugins now work on Windows.
          • +
          • New option property: init. Makes possible to provide default values for + options defined in plugins (interface to cl::init).
          • +
          • New example: Skeleton, shows how to create a standalone LLVMC-based + driver.
          • +
          • New example: mcc16, a driver for the PIC16 toolchain.
          • +
          +
        @@ -605,13 +899,24 @@

        If you're already an LLVM user or developer with out-of-tree changes based -on LLVM 2.4, this section lists some "gotchas" that you may run into upgrading +on LLVM 2.5, this section lists some "gotchas" that you may run into upgrading from the previous release.

          - -
        • llvm-gcc defaults to -fno-math-errno on all X86 targets.
        • - +
        • The Itanium (IA64) backend has been removed. It was not actively supported + and had bitrotted.
        • +
        • The BigBlock register allocator has been removed, it had also bitrotted.
        • +
        • The C Backend (-march=c) is no longer considered part of the LLVM release +criteria. We still want it to work, but no one is maintaining it and it lacks +support for arbitrary precision integers and other important IR features.
        • + +
        • All LLVM tools now default to overwriting their output file, behaving more + like standard unix tools. Previously, this only happened with the '-f' + option.
        • +
        • LLVM build now builds all libraries as .a files instead of some + libraries as relinked .o files. This requires some APIs like + InitializeAllTargets.h. +
        @@ -619,8 +924,82 @@ API changes are:

          -
        • Some deprecated interfaces to create Instruction subclasses, that - were spelled with lower case "create," have been removed.
        • +
        • All uses of hash_set and hash_map have been removed from + the LLVM tree and the wrapper headers have been removed.
        • +
        • The llvm/Streams.h and DOUT member of Debug.h have been removed. The + llvm::Ostream class has been completely removed and replaced with + uses of raw_ostream.
        • +
        • LLVM's global uniquing tables for Types and Constants have + been privatized into members of an LLVMContext. A number of APIs + now take an LLVMContext as a parameter. To smooth the transition + for clients that will only ever use a single context, the new + getGlobalContext() API can be used to access a default global + context which can be passed in any and all cases where a context is + required. +
        • The getABITypeSize methods are now called getAllocSize.
        • +
        • The Add, Sub and Mul operators are no longer + overloaded for floating-point types. Floating-point addition, subtraction + and multiplication are now represented with new operators FAdd, + FSub and FMul. In the IRBuilder API, + CreateAdd, CreateSub, CreateMul and + CreateNeg should only be used for integer arithmetic now; + CreateFAdd, CreateFSub, CreateFMul and + CreateFNeg should now be used for floating-point arithmetic.
        • +
        • The DynamicLibrary class can no longer be constructed, its functionality has + moved to static member functions.
        • +
        • raw_fd_ostream's constructor for opening a given filename now + takes an extra Force argument. If Force is set to + false, an error will be reported if a file with the given name + already exists. If Force is set to true, the file will + be silently truncated (which is the behavior before this flag was + added).
        • +
        • SCEVHandle no longer exists, because reference counting is no + longer done for SCEV* objects, instead const SCEV* + should be used.
        • + +
        • Many APIs, notably llvm::Value, now use the StringRef +and Twine classes instead of passing const char* +or std::string, as described in +the Programmer's Manual. Most +clients should be unaffected by this transition, unless they are used to +Value::getName() returning a string. Here are some tips on updating to +2.6: +
            +
          • getNameStr() is still available, and matches the old + behavior. Replacing getName() calls with this is an safe option, + although more efficient alternatives are now possible.
          • + +
          • If you were just relying on getName() being able to be sent to + a std::ostream, consider migrating + to llvm::raw_ostream.
          • + +
          • If you were using getName().c_str() to get a const + char* pointer to the name, you can use getName().data(). + Note that this string (as before), may not be the entire name if the + name contains embedded null characters.
          • + +
          • If you were using operator + on the result of getName() and + treating the result as an std::string, you can either + use Twine::str to get the result as an std::string, or + could move to a Twine based design.
          • + +
          • isName() should be replaced with comparison + against getName() (this is now efficient). +
          +
        • + +
        • The registration interfaces for backend Targets has changed (what was +previously TargetMachineRegistry). For backend authors, see the Writing An LLVM Backend +guide. For clients, the notable API changes are: +
            +
          • TargetMachineRegistry has been renamed + to TargetRegistry.
          • + +
          • Clients should move to using the TargetRegistry::lookupTarget() + function to find targets.
          • +
          +
        @@ -639,15 +1018,15 @@
        • Intel and AMD machines (IA32, X86-64, AMD64, EMT-64) running Red Hat -Linux, Fedora Core and FreeBSD (and probably other unix-like systems).
        • + Linux, Fedora Core, FreeBSD and AuroraUX (and probably other unix-like + systems).
        • PowerPC and X86-based Mac OS X systems, running 10.3 and above in 32-bit -and 64-bit modes.
        • + and 64-bit modes.
        • Intel and AMD machines running on Win32 using MinGW libraries (native).
        • Intel and AMD machines running on Win32 with the Cygwin libraries (limited support is available for native builds with Visual C++).
        • Sun UltraSPARC workstations running Solaris 10.
        • Alpha-based machines running Debian GNU/Linux.
        • -
        • Itanium-based (IA64) machines running Linux and HP-UX.

        The core LLVM infrastructure uses GNU autoconf to adapt itself @@ -670,6 +1049,21 @@ href="http://llvm.org/bugs/">LLVM bug database and submit a bug if there isn't already one.

        +
          +
        • The llvm-gcc bootstrap will fail with some versions of binutils (e.g. 2.15) + with a message of "Error: can not do 8 + byte pc-relative relocation" when building C++ code. We intend to + fix this on mainline, but a workaround for 2.6 is to upgrade to binutils + 2.17 or later.
        • + +
        • LLVM will not correctly compile on Solaris and/or OpenSolaris +using the stock GCC 3.x.x series 'out the box', +See: Broken versions of GCC and other tools. +However, A Modern GCC Build +for x86/x86-64 has been made available from the third party AuroraUX Project +that has been meticulously tested for bootstrapping LLVM & Clang.
        • +
        +
        @@ -687,9 +1081,11 @@ href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">LLVMdev list.

          -
        • The MSIL, IA64, Alpha, SPU, MIPS, and PIC16 backends are experimental.
        • +
        • The MSIL, Alpha, SPU, MIPS, PIC16, Blackfin, MSP430 and SystemZ backends are + experimental.
        • The llc "-filetype=asm" (the default) is the only - supported value for this option.
        • + supported value for this option. The ELF writer is experimental. +
        • The implementation of Andersen's Alias Analysis has many known bugs.
        @@ -744,14 +1140,14 @@
          +
        • Support for the Advanced SIMD (Neon) instruction set is still incomplete +and not well tested. Some features may not work at all, and the code quality +may be poor in some cases.
        • Thumb mode works only on ARMv6 or higher processors. On sub-ARMv6 processors, thumb programs can crash or produce wrong results (PR1388).
        • Compilation for ARM Linux OABI (old ABI) is supported but not fully tested.
        • -
        • There is a bug in QEMU-ARM (<= 0.9.0) which causes it to incorrectly - execute -programs compiled with LLVM. Please use more recent versions of QEMU.
        @@ -778,7 +1174,6 @@
          -
        • The O32 ABI is not fully supported.
        • 64-bit MIPS targets are not supported yet.
        @@ -801,21 +1196,6 @@ - -
        - -
          -
        • The Itanium backend is highly experimental and has a number of known - issues. We are looking for a maintainer for the Itanium backend. If you - are interested, please contact the LLVMdev mailing list.
        • -
        - -
        - - - @@ -841,10 +1221,6 @@
        -

        llvm-gcc does not currently support Link-Time -Optimization on most platforms "out-of-the-box". Please inquire on the -LLVMdev mailing list if you are interested.

        -

        The only major language feature of GCC not supported by llvm-gcc is the __builtin_apply family of builtins. However, some extensions are only supported on some targets. For example, trampolines are only @@ -882,7 +1258,8 @@

        • Fortran support generally works, but there are still several unresolved bugs - in Bugzilla. Please see the tools/gfortran component for details.
        • + in Bugzilla. Please see the + tools/gfortran component for details.
        @@ -902,16 +1279,16 @@
      43. The Ada front-end fails to bootstrap. This is due to lack of LLVM support for setjmp/longjmp style exception handling, which is used internally by the compiler. -Workaround: configure with --disable-bootstrap.
      44. +Workaround: configure with --disable-bootstrap.
      45. The c380004, c393010 and cxg2021 ACATS tests fail (c380004 also fails with gcc-4.2 mainline). If the compiler is built with checks disabled then c393010 causes the compiler to go into an infinite loop, using up all system memory.
      46. Some GCC specific Ada tests continue to crash the compiler.
      47. -
      48. The -E binder option (exception backtraces) +
      49. The -E binder option (exception backtraces) does not work and will result in programs -crashing if an exception is raised. Workaround: do not use -E.
      50. +crashing if an exception is raised. Workaround: do not use -E.
      51. Only discrete types are allowed to start or finish at a non-byte offset in a record. Workaround: do not pack records or use representation clauses that result in a field of a non-discrete type @@ -925,6 +1302,20 @@
      52. + + + +
        + +

        The Llvm.Linkage module is broken, and has incorrect values. Only +Llvm.Linkage.External, Llvm.Linkage.Available_externally, and +Llvm.Linkage.Link_once will be correct. If you need any of the other linkage +modes, you'll have to write an external C library in order to expose the +functionality. This has been fixed in the trunk.

        +
        +
        Additional Information From gohman at apple.com Tue Oct 13 12:50:43 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 13 Oct 2009 17:50:43 -0000 Subject: [llvm-commits] [llvm] r83992 - /llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Message-ID: <200910131750.n9DHohoW012671@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 12:50:43 2009 New Revision: 83992 URL: http://llvm.org/viewvc/llvm-project?rev=83992&view=rev Log: Make LoopUnswitch's cost estimation count Instructions, rather than BasicBlocks, so that it doesn't blindly procede in the presence of large individual BasicBlocks. This addresses a class of code-size expansion problems. Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=83992&r1=83991&r2=83992&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 12:50:43 2009 @@ -56,9 +56,11 @@ STATISTIC(NumTrivial , "Number of unswitches that are trivial"); STATISTIC(NumSimplify, "Number of simplifications of unswitched code"); +// The specific value of 50 here was chosen based only on intuition and a +// few specific examples. static cl::opt Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), - cl::init(10), cl::Hidden); + cl::init(50), cl::Hidden); namespace { class LoopUnswitch : public LoopPass { @@ -406,27 +408,13 @@ if (IsTrivialUnswitchCondition(LIC)) return 0; - // FIXME: This is really overly conservative. However, more liberal - // estimations have thus far resulted in excessive unswitching, which is bad - // both in compile time and in code size. This should be replaced once - // someone figures out how a good estimation. - return currentLoop->getBlocks().size(); - + // FIXME: This is really overly conservative and brain dead. unsigned Cost = 0; - // FIXME: this is brain dead. It should take into consideration code - // shrinkage. for (Loop::block_iterator I = currentLoop->block_begin(), E = currentLoop->block_end(); - I != E; ++I) { - BasicBlock *BB = *I; - // Do not include empty blocks in the cost calculation. This happen due to - // loop canonicalization and will be removed. - if (BB->begin() == BasicBlock::iterator(BB->getTerminator())) - continue; - - // Count basic blocks. - ++Cost; - } + I != E; ++I) + // Count instructions. + Cost += (*I)->size(); return Cost; } From clattner at apple.com Tue Oct 13 12:53:27 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 13 Oct 2009 10:53:27 -0700 Subject: [llvm-commits] [llvm] r83992 - /llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp In-Reply-To: <200910131750.n9DHohoW012671@zion.cs.uiuc.edu> References: <200910131750.n9DHohoW012671@zion.cs.uiuc.edu> Message-ID: On Oct 13, 2009, at 10:50 AM, Dan Gohman wrote: > Author: djg > Date: Tue Oct 13 12:50:43 2009 > New Revision: 83992 > > URL: http://llvm.org/viewvc/llvm-project?rev=83992&view=rev > Log: > Make LoopUnswitch's cost estimation count Instructions, rather than > BasicBlocks, so that it doesn't blindly procede in the presence of > large individual BasicBlocks. This addresses a class of code-size > expansion problems. This should use the heuristic the inliner etc has. In particular it is important that presence of debug intrinsics not affect the cost. -Chris > > Modified: > llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=83992&r1=83991&r2=83992&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 > 12:50:43 2009 > @@ -56,9 +56,11 @@ > STATISTIC(NumTrivial , "Number of unswitches that are trivial"); > STATISTIC(NumSimplify, "Number of simplifications of unswitched > code"); > > +// The specific value of 50 here was chosen based only on intuition > and a > +// few specific examples. > static cl::opt > Threshold("loop-unswitch-threshold", cl::desc("Max loop size to > unswitch"), > - cl::init(10), cl::Hidden); > + cl::init(50), cl::Hidden); > > namespace { > class LoopUnswitch : public LoopPass { > @@ -406,27 +408,13 @@ > if (IsTrivialUnswitchCondition(LIC)) > return 0; > > - // FIXME: This is really overly conservative. However, more > liberal > - // estimations have thus far resulted in excessive unswitching, > which is bad > - // both in compile time and in code size. This should be > replaced once > - // someone figures out how a good estimation. > - return currentLoop->getBlocks().size(); > - > + // FIXME: This is really overly conservative and brain dead. > unsigned Cost = 0; > - // FIXME: this is brain dead. It should take into consideration > code > - // shrinkage. > for (Loop::block_iterator I = currentLoop->block_begin(), > E = currentLoop->block_end(); > - I != E; ++I) { > - BasicBlock *BB = *I; > - // Do not include empty blocks in the cost calculation. This > happen due to > - // loop canonicalization and will be removed. > - if (BB->begin() == BasicBlock::iterator(BB->getTerminator())) > - continue; > - > - // Count basic blocks. > - ++Cost; > - } > + I != E; ++I) > + // Count instructions. > + Cost += (*I)->size(); > > return Cost; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Tue Oct 13 13:08:22 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 13 Oct 2009 18:08:22 -0000 Subject: [llvm-commits] [llvm] r83994 - in /llvm/trunk/test/Transforms/SimplifyCFG: InvokeEliminate.ll invoke_unwind.ll Message-ID: <200910131808.n9DI8MQq013486@zion.cs.uiuc.edu> Author: lattner Date: Tue Oct 13 13:08:21 2009 New Revision: 83994 URL: http://llvm.org/viewvc/llvm-project?rev=83994&view=rev Log: rename test Added: llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll - copied unchanged from r83936, llvm/trunk/test/Transforms/SimplifyCFG/InvokeEliminate.ll Removed: llvm/trunk/test/Transforms/SimplifyCFG/InvokeEliminate.ll Removed: llvm/trunk/test/Transforms/SimplifyCFG/InvokeEliminate.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/InvokeEliminate.ll?rev=83993&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/InvokeEliminate.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/InvokeEliminate.ll (removed) @@ -1,18 +0,0 @@ -; This testcase checks to see if the simplifycfg pass is converting invoke -; instructions to call instructions if the handler just rethrows the exception. - -; If this test is successful, the function should be reduced to 'call; ret' - -; RUN: opt < %s -simplifycfg -S | \ -; RUN: not egrep {\\(invoke\\)|\\(br\\)} - -declare void @bar() - -define i32 @test() { - invoke void @bar( ) - to label %Ok unwind label %Rethrow -Ok: ; preds = %0 - ret i32 0 -Rethrow: ; preds = %0 - unwind -} From sabre at nondot.org Tue Oct 13 13:10:06 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 13 Oct 2009 18:10:06 -0000 Subject: [llvm-commits] [llvm] r83995 - /llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll Message-ID: <200910131810.n9DIA6TU013598@zion.cs.uiuc.edu> Author: lattner Date: Tue Oct 13 13:10:05 2009 New Revision: 83995 URL: http://llvm.org/viewvc/llvm-project?rev=83995&view=rev Log: convert to filecheck Modified: llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll Modified: llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll?rev=83995&r1=83994&r2=83995&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll Tue Oct 13 13:10:05 2009 @@ -1,14 +1,14 @@ ; This testcase checks to see if the simplifycfg pass is converting invoke ; instructions to call instructions if the handler just rethrows the exception. -; If this test is successful, the function should be reduced to 'call; ret' - -; RUN: opt < %s -simplifycfg -S | \ -; RUN: not egrep {\\(invoke\\)|\\(br\\)} +; RUN: opt < %s -simplifycfg -S | FileCheck %s declare void @bar() -define i32 @test() { +define i32 @test1() { +; CHECK: @test1 +; CHECK-NEXT: call void @bar() +; CHECK-NEXT: ret i32 0 invoke void @bar( ) to label %Ok unwind label %Rethrow Ok: ; preds = %0 From sabre at nondot.org Tue Oct 13 13:13:06 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 13 Oct 2009 18:13:06 -0000 Subject: [llvm-commits] [llvm] r83996 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/invoke_unwind.ll Message-ID: <200910131813.n9DID6Cb013722@zion.cs.uiuc.edu> Author: lattner Date: Tue Oct 13 13:13:05 2009 New Revision: 83996 URL: http://llvm.org/viewvc/llvm-project?rev=83996&view=rev Log: change simplifycfg to not duplicate 'unwind' instructions. Hopefully this will increase the likelihood of common code getting sunk towards the unwind. Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=83996&r1=83995&r2=83996&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Tue Oct 13 13:13:05 2009 @@ -1860,33 +1860,26 @@ } else if (isa(BB->begin())) { // Check to see if the first instruction in this block is just an unwind. // If so, replace any invoke instructions which use this as an exception - // destination with call instructions, and any unconditional branch - // predecessor with an unwind. + // destination with call instructions. // SmallVector Preds(pred_begin(BB), pred_end(BB)); while (!Preds.empty()) { BasicBlock *Pred = Preds.back(); - if (BranchInst *BI = dyn_cast(Pred->getTerminator())) { - if (BI->isUnconditional()) { - Pred->getInstList().pop_back(); // nuke uncond branch - new UnwindInst(Pred->getContext(), Pred); // Use unwind. - Changed = true; - } - } else if (InvokeInst *II = dyn_cast(Pred->getTerminator())) + if (InvokeInst *II = dyn_cast(Pred->getTerminator())) if (II->getUnwindDest() == BB) { // Insert a new branch instruction before the invoke, because this - // is now a fall through... + // is now a fall through. BranchInst *BI = BranchInst::Create(II->getNormalDest(), II); Pred->getInstList().remove(II); // Take out of symbol table - // Insert the call now... + // Insert the call now. SmallVector Args(II->op_begin()+3, II->op_end()); CallInst *CI = CallInst::Create(II->getCalledValue(), Args.begin(), Args.end(), II->getName(), BI); CI->setCallingConv(II->getCallingConv()); CI->setAttributes(II->getAttributes()); - // If the invoke produced a value, the Call now does instead + // If the invoke produced a value, the Call now does instead. II->replaceAllUsesWith(CI); delete II; Changed = true; Modified: llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll?rev=83996&r1=83995&r2=83996&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/invoke_unwind.ll Tue Oct 13 13:13:05 2009 @@ -1,10 +1,9 @@ -; This testcase checks to see if the simplifycfg pass is converting invoke -; instructions to call instructions if the handler just rethrows the exception. - ; RUN: opt < %s -simplifycfg -S | FileCheck %s declare void @bar() +; This testcase checks to see if the simplifycfg pass is converting invoke +; instructions to call instructions if the handler just rethrows the exception. define i32 @test1() { ; CHECK: @test1 ; CHECK-NEXT: call void @bar() @@ -16,3 +15,19 @@ Rethrow: ; preds = %0 unwind } + + +; Verify that simplifycfg isn't duplicating 'unwind' instructions. Doing this +; is bad because it discourages commoning. +define i32 @test2(i1 %c) { +; CHECK: @test2 +; CHECK: T: +; CHECK-NEXT: call void @bar() +; CHECK-NEXT: br label %F + br i1 %c, label %T, label %F +T: + call void @bar() + br label %F +F: + unwind +} From gohman at apple.com Tue Oct 13 13:24:11 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 13 Oct 2009 18:24:11 -0000 Subject: [llvm-commits] [llvm] r83997 - in /llvm/trunk: include/llvm/Transforms/Utils/InlineCost.h lib/Transforms/Utils/InlineCost.cpp Message-ID: <200910131824.n9DIOBJu014153@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 13:24:11 2009 New Revision: 83997 URL: http://llvm.org/viewvc/llvm-project?rev=83997&view=rev Log: Start refactoring the inline cost estimation code so that it can be used for purposes other than inlining. Modified: llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h?rev=83997&r1=83996&r2=83997&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h Tue Oct 13 13:24:11 2009 @@ -23,6 +23,7 @@ class Value; class Function; + class BasicBlock; class CallSite; template class SmallPtrSet; @@ -96,9 +97,9 @@ : ConstantWeight(CWeight), AllocaWeight(AWeight) {} }; - // FunctionInfo - For each function, calculate the size of it in blocks and - // instructions. - struct FunctionInfo { + // RegionInfo - Calculate size and a few related metrics for a set of + // basic blocks. + struct RegionInfo { /// NeverInline - True if this callee should never be inlined into a /// caller. bool NeverInline; @@ -115,17 +116,24 @@ /// kernels. unsigned NumVectorInsts; + /// NumRets - Keep track of how many Ret instructions the block contains. + unsigned NumRets; + /// ArgumentWeights - Each formal argument of the function is inspected to /// see if it is used in any contexts where making it a constant or alloca /// would reduce the code size. If so, we add some value to the argument /// entry here. std::vector ArgumentWeights; - FunctionInfo() : NeverInline(false), usesDynamicAlloca(false), NumInsts(0), - NumBlocks(0), NumVectorInsts(0) {} + RegionInfo() : NeverInline(false), usesDynamicAlloca(false), NumInsts(0), + NumBlocks(0), NumVectorInsts(0), NumRets(0) {} - /// analyzeFunction - Fill in the current structure with information - /// gleaned from the specified function. + /// analyzeBasicBlock - Add information about the specified basic block + /// to the current structure. + void analyzeBasicBlock(const BasicBlock *BB); + + /// analyzeFunction - Add information about the specified function + /// to the current structure. void analyzeFunction(Function *F); /// CountCodeReductionForConstant - Figure out an approximation for how @@ -140,7 +148,7 @@ unsigned CountCodeReductionForAlloca(Value *V); }; - std::map CachedFunctionInfo; + std::map CachedFunctionInfo; public: Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=83997&r1=83996&r2=83997&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Tue Oct 13 13:24:11 2009 @@ -21,7 +21,7 @@ // CountCodeReductionForConstant - Figure out an approximation for how many // instructions will be constant folded if the specified value is constant. // -unsigned InlineCostAnalyzer::FunctionInfo:: +unsigned InlineCostAnalyzer::RegionInfo:: CountCodeReductionForConstant(Value *V) { unsigned Reduction = 0; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) @@ -77,7 +77,7 @@ // the function will be if it is inlined into a context where an argument // becomes an alloca. // -unsigned InlineCostAnalyzer::FunctionInfo:: +unsigned InlineCostAnalyzer::RegionInfo:: CountCodeReductionForAlloca(Value *V) { if (!isa(V->getType())) return 0; // Not a pointer unsigned Reduction = 0; @@ -99,85 +99,85 @@ return Reduction; } -/// analyzeFunction - Fill in the current structure with information gleaned -/// from the specified function. -void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) { - unsigned NumInsts = 0, NumBlocks = 0, NumVectorInsts = 0, NumRets = 0; - - // Look at the size of the callee. Each basic block counts as 20 units, and - // each instruction counts as 5. - for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { - for (BasicBlock::const_iterator II = BB->begin(), E = BB->end(); - II != E; ++II) { - if (isa(II)) continue; // PHI nodes don't count. - - // Special handling for calls. - if (isa(II) || isa(II)) { - if (isa(II)) - continue; // Debug intrinsics don't count as size. - - CallSite CS = CallSite::get(const_cast(&*II)); - - // If this function contains a call to setjmp or _setjmp, never inline - // it. This is a hack because we depend on the user marking their local - // variables as volatile if they are live across a setjmp call, and they - // probably won't do this in callers. - if (Function *F = CS.getCalledFunction()) - if (F->isDeclaration() && - (F->getName() == "setjmp" || F->getName() == "_setjmp")) { - NeverInline = true; - return; - } - - // Calls often compile into many machine instructions. Bump up their - // cost to reflect this. - if (!isa(II)) - NumInsts += InlineConstants::CallPenalty; - } +/// analyzeBasicBlock - Fill in the current structure with information gleaned +/// from the specified block. +void InlineCostAnalyzer::RegionInfo::analyzeBasicBlock(const BasicBlock *BB) { + ++NumBlocks; + + for (BasicBlock::const_iterator II = BB->begin(), E = BB->end(); + II != E; ++II) { + if (isa(II)) continue; // PHI nodes don't count. + + // Special handling for calls. + if (isa(II) || isa(II)) { + if (isa(II)) + continue; // Debug intrinsics don't count as size. - // These, too, are calls. - if (isa(II) || isa(II)) - NumInsts += InlineConstants::CallPenalty; - - if (const AllocaInst *AI = dyn_cast(II)) { - if (!AI->isStaticAlloca()) - this->usesDynamicAlloca = true; - } - - if (isa(II) || isa(II->getType())) - ++NumVectorInsts; + CallSite CS = CallSite::get(const_cast(&*II)); - // Noop casts, including ptr <-> int, don't count. - if (const CastInst *CI = dyn_cast(II)) { - if (CI->isLosslessCast() || isa(CI) || - isa(CI)) - continue; - } else if (const GetElementPtrInst *GEPI = - dyn_cast(II)) { - // If a GEP has all constant indices, it will probably be folded with - // a load/store. - if (GEPI->hasAllConstantIndices()) - continue; - } + // If this function contains a call to setjmp or _setjmp, never inline + // it. This is a hack because we depend on the user marking their local + // variables as volatile if they are live across a setjmp call, and they + // probably won't do this in callers. + if (Function *F = CS.getCalledFunction()) + if (F->isDeclaration() && + (F->getName() == "setjmp" || F->getName() == "_setjmp")) { + NeverInline = true; + return; + } - if (isa(II)) - ++NumRets; - - ++NumInsts; + // Calls often compile into many machine instructions. Bump up their + // cost to reflect this. + if (!isa(II)) + NumInsts += InlineConstants::CallPenalty; + } + + // These, too, are calls. + if (isa(II) || isa(II)) + NumInsts += InlineConstants::CallPenalty; + + if (const AllocaInst *AI = dyn_cast(II)) { + if (!AI->isStaticAlloca()) + this->usesDynamicAlloca = true; } - ++NumBlocks; + if (isa(II) || isa(II->getType())) + ++NumVectorInsts; + + // Noop casts, including ptr <-> int, don't count. + if (const CastInst *CI = dyn_cast(II)) { + if (CI->isLosslessCast() || isa(CI) || + isa(CI)) + continue; + } else if (const GetElementPtrInst *GEPI = + dyn_cast(II)) { + // If a GEP has all constant indices, it will probably be folded with + // a load/store. + if (GEPI->hasAllConstantIndices()) + continue; + } + + if (isa(II)) + ++NumRets; + + ++NumInsts; } +} + +/// analyzeFunction - Fill in the current structure with information gleaned +/// from the specified function. +void InlineCostAnalyzer::RegionInfo::analyzeFunction(Function *F) { + // Look at the size of the callee. Each basic block counts as 20 units, and + // each instruction counts as 5. + for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) + analyzeBasicBlock(&*BB); // A function with exactly one return has it removed during the inlining // process (see InlineFunction), so don't count it. + // FIXME: This knowledge should really be encoded outside of RegionInfo. if (NumRets==1) --NumInsts; - this->NumBlocks = NumBlocks; - this->NumInsts = NumInsts; - this->NumVectorInsts = NumVectorInsts; - // Check out all of the arguments to the function, figuring out how much // code can be eliminated if one of the arguments is a constant. for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) @@ -229,7 +229,7 @@ InlineCost += InlineConstants::NoreturnPenalty; // Get information about the callee... - FunctionInfo &CalleeFI = CachedFunctionInfo[Callee]; + RegionInfo &CalleeFI = CachedFunctionInfo[Callee]; // If we haven't calculated this information yet, do so now. if (CalleeFI.NumBlocks == 0) @@ -240,7 +240,7 @@ return InlineCost::getNever(); // FIXME: It would be nice to kill off CalleeFI.NeverInline. Then we - // could move this up and avoid computing the FunctionInfo for + // could move this up and avoid computing the RegionInfo for // things we are going to just return always inline for. This // requires handling setjmp somewhere else, however. if (!Callee->isDeclaration() && Callee->hasFnAttr(Attribute::AlwaysInline)) @@ -248,7 +248,7 @@ if (CalleeFI.usesDynamicAlloca) { // Get infomation about the caller... - FunctionInfo &CallerFI = CachedFunctionInfo[Caller]; + RegionInfo &CallerFI = CachedFunctionInfo[Caller]; // If we haven't calculated this information yet, do so now. if (CallerFI.NumBlocks == 0) @@ -316,7 +316,7 @@ Function *Callee = CS.getCalledFunction(); // Get information about the callee... - FunctionInfo &CalleeFI = CachedFunctionInfo[Callee]; + RegionInfo &CalleeFI = CachedFunctionInfo[Callee]; // If we haven't calculated this information yet, do so now. if (CalleeFI.NumBlocks == 0) From gohman at apple.com Tue Oct 13 13:30:07 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 13 Oct 2009 18:30:07 -0000 Subject: [llvm-commits] [llvm] r83998 - in /llvm/trunk: include/llvm/Analysis/InlineCost.h include/llvm/Transforms/Utils/BasicInliner.h include/llvm/Transforms/Utils/InlineCost.h lib/Analysis/InlineCost.cpp lib/Transforms/IPO/InlineAlways.cpp lib/Transforms/IPO/InlineSimple.cpp lib/Transforms/IPO/Inliner.cpp Message-ID: <200910131830.n9DIU8BE014408@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 13:30:07 2009 New Revision: 83998 URL: http://llvm.org/viewvc/llvm-project?rev=83998&view=rev Log: Move the InlineCost code from Transforms/Utils to Analysis. Added: llvm/trunk/include/llvm/Analysis/InlineCost.h - copied, changed from r83997, llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h llvm/trunk/lib/Analysis/InlineCost.cpp - copied, changed from r83997, llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Removed: llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicInliner.h llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp llvm/trunk/lib/Transforms/IPO/Inliner.cpp Copied: llvm/trunk/include/llvm/Analysis/InlineCost.h (from r83997, llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InlineCost.h?p2=llvm/trunk/include/llvm/Analysis/InlineCost.h&p1=llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h&r1=83997&r2=83998&rev=83998&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h (original) +++ llvm/trunk/include/llvm/Analysis/InlineCost.h Tue Oct 13 13:30:07 2009 @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_TRANSFORMS_UTILS_INLINECOST_H -#define LLVM_TRANSFORMS_UTILS_INLINECOST_H +#ifndef LLVM_ANALYSIS_INLINECOST_H +#define LLVM_ANALYSIS_INLINECOST_H #include #include Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicInliner.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BasicInliner.h?rev=83998&r1=83997&r2=83998&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/BasicInliner.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/BasicInliner.h Tue Oct 13 13:30:07 2009 @@ -15,7 +15,7 @@ #ifndef BASICINLINER_H #define BASICINLINER_H -#include "llvm/Transforms/Utils/InlineCost.h" +#include "llvm/Analysis/InlineCost.h" namespace llvm { Removed: llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h?rev=83997&view=auto ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h (removed) @@ -1,172 +0,0 @@ -//===- InlineCost.cpp - Cost analysis for inliner ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements heuristics for inlining decisions. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_INLINECOST_H -#define LLVM_TRANSFORMS_UTILS_INLINECOST_H - -#include -#include -#include -#include - -namespace llvm { - - class Value; - class Function; - class BasicBlock; - class CallSite; - template - class SmallPtrSet; - - namespace InlineConstants { - // Various magic constants used to adjust heuristics. - const int CallPenalty = 5; - const int LastCallToStaticBonus = -15000; - const int ColdccPenalty = 2000; - const int NoreturnPenalty = 10000; - } - - /// InlineCost - Represent the cost of inlining a function. This - /// supports special values for functions which should "always" or - /// "never" be inlined. Otherwise, the cost represents a unitless - /// amount; smaller values increase the likelyhood of the function - /// being inlined. - class InlineCost { - enum Kind { - Value, - Always, - Never - }; - - // This is a do-it-yourself implementation of - // int Cost : 30; - // unsigned Type : 2; - // We used to use bitfields, but they were sometimes miscompiled (PR3822). - enum { TYPE_BITS = 2 }; - enum { COST_BITS = unsigned(sizeof(unsigned)) * CHAR_BIT - TYPE_BITS }; - unsigned TypedCost; // int Cost : COST_BITS; unsigned Type : TYPE_BITS; - - Kind getType() const { - return Kind(TypedCost >> COST_BITS); - } - - int getCost() const { - // Sign-extend the bottom COST_BITS bits. - return (int(TypedCost << TYPE_BITS)) >> TYPE_BITS; - } - - InlineCost(int C, int T) { - TypedCost = (unsigned(C << TYPE_BITS) >> TYPE_BITS) | (T << COST_BITS); - assert(getCost() == C && "Cost exceeds InlineCost precision"); - } - public: - static InlineCost get(int Cost) { return InlineCost(Cost, Value); } - static InlineCost getAlways() { return InlineCost(0, Always); } - static InlineCost getNever() { return InlineCost(0, Never); } - - bool isVariable() const { return getType() == Value; } - bool isAlways() const { return getType() == Always; } - bool isNever() const { return getType() == Never; } - - /// getValue() - Return a "variable" inline cost's amount. It is - /// an error to call this on an "always" or "never" InlineCost. - int getValue() const { - assert(getType() == Value && "Invalid access of InlineCost"); - return getCost(); - } - }; - - /// InlineCostAnalyzer - Cost analyzer used by inliner. - class InlineCostAnalyzer { - struct ArgInfo { - public: - unsigned ConstantWeight; - unsigned AllocaWeight; - - ArgInfo(unsigned CWeight, unsigned AWeight) - : ConstantWeight(CWeight), AllocaWeight(AWeight) {} - }; - - // RegionInfo - Calculate size and a few related metrics for a set of - // basic blocks. - struct RegionInfo { - /// NeverInline - True if this callee should never be inlined into a - /// caller. - bool NeverInline; - - /// usesDynamicAlloca - True if this function calls alloca (in the C sense). - bool usesDynamicAlloca; - - /// NumInsts, NumBlocks - Keep track of how large each function is, which - /// is used to estimate the code size cost of inlining it. - unsigned NumInsts, NumBlocks; - - /// NumVectorInsts - Keep track of how many instructions produce vector - /// values. The inliner is being more aggressive with inlining vector - /// kernels. - unsigned NumVectorInsts; - - /// NumRets - Keep track of how many Ret instructions the block contains. - unsigned NumRets; - - /// ArgumentWeights - Each formal argument of the function is inspected to - /// see if it is used in any contexts where making it a constant or alloca - /// would reduce the code size. If so, we add some value to the argument - /// entry here. - std::vector ArgumentWeights; - - RegionInfo() : NeverInline(false), usesDynamicAlloca(false), NumInsts(0), - NumBlocks(0), NumVectorInsts(0), NumRets(0) {} - - /// analyzeBasicBlock - Add information about the specified basic block - /// to the current structure. - void analyzeBasicBlock(const BasicBlock *BB); - - /// analyzeFunction - Add information about the specified function - /// to the current structure. - void analyzeFunction(Function *F); - - /// CountCodeReductionForConstant - Figure out an approximation for how - /// many instructions will be constant folded if the specified value is - /// constant. - unsigned CountCodeReductionForConstant(Value *V); - - /// CountCodeReductionForAlloca - Figure out an approximation of how much - /// smaller the function will be if it is inlined into a context where an - /// argument becomes an alloca. - /// - unsigned CountCodeReductionForAlloca(Value *V); - }; - - std::map CachedFunctionInfo; - - public: - - /// getInlineCost - The heuristic used to determine if we should inline the - /// function call or not. - /// - InlineCost getInlineCost(CallSite CS, - SmallPtrSet &NeverInline); - - /// getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a - /// higher threshold to determine if the function call should be inlined. - float getInlineFudgeFactor(CallSite CS); - - /// resetCachedFunctionInfo - erase any cached cost info for this function. - void resetCachedCostInfo(Function* Caller) { - CachedFunctionInfo[Caller].NumBlocks = 0; - } - }; -} - -#endif Copied: llvm/trunk/lib/Analysis/InlineCost.cpp (from r83997, llvm/trunk/lib/Transforms/Utils/InlineCost.cpp) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?p2=llvm/trunk/lib/Analysis/InlineCost.cpp&p1=llvm/trunk/lib/Transforms/Utils/InlineCost.cpp&r1=83997&r2=83998&rev=83998&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original) +++ llvm/trunk/lib/Analysis/InlineCost.cpp Tue Oct 13 13:30:07 2009 @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Transforms/Utils/InlineCost.h" +#include "llvm/Analysis/InlineCost.h" #include "llvm/Support/CallSite.h" #include "llvm/CallingConv.h" #include "llvm/IntrinsicInst.h" Modified: llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp?rev=83998&r1=83997&r2=83998&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp Tue Oct 13 13:30:07 2009 @@ -19,11 +19,11 @@ #include "llvm/Module.h" #include "llvm/Type.h" #include "llvm/Analysis/CallGraph.h" +#include "llvm/Analysis/InlineCost.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/Compiler.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/InlinerPass.h" -#include "llvm/Transforms/Utils/InlineCost.h" #include "llvm/ADT/SmallPtrSet.h" using namespace llvm; Modified: llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp?rev=83998&r1=83997&r2=83998&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp Tue Oct 13 13:30:07 2009 @@ -18,11 +18,11 @@ #include "llvm/Module.h" #include "llvm/Type.h" #include "llvm/Analysis/CallGraph.h" +#include "llvm/Analysis/InlineCost.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/Compiler.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/InlinerPass.h" -#include "llvm/Transforms/Utils/InlineCost.h" #include "llvm/ADT/SmallPtrSet.h" using namespace llvm; Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=83998&r1=83997&r2=83998&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Tue Oct 13 13:30:07 2009 @@ -18,10 +18,10 @@ #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" #include "llvm/Analysis/CallGraph.h" +#include "llvm/Analysis/InlineCost.h" #include "llvm/Support/CallSite.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/IPO/InlinerPass.h" -#include "llvm/Transforms/Utils/InlineCost.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" From gohman at apple.com Tue Oct 13 13:37:21 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 13 Oct 2009 18:37:21 -0000 Subject: [llvm-commits] [llvm] r83999 - /llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Message-ID: <200910131837.n9DIbLpU014672@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 13:37:20 2009 New Revision: 83999 URL: http://llvm.org/viewvc/llvm-project?rev=83999&view=rev Log: Commit the removal of this file, which is now moved to lib/Analysis. Removed: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Removed: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=83998&view=auto ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (removed) @@ -1,337 +0,0 @@ -//===- InlineCost.cpp - Cost analysis for inliner -------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements inline cost analysis. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Transforms/Utils/InlineCost.h" -#include "llvm/Support/CallSite.h" -#include "llvm/CallingConv.h" -#include "llvm/IntrinsicInst.h" -#include "llvm/ADT/SmallPtrSet.h" -using namespace llvm; - -// CountCodeReductionForConstant - Figure out an approximation for how many -// instructions will be constant folded if the specified value is constant. -// -unsigned InlineCostAnalyzer::RegionInfo:: - CountCodeReductionForConstant(Value *V) { - unsigned Reduction = 0; - for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) - if (isa(*UI)) - Reduction += 40; // Eliminating a conditional branch is a big win - else if (SwitchInst *SI = dyn_cast(*UI)) - // Eliminating a switch is a big win, proportional to the number of edges - // deleted. - Reduction += (SI->getNumSuccessors()-1) * 40; - else if (CallInst *CI = dyn_cast(*UI)) { - // Turning an indirect call into a direct call is a BIG win - Reduction += CI->getCalledValue() == V ? 500 : 0; - } else if (InvokeInst *II = dyn_cast(*UI)) { - // Turning an indirect call into a direct call is a BIG win - Reduction += II->getCalledValue() == V ? 500 : 0; - } else { - // Figure out if this instruction will be removed due to simple constant - // propagation. - Instruction &Inst = cast(**UI); - - // We can't constant propagate instructions which have effects or - // read memory. - // - // FIXME: It would be nice to capture the fact that a load from a - // pointer-to-constant-global is actually a *really* good thing to zap. - // Unfortunately, we don't know the pointer that may get propagated here, - // so we can't make this decision. - if (Inst.mayReadFromMemory() || Inst.mayHaveSideEffects() || - isa(Inst)) - continue; - - bool AllOperandsConstant = true; - for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i) - if (!isa(Inst.getOperand(i)) && Inst.getOperand(i) != V) { - AllOperandsConstant = false; - break; - } - - if (AllOperandsConstant) { - // We will get to remove this instruction... - Reduction += 7; - - // And any other instructions that use it which become constants - // themselves. - Reduction += CountCodeReductionForConstant(&Inst); - } - } - - return Reduction; -} - -// CountCodeReductionForAlloca - Figure out an approximation of how much smaller -// the function will be if it is inlined into a context where an argument -// becomes an alloca. -// -unsigned InlineCostAnalyzer::RegionInfo:: - CountCodeReductionForAlloca(Value *V) { - if (!isa(V->getType())) return 0; // Not a pointer - unsigned Reduction = 0; - for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){ - Instruction *I = cast(*UI); - if (isa(I) || isa(I)) - Reduction += 10; - else if (GetElementPtrInst *GEP = dyn_cast(I)) { - // If the GEP has variable indices, we won't be able to do much with it. - if (!GEP->hasAllConstantIndices()) - Reduction += CountCodeReductionForAlloca(GEP)+15; - } else { - // If there is some other strange instruction, we're not going to be able - // to do much if we inline this. - return 0; - } - } - - return Reduction; -} - -/// analyzeBasicBlock - Fill in the current structure with information gleaned -/// from the specified block. -void InlineCostAnalyzer::RegionInfo::analyzeBasicBlock(const BasicBlock *BB) { - ++NumBlocks; - - for (BasicBlock::const_iterator II = BB->begin(), E = BB->end(); - II != E; ++II) { - if (isa(II)) continue; // PHI nodes don't count. - - // Special handling for calls. - if (isa(II) || isa(II)) { - if (isa(II)) - continue; // Debug intrinsics don't count as size. - - CallSite CS = CallSite::get(const_cast(&*II)); - - // If this function contains a call to setjmp or _setjmp, never inline - // it. This is a hack because we depend on the user marking their local - // variables as volatile if they are live across a setjmp call, and they - // probably won't do this in callers. - if (Function *F = CS.getCalledFunction()) - if (F->isDeclaration() && - (F->getName() == "setjmp" || F->getName() == "_setjmp")) { - NeverInline = true; - return; - } - - // Calls often compile into many machine instructions. Bump up their - // cost to reflect this. - if (!isa(II)) - NumInsts += InlineConstants::CallPenalty; - } - - // These, too, are calls. - if (isa(II) || isa(II)) - NumInsts += InlineConstants::CallPenalty; - - if (const AllocaInst *AI = dyn_cast(II)) { - if (!AI->isStaticAlloca()) - this->usesDynamicAlloca = true; - } - - if (isa(II) || isa(II->getType())) - ++NumVectorInsts; - - // Noop casts, including ptr <-> int, don't count. - if (const CastInst *CI = dyn_cast(II)) { - if (CI->isLosslessCast() || isa(CI) || - isa(CI)) - continue; - } else if (const GetElementPtrInst *GEPI = - dyn_cast(II)) { - // If a GEP has all constant indices, it will probably be folded with - // a load/store. - if (GEPI->hasAllConstantIndices()) - continue; - } - - if (isa(II)) - ++NumRets; - - ++NumInsts; - } -} - -/// analyzeFunction - Fill in the current structure with information gleaned -/// from the specified function. -void InlineCostAnalyzer::RegionInfo::analyzeFunction(Function *F) { - // Look at the size of the callee. Each basic block counts as 20 units, and - // each instruction counts as 5. - for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) - analyzeBasicBlock(&*BB); - - // A function with exactly one return has it removed during the inlining - // process (see InlineFunction), so don't count it. - // FIXME: This knowledge should really be encoded outside of RegionInfo. - if (NumRets==1) - --NumInsts; - - // Check out all of the arguments to the function, figuring out how much - // code can be eliminated if one of the arguments is a constant. - for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) - ArgumentWeights.push_back(ArgInfo(CountCodeReductionForConstant(I), - CountCodeReductionForAlloca(I))); -} - - - -// getInlineCost - The heuristic used to determine if we should inline the -// function call or not. -// -InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS, - SmallPtrSet &NeverInline) { - Instruction *TheCall = CS.getInstruction(); - Function *Callee = CS.getCalledFunction(); - Function *Caller = TheCall->getParent()->getParent(); - - // Don't inline functions which can be redefined at link-time to mean - // something else. Don't inline functions marked noinline. - if (Callee->mayBeOverridden() || - Callee->hasFnAttr(Attribute::NoInline) || NeverInline.count(Callee)) - return llvm::InlineCost::getNever(); - - // InlineCost - This value measures how good of an inline candidate this call - // site is to inline. A lower inline cost make is more likely for the call to - // be inlined. This value may go negative. - // - int InlineCost = 0; - - // If there is only one call of the function, and it has internal linkage, - // make it almost guaranteed to be inlined. - // - if (Callee->hasLocalLinkage() && Callee->hasOneUse()) - InlineCost += InlineConstants::LastCallToStaticBonus; - - // If this function uses the coldcc calling convention, prefer not to inline - // it. - if (Callee->getCallingConv() == CallingConv::Cold) - InlineCost += InlineConstants::ColdccPenalty; - - // If the instruction after the call, or if the normal destination of the - // invoke is an unreachable instruction, the function is noreturn. As such, - // there is little point in inlining this. - if (InvokeInst *II = dyn_cast(TheCall)) { - if (isa(II->getNormalDest()->begin())) - InlineCost += InlineConstants::NoreturnPenalty; - } else if (isa(++BasicBlock::iterator(TheCall))) - InlineCost += InlineConstants::NoreturnPenalty; - - // Get information about the callee... - RegionInfo &CalleeFI = CachedFunctionInfo[Callee]; - - // If we haven't calculated this information yet, do so now. - if (CalleeFI.NumBlocks == 0) - CalleeFI.analyzeFunction(Callee); - - // If we should never inline this, return a huge cost. - if (CalleeFI.NeverInline) - return InlineCost::getNever(); - - // FIXME: It would be nice to kill off CalleeFI.NeverInline. Then we - // could move this up and avoid computing the RegionInfo for - // things we are going to just return always inline for. This - // requires handling setjmp somewhere else, however. - if (!Callee->isDeclaration() && Callee->hasFnAttr(Attribute::AlwaysInline)) - return InlineCost::getAlways(); - - if (CalleeFI.usesDynamicAlloca) { - // Get infomation about the caller... - RegionInfo &CallerFI = CachedFunctionInfo[Caller]; - - // If we haven't calculated this information yet, do so now. - if (CallerFI.NumBlocks == 0) - CallerFI.analyzeFunction(Caller); - - // Don't inline a callee with dynamic alloca into a caller without them. - // Functions containing dynamic alloca's are inefficient in various ways; - // don't create more inefficiency. - if (!CallerFI.usesDynamicAlloca) - return InlineCost::getNever(); - } - - // Add to the inline quality for properties that make the call valuable to - // inline. This includes factors that indicate that the result of inlining - // the function will be optimizable. Currently this just looks at arguments - // passed into the function. - // - unsigned ArgNo = 0; - for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); - I != E; ++I, ++ArgNo) { - // Each argument passed in has a cost at both the caller and the callee - // sides. This favors functions that take many arguments over functions - // that take few arguments. - InlineCost -= 20; - - // If this is a function being passed in, it is very likely that we will be - // able to turn an indirect function call into a direct function call. - if (isa(I)) - InlineCost -= 100; - - // If an alloca is passed in, inlining this function is likely to allow - // significant future optimization possibilities (like scalar promotion, and - // scalarization), so encourage the inlining of the function. - // - else if (isa(I)) { - if (ArgNo < CalleeFI.ArgumentWeights.size()) - InlineCost -= CalleeFI.ArgumentWeights[ArgNo].AllocaWeight; - - // If this is a constant being passed into the function, use the argument - // weights calculated for the callee to determine how much will be folded - // away with this information. - } else if (isa(I)) { - if (ArgNo < CalleeFI.ArgumentWeights.size()) - InlineCost -= CalleeFI.ArgumentWeights[ArgNo].ConstantWeight; - } - } - - // Now that we have considered all of the factors that make the call site more - // likely to be inlined, look at factors that make us not want to inline it. - - // Don't inline into something too big, which would make it bigger. - // "size" here is the number of basic blocks, not instructions. - // - InlineCost += Caller->size()/15; - - // Look at the size of the callee. Each instruction counts as 5. - InlineCost += CalleeFI.NumInsts*5; - - return llvm::InlineCost::get(InlineCost); -} - -// getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a -// higher threshold to determine if the function call should be inlined. -float InlineCostAnalyzer::getInlineFudgeFactor(CallSite CS) { - Function *Callee = CS.getCalledFunction(); - - // Get information about the callee... - RegionInfo &CalleeFI = CachedFunctionInfo[Callee]; - - // If we haven't calculated this information yet, do so now. - if (CalleeFI.NumBlocks == 0) - CalleeFI.analyzeFunction(Callee); - - float Factor = 1.0f; - // Single BB functions are often written to be inlined. - if (CalleeFI.NumBlocks == 1) - Factor += 0.5f; - - // Be more aggressive if the function contains a good chunk (if it mades up - // at least 10% of the instructions) of vector instructions. - if (CalleeFI.NumVectorInsts > CalleeFI.NumInsts/2) - Factor += 2.0f; - else if (CalleeFI.NumVectorInsts > CalleeFI.NumInsts/10) - Factor += 1.5f; - return Factor; -} From evan.cheng at apple.com Tue Oct 13 13:42:05 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 13 Oct 2009 18:42:05 -0000 Subject: [llvm-commits] [llvm] r84000 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200910131842.n9DIg5Mf014885@zion.cs.uiuc.edu> Author: evancheng Date: Tue Oct 13 13:42:04 2009 New Revision: 84000 URL: http://llvm.org/viewvc/llvm-project?rev=84000&view=rev Log: Refactor some code. No functionality changes. Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84000&r1=83999&r2=84000&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Tue Oct 13 13:42:04 2009 @@ -215,6 +215,11 @@ bool pointsToConstantMemory(const Value *P); private: + // aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a GEP instruction + // against another. + AliasResult aliasGEP(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size); + // CheckGEPInstructions - Check two GEP instructions with known // must-aliasing base pointers. This checks to see if the index expressions // preclude the pointers from aliasing... @@ -329,61 +334,12 @@ return NoAA::getModRefInfo(CS1, CS2); } - -// alias - Provide a bunch of ad-hoc rules to disambiguate in common cases, such -// as array references. +// aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a GEP instruction +// against another. // AliasAnalysis::AliasResult -BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size) { - // Strip off any casts if they exist. - V1 = V1->stripPointerCasts(); - V2 = V2->stripPointerCasts(); - - // Are we checking for alias of the same value? - if (V1 == V2) return MustAlias; - - if (!isa(V1->getType()) || !isa(V2->getType())) - return NoAlias; // Scalars cannot alias each other - - // Figure out what objects these things are pointing to if we can. - const Value *O1 = V1->getUnderlyingObject(); - const Value *O2 = V2->getUnderlyingObject(); - - if (O1 != O2) { - // If V1/V2 point to two different objects we know that we have no alias. - if (isIdentifiedObject(O1) && isIdentifiedObject(O2)) - return NoAlias; - - // Arguments can't alias with local allocations or noalias calls. - if ((isa(O1) && (isa(O2) || isNoAliasCall(O2))) || - (isa(O2) && (isa(O1) || isNoAliasCall(O1)))) - return NoAlias; - - // Most objects can't alias null. - if ((isa(V2) && isKnownNonNull(O1)) || - (isa(V1) && isKnownNonNull(O2))) - return NoAlias; - } - - // If the size of one access is larger than the entire object on the other - // side, then we know such behavior is undefined and can assume no alias. - LLVMContext &Context = V1->getContext(); - if (TD) - if ((V1Size != ~0U && isObjectSmallerThan(O2, V1Size, Context, *TD)) || - (V2Size != ~0U && isObjectSmallerThan(O1, V2Size, Context, *TD))) - return NoAlias; - - // If one pointer is the result of a call/invoke and the other is a - // non-escaping local object, then we know the object couldn't escape to a - // point where the call could return it. - if ((isa(O1) || isa(O1)) && - isNonEscapingLocalObject(O2) && O1 != O2) - return NoAlias; - if ((isa(O2) || isa(O2)) && - isNonEscapingLocalObject(O1) && O1 != O2) - return NoAlias; - +BasicAliasAnalysis::aliasGEP(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size) { // If we have two gep instructions with must-alias'ing base pointers, figure // out if the indexes to the GEP tell us anything about the derived pointer. // Note that we also handle chains of getelementptr instructions as well as @@ -451,63 +407,121 @@ // instruction. If one pointer is a GEP with a non-zero index of the other // pointer, we know they cannot alias. // - if (isGEP(V2)) { - std::swap(V1, V2); - std::swap(V1Size, V2Size); - } + if (V1Size == ~0U || V2Size == ~0U) + return MayAlias; - if (V1Size != ~0U && V2Size != ~0U) - if (isGEP(V1)) { - SmallVector GEPOperands; - const Value *BasePtr = GetGEPOperands(V1, GEPOperands); - - AliasResult R = alias(BasePtr, V1Size, V2, V2Size); - if (R == MustAlias) { - // If there is at least one non-zero constant index, we know they cannot - // alias. - bool ConstantFound = false; - bool AllZerosFound = true; - for (unsigned i = 0, e = GEPOperands.size(); i != e; ++i) - if (const Constant *C = dyn_cast(GEPOperands[i])) { - if (!C->isNullValue()) { - ConstantFound = true; - AllZerosFound = false; - break; - } - } else { - AllZerosFound = false; - } + SmallVector GEPOperands; + const Value *BasePtr = GetGEPOperands(V1, GEPOperands); - // If we have getelementptr , 0, 0, 0, 0, ... and V2 must aliases - // the ptr, the end result is a must alias also. - if (AllZerosFound) - return MustAlias; + AliasResult R = alias(BasePtr, V1Size, V2, V2Size); + if (R == MustAlias) { + // If there is at least one non-zero constant index, we know they cannot + // alias. + bool ConstantFound = false; + bool AllZerosFound = true; + for (unsigned i = 0, e = GEPOperands.size(); i != e; ++i) + if (const Constant *C = dyn_cast(GEPOperands[i])) { + if (!C->isNullValue()) { + ConstantFound = true; + AllZerosFound = false; + break; + } + } else { + AllZerosFound = false; + } - if (ConstantFound) { - if (V2Size <= 1 && V1Size <= 1) // Just pointer check? - return NoAlias; + // If we have getelementptr , 0, 0, 0, 0, ... and V2 must aliases + // the ptr, the end result is a must alias also. + if (AllZerosFound) + return MustAlias; - // Otherwise we have to check to see that the distance is more than - // the size of the argument... build an index vector that is equal to - // the arguments provided, except substitute 0's for any variable - // indexes we find... - if (TD && cast( - BasePtr->getType())->getElementType()->isSized()) { - for (unsigned i = 0; i != GEPOperands.size(); ++i) - if (!isa(GEPOperands[i])) - GEPOperands[i] = - Constant::getNullValue(GEPOperands[i]->getType()); - int64_t Offset = - TD->getIndexedOffset(BasePtr->getType(), - &GEPOperands[0], - GEPOperands.size()); + if (ConstantFound) { + if (V2Size <= 1 && V1Size <= 1) // Just pointer check? + return NoAlias; + + // Otherwise we have to check to see that the distance is more than + // the size of the argument... build an index vector that is equal to + // the arguments provided, except substitute 0's for any variable + // indexes we find... + if (TD && + cast(BasePtr->getType())->getElementType()->isSized()) { + for (unsigned i = 0; i != GEPOperands.size(); ++i) + if (!isa(GEPOperands[i])) + GEPOperands[i] = Constant::getNullValue(GEPOperands[i]->getType()); + int64_t Offset = + TD->getIndexedOffset(BasePtr->getType(), + &GEPOperands[0], + GEPOperands.size()); - if (Offset >= (int64_t)V2Size || Offset <= -(int64_t)V1Size) - return NoAlias; - } - } + if (Offset >= (int64_t)V2Size || Offset <= -(int64_t)V1Size) + return NoAlias; } } + } + + return MayAlias; +} + +// alias - Provide a bunch of ad-hoc rules to disambiguate in common cases, such +// as array references. +// +AliasAnalysis::AliasResult +BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size) { + // Strip off any casts if they exist. + V1 = V1->stripPointerCasts(); + V2 = V2->stripPointerCasts(); + + // Are we checking for alias of the same value? + if (V1 == V2) return MustAlias; + + if (!isa(V1->getType()) || !isa(V2->getType())) + return NoAlias; // Scalars cannot alias each other + + // Figure out what objects these things are pointing to if we can. + const Value *O1 = V1->getUnderlyingObject(); + const Value *O2 = V2->getUnderlyingObject(); + + if (O1 != O2) { + // If V1/V2 point to two different objects we know that we have no alias. + if (isIdentifiedObject(O1) && isIdentifiedObject(O2)) + return NoAlias; + + // Arguments can't alias with local allocations or noalias calls. + if ((isa(O1) && (isa(O2) || isNoAliasCall(O2))) || + (isa(O2) && (isa(O1) || isNoAliasCall(O1)))) + return NoAlias; + + // Most objects can't alias null. + if ((isa(V2) && isKnownNonNull(O1)) || + (isa(V1) && isKnownNonNull(O2))) + return NoAlias; + } + + // If the size of one access is larger than the entire object on the other + // side, then we know such behavior is undefined and can assume no alias. + LLVMContext &Context = V1->getContext(); + if (TD) + if ((V1Size != ~0U && isObjectSmallerThan(O2, V1Size, Context, *TD)) || + (V2Size != ~0U && isObjectSmallerThan(O1, V2Size, Context, *TD))) + return NoAlias; + + // If one pointer is the result of a call/invoke and the other is a + // non-escaping local object, then we know the object couldn't escape to a + // point where the call could return it. + if ((isa(O1) || isa(O1)) && + isNonEscapingLocalObject(O2) && O1 != O2) + return NoAlias; + if ((isa(O2) || isa(O2)) && + isNonEscapingLocalObject(O1) && O1 != O2) + return NoAlias; + + if (!isGEP(V1) && isGEP(V2)) { + std::swap(V1, V2); + std::swap(V1Size, V2Size); + } + if (isGEP(V1)) + return aliasGEP(V1, V1Size, V2, V2Size); return MayAlias; } From devang.patel at gmail.com Tue Oct 13 13:46:49 2009 From: devang.patel at gmail.com (Devang Patel) Date: Tue, 13 Oct 2009 11:46:49 -0700 Subject: [llvm-commits] [llvm] r83998 - in /llvm/trunk: include/llvm/Analysis/InlineCost.h include/llvm/Transforms/Utils/BasicInliner.h include/llvm/Transforms/Utils/InlineCost.h lib/Analysis/InlineCost.cpp lib/Transforms/IPO/InlineAlways.cpp lib/Transfor Message-ID: <352a1fb20910131146tca5d08ak45c7b95fc511d15f@mail.gmail.com> On Tue, Oct 13, 2009 at 11:30 AM, Dan Gohman wrote: > Author: djg > Date: Tue Oct 13 13:30:07 2009 > New Revision: 83998 > > URL: http://llvm.org/viewvc/llvm-project?rev=83998&view=rev > Log: > Move the InlineCost code from Transforms/Utils to Analysis. Thanks Dan! I'd rename this as CodeSizeEstimate or something like that because we intend to use it to estimate code size for loop transformations e.g. loop rotate, loop unswitch etc.. > > Added: > ? ?llvm/trunk/include/llvm/Analysis/InlineCost.h > ? ? ?- copied, changed from r83997, llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h > ? ?llvm/trunk/lib/Analysis/InlineCost.cpp > ? ? ?- copied, changed from r83997, llvm/trunk/lib/Transforms/Utils/InlineCost.cpp > Removed: > ? ?llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h > Modified: > ? ?llvm/trunk/include/llvm/Transforms/Utils/BasicInliner.h > ? ?llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp > ? ?llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp > ? ?llvm/trunk/lib/Transforms/IPO/Inliner.cpp > > Copied: llvm/trunk/include/llvm/Analysis/InlineCost.h (from r83997, llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h) > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InlineCost.h?p2=llvm/trunk/include/llvm/Analysis/InlineCost.h&p1=llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h&r1=83997&r2=83998&rev=83998&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h (original) > +++ llvm/trunk/include/llvm/Analysis/InlineCost.h Tue Oct 13 13:30:07 2009 > @@ -11,8 +11,8 @@ > ?// > ?//===----------------------------------------------------------------------===// > > -#ifndef LLVM_TRANSFORMS_UTILS_INLINECOST_H > -#define LLVM_TRANSFORMS_UTILS_INLINECOST_H > +#ifndef LLVM_ANALYSIS_INLINECOST_H > +#define LLVM_ANALYSIS_INLINECOST_H > > ?#include > ?#include > > Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicInliner.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BasicInliner.h?rev=83998&r1=83997&r2=83998&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Transforms/Utils/BasicInliner.h (original) > +++ llvm/trunk/include/llvm/Transforms/Utils/BasicInliner.h Tue Oct 13 13:30:07 2009 > @@ -15,7 +15,7 @@ > ?#ifndef BASICINLINER_H > ?#define BASICINLINER_H > > -#include "llvm/Transforms/Utils/InlineCost.h" > +#include "llvm/Analysis/InlineCost.h" > > ?namespace llvm { > > > Removed: llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h?rev=83997&view=auto > > ============================================================================== > --- llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h (original) > +++ llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h (removed) > @@ -1,172 +0,0 @@ > -//===- InlineCost.cpp - Cost analysis for inliner ---------------*- C++ -*-===// > -// > -// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure > -// > -// This file is distributed under the University of Illinois Open Source > -// License. See LICENSE.TXT for details. > -// > -//===----------------------------------------------------------------------===// > -// > -// This file implements heuristics for inlining decisions. > -// > -//===----------------------------------------------------------------------===// > - > -#ifndef LLVM_TRANSFORMS_UTILS_INLINECOST_H > -#define LLVM_TRANSFORMS_UTILS_INLINECOST_H > - > -#include > -#include > -#include > -#include > - > -namespace llvm { > - > - ?class Value; > - ?class Function; > - ?class BasicBlock; > - ?class CallSite; > - ?template > - ?class SmallPtrSet; > - > - ?namespace InlineConstants { > - ? ?// Various magic constants used to adjust heuristics. > - ? ?const int CallPenalty = 5; > - ? ?const int LastCallToStaticBonus = -15000; > - ? ?const int ColdccPenalty = 2000; > - ? ?const int NoreturnPenalty = 10000; > - ?} > - > - ?/// InlineCost - Represent the cost of inlining a function. This > - ?/// supports special values for functions which should "always" or > - ?/// "never" be inlined. Otherwise, the cost represents a unitless > - ?/// amount; smaller values increase the likelyhood of the function > - ?/// being inlined. > - ?class InlineCost { > - ? ?enum Kind { > - ? ? ?Value, > - ? ? ?Always, > - ? ? ?Never > - ? ?}; > - > - ? ?// This is a do-it-yourself implementation of > - ? ?// ? int Cost : 30; > - ? ?// ? unsigned Type : 2; > - ? ?// We used to use bitfields, but they were sometimes miscompiled (PR3822). > - ? ?enum { TYPE_BITS = 2 }; > - ? ?enum { COST_BITS = unsigned(sizeof(unsigned)) * CHAR_BIT - TYPE_BITS }; > - ? ?unsigned TypedCost; // int Cost : COST_BITS; unsigned Type : TYPE_BITS; > - > - ? ?Kind getType() const { > - ? ? ?return Kind(TypedCost >> COST_BITS); > - ? ?} > - > - ? ?int getCost() const { > - ? ? ?// Sign-extend the bottom COST_BITS bits. > - ? ? ?return (int(TypedCost << TYPE_BITS)) >> TYPE_BITS; > - ? ?} > - > - ? ?InlineCost(int C, int T) { > - ? ? ?TypedCost = (unsigned(C << TYPE_BITS) >> TYPE_BITS) | (T << COST_BITS); > - ? ? ?assert(getCost() == C && "Cost exceeds InlineCost precision"); > - ? ?} > - ?public: > - ? ?static InlineCost get(int Cost) { return InlineCost(Cost, Value); } > - ? ?static InlineCost getAlways() { return InlineCost(0, Always); } > - ? ?static InlineCost getNever() { return InlineCost(0, Never); } > - > - ? ?bool isVariable() const { return getType() == Value; } > - ? ?bool isAlways() const { return getType() == Always; } > - ? ?bool isNever() const { return getType() == Never; } > - > - ? ?/// getValue() - Return a "variable" inline cost's amount. It is > - ? ?/// an error to call this on an "always" or "never" InlineCost. > - ? ?int getValue() const { > - ? ? ?assert(getType() == Value && "Invalid access of InlineCost"); > - ? ? ?return getCost(); > - ? ?} > - ?}; > - > - ?/// InlineCostAnalyzer - Cost analyzer used by inliner. > - ?class InlineCostAnalyzer { > - ? ?struct ArgInfo { > - ? ?public: > - ? ? ?unsigned ConstantWeight; > - ? ? ?unsigned AllocaWeight; > - > - ? ? ?ArgInfo(unsigned CWeight, unsigned AWeight) > - ? ? ? ?: ConstantWeight(CWeight), AllocaWeight(AWeight) {} > - ? ?}; > - > - ? ?// RegionInfo - Calculate size and a few related metrics for a set of > - ? ?// basic blocks. > - ? ?struct RegionInfo { > - ? ? ?/// NeverInline - True if this callee should never be inlined into a > - ? ? ?/// caller. > - ? ? ?bool NeverInline; > - > - ? ? ?/// usesDynamicAlloca - True if this function calls alloca (in the C sense). > - ? ? ?bool usesDynamicAlloca; > - > - ? ? ?/// NumInsts, NumBlocks - Keep track of how large each function is, which > - ? ? ?/// is used to estimate the code size cost of inlining it. > - ? ? ?unsigned NumInsts, NumBlocks; > - > - ? ? ?/// NumVectorInsts - Keep track of how many instructions produce vector > - ? ? ?/// values. ?The inliner is being more aggressive with inlining vector > - ? ? ?/// kernels. > - ? ? ?unsigned NumVectorInsts; > - > - ? ? ?/// NumRets - Keep track of how many Ret instructions the block contains. > - ? ? ?unsigned NumRets; > - > - ? ? ?/// ArgumentWeights - Each formal argument of the function is inspected to > - ? ? ?/// see if it is used in any contexts where making it a constant or alloca > - ? ? ?/// would reduce the code size. ?If so, we add some value to the argument > - ? ? ?/// entry here. > - ? ? ?std::vector ArgumentWeights; > - > - ? ? ?RegionInfo() : NeverInline(false), usesDynamicAlloca(false), NumInsts(0), > - ? ? ? ? ? ? ? ? ? ? NumBlocks(0), NumVectorInsts(0), NumRets(0) {} > - > - ? ? ?/// analyzeBasicBlock - Add information about the specified basic block > - ? ? ?/// to the current structure. > - ? ? ?void analyzeBasicBlock(const BasicBlock *BB); > - > - ? ? ?/// analyzeFunction - Add information about the specified function > - ? ? ?/// to the current structure. > - ? ? ?void analyzeFunction(Function *F); > - > - ? ? ?/// CountCodeReductionForConstant - Figure out an approximation for how > - ? ? ?/// many instructions will be constant folded if the specified value is > - ? ? ?/// constant. > - ? ? ?unsigned CountCodeReductionForConstant(Value *V); > - > - ? ? ?/// CountCodeReductionForAlloca - Figure out an approximation of how much > - ? ? ?/// smaller the function will be if it is inlined into a context where an > - ? ? ?/// argument becomes an alloca. > - ? ? ?/// > - ? ? ?unsigned CountCodeReductionForAlloca(Value *V); > - ? ?}; > - > - ? ?std::map CachedFunctionInfo; > - > - ?public: > - > - ? ?/// getInlineCost - The heuristic used to determine if we should inline the > - ? ?/// function call or not. > - ? ?/// > - ? ?InlineCost getInlineCost(CallSite CS, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? SmallPtrSet &NeverInline); > - > - ? ?/// getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a > - ? ?/// higher threshold to determine if the function call should be inlined. > - ? ?float getInlineFudgeFactor(CallSite CS); > - > - ? ?/// resetCachedFunctionInfo - erase any cached cost info for this function. > - ? ?void resetCachedCostInfo(Function* Caller) { > - ? ? ?CachedFunctionInfo[Caller].NumBlocks = 0; > - ? ?} > - ?}; > -} > - > -#endif > > Copied: llvm/trunk/lib/Analysis/InlineCost.cpp (from r83997, llvm/trunk/lib/Transforms/Utils/InlineCost.cpp) > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?p2=llvm/trunk/lib/Analysis/InlineCost.cpp&p1=llvm/trunk/lib/Transforms/Utils/InlineCost.cpp&r1=83997&r2=83998&rev=83998&view=diff > > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original) > +++ llvm/trunk/lib/Analysis/InlineCost.cpp Tue Oct 13 13:30:07 2009 > @@ -11,7 +11,7 @@ > ?// > ?//===----------------------------------------------------------------------===// > > -#include "llvm/Transforms/Utils/InlineCost.h" > +#include "llvm/Analysis/InlineCost.h" > ?#include "llvm/Support/CallSite.h" > ?#include "llvm/CallingConv.h" > ?#include "llvm/IntrinsicInst.h" > > Modified: llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp?rev=83998&r1=83997&r2=83998&view=diff > > ============================================================================== > --- llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp Tue Oct 13 13:30:07 2009 > @@ -19,11 +19,11 @@ > ?#include "llvm/Module.h" > ?#include "llvm/Type.h" > ?#include "llvm/Analysis/CallGraph.h" > +#include "llvm/Analysis/InlineCost.h" > ?#include "llvm/Support/CallSite.h" > ?#include "llvm/Support/Compiler.h" > ?#include "llvm/Transforms/IPO.h" > ?#include "llvm/Transforms/IPO/InlinerPass.h" > -#include "llvm/Transforms/Utils/InlineCost.h" > ?#include "llvm/ADT/SmallPtrSet.h" > > ?using namespace llvm; > > Modified: llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp?rev=83998&r1=83997&r2=83998&view=diff > > ============================================================================== > --- llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp Tue Oct 13 13:30:07 2009 > @@ -18,11 +18,11 @@ > ?#include "llvm/Module.h" > ?#include "llvm/Type.h" > ?#include "llvm/Analysis/CallGraph.h" > +#include "llvm/Analysis/InlineCost.h" > ?#include "llvm/Support/CallSite.h" > ?#include "llvm/Support/Compiler.h" > ?#include "llvm/Transforms/IPO.h" > ?#include "llvm/Transforms/IPO/InlinerPass.h" > -#include "llvm/Transforms/Utils/InlineCost.h" > ?#include "llvm/ADT/SmallPtrSet.h" > > ?using namespace llvm; > > Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=83998&r1=83997&r2=83998&view=diff > > ============================================================================== > --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Tue Oct 13 13:30:07 2009 > @@ -18,10 +18,10 @@ > ?#include "llvm/Instructions.h" > ?#include "llvm/IntrinsicInst.h" > ?#include "llvm/Analysis/CallGraph.h" > +#include "llvm/Analysis/InlineCost.h" > ?#include "llvm/Support/CallSite.h" > ?#include "llvm/Target/TargetData.h" > ?#include "llvm/Transforms/IPO/InlinerPass.h" > -#include "llvm/Transforms/Utils/InlineCost.h" > ?#include "llvm/Transforms/Utils/Cloning.h" > ?#include "llvm/Support/CommandLine.h" > ?#include "llvm/Support/Debug.h" > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- - Devang From kremenek at apple.com Tue Oct 13 13:48:07 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 13 Oct 2009 18:48:07 -0000 Subject: [llvm-commits] [llvm] r84001 - /llvm/trunk/lib/Transforms/Utils/CMakeLists.txt Message-ID: <200910131848.n9DIm7qq015103@zion.cs.uiuc.edu> Author: kremenek Date: Tue Oct 13 13:48:07 2009 New Revision: 84001 URL: http://llvm.org/viewvc/llvm-project?rev=84001&view=rev Log: Update CMake file. Modified: llvm/trunk/lib/Transforms/Utils/CMakeLists.txt Modified: llvm/trunk/lib/Transforms/Utils/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CMakeLists.txt?rev=84001&r1=84000&r2=84001&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CMakeLists.txt (original) +++ llvm/trunk/lib/Transforms/Utils/CMakeLists.txt Tue Oct 13 13:48:07 2009 @@ -8,7 +8,6 @@ CloneModule.cpp CodeExtractor.cpp DemoteRegToStack.cpp - InlineCost.cpp InlineFunction.cpp InstructionNamer.cpp LCSSA.cpp From dpatel at apple.com Tue Oct 13 13:49:55 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 18:49:55 -0000 Subject: [llvm-commits] [llvm] r84002 - /llvm/trunk/lib/AsmParser/LLParser.cpp Message-ID: <200910131849.n9DIntDP015161@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 13:49:55 2009 New Revision: 84002 URL: http://llvm.org/viewvc/llvm-project?rev=84002&view=rev Log: Parse GEP with attached custom metadata. This happens during libprofile_rt.bca build. Modified: llvm/trunk/lib/AsmParser/LLParser.cpp Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=84002&r1=84001&r2=84002&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Oct 13 13:49:55 2009 @@ -3554,11 +3554,15 @@ SmallVector Indices; while (EatIfPresent(lltok::comma)) { + if (Lex.getKind() == lltok::NamedOrCustomMD) + break; if (ParseTypeAndValue(Val, EltLoc, PFS)) return true; if (!isa(Val->getType())) return Error(EltLoc, "getelementptr index must be an integer"); Indices.push_back(Val); } + if (Lex.getKind() == lltok::NamedOrCustomMD) + if (ParseOptionalCustomMetadata()) return true; if (!GetElementPtrInst::getIndexedType(Ptr->getType(), Indices.begin(), Indices.end())) From benny.kra at googlemail.com Tue Oct 13 13:50:54 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 13 Oct 2009 18:50:54 -0000 Subject: [llvm-commits] [llvm] r84003 - /llvm/trunk/lib/Analysis/CMakeLists.txt Message-ID: <200910131850.n9DIosTr015214@zion.cs.uiuc.edu> Author: d0k Date: Tue Oct 13 13:50:54 2009 New Revision: 84003 URL: http://llvm.org/viewvc/llvm-project?rev=84003&view=rev Log: Update the other CMake file. Modified: llvm/trunk/lib/Analysis/CMakeLists.txt Modified: llvm/trunk/lib/Analysis/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CMakeLists.txt?rev=84003&r1=84002&r2=84003&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/CMakeLists.txt (original) +++ llvm/trunk/lib/Analysis/CMakeLists.txt Tue Oct 13 13:50:54 2009 @@ -12,6 +12,7 @@ DbgInfoPrinter.cpp DebugInfo.cpp IVUsers.cpp + InlineCost.cpp InstCount.cpp Interval.cpp IntervalPartition.cpp From dpatel at apple.com Tue Oct 13 13:51:03 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 18:51:03 -0000 Subject: [llvm-commits] [llvm] r84004 - /llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Message-ID: <200910131851.n9DIp3FC015234@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 13:51:03 2009 New Revision: 84004 URL: http://llvm.org/viewvc/llvm-project?rev=84004&view=rev Log: Remove unnecessary assert. Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=84004&r1=84003&r2=84004&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Oct 13 13:51:03 2009 @@ -840,9 +840,6 @@ for (unsigned i = 1; i != RecordLength; ++i) Name[i-1] = Record[i]; MetadataContext &TheMetadata = Context.getMetadata(); - assert(TheMetadata.MDHandlerNames.find(Name.str()) - == TheMetadata.MDHandlerNames.end() && - "Already registered MDKind!"); TheMetadata.MDHandlerNames[Name.str()] = Kind; break; } From dpatel at apple.com Tue Oct 13 13:51:28 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 18:51:28 -0000 Subject: [llvm-commits] [llvm] r84006 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Message-ID: <200910131851.n9DIpShY015276@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 13:51:28 2009 New Revision: 84006 URL: http://llvm.org/viewvc/llvm-project?rev=84006&view=rev Log: Do not write empty METADATA_ATTACHMENT record. Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=84006&r1=84005&r2=84006&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Oct 13 13:51:28 2009 @@ -580,12 +580,14 @@ Record.push_back(VE.getValueID(ND)); } } - if (!StartedMetadataBlock) { - Stream.EnterSubblock(bitc::METADATA_ATTACHMENT_ID, 3); - StartedMetadataBlock = true; + if (!Record.empty()) { + if (!StartedMetadataBlock) { + Stream.EnterSubblock(bitc::METADATA_ATTACHMENT_ID, 3); + StartedMetadataBlock = true; + } + Stream.EmitRecord(bitc::METADATA_ATTACHMENT, Record, 0); + Record.clear(); } - Stream.EmitRecord(bitc::METADATA_ATTACHMENT, Record, 0); - Record.clear(); } if (StartedMetadataBlock) From kremenek at apple.com Tue Oct 13 13:57:27 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 13 Oct 2009 18:57:27 -0000 Subject: [llvm-commits] [llvm] r84008 - /llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt Message-ID: <200910131857.n9DIvRgx015504@zion.cs.uiuc.edu> Author: kremenek Date: Tue Oct 13 13:57:27 2009 New Revision: 84008 URL: http://llvm.org/viewvc/llvm-project?rev=84008&view=rev Log: Update CMake file (lexically order files). Modified: llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt Modified: llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt?rev=84008&r1=84007&r2=84008&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt Tue Oct 13 13:57:27 2009 @@ -1,8 +1,8 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) add_llvm_library(LLVMX86AsmPrinter - X86AsmPrinter.cpp X86ATTInstPrinter.cpp + X86AsmPrinter.cpp X86IntelInstPrinter.cpp X86MCInstLower.cpp ) From deeppatel1987 at gmail.com Tue Oct 13 13:59:49 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Tue, 13 Oct 2009 18:59:49 -0000 Subject: [llvm-commits] [llvm] r84009 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/sbfx.ll Message-ID: <200910131859.n9DIxnS6015673@zion.cs.uiuc.edu> Author: sandeep Date: Tue Oct 13 13:59:48 2009 New Revision: 84009 URL: http://llvm.org/viewvc/llvm-project?rev=84009&view=rev Log: Add ARMv6T2 SBFX/UBFX instructions. Approved by Anton Korobeynikov. Added: llvm/trunk/test/CodeGen/ARM/sbfx.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84009&r1=84008&r2=84009&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue Oct 13 13:59:48 2009 @@ -126,6 +126,9 @@ /// SelectDYN_ALLOC - Select dynamic alloc for Thumb. SDNode *SelectDYN_ALLOC(SDValue Op); + /// SelectV6T2BitfielsOp - Select SBFX/UBFX instructions for ARM. + SDNode *SelectV6T2BitfieldExtractOp(SDValue Op, unsigned Opc); + /// SelectInlineAsmMemoryOperand - Implement addressing mode selection for /// inline asm expressions. virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, @@ -138,6 +141,31 @@ }; } +/// isInt32Immediate - This method tests to see if the node is a 32-bit constant +/// operand. If so Imm will receive the 32-bit value. +static bool isInt32Immediate(SDNode *N, unsigned &Imm) { + if (N->getOpcode() == ISD::Constant && N->getValueType(0) == MVT::i32) { + Imm = cast(N)->getZExtValue(); + return true; + } + return false; +} + +// isInt32Immediate - This method tests to see if a constant operand. +// If so Imm will receive the 32 bit value. +static bool isInt32Immediate(SDValue N, unsigned &Imm) { + return isInt32Immediate(N.getNode(), Imm); +} + +// isOpcWithIntImmediate - This method tests to see if the node is a specific +// opcode and that it has a immediate integer right operand. +// If so Imm will receive the 32 bit value. +static bool isOpcWithIntImmediate(SDNode *N, unsigned Opc, unsigned& Imm) { + return N->getOpcode() == Opc && + isInt32Immediate(N->getOperand(1).getNode(), Imm); +} + + void ARMDAGToDAGISel::InstructionSelect() { DEBUG(BB->dump()); @@ -942,6 +970,32 @@ VT, SDValue(Pair, 0), V1, SubReg1); } +SDNode *ARMDAGToDAGISel::SelectV6T2BitfieldExtractOp(SDValue Op, + unsigned Opc) { + if (!Subtarget->hasV6T2Ops()) + return NULL; + + unsigned Shl_imm = 0; + if (isOpcWithIntImmediate(Op.getOperand(0).getNode(), ISD::SHL, Shl_imm)){ + assert(Shl_imm > 0 && Shl_imm < 32 && "bad amount in shift node!"); + unsigned Srl_imm = 0; + if (isInt32Immediate(Op.getOperand(1), Srl_imm)) { + assert(Srl_imm > 0 && Srl_imm < 32 && "bad amount in shift node!"); + unsigned Width = 32 - Srl_imm; + int LSB = Srl_imm - Shl_imm; + if ((LSB + Width) > 32) + return NULL; + SDValue Reg0 = CurDAG->getRegister(0, MVT::i32); + SDValue Ops[] = { Op.getOperand(0).getOperand(0), + CurDAG->getTargetConstant(LSB, MVT::i32), + CurDAG->getTargetConstant(Width, MVT::i32), + getAL(CurDAG), Reg0 }; + return CurDAG->SelectNodeTo(Op.getNode(), Opc, MVT::i32, Ops, 5); + } + } + return NULL; +} + SDNode *ARMDAGToDAGISel::Select(SDValue Op) { SDNode *N = Op.getNode(); DebugLoc dl = N->getDebugLoc(); @@ -1019,6 +1073,16 @@ } case ARMISD::DYN_ALLOC: return SelectDYN_ALLOC(Op); + case ISD::SRL: + if (SDNode *I = SelectV6T2BitfieldExtractOp(Op, + Subtarget->isThumb() ? ARM::t2UBFX : ARM::UBFX)) + return I; + break; + case ISD::SRA: + if (SDNode *I = SelectV6T2BitfieldExtractOp(Op, + Subtarget->isThumb() ? ARM::t2SBFX : ARM::SBFX)) + return I; + break; case ISD::MUL: if (Subtarget->isThumb1Only()) break; Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=84009&r1=84008&r2=84009&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Oct 13 13:59:48 2009 @@ -284,6 +284,10 @@ return CurDAG->getTargetConstant(V, MVT::i32); }]>; +/// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31]. +def imm0_31 : Operand, PatLeaf<(imm), [{ + return (int32_t)N->getZExtValue() < 32; +}]>; // Define ARM specific addressing modes. @@ -1014,6 +1018,24 @@ // TODO: UXT(A){B|H}16 +def SBFX : I<(outs GPR:$dst), + (ins GPR:$src, imm0_31:$lsb, imm0_31:$width), + AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi, + "sbfx", " $dst, $src, $lsb, $width", "", []>, + Requires<[IsARM, HasV6T2]> { + let Inst{27-21} = 0b0111101; + let Inst{6-4} = 0b101; +} + +def UBFX : I<(outs GPR:$dst), + (ins GPR:$src, imm0_31:$lsb, imm0_31:$width), + AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi, + "ubfx", " $dst, $src, $lsb, $width", "", []>, + Requires<[IsARM, HasV6T2]> { + let Inst{27-21} = 0b0111111; + let Inst{6-4} = 0b101; +} + //===----------------------------------------------------------------------===// // Arithmetic Instructions. // Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=84009&r1=84008&r2=84009&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Oct 13 13:59:48 2009 @@ -767,6 +767,12 @@ IIC_iALUi, "bfc", " $dst, $imm", [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>; +def t2SBFX : T2I<(outs GPR:$dst), (ins GPR:$src, imm0_31:$lsb, imm0_31:$width), + IIC_iALUi, "sbfx", " $dst, $src, $lsb, $width", []>; + +def t2UBFX : T2I<(outs GPR:$dst), (ins GPR:$src, imm0_31:$lsb, imm0_31:$width), + IIC_iALUi, "ubfx", " $dst, $src, $lsb, $width", []>; + // FIXME: A8.6.18 BFI - Bitfield insert (Encoding T1) defm t2ORN : T2I_bin_irs<"orn", BinOpFrag<(or node:$LHS, (not node:$RHS))>>; Added: llvm/trunk/test/CodeGen/ARM/sbfx.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/sbfx.ll?rev=84009&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/sbfx.ll (added) +++ llvm/trunk/test/CodeGen/ARM/sbfx.ll Tue Oct 13 13:59:48 2009 @@ -0,0 +1,37 @@ +; RUN: llc < %s -march=arm -mattr=+v6t2 | FileCheck %s + +define i32 @f1(i32 %a) { +entry: +; CHECK: f1: +; CHECK: sbfx r0, r0, #0, #20 + %tmp = shl i32 %a, 12 + %tmp2 = ashr i32 %tmp, 12 + ret i32 %tmp2 +} + +define i32 @f2(i32 %a) { +entry: +; CHECK: f2: +; CHECK: ubfx r0, r0, #0, #20 + %tmp = shl i32 %a, 12 + %tmp2 = lshr i32 %tmp, 12 + ret i32 %tmp2 +} + +define i32 @f3(i32 %a) { +entry: +; CHECK: f3: +; CHECK: sbfx r0, r0, #5, #3 + %tmp = shl i32 %a, 24 + %tmp2 = ashr i32 %tmp, 29 + ret i32 %tmp2 +} + +define i32 @f4(i32 %a) { +entry: +; CHECK: f4: +; CHECK: ubfx r0, r0, #5, #3 + %tmp = shl i32 %a, 24 + %tmp2 = lshr i32 %tmp, 29 + ret i32 %tmp2 +} From kremenek at apple.com Tue Oct 13 14:08:11 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 13 Oct 2009 19:08:11 -0000 Subject: [llvm-commits] [llvm] r84010 - in /llvm/trunk/include/llvm/ADT: ImmutableMap.h ImmutableSet.h Message-ID: <200910131908.n9DJ8BkN016022@zion.cs.uiuc.edu> Author: kremenek Date: Tue Oct 13 14:08:10 2009 New Revision: 84010 URL: http://llvm.org/viewvc/llvm-project?rev=84010&view=rev Log: Provide a mode for ImmutableMap/ImmutableSet to not automatically canonicalize the internal functional AVL trees. This should speedup clients that use ImmutableMap/ImmutableSet but don't require fast comparisons of maps. Modified: llvm/trunk/include/llvm/ADT/ImmutableMap.h llvm/trunk/include/llvm/ADT/ImmutableSet.h Modified: llvm/trunk/include/llvm/ADT/ImmutableMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableMap.h?rev=84010&r1=84009&r2=84010&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/ImmutableMap.h (original) +++ llvm/trunk/include/llvm/ADT/ImmutableMap.h Tue Oct 13 14:08:10 2009 @@ -80,23 +80,25 @@ class Factory { typename TreeTy::Factory F; + const bool Canonicalize; public: - Factory() {} - - Factory(BumpPtrAllocator& Alloc) - : F(Alloc) {} + Factory(bool canonicalize = true) + : Canonicalize(canonicalize) {} + + Factory(BumpPtrAllocator& Alloc, bool canonicalize = true) + : F(Alloc), Canonicalize(canonicalize) {} ImmutableMap GetEmptyMap() { return ImmutableMap(F.GetEmptyTree()); } ImmutableMap Add(ImmutableMap Old, key_type_ref K, data_type_ref D) { TreeTy *T = F.Add(Old.Root, std::make_pair(K,D)); - return ImmutableMap(F.GetCanonicalTree(T)); + return ImmutableMap(Canonicalize ? F.GetCanonicalTree(T): T); } ImmutableMap Remove(ImmutableMap Old, key_type_ref K) { TreeTy *T = F.Remove(Old.Root,K); - return ImmutableMap(F.GetCanonicalTree(T)); + return ImmutableMap(Canonicalize ? F.GetCanonicalTree(T): T); } private: Modified: llvm/trunk/include/llvm/ADT/ImmutableSet.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableSet.h?rev=84010&r1=84009&r2=84010&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/ImmutableSet.h (original) +++ llvm/trunk/include/llvm/ADT/ImmutableSet.h Tue Oct 13 14:08:10 2009 @@ -947,15 +947,19 @@ class Factory { typename TreeTy::Factory F; + const bool Canonicalize; public: - Factory() {} + Factory(bool canonicalize = true) + : Canonicalize(canonicalize) {} - Factory(BumpPtrAllocator& Alloc) - : F(Alloc) {} + Factory(BumpPtrAllocator& Alloc, bool canonicalize = true) + : F(Alloc), Canonicalize(canonicalize) {} /// GetEmptySet - Returns an immutable set that contains no elements. - ImmutableSet GetEmptySet() { return ImmutableSet(F.GetEmptyTree()); } + ImmutableSet GetEmptySet() { + return ImmutableSet(F.GetEmptyTree()); + } /// Add - Creates a new immutable set that contains all of the values /// of the original set with the addition of the specified value. If @@ -965,7 +969,8 @@ /// The memory allocated to represent the set is released when the /// factory object that created the set is destroyed. ImmutableSet Add(ImmutableSet Old, value_type_ref V) { - return ImmutableSet(F.GetCanonicalTree(F.Add(Old.Root,V))); + TreeTy *NewT = F.Add(Old.Root, V); + return ImmutableSet(Canonicalize ? F.GetCanonicalTree(NewT) : NewT); } /// Remove - Creates a new immutable set that contains all of the values @@ -976,7 +981,8 @@ /// The memory allocated to represent the set is released when the /// factory object that created the set is destroyed. ImmutableSet Remove(ImmutableSet Old, value_type_ref V) { - return ImmutableSet(F.GetCanonicalTree(F.Remove(Old.Root,V))); + TreeTy *NewT = F.Remove(Old.Root, V); + return ImmutableSet(Canonicalize ? F.GetCanonicalTree(NewT) : NewT); } BumpPtrAllocator& getAllocator() { return F.getAllocator(); } From david_goodwin at apple.com Tue Oct 13 14:16:03 2009 From: david_goodwin at apple.com (David Goodwin) Date: Tue, 13 Oct 2009 19:16:03 -0000 Subject: [llvm-commits] [llvm] r84011 - /llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Message-ID: <200910131916.n9DJG3bU016379@zion.cs.uiuc.edu> Author: david_goodwin Date: Tue Oct 13 14:16:03 2009 New Revision: 84011 URL: http://llvm.org/viewvc/llvm-project?rev=84011&view=rev Log: Add debugging output. Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=84011&r1=84010&r2=84011&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Tue Oct 13 14:16:03 2009 @@ -643,8 +643,18 @@ Max = SU; } - DEBUG(errs() << "Critical path has total latency " - << (Max->getDepth() + Max->Latency) << "\n"); +#ifndef NDEBUG + { + DEBUG(errs() << "Critical path has total latency " + << (Max->getDepth() + Max->Latency) << "\n"); + DEBUG(errs() << "Available regs:"); + for (unsigned Reg = 0; Reg < TRI->getNumRegs(); ++Reg) { + if (KillIndices[Reg] == ~0u) + DEBUG(errs() << " " << TRI->getName(Reg)); + } + DEBUG(errs() << '\n'); + } +#endif // Track progress along the critical path through the SUnit graph as we walk // the instructions. From gohman at apple.com Tue Oct 13 14:58:08 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 13 Oct 2009 19:58:08 -0000 Subject: [llvm-commits] [llvm] r84013 - in /llvm/trunk: include/llvm/Analysis/InlineCost.h lib/Analysis/InlineCost.cpp Message-ID: <200910131958.n9DJw8Gk017817@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 14:58:07 2009 New Revision: 84013 URL: http://llvm.org/viewvc/llvm-project?rev=84013&view=rev Log: Split code not specific to Function inlining out into a separate class, named CodeMetrics. Move it to be a non-nested class. Rename RegionInfo back to FunctionInfo. Modified: llvm/trunk/include/llvm/Analysis/InlineCost.h llvm/trunk/lib/Analysis/InlineCost.cpp Modified: llvm/trunk/include/llvm/Analysis/InlineCost.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InlineCost.h?rev=84013&r1=84012&r2=84013&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/InlineCost.h (original) +++ llvm/trunk/include/llvm/Analysis/InlineCost.h Tue Oct 13 14:58:07 2009 @@ -28,6 +28,40 @@ template class SmallPtrSet; + // CodeMetrics - Calculate size and a few similar metrics for a set of + // basic blocks. + struct CodeMetrics { + /// NeverInline - True if this callee should never be inlined into a + /// caller. + bool NeverInline; + + /// usesDynamicAlloca - True if this function calls alloca (in the C sense). + bool usesDynamicAlloca; + + /// NumInsts, NumBlocks - Keep track of how large each function is, which + /// is used to estimate the code size cost of inlining it. + unsigned NumInsts, NumBlocks; + + /// NumVectorInsts - Keep track of how many instructions produce vector + /// values. The inliner is being more aggressive with inlining vector + /// kernels. + unsigned NumVectorInsts; + + /// NumRets - Keep track of how many Ret instructions the block contains. + unsigned NumRets; + + CodeMetrics() : NeverInline(false), usesDynamicAlloca(false), NumInsts(0), + NumBlocks(0), NumVectorInsts(0), NumRets(0) {} + + /// analyzeBasicBlock - Add information about the specified basic block + /// to the current structure. + void analyzeBasicBlock(const BasicBlock *BB); + + /// analyzeFunction - Add information about the specified function + /// to the current structure. + void analyzeFunction(Function *F); + }; + namespace InlineConstants { // Various magic constants used to adjust heuristics. const int CallPenalty = 5; @@ -97,58 +131,32 @@ : ConstantWeight(CWeight), AllocaWeight(AWeight) {} }; - // RegionInfo - Calculate size and a few related metrics for a set of - // basic blocks. - struct RegionInfo { - /// NeverInline - True if this callee should never be inlined into a - /// caller. - bool NeverInline; - - /// usesDynamicAlloca - True if this function calls alloca (in the C sense). - bool usesDynamicAlloca; - - /// NumInsts, NumBlocks - Keep track of how large each function is, which - /// is used to estimate the code size cost of inlining it. - unsigned NumInsts, NumBlocks; - - /// NumVectorInsts - Keep track of how many instructions produce vector - /// values. The inliner is being more aggressive with inlining vector - /// kernels. - unsigned NumVectorInsts; - - /// NumRets - Keep track of how many Ret instructions the block contains. - unsigned NumRets; + struct FunctionInfo { + CodeMetrics Metrics; /// ArgumentWeights - Each formal argument of the function is inspected to /// see if it is used in any contexts where making it a constant or alloca /// would reduce the code size. If so, we add some value to the argument /// entry here. std::vector ArgumentWeights; - - RegionInfo() : NeverInline(false), usesDynamicAlloca(false), NumInsts(0), - NumBlocks(0), NumVectorInsts(0), NumRets(0) {} - - /// analyzeBasicBlock - Add information about the specified basic block - /// to the current structure. - void analyzeBasicBlock(const BasicBlock *BB); - - /// analyzeFunction - Add information about the specified function - /// to the current structure. - void analyzeFunction(Function *F); - + /// CountCodeReductionForConstant - Figure out an approximation for how /// many instructions will be constant folded if the specified value is /// constant. unsigned CountCodeReductionForConstant(Value *V); - + /// CountCodeReductionForAlloca - Figure out an approximation of how much /// smaller the function will be if it is inlined into a context where an /// argument becomes an alloca. /// unsigned CountCodeReductionForAlloca(Value *V); + + /// analyzeFunction - Add information about the specified function + /// to the current structure. + void analyzeFunction(Function *F); }; - std::map CachedFunctionInfo; + std::map CachedFunctionInfo; public: @@ -164,7 +172,7 @@ /// resetCachedFunctionInfo - erase any cached cost info for this function. void resetCachedCostInfo(Function* Caller) { - CachedFunctionInfo[Caller].NumBlocks = 0; + CachedFunctionInfo[Caller].Metrics.NumBlocks = 0; } }; } Modified: llvm/trunk/lib/Analysis/InlineCost.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=84013&r1=84012&r2=84013&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InlineCost.cpp (original) +++ llvm/trunk/lib/Analysis/InlineCost.cpp Tue Oct 13 14:58:07 2009 @@ -21,7 +21,7 @@ // CountCodeReductionForConstant - Figure out an approximation for how many // instructions will be constant folded if the specified value is constant. // -unsigned InlineCostAnalyzer::RegionInfo:: +unsigned InlineCostAnalyzer::FunctionInfo:: CountCodeReductionForConstant(Value *V) { unsigned Reduction = 0; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) @@ -77,7 +77,7 @@ // the function will be if it is inlined into a context where an argument // becomes an alloca. // -unsigned InlineCostAnalyzer::RegionInfo:: +unsigned InlineCostAnalyzer::FunctionInfo:: CountCodeReductionForAlloca(Value *V) { if (!isa(V->getType())) return 0; // Not a pointer unsigned Reduction = 0; @@ -101,7 +101,7 @@ /// analyzeBasicBlock - Fill in the current structure with information gleaned /// from the specified block. -void InlineCostAnalyzer::RegionInfo::analyzeBasicBlock(const BasicBlock *BB) { +void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB) { ++NumBlocks; for (BasicBlock::const_iterator II = BB->begin(), E = BB->end(); @@ -166,17 +166,22 @@ /// analyzeFunction - Fill in the current structure with information gleaned /// from the specified function. -void InlineCostAnalyzer::RegionInfo::analyzeFunction(Function *F) { - // Look at the size of the callee. Each basic block counts as 20 units, and - // each instruction counts as 5. +void CodeMetrics::analyzeFunction(Function *F) { + // Look at the size of the callee. for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) analyzeBasicBlock(&*BB); +} + +/// analyzeFunction - Fill in the current structure with information gleaned +/// from the specified function. +void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) { + Metrics.analyzeFunction(F); // A function with exactly one return has it removed during the inlining // process (see InlineFunction), so don't count it. - // FIXME: This knowledge should really be encoded outside of RegionInfo. - if (NumRets==1) - --NumInsts; + // FIXME: This knowledge should really be encoded outside of FunctionInfo. + if (Metrics.NumRets==1) + --Metrics.NumInsts; // Check out all of the arguments to the function, figuring out how much // code can be eliminated if one of the arguments is a constant. @@ -185,8 +190,6 @@ CountCodeReductionForAlloca(I))); } - - // getInlineCost - The heuristic used to determine if we should inline the // function call or not. // @@ -229,35 +232,35 @@ InlineCost += InlineConstants::NoreturnPenalty; // Get information about the callee... - RegionInfo &CalleeFI = CachedFunctionInfo[Callee]; + FunctionInfo &CalleeFI = CachedFunctionInfo[Callee]; // If we haven't calculated this information yet, do so now. - if (CalleeFI.NumBlocks == 0) + if (CalleeFI.Metrics.NumBlocks == 0) CalleeFI.analyzeFunction(Callee); // If we should never inline this, return a huge cost. - if (CalleeFI.NeverInline) + if (CalleeFI.Metrics.NeverInline) return InlineCost::getNever(); // FIXME: It would be nice to kill off CalleeFI.NeverInline. Then we - // could move this up and avoid computing the RegionInfo for + // could move this up and avoid computing the FunctionInfo for // things we are going to just return always inline for. This // requires handling setjmp somewhere else, however. if (!Callee->isDeclaration() && Callee->hasFnAttr(Attribute::AlwaysInline)) return InlineCost::getAlways(); - if (CalleeFI.usesDynamicAlloca) { + if (CalleeFI.Metrics.usesDynamicAlloca) { // Get infomation about the caller... - RegionInfo &CallerFI = CachedFunctionInfo[Caller]; + FunctionInfo &CallerFI = CachedFunctionInfo[Caller]; // If we haven't calculated this information yet, do so now. - if (CallerFI.NumBlocks == 0) + if (CallerFI.Metrics.NumBlocks == 0) CallerFI.analyzeFunction(Caller); // Don't inline a callee with dynamic alloca into a caller without them. // Functions containing dynamic alloca's are inefficient in various ways; // don't create more inefficiency. - if (!CallerFI.usesDynamicAlloca) + if (!CallerFI.Metrics.usesDynamicAlloca) return InlineCost::getNever(); } @@ -305,7 +308,7 @@ InlineCost += Caller->size()/15; // Look at the size of the callee. Each instruction counts as 5. - InlineCost += CalleeFI.NumInsts*5; + InlineCost += CalleeFI.Metrics.NumInsts*5; return llvm::InlineCost::get(InlineCost); } @@ -316,22 +319,22 @@ Function *Callee = CS.getCalledFunction(); // Get information about the callee... - RegionInfo &CalleeFI = CachedFunctionInfo[Callee]; + FunctionInfo &CalleeFI = CachedFunctionInfo[Callee]; // If we haven't calculated this information yet, do so now. - if (CalleeFI.NumBlocks == 0) + if (CalleeFI.Metrics.NumBlocks == 0) CalleeFI.analyzeFunction(Callee); float Factor = 1.0f; // Single BB functions are often written to be inlined. - if (CalleeFI.NumBlocks == 1) + if (CalleeFI.Metrics.NumBlocks == 1) Factor += 0.5f; // Be more aggressive if the function contains a good chunk (if it mades up // at least 10% of the instructions) of vector instructions. - if (CalleeFI.NumVectorInsts > CalleeFI.NumInsts/2) + if (CalleeFI.Metrics.NumVectorInsts > CalleeFI.Metrics.NumInsts/2) Factor += 2.0f; - else if (CalleeFI.NumVectorInsts > CalleeFI.NumInsts/10) + else if (CalleeFI.Metrics.NumVectorInsts > CalleeFI.Metrics.NumInsts/10) Factor += 1.5f; return Factor; } From gohman at apple.com Tue Oct 13 15:10:11 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 13 Oct 2009 20:10:11 -0000 Subject: [llvm-commits] [llvm] r84015 - /llvm/trunk/lib/Analysis/InlineCost.cpp Message-ID: <200910132010.n9DKABhd018492@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 15:10:10 2009 New Revision: 84015 URL: http://llvm.org/viewvc/llvm-project?rev=84015&view=rev Log: Compute a full cost value even when a setjmp call is found. Modified: llvm/trunk/lib/Analysis/InlineCost.cpp Modified: llvm/trunk/lib/Analysis/InlineCost.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=84015&r1=84014&r2=84015&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InlineCost.cpp (original) +++ llvm/trunk/lib/Analysis/InlineCost.cpp Tue Oct 13 15:10:10 2009 @@ -121,10 +121,8 @@ // probably won't do this in callers. if (Function *F = CS.getCalledFunction()) if (F->isDeclaration() && - (F->getName() == "setjmp" || F->getName() == "_setjmp")) { + (F->getName() == "setjmp" || F->getName() == "_setjmp")) NeverInline = true; - return; - } // Calls often compile into many machine instructions. Bump up their // cost to reflect this. From bob.wilson at apple.com Tue Oct 13 15:09:14 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 13 Oct 2009 13:09:14 -0700 Subject: [llvm-commits] [llvm] r84009 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/sbfx.ll In-Reply-To: <200910131859.n9DIxnS6015673@zion.cs.uiuc.edu> References: <200910131859.n9DIxnS6015673@zion.cs.uiuc.edu> Message-ID: Thanks, Sandeep. I have a few comments below: On Oct 13, 2009, at 11:59 AM, Sandeep Patel wrote: > --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue Oct 13 > 13:59:48 2009 > @@ -126,6 +126,9 @@ > /// SelectDYN_ALLOC - Select dynamic alloc for Thumb. > SDNode *SelectDYN_ALLOC(SDValue Op); > > + /// SelectV6T2BitfielsOp - Select SBFX/UBFX instructions for ARM. > + SDNode *SelectV6T2BitfieldExtractOp(SDValue Op, unsigned Opc); > + > The method name in the comment doesn't match the code. > +// isInt32Immediate - This method tests to see if a constant operand. > +// If so Imm will receive the 32 bit value. > +static bool isInt32Immediate(SDValue N, unsigned &Imm) { > + return isInt32Immediate(N.getNode(), Imm); > +} This is only called in one place -- wouldn't be better to just add the "getNode()" at that one call site? > + > +// isOpcWithIntImmediate - This method tests to see if the node is > a specific > +// opcode and that it has a immediate integer right operand. > +// If so Imm will receive the 32 bit value. > +static bool isOpcWithIntImmediate(SDNode *N, unsigned Opc, > unsigned& Imm) { > + return N->getOpcode() == Opc && > + isInt32Immediate(N->getOperand(1).getNode(), Imm); > +} > + > + Same thing here. I guess this is just a matter of style, but I would just put this in-line in the one place where it is used. Also, the comments for this function and the previous one are not doxygenated. From gohman at apple.com Tue Oct 13 15:12:23 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 13 Oct 2009 20:12:23 -0000 Subject: [llvm-commits] [llvm] r84016 - /llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Message-ID: <200910132012.n9DKCN2X018596@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 15:12:23 2009 New Revision: 84016 URL: http://llvm.org/viewvc/llvm-project?rev=84016&view=rev Log: Use the new CodeMetrics class to compute code size instead of manually counting instructions. Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=84016&r1=84015&r2=84016&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 15:12:23 2009 @@ -34,6 +34,7 @@ #include "llvm/Instructions.h" #include "llvm/LLVMContext.h" #include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Analysis/InlineCost.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/Dominators.h" @@ -408,15 +409,14 @@ if (IsTrivialUnswitchCondition(LIC)) return 0; - // FIXME: This is really overly conservative and brain dead. - unsigned Cost = 0; + // FIXME: This is overly conservative because it does not take into + // consideration code simplification opportunities. + CodeMetrics Metrics; for (Loop::block_iterator I = currentLoop->block_begin(), E = currentLoop->block_end(); I != E; ++I) - // Count instructions. - Cost += (*I)->size(); - - return Cost; + Metrics.analyzeBasicBlock(*I); + return Metrics.NumInsts; } /// UnswitchIfProfitable - We have found that we can unswitch currentLoop when From deeppatel1987 at gmail.com Tue Oct 13 15:25:54 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Tue, 13 Oct 2009 20:25:54 +0000 Subject: [llvm-commits] [llvm] r84009 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/sbfx.ll In-Reply-To: References: <200910131859.n9DIxnS6015673@zion.cs.uiuc.edu> Message-ID: <305d6f60910131325x6c1ecaedq41d485a9bfb1ee04@mail.gmail.com> On Tue, Oct 13, 2009 at 8:09 PM, Bob Wilson wrote: > Thanks, Sandeep. ?I have a few comments below: > > On Oct 13, 2009, at 11:59 AM, Sandeep Patel wrote: >> >> --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue Oct 13 13:59:48 2009 >> @@ -126,6 +126,9 @@ >> ?/// SelectDYN_ALLOC - Select dynamic alloc for Thumb. >> ?SDNode *SelectDYN_ALLOC(SDValue Op); >> >> + ?/// SelectV6T2BitfielsOp - Select SBFX/UBFX instructions for ARM. > >> + ?SDNode *SelectV6T2BitfieldExtractOp(SDValue Op, unsigned Opc); >> + >> > > The method name in the comment doesn't match the code. Fixed. >> +// isInt32Immediate - This method tests to see if a constant operand. >> +// If so Imm will receive the 32 bit value. >> +static bool isInt32Immediate(SDValue N, unsigned &Imm) { >> + ?return isInt32Immediate(N.getNode(), Imm); >> +} > > This is only called in one place -- wouldn't be better to just add the > "getNode()" at that one call site? > > >> + >> +// isOpcWithIntImmediate - This method tests to see if the node is a >> specific >> +// opcode and that it has a immediate integer right operand. >> +// If so Imm will receive the 32 bit value. >> +static bool isOpcWithIntImmediate(SDNode *N, unsigned Opc, unsigned& Imm) >> { >> + ?return N->getOpcode() == Opc && >> + ? ? ? ? isInt32Immediate(N->getOperand(1).getNode(), Imm); >> +} >> + >> + > > Same thing here. ?I guess this is just a matter of style, but I would just > put this in-line in the one place where it is used. ?Also, the comments for > this function and the previous one are not doxygenated. I cribbed these helpers from the PPC target. deep From deeppatel1987 at gmail.com Tue Oct 13 15:25:59 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Tue, 13 Oct 2009 20:25:59 -0000 Subject: [llvm-commits] [llvm] r84017 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <200910132025.n9DKPx7s019027@zion.cs.uiuc.edu> Author: sandeep Date: Tue Oct 13 15:25:58 2009 New Revision: 84017 URL: http://llvm.org/viewvc/llvm-project?rev=84017&view=rev Log: Fix method name in comment, per Bob Wilson. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84017&r1=84016&r2=84017&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue Oct 13 15:25:58 2009 @@ -126,7 +126,7 @@ /// SelectDYN_ALLOC - Select dynamic alloc for Thumb. SDNode *SelectDYN_ALLOC(SDValue Op); - /// SelectV6T2BitfielsOp - Select SBFX/UBFX instructions for ARM. + /// SelectV6T2BitfieldExtractOp - Select SBFX/UBFX instructions for ARM. SDNode *SelectV6T2BitfieldExtractOp(SDValue Op, unsigned Opc); /// SelectInlineAsmMemoryOperand - Implement addressing mode selection for From bob.wilson at apple.com Tue Oct 13 15:28:41 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 13 Oct 2009 13:28:41 -0700 Subject: [llvm-commits] [llvm] r84009 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/sbfx.ll In-Reply-To: <305d6f60910131325x6c1ecaedq41d485a9bfb1ee04@mail.gmail.com> References: <200910131859.n9DIxnS6015673@zion.cs.uiuc.edu> <305d6f60910131325x6c1ecaedq41d485a9bfb1ee04@mail.gmail.com> Message-ID: <0C1660E1-5386-4DB2-9C57-E8F8B20E0147@apple.com> On Oct 13, 2009, at 1:25 PM, Sandeep Patel wrote: > On Tue, Oct 13, 2009 at 8:09 PM, Bob Wilson > wrote: >> Same thing here. I guess this is just a matter of style, but I >> would just >> put this in-line in the one place where it is used. Also, the >> comments for >> this function and the previous one are not doxygenated. > > I cribbed these helpers from the PPC target. Oh, I see. But, for PPC these get called from more places.... I would still be inclined to put the code in-line, but that's pretty subjective, so I'll leave it up to you. From dpatel at apple.com Tue Oct 13 15:45:18 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 20:45:18 -0000 Subject: [llvm-commits] [llvm] r84019 - in /llvm/trunk/test: FrontendC++/2006-11-06-StackTrace.cpp FrontendC/2009-02-17-BitField-dbg.c FrontendObjC/2009-08-17-DebugInfo.m Message-ID: <200910132045.n9DKjIMr020055@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 15:45:18 2009 New Revision: 84019 URL: http://llvm.org/viewvc/llvm-project?rev=84019&view=rev Log: These tests now pass. Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-06-StackTrace.cpp?rev=84019&r1=84018&r2=84019&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp Tue Oct 13 15:45:18 2009 @@ -13,7 +13,6 @@ // Only works on ppc (but not apple-darwin9), x86 and x86_64. Should // generalize? // XFAIL: alpha|arm|powerpc-apple-darwin9 -// XFAIL: * #include Modified: llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c?rev=84019&r1=84018&r2=84019&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c (original) +++ llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c Tue Oct 13 15:45:18 2009 @@ -5,7 +5,6 @@ // RUN: echo {ptype mystruct} > %t2 // RUN: gdb -q -batch -n -x %t2 2009-02-17-BitField-dbg.o | \ // RUN: tee 2009-02-17-BitField-dbg.out | grep "int a : 4" -// XFAIL: * struct { int a:4; Modified: llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m?rev=84019&r1=84018&r2=84019&view=diff ============================================================================== --- llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m (original) +++ llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m Tue Oct 13 15:45:18 2009 @@ -6,7 +6,7 @@ // RUN: echo {break randomFunc\n} > %t.in // RUN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | \ // RUN: grep {Breakpoint 1 at 0x.*: file 2009-08-17-DebugInfo.m, line 21} -// XFAIL: * +// XTARGET: darwin @interface MyClass { int my; From dalej at apple.com Tue Oct 13 15:46:56 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 13 Oct 2009 20:46:56 -0000 Subject: [llvm-commits] [llvm] r84020 - in /llvm/trunk: include/llvm/InlineAsm.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/AsmWriter.cpp lib/VMCore/Core.cpp lib/VMCore/InlineAsm.cpp test/Assembler/msasm.ll Message-ID: <200910132046.n9DKkvKl020165@zion.cs.uiuc.edu> Author: johannes Date: Tue Oct 13 15:46:56 2009 New Revision: 84020 URL: http://llvm.org/viewvc/llvm-project?rev=84020&view=rev Log: Add an "msasm" flag to inline asm as suggested in PR 5125. A little ugliness is accepted to keep the binary file format compatible. No functional change yet. Added: llvm/trunk/test/Assembler/msasm.ll Modified: llvm/trunk/include/llvm/InlineAsm.h llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLToken.h llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/trunk/lib/VMCore/AsmWriter.cpp llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/InlineAsm.cpp Modified: llvm/trunk/include/llvm/InlineAsm.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InlineAsm.h?rev=84020&r1=84019&r2=84020&view=diff ============================================================================== --- llvm/trunk/include/llvm/InlineAsm.h (original) +++ llvm/trunk/include/llvm/InlineAsm.h Tue Oct 13 15:46:56 2009 @@ -31,18 +31,22 @@ std::string AsmString, Constraints; bool HasSideEffects; + bool IsMsAsm; InlineAsm(const FunctionType *Ty, const StringRef &AsmString, - const StringRef &Constraints, bool hasSideEffects); + const StringRef &Constraints, bool hasSideEffects, + bool isMsAsm = false); virtual ~InlineAsm(); public: /// InlineAsm::get - Return the the specified uniqued inline asm string. /// static InlineAsm *get(const FunctionType *Ty, const StringRef &AsmString, - const StringRef &Constraints, bool hasSideEffects); + const StringRef &Constraints, bool hasSideEffects, + bool isMsAsm = false); bool hasSideEffects() const { return HasSideEffects; } + bool isMsAsm() const { return IsMsAsm; } /// getType - InlineAsm's are always pointers. /// Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=84020&r1=84019&r2=84020&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Tue Oct 13 15:46:56 2009 @@ -529,6 +529,7 @@ KEYWORD(module); KEYWORD(asm); KEYWORD(sideeffect); + KEYWORD(msasm); KEYWORD(gc); KEYWORD(ccc); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=84020&r1=84019&r2=84020&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Oct 13 15:46:56 2009 @@ -1959,16 +1959,17 @@ return false; case lltok::kw_asm: { - // ValID ::= 'asm' SideEffect? STRINGCONSTANT ',' STRINGCONSTANT - bool HasSideEffect; + // ValID ::= 'asm' SideEffect? MsAsm? STRINGCONSTANT ',' STRINGCONSTANT + bool HasSideEffect, MsAsm; Lex.Lex(); if (ParseOptionalToken(lltok::kw_sideeffect, HasSideEffect) || + ParseOptionalToken(lltok::kw_msasm, MsAsm) || ParseStringConstant(ID.StrVal) || ParseToken(lltok::comma, "expected comma in inline asm expression") || ParseToken(lltok::StringConstant, "expected constraint string")) return true; ID.StrVal2 = Lex.getStrVal(); - ID.UIntVal = HasSideEffect; + ID.UIntVal = HasSideEffect | ((unsigned)MsAsm<<1); ID.Kind = ValID::t_InlineAsm; return false; } @@ -2368,7 +2369,7 @@ PTy ? dyn_cast(PTy->getElementType()) : 0; if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2)) return Error(ID.Loc, "invalid type for inline asm constraint string"); - V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal); + V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1, ID.UIntVal>>1); return false; } else if (ID.Kind == ValID::t_Metadata) { V = ID.MetadataVal; Modified: llvm/trunk/lib/AsmParser/LLToken.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=84020&r1=84019&r2=84020&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLToken.h (original) +++ llvm/trunk/lib/AsmParser/LLToken.h Tue Oct 13 15:46:56 2009 @@ -62,6 +62,7 @@ kw_module, kw_asm, kw_sideeffect, + kw_msasm, kw_gc, kw_dbg, kw_c, Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=84020&r1=84019&r2=84020&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Oct 13 15:46:56 2009 @@ -1164,7 +1164,8 @@ case bitc::CST_CODE_INLINEASM: { if (Record.size() < 2) return Error("Invalid INLINEASM record"); std::string AsmStr, ConstrStr; - bool HasSideEffects = Record[0]; + bool HasSideEffects = Record[0] & 1; + bool IsMsAsm = Record[0] >> 1; unsigned AsmStrSize = Record[1]; if (2+AsmStrSize >= Record.size()) return Error("Invalid INLINEASM record"); @@ -1178,7 +1179,7 @@ ConstrStr += (char)Record[3+AsmStrSize+i]; const PointerType *PTy = cast(CurTy); V = InlineAsm::get(cast(PTy->getElementType()), - AsmStr, ConstrStr, HasSideEffects); + AsmStr, ConstrStr, HasSideEffects, IsMsAsm); break; } } Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=84020&r1=84019&r2=84020&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Oct 13 15:46:56 2009 @@ -679,7 +679,8 @@ } if (const InlineAsm *IA = dyn_cast(V)) { - Record.push_back(unsigned(IA->hasSideEffects())); + Record.push_back(unsigned(IA->hasSideEffects()) | + unsigned(IA->isMsAsm()) << 1); // Add the asm string. const std::string &AsmStr = IA->getAsmString(); Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=84020&r1=84019&r2=84020&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Oct 13 15:46:56 2009 @@ -1206,6 +1206,8 @@ Out << "asm "; if (IA->hasSideEffects()) Out << "sideeffect "; + if (IA->isMsAsm()) + Out << "msasm "; Out << '"'; PrintEscapedString(IA->getAsmString(), Out); Out << "\", \""; Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=84020&r1=84019&r2=84020&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Tue Oct 13 15:46:56 2009 @@ -884,9 +884,10 @@ } LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, - const char *Constraints, int HasSideEffects) { + const char *Constraints, int HasSideEffects, + int IsMsAsm) { return wrap(InlineAsm::get(dyn_cast(unwrap(Ty)), AsmString, - Constraints, HasSideEffects)); + Constraints, HasSideEffects, IsMsAsm)); } /*--.. Operations on global variables, functions, and aliases (globals) ....--*/ Modified: llvm/trunk/lib/VMCore/InlineAsm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/InlineAsm.cpp?rev=84020&r1=84019&r2=84020&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/InlineAsm.cpp (original) +++ llvm/trunk/lib/VMCore/InlineAsm.cpp Tue Oct 13 15:46:56 2009 @@ -27,17 +27,19 @@ // case when the type gets refined. InlineAsm *InlineAsm::get(const FunctionType *Ty, const StringRef &AsmString, - const StringRef &Constraints, bool hasSideEffects) { + const StringRef &Constraints, bool hasSideEffects, + bool isMsAsm) { // FIXME: memoize! - return new InlineAsm(Ty, AsmString, Constraints, hasSideEffects); + return new InlineAsm(Ty, AsmString, Constraints, hasSideEffects, isMsAsm); } InlineAsm::InlineAsm(const FunctionType *Ty, const StringRef &asmString, - const StringRef &constraints, bool hasSideEffects) + const StringRef &constraints, bool hasSideEffects, + bool isMsAsm) : Value(PointerType::getUnqual(Ty), Value::InlineAsmVal), AsmString(asmString), - Constraints(constraints), HasSideEffects(hasSideEffects) { + Constraints(constraints), HasSideEffects(hasSideEffects), IsMsAsm(isMsAsm) { // Do various checks on the constraint string and type. assert(Verify(Ty, constraints) && "Function type not legal for constraints!"); Added: llvm/trunk/test/Assembler/msasm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/msasm.ll?rev=84020&view=auto ============================================================================== --- llvm/trunk/test/Assembler/msasm.ll (added) +++ llvm/trunk/test/Assembler/msasm.ll Tue Oct 13 15:46:56 2009 @@ -0,0 +1,36 @@ +; RUN: llvm-as < %s | llvm-dis | FileCheck %s +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin10.0" + +define void @test1() nounwind { +; CHECK: test1 +; CHECK: sideeffect +; CHECK-NOT: msasm + tail call void asm sideeffect "mov", "~{dirflag},~{fpsr},~{flags}"() nounwind + ret void +; CHECK: ret +} +define void @test2() nounwind { +; CHECK: test2 +; CHECK: sideeffect +; CHECK: msasm + tail call void asm sideeffect msasm "mov", "~{dirflag},~{fpsr},~{flags}"() nounwind + ret void +; CHECK: ret +} +define void @test3() nounwind { +; CHECK: test3 +; CHECK-NOT: sideeffect +; CHECK: msasm + tail call void asm msasm "mov", "~{dirflag},~{fpsr},~{flags}"() nounwind + ret void +; CHECK: ret +} +define void @test4() nounwind { +; CHECK: test4 +; CHECK-NOT: sideeffect +; CHECK-NOT: msasm + tail call void asm "mov", "~{dirflag},~{fpsr},~{flags}"() nounwind + ret void +; CHECK: ret +} From bob.wilson at apple.com Tue Oct 13 15:50:28 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 13 Oct 2009 20:50:28 -0000 Subject: [llvm-commits] [llvm] r84022 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll Message-ID: <200910132050.n9DKoSR7020324@zion.cs.uiuc.edu> Author: bwilson Date: Tue Oct 13 15:50:28 2009 New Revision: 84022 URL: http://llvm.org/viewvc/llvm-project?rev=84022&view=rev Log: Revise ARM inline assembly memory operands to require the memory address to be in a register. The previous use of ARM address mode 2 was completely arbitrary and inappropriate for Thumb. Radar 7137468. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84022&r1=84021&r2=84022&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue Oct 13 15:50:28 2009 @@ -2156,14 +2156,10 @@ SelectInlineAsmMemoryOperand(const SDValue &Op, char ConstraintCode, std::vector &OutOps) { assert(ConstraintCode == 'm' && "unexpected asm memory constraint"); - - SDValue Base, Offset, Opc; - if (!SelectAddrMode2(Op, Op, Base, Offset, Opc)) - return true; - - OutOps.push_back(Base); - OutOps.push_back(Offset); - OutOps.push_back(Opc); + // Require the address to be in a register. That is safe for all ARM + // variants and it is hard to do anything much smarter without knowing + // how the operand is used. + OutOps.push_back(Op); return false; } Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=84022&r1=84021&r2=84022&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue Oct 13 15:50:28 2009 @@ -1017,7 +1017,10 @@ const char *ExtraCode) { if (ExtraCode && ExtraCode[0]) return true; // Unknown modifier. - printAddrMode2Operand(MI, OpNum); + + const MachineOperand &MO = MI->getOperand(OpNum); + assert(MO.isReg() && "unexpected inline asm memory operand"); + O << "[" << getRegisterName(MO.getReg()) << "]"; return false; } Modified: llvm/trunk/test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll?rev=84022&r1=84021&r2=84022&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2009-05-18-InlineAsmMem.ll Tue Oct 13 15:50:28 2009 @@ -1,7 +1,9 @@ -; RUN: llc < %s -march=arm | grep swp +; RUN: llc < %s -march=arm | FileCheck %s +; RUN: llc < %s -march=thumb | FileCheck %s ; PR4091 define void @foo(i32 %i, i32* %p) nounwind { +;CHECK: swp r2, r0, [r1] %asmtmp = call i32 asm sideeffect "swp $0, $2, $3", "=&r,=*m,r,*m,~{memory}"(i32* %p, i32 %i, i32* %p) nounwind ret void } From dpatel at apple.com Tue Oct 13 15:56:38 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 20:56:38 -0000 Subject: [llvm-commits] [llvm] r84025 - /llvm/trunk/test/FrontendC/2006-01-13-Includes.c Message-ID: <200910132056.n9DKucMJ020627@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 15:56:38 2009 New Revision: 84025 URL: http://llvm.org/viewvc/llvm-project?rev=84025&view=rev Log: Optimizer may remove debug info. This test checks debug info for include headers. Modified: llvm/trunk/test/FrontendC/2006-01-13-Includes.c Modified: llvm/trunk/test/FrontendC/2006-01-13-Includes.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2006-01-13-Includes.c?rev=84025&r1=84024&r2=84025&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2006-01-13-Includes.c (original) +++ llvm/trunk/test/FrontendC/2006-01-13-Includes.c Tue Oct 13 15:56:38 2009 @@ -1,7 +1,5 @@ -// RUN: %llvmgcc %s -g -S -o - | llvm-as | opt -std-compile-opts | \ -// RUN: llvm-dis | grep {test/FrontendC} +// RUN: %llvmgcc %s -g -S -o - | grep {test/FrontendC} // PR676 -// XFAIL: * #include From anton at korobeynikov.info Tue Oct 13 16:02:30 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 14 Oct 2009 01:02:30 +0400 Subject: [llvm-commits] [llvm] r84020 - in /llvm/trunk: include/llvm/InlineAsm.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/AsmWriter.cp Message-ID: Hello, Dale > URL: http://llvm.org/viewvc/llvm-project?rev=84020&view=rev > Log: > Add an "msasm" flag to inline asm as suggested in PR 5125. > A little ugliness is accepted to keep the binary file format > compatible. ?No functional change yet. Any documentation bits? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From baldrick at free.fr Tue Oct 13 16:04:12 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 13 Oct 2009 21:04:12 -0000 Subject: [llvm-commits] [llvm] r84027 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Message-ID: <200910132104.n9DL4D33020907@zion.cs.uiuc.edu> Author: baldrick Date: Tue Oct 13 16:04:12 2009 New Revision: 84027 URL: http://llvm.org/viewvc/llvm-project?rev=84027&view=rev Log: Introduce new convenience methods for sign extending or truncating an SDValue (depending on whether the target type is bigger or smaller than the value's type); or zero extending or truncating it. Use it in a few places (this seems to be a popular operation, but I only modified cases of it in SelectionDAGBuild). In particular, the eh_selector lowering was doing this wrong due to a repeated rather than inverted test, fixed with this change. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=84027&r1=84026&r2=84027&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Tue Oct 13 16:04:12 2009 @@ -381,6 +381,14 @@ SDValue getVectorShuffle(EVT VT, DebugLoc dl, SDValue N1, SDValue N2, const int *MaskElts); + /// getSExtOrTrunc - Convert Op, which must be of integer type, to the + /// integer type VT, by either sign-extending or truncating it. + SDValue getSExtOrTrunc(SDValue Op, DebugLoc DL, EVT VT); + + /// getZExtOrTrunc - Convert Op, which must be of integer type, to the + /// integer type VT, by either zero-extending or truncating it. + SDValue getZExtOrTrunc(SDValue Op, DebugLoc DL, EVT VT); + /// getZeroExtendInReg - Return the expression required to zero extend the Op /// value assuming it was the smaller SrcTy value. SDValue getZeroExtendInReg(SDValue Op, DebugLoc DL, EVT SrcTy); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=84027&r1=84026&r2=84027&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Oct 13 16:04:12 2009 @@ -832,6 +832,18 @@ Root = getEntryNode(); } +SDValue SelectionDAG::getSExtOrTrunc(SDValue Op, DebugLoc DL, EVT VT) { + return VT.bitsGT(Op.getValueType()) ? + getNode(ISD::SIGN_EXTEND, DL, VT, Op) : + getNode(ISD::TRUNCATE, DL, VT, Op); +} + +SDValue SelectionDAG::getZExtOrTrunc(SDValue Op, DebugLoc DL, EVT VT) { + return VT.bitsGT(Op.getValueType()) ? + getNode(ISD::ZERO_EXTEND, DL, VT, Op) : + getNode(ISD::TRUNCATE, DL, VT, Op); +} + SDValue SelectionDAG::getZeroExtendInReg(SDValue Op, DebugLoc DL, EVT VT) { if (Op.getValueType() == VT) return Op; APInt Imm = APInt::getLowBitsSet(Op.getValueSizeInBits(), Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=84027&r1=84026&r2=84027&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Tue Oct 13 16:04:12 2009 @@ -1429,12 +1429,7 @@ // can be used as an index into the jump table in a subsequent basic block. // This value may be smaller or larger than the target's pointer type, and // therefore require extension or truncating. - if (VT.bitsGT(TLI.getPointerTy())) - SwitchOp = DAG.getNode(ISD::TRUNCATE, getCurDebugLoc(), - TLI.getPointerTy(), SUB); - else - SwitchOp = DAG.getNode(ISD::ZERO_EXTEND, getCurDebugLoc(), - TLI.getPointerTy(), SUB); + SwitchOp = DAG.getZExtOrTrunc(SUB, getCurDebugLoc(), TLI.getPointerTy()); unsigned JumpTableReg = FuncInfo.MakeReg(TLI.getPointerTy()); SDValue CopyTo = DAG.getCopyToReg(getControlRoot(), getCurDebugLoc(), @@ -1482,13 +1477,7 @@ SUB, DAG.getConstant(B.Range, VT), ISD::SETUGT); - SDValue ShiftOp; - if (VT.bitsGT(TLI.getPointerTy())) - ShiftOp = DAG.getNode(ISD::TRUNCATE, getCurDebugLoc(), - TLI.getPointerTy(), SUB); - else - ShiftOp = DAG.getNode(ISD::ZERO_EXTEND, getCurDebugLoc(), - TLI.getPointerTy(), SUB); + SDValue ShiftOp = DAG.getZExtOrTrunc(SUB, getCurDebugLoc(), TLI.getPointerTy()); B.Reg = FuncInfo.MakeReg(TLI.getPointerTy()); SDValue CopyTo = DAG.getCopyToReg(getControlRoot(), getCurDebugLoc(), @@ -2336,12 +2325,7 @@ SDValue N = getValue(I.getOperand(0)); EVT SrcVT = N.getValueType(); EVT DestVT = TLI.getValueType(I.getType()); - SDValue Result; - if (DestVT.bitsLT(SrcVT)) - Result = DAG.getNode(ISD::TRUNCATE, getCurDebugLoc(), DestVT, N); - else - // Note: ZERO_EXTEND can handle cases where the sizes are equal too - Result = DAG.getNode(ISD::ZERO_EXTEND, getCurDebugLoc(), DestVT, N); + SDValue Result = DAG.getZExtOrTrunc(N, getCurDebugLoc(), DestVT); setValue(&I, Result); } @@ -2351,12 +2335,7 @@ SDValue N = getValue(I.getOperand(0)); EVT SrcVT = N.getValueType(); EVT DestVT = TLI.getValueType(I.getType()); - if (DestVT.bitsLT(SrcVT)) - setValue(&I, DAG.getNode(ISD::TRUNCATE, getCurDebugLoc(), DestVT, N)); - else - // Note: ZERO_EXTEND can handle cases where the sizes are equal too - setValue(&I, DAG.getNode(ISD::ZERO_EXTEND, getCurDebugLoc(), - DestVT, N)); + setValue(&I, DAG.getZExtOrTrunc(N, getCurDebugLoc(), DestVT)); } void SelectionDAGLowering::visitBitCast(User &I) { @@ -2692,12 +2671,7 @@ // If the index is smaller or larger than intptr_t, truncate or extend // it. - if (IdxN.getValueType().bitsLT(N.getValueType())) - IdxN = DAG.getNode(ISD::SIGN_EXTEND, getCurDebugLoc(), - N.getValueType(), IdxN); - else if (IdxN.getValueType().bitsGT(N.getValueType())) - IdxN = DAG.getNode(ISD::TRUNCATE, getCurDebugLoc(), - N.getValueType(), IdxN); + IdxN = DAG.getSExtOrTrunc(IdxN, getCurDebugLoc(), N.getValueType()); // If this is a multiply by a power of two, turn it into a shl // immediately. This is a very common case. @@ -2742,12 +2716,7 @@ EVT IntPtr = TLI.getPointerTy(); - if (IntPtr.bitsLT(AllocSize.getValueType())) - AllocSize = DAG.getNode(ISD::TRUNCATE, getCurDebugLoc(), - IntPtr, AllocSize); - else if (IntPtr.bitsGT(AllocSize.getValueType())) - AllocSize = DAG.getNode(ISD::ZERO_EXTEND, getCurDebugLoc(), - IntPtr, AllocSize); + AllocSize = DAG.getZExtOrTrunc(AllocSize, getCurDebugLoc(), IntPtr); // Handle alignment. If the requested alignment is less than or equal to // the stack alignment, ignore it. If the size is greater than or equal to @@ -4030,12 +3999,7 @@ MVT::SimpleValueType VT = (Intrinsic == Intrinsic::eh_selector_i32 ? MVT::i32 : MVT::i64); - if (Op.getValueType().getSimpleVT() < VT) - Op = DAG.getNode(ISD::SIGN_EXTEND, dl, VT, Op); - else if (Op.getValueType().getSimpleVT() < VT) - Op = DAG.getNode(ISD::TRUNCATE, dl, VT, Op); - - setValue(&I, Op); + setValue(&I, DAG.getSExtOrTrunc(Op, dl, VT)); return 0; } @@ -4082,13 +4046,8 @@ case Intrinsic::eh_dwarf_cfa: { EVT VT = getValue(I.getOperand(1)).getValueType(); - SDValue CfaArg; - if (VT.bitsGT(TLI.getPointerTy())) - CfaArg = DAG.getNode(ISD::TRUNCATE, dl, - TLI.getPointerTy(), getValue(I.getOperand(1))); - else - CfaArg = DAG.getNode(ISD::SIGN_EXTEND, dl, - TLI.getPointerTy(), getValue(I.getOperand(1))); + SDValue CfaArg = DAG.getSExtOrTrunc(getValue(I.getOperand(1)), dl, + TLI.getPointerTy()); SDValue Offset = DAG.getNode(ISD::ADD, dl, TLI.getPointerTy(), @@ -5552,10 +5511,7 @@ EVT IntPtr = TLI.getPointerTy(); - if (IntPtr.bitsLT(Src.getValueType())) - Src = DAG.getNode(ISD::TRUNCATE, getCurDebugLoc(), IntPtr, Src); - else if (IntPtr.bitsGT(Src.getValueType())) - Src = DAG.getNode(ISD::ZERO_EXTEND, getCurDebugLoc(), IntPtr, Src); + Src = DAG.getZExtOrTrunc(Src, getCurDebugLoc(), IntPtr); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; From dgregor at apple.com Tue Oct 13 16:17:00 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 13 Oct 2009 21:17:00 -0000 Subject: [llvm-commits] [llvm] r84029 - /llvm/trunk/include/llvm/Support/type_traits.h Message-ID: <200910132117.n9DLH0nc021425@zion.cs.uiuc.edu> Author: dgregor Date: Tue Oct 13 16:17:00 2009 New Revision: 84029 URL: http://llvm.org/viewvc/llvm-project?rev=84029&view=rev Log: Add is_same type trait Modified: llvm/trunk/include/llvm/Support/type_traits.h Modified: llvm/trunk/include/llvm/Support/type_traits.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/type_traits.h?rev=84029&r1=84028&r2=84029&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/type_traits.h (original) +++ llvm/trunk/include/llvm/Support/type_traits.h Tue Oct 13 16:17:00 2009 @@ -49,6 +49,17 @@ enum { value = sizeof(char) == sizeof(dont_use::is_class_helper(0)) }; }; +/// \brief Metafunction that determines whether the two given types are +/// equivalent. +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; // enable_if_c - Enable/disable a template based on a metafunction template From jyasskin at google.com Tue Oct 13 16:32:57 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Tue, 13 Oct 2009 21:32:57 -0000 Subject: [llvm-commits] [llvm] r84032 - in /llvm/trunk: lib/ExecutionEngine/JIT/JIT.h lib/ExecutionEngine/JIT/JITEmitter.cpp unittests/ExecutionEngine/JIT/JITTest.cpp Message-ID: <200910132132.n9DLWvV5022125@zion.cs.uiuc.edu> Author: jyasskin Date: Tue Oct 13 16:32:57 2009 New Revision: 84032 URL: http://llvm.org/viewvc/llvm-project?rev=84032&view=rev Log: Keep track of stubs that are created. This fixes PR5162 and probably PR4822 and 4406. Patch by Nick Lewycky! Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.h llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.h?rev=84032&r1=84031&r2=84032&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.h (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.h Tue Oct 13 16:32:57 2009 @@ -16,6 +16,7 @@ #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/PassManager.h" +#include "llvm/Support/ValueHandle.h" namespace llvm { @@ -33,7 +34,7 @@ /// PendingFunctions - Functions which have not been code generated yet, but /// were called from a function being code generated. - std::vector PendingFunctions; + std::vector > PendingFunctions; public: explicit JITState(ModuleProvider *MP) : PM(MP), MP(MP) {} @@ -43,7 +44,7 @@ } ModuleProvider *getMP() const { return MP; } - std::vector &getPendingFunctions(const MutexGuard &L) { + std::vector > &getPendingFunctions(const MutexGuard &L){ return PendingFunctions; } }; Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=84032&r1=84031&r2=84032&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Tue Oct 13 16:32:57 2009 @@ -64,7 +64,7 @@ class JITResolverState { public: typedef std::map, void*> FunctionToStubMapTy; - typedef std::map StubToFunctionMapTy; + typedef std::map > StubToFunctionMapTy; typedef std::map, void*> GlobalToIndirectSymMapTy; private: /// FunctionToStubMap - Keep track of the stub created for a particular @@ -198,9 +198,9 @@ // Call the lazy resolver function unless we are JIT'ing non-lazily, in which // case we must resolve the symbol now. - void *Actual = TheJIT->isLazyCompilationDisabled() + void *Actual = TheJIT->isLazyCompilationDisabled() ? (void *)0 : (void *)(intptr_t)LazyResolverFn; - + // If this is an external declaration, attempt to resolve the address now // to place in the stub. if (F->isDeclaration() && !F->hasNotBeenReadFromBitcode()) { @@ -231,14 +231,14 @@ // Finally, keep track of the stub-to-Function mapping so that the // JITCompilerFn knows which function to compile! state.getStubToFunctionMap(locked)[Stub] = F; - + // If we are JIT'ing non-lazily but need to call a function that does not // exist yet, add it to the JIT's work list so that we can fill in the stub // address later. if (!Actual && TheJIT->isLazyCompilationDisabled()) if (!F->isDeclaration() || F->hasNotBeenReadFromBitcode()) TheJIT->addPendingFunction(F); - + return Stub; } @@ -696,11 +696,8 @@ } void JITEmitter::AddStubToCurrentFunction(void *StubAddr) { - if (!TheJIT->areDlsymStubsEnabled()) - return; - assert(CurFn && "Stub added to current function, but current function is 0!"); - + SmallVectorImpl &StubsUsed = CurFnStubUses[CurFn]; StubsUsed.push_back(StubAddr); Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=84032&r1=84031&r2=84032&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Tue Oct 13 16:32:57 2009 @@ -166,6 +166,102 @@ EXPECT_EQ(8, TestFunctionPtr()); } +// Test a function C which calls A and B which call each other. +TEST_F(JITTest, NonLazyCompilationStillNeedsStubs) { + TheJIT->DisableLazyCompilation(); + + const FunctionType *Func1Ty = + cast(TypeBuilder::get(Context)); + std::vector arg_types; + arg_types.push_back(Type::getInt1Ty(Context)); + const FunctionType *FuncTy = FunctionType::get( + Type::getVoidTy(Context), arg_types, false); + Function *Func1 = Function::Create(Func1Ty, Function::ExternalLinkage, + "func1", M); + Function *Func2 = Function::Create(FuncTy, Function::InternalLinkage, + "func2", M); + Function *Func3 = Function::Create(FuncTy, Function::InternalLinkage, + "func3", M); + BasicBlock *Block1 = BasicBlock::Create(Context, "block1", Func1); + BasicBlock *Block2 = BasicBlock::Create(Context, "block2", Func2); + BasicBlock *True2 = BasicBlock::Create(Context, "cond_true", Func2); + BasicBlock *False2 = BasicBlock::Create(Context, "cond_false", Func2); + BasicBlock *Block3 = BasicBlock::Create(Context, "block3", Func3); + BasicBlock *True3 = BasicBlock::Create(Context, "cond_true", Func3); + BasicBlock *False3 = BasicBlock::Create(Context, "cond_false", Func3); + + // Make Func1 call Func2(0) and Func3(0). + IRBuilder<> Builder(Block1); + Builder.CreateCall(Func2, ConstantInt::getTrue(Context)); + Builder.CreateCall(Func3, ConstantInt::getTrue(Context)); + Builder.CreateRetVoid(); + + // void Func2(bool b) { if (b) { Func3(false); return; } return; } + Builder.SetInsertPoint(Block2); + Builder.CreateCondBr(Func2->arg_begin(), True2, False2); + Builder.SetInsertPoint(True2); + Builder.CreateCall(Func3, ConstantInt::getFalse(Context)); + Builder.CreateRetVoid(); + Builder.SetInsertPoint(False2); + Builder.CreateRetVoid(); + + // void Func3(bool b) { if (b) { Func2(false); return; } return; } + Builder.SetInsertPoint(Block3); + Builder.CreateCondBr(Func3->arg_begin(), True3, False3); + Builder.SetInsertPoint(True3); + Builder.CreateCall(Func2, ConstantInt::getFalse(Context)); + Builder.CreateRetVoid(); + Builder.SetInsertPoint(False3); + Builder.CreateRetVoid(); + + // Compile the function to native code + void (*F1Ptr)() = + reinterpret_cast((intptr_t)TheJIT->getPointerToFunction(Func1)); + + F1Ptr(); +} + +// Regression test for PR5162. This used to trigger an AssertingVH inside the +// JIT's Function to stub mapping. +TEST_F(JITTest, NonLazyLeaksNoStubs) { + TheJIT->DisableLazyCompilation(); + + // Create two functions with a single basic block each. + const FunctionType *FuncTy = + cast(TypeBuilder::get(Context)); + Function *Func1 = Function::Create(FuncTy, Function::ExternalLinkage, + "func1", M); + Function *Func2 = Function::Create(FuncTy, Function::InternalLinkage, + "func2", M); + BasicBlock *Block1 = BasicBlock::Create(Context, "block1", Func1); + BasicBlock *Block2 = BasicBlock::Create(Context, "block2", Func2); + + // The first function calls the second and returns the result + IRBuilder<> Builder(Block1); + Value *Result = Builder.CreateCall(Func2); + Builder.CreateRet(Result); + + // The second function just returns a constant + Builder.SetInsertPoint(Block2); + Builder.CreateRet(ConstantInt::get(TypeBuilder::get(Context),42)); + + // Compile the function to native code + (void)TheJIT->getPointerToFunction(Func1); + + // Free the JIT state for the functions + TheJIT->freeMachineCodeForFunction(Func1); + TheJIT->freeMachineCodeForFunction(Func2); + + // Delete the first function (and show that is has no users) + EXPECT_EQ(Func1->getNumUses(), 0u); + Func1->eraseFromParent(); + + // Delete the second function (and show that it has no users - it had one, + // func1 but that's gone now) + EXPECT_EQ(Func2->getNumUses(), 0u); + Func2->eraseFromParent(); +} + // This code is copied from JITEventListenerTest, but it only runs once for all // the tests in this directory. Everything seems fine, but that's strange // behavior. From dpatel at apple.com Tue Oct 13 16:41:20 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 21:41:20 -0000 Subject: [llvm-commits] [llvm] r84033 - in /llvm/trunk/lib/Transforms/Scalar: InstructionCombining.cpp LICM.cpp LoopUnswitch.cpp Message-ID: <200910132141.n9DLfKNM022426@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 16:41:20 2009 New Revision: 84033 URL: http://llvm.org/viewvc/llvm-project?rev=84033&view=rev Log: Do not check use_empty() before replaceAllUsesWith(). This gives ValueHandles a chance to get properly updated. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/Transforms/Scalar/LICM.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84033&r1=84032&r2=84033&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Oct 13 16:41:20 2009 @@ -9979,8 +9979,7 @@ new StoreInst(ConstantInt::getTrue(*Context), UndefValue::get(Type::getInt1PtrTy(*Context)), OldCall); - if (!OldCall->use_empty()) - OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType())); + OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType())); if (isa(OldCall)) // Not worth removing an invoke here. return EraseInstFromFunction(*OldCall); return 0; @@ -9994,9 +9993,8 @@ UndefValue::get(Type::getInt1PtrTy(*Context)), CS.getInstruction()); - if (!CS.getInstruction()->use_empty()) - CS.getInstruction()-> - replaceAllUsesWith(UndefValue::get(CS.getInstruction()->getType())); + CS.getInstruction()-> + replaceAllUsesWith(UndefValue::get(CS.getInstruction()->getType())); if (InvokeInst *II = dyn_cast(CS.getInstruction())) { // Don't break the CFG, insert a dummy cond branch. @@ -10251,7 +10249,7 @@ } } - + if (!Caller->use_empty()) Caller->replaceAllUsesWith(NV); @@ -10398,7 +10396,7 @@ setCallingConv(cast(Caller)->getCallingConv()); cast(NewCaller)->setAttributes(NewPAL); } - if (Caller->getType() != Type::getVoidTy(*Context) && !Caller->use_empty()) + if (Caller->getType() != Type::getVoidTy(*Context)) Caller->replaceAllUsesWith(NewCaller); Caller->eraseFromParent(); Worklist.Remove(Caller); @@ -12781,8 +12779,7 @@ ++NumDeadInst; MadeIRChange = true; } - if (!I->use_empty()) - I->replaceAllUsesWith(UndefValue::get(I->getType())); + I->replaceAllUsesWith(UndefValue::get(I->getType())); I->eraseFromParent(); } } Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=84033&r1=84032&r2=84033&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Tue Oct 13 16:41:20 2009 @@ -486,8 +486,8 @@ if (!isExitBlockDominatedByBlockInLoop(ExitBlocks[0], I.getParent())) { // Instruction is not used, just delete it. CurAST->deleteValue(&I); - if (!I.use_empty()) // If I has users in unreachable blocks, eliminate. - I.replaceAllUsesWith(UndefValue::get(I.getType())); + // If I has users in unreachable blocks, eliminate. + I.replaceAllUsesWith(UndefValue::get(I.getType())); I.eraseFromParent(); } else { // Move the instruction to the start of the exit block, after any PHI @@ -499,8 +499,8 @@ } else if (ExitBlocks.empty()) { // The instruction is actually dead if there ARE NO exit blocks. CurAST->deleteValue(&I); - if (!I.use_empty()) // If I has users in unreachable blocks, eliminate. - I.replaceAllUsesWith(UndefValue::get(I.getType())); + // If I has users in unreachable blocks, eliminate. + I.replaceAllUsesWith(UndefValue::get(I.getType())); I.eraseFromParent(); } else { // Otherwise, if we have multiple exits, use the PromoteMem2Reg function to Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=84033&r1=84032&r2=84033&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 16:41:20 2009 @@ -781,8 +781,7 @@ // Anything that uses the instructions in this basic block should have their // uses replaced with undefs. - if (!I->use_empty()) - I->replaceAllUsesWith(UndefValue::get(I->getType())); + I->replaceAllUsesWith(UndefValue::get(I->getType())); } // If this is the edge to the header block for a loop, remove the loop and From clattner at apple.com Tue Oct 13 16:50:01 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 13 Oct 2009 14:50:01 -0700 Subject: [llvm-commits] [llvm] r84033 - in /llvm/trunk/lib/Transforms/Scalar: InstructionCombining.cpp LICM.cpp LoopUnswitch.cpp In-Reply-To: <200910132141.n9DLfKNM022426@zion.cs.uiuc.edu> References: <200910132141.n9DLfKNM022426@zion.cs.uiuc.edu> Message-ID: <6019B1B7-2268-49D4-84AF-9C8CC60072F6@apple.com> On Oct 13, 2009, at 2:41 PM, Devang Patel wrote: > Author: dpatel > Date: Tue Oct 13 16:41:20 2009 > New Revision: 84033 > > URL: http://llvm.org/viewvc/llvm-project?rev=84033&view=rev > Log: > Do not check use_empty() before replaceAllUsesWith(). This gives > ValueHandles a chance to get properly updated. Ok, but two requests: 1. please add a comment that this is updating the uses and the metadata. 2. The code may need to check to see that the call doesn't return void. UndefValue::get(void) is not valid. -Chris > > > Modified: > llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > llvm/trunk/lib/Transforms/Scalar/LICM.cpp > llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84033&r1=84032&r2=84033&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > (original) > +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue > Oct 13 16:41:20 2009 > @@ -9979,8 +9979,7 @@ > new StoreInst(ConstantInt::getTrue(*Context), > UndefValue::get(Type::getInt1PtrTy(*Context)), > OldCall); > - if (!OldCall->use_empty()) > - OldCall->replaceAllUsesWith(UndefValue::get(OldCall- > >getType())); > + OldCall->replaceAllUsesWith(UndefValue::get(OldCall- > >getType())); > if (isa(OldCall)) // Not worth removing an invoke > here. > return EraseInstFromFunction(*OldCall); > return 0; > @@ -9994,9 +9993,8 @@ > UndefValue::get(Type::getInt1PtrTy(*Context)), > CS.getInstruction()); > > - if (!CS.getInstruction()->use_empty()) > - CS.getInstruction()-> > - replaceAllUsesWith(UndefValue::get(CS.getInstruction()- > >getType())); > + CS.getInstruction()-> > + replaceAllUsesWith(UndefValue::get(CS.getInstruction()- > >getType())); > > if (InvokeInst *II = dyn_cast(CS.getInstruction())) { > // Don't break the CFG, insert a dummy cond branch. > @@ -10251,7 +10249,7 @@ > } > } > > - > + > if (!Caller->use_empty()) > Caller->replaceAllUsesWith(NV); > > @@ -10398,7 +10396,7 @@ > setCallingConv(cast(Caller)->getCallingConv()); > cast(NewCaller)->setAttributes(NewPAL); > } > - if (Caller->getType() != Type::getVoidTy(*Context) && !Caller- > >use_empty()) > + if (Caller->getType() != Type::getVoidTy(*Context)) > Caller->replaceAllUsesWith(NewCaller); > Caller->eraseFromParent(); > Worklist.Remove(Caller); > @@ -12781,8 +12779,7 @@ > ++NumDeadInst; > MadeIRChange = true; > } > - if (!I->use_empty()) > - I->replaceAllUsesWith(UndefValue::get(I->getType())); > + I->replaceAllUsesWith(UndefValue::get(I->getType())); > I->eraseFromParent(); > } > } > > Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=84033&r1=84032&r2=84033&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Tue Oct 13 16:41:20 2009 > @@ -486,8 +486,8 @@ > if (!isExitBlockDominatedByBlockInLoop(ExitBlocks[0], > I.getParent())) { > // Instruction is not used, just delete it. > CurAST->deleteValue(&I); > - if (!I.use_empty()) // If I has users in unreachable blocks, > eliminate. > - I.replaceAllUsesWith(UndefValue::get(I.getType())); > + // If I has users in unreachable blocks, eliminate. > + I.replaceAllUsesWith(UndefValue::get(I.getType())); > I.eraseFromParent(); > } else { > // Move the instruction to the start of the exit block, after > any PHI > @@ -499,8 +499,8 @@ > } else if (ExitBlocks.empty()) { > // The instruction is actually dead if there ARE NO exit blocks. > CurAST->deleteValue(&I); > - if (!I.use_empty()) // If I has users in unreachable blocks, > eliminate. > - I.replaceAllUsesWith(UndefValue::get(I.getType())); > + // If I has users in unreachable blocks, eliminate. > + I.replaceAllUsesWith(UndefValue::get(I.getType())); > I.eraseFromParent(); > } else { > // Otherwise, if we have multiple exits, use the PromoteMem2Reg > function to > > Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=84033&r1=84032&r2=84033&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 > 16:41:20 2009 > @@ -781,8 +781,7 @@ > > // Anything that uses the instructions in this basic block > should have their > // uses replaced with undefs. > - if (!I->use_empty()) > - I->replaceAllUsesWith(UndefValue::get(I->getType())); > + I->replaceAllUsesWith(UndefValue::get(I->getType())); > } > > // If this is the edge to the header block for a loop, remove the > loop and > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From bob.wilson at apple.com Tue Oct 13 16:55:24 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 13 Oct 2009 21:55:24 -0000 Subject: [llvm-commits] [llvm] r84036 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <200910132155.n9DLtOTs023060@zion.cs.uiuc.edu> Author: bwilson Date: Tue Oct 13 16:55:24 2009 New Revision: 84036 URL: http://llvm.org/viewvc/llvm-project?rev=84036&view=rev Log: NEON VLD/VST are now fully implemented. For operations that expand to multiple instructions, the expansion is done during selection so there is no need to do anything special during legalization. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=84036&r1=84035&r2=84036&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Oct 13 16:55:24 2009 @@ -1369,44 +1369,11 @@ return DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel); } -static SDValue LowerNeonVLDIntrinsic(SDValue Op, SelectionDAG &DAG, - unsigned NumVecs) { - SDNode *Node = Op.getNode(); - EVT VT = Node->getValueType(0); - - // No expansion needed for 64-bit vectors. - if (VT.is64BitVector()) - return SDValue(); - - // FIXME: We need to expand VLD3 and VLD4 of 128-bit vectors into separate - // operations to load the even and odd registers. - return SDValue(); -} - -static SDValue LowerNeonVSTIntrinsic(SDValue Op, SelectionDAG &DAG, - unsigned NumVecs) { - SDNode *Node = Op.getNode(); - EVT VT = Node->getOperand(3).getValueType(); - - // No expansion needed for 64-bit vectors. - if (VT.is64BitVector()) - return SDValue(); - - // FIXME: We need to expand VST3 and VST4 of 128-bit vectors into separate - // operations to store the even and odd registers. - return SDValue(); -} - static SDValue LowerNeonVLDLaneIntrinsic(SDValue Op, SelectionDAG &DAG, unsigned NumVecs) { - SDNode *Node = Op.getNode(); - EVT VT = Node->getValueType(0); - - if (!VT.is64BitVector()) - return SDValue(); // unimplemented - // Change the lane number operand to be a TargetConstant; otherwise it // will be legalized into a register. + SDNode *Node = Op.getNode(); ConstantSDNode *Lane = dyn_cast(Node->getOperand(NumVecs+3)); if (!Lane) { assert(false && "vld lane number must be a constant"); @@ -1419,14 +1386,9 @@ static SDValue LowerNeonVSTLaneIntrinsic(SDValue Op, SelectionDAG &DAG, unsigned NumVecs) { - SDNode *Node = Op.getNode(); - EVT VT = Node->getOperand(3).getValueType(); - - if (!VT.is64BitVector()) - return SDValue(); // unimplemented - // Change the lane number operand to be a TargetConstant; otherwise it // will be legalized into a register. + SDNode *Node = Op.getNode(); ConstantSDNode *Lane = dyn_cast(Node->getOperand(NumVecs+3)); if (!Lane) { assert(false && "vst lane number must be a constant"); @@ -1441,20 +1403,12 @@ ARMTargetLowering::LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) { unsigned IntNo = cast(Op.getOperand(1))->getZExtValue(); switch (IntNo) { - case Intrinsic::arm_neon_vld3: - return LowerNeonVLDIntrinsic(Op, DAG, 3); - case Intrinsic::arm_neon_vld4: - return LowerNeonVLDIntrinsic(Op, DAG, 4); case Intrinsic::arm_neon_vld2lane: return LowerNeonVLDLaneIntrinsic(Op, DAG, 2); case Intrinsic::arm_neon_vld3lane: return LowerNeonVLDLaneIntrinsic(Op, DAG, 3); case Intrinsic::arm_neon_vld4lane: return LowerNeonVLDLaneIntrinsic(Op, DAG, 4); - case Intrinsic::arm_neon_vst3: - return LowerNeonVSTIntrinsic(Op, DAG, 3); - case Intrinsic::arm_neon_vst4: - return LowerNeonVSTIntrinsic(Op, DAG, 4); case Intrinsic::arm_neon_vst2lane: return LowerNeonVSTLaneIntrinsic(Op, DAG, 2); case Intrinsic::arm_neon_vst3lane: From dalej at apple.com Tue Oct 13 16:56:56 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 13 Oct 2009 21:56:56 -0000 Subject: [llvm-commits] [llvm] r84037 - /llvm/trunk/docs/LangRef.html Message-ID: <200910132156.n9DLuuMX023122@zion.cs.uiuc.edu> Author: johannes Date: Tue Oct 13 16:56:55 2009 New Revision: 84037 URL: http://llvm.org/viewvc/llvm-project?rev=84037&view=rev Log: Documentation for the new msasm flag, which is no worse than the rest of the asm documentation. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=84037&r1=84036&r2=84037&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Tue Oct 13 16:56:55 2009 @@ -2338,8 +2338,10 @@ to Module-Level Inline Assembly) through the use of a special value. This value represents the inline assembler as a string (containing the instructions to emit), a list of operand constraints (stored - as a string), and a flag that indicates whether or not the inline asm - expression has side effects. An example inline assembler expression is:

        + as a string), a flag that indicates whether or not the inline asm + expression has side effects, and a flag indicating whether the asm came + originally from an asm block. An example inline assembler + expression is:

        @@ -2367,6 +2369,18 @@
         
        +

        Inline asms derived from asm blocks are similarly marked with the + 'msasm' keyword:

        + +
        +
        +call void asm msasm "eieio", ""()
        +
        +
        + +

        If both keywords appear the 'sideeffect' keyword must come + first.

        +

        TODO: The format of the asm and constraints string still need to be documented here. Constraints on what can be done (e.g. duplication, moving, etc need to be documented). This is probably best done by reference to From evan.cheng at apple.com Tue Oct 13 17:02:20 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 13 Oct 2009 22:02:20 -0000 Subject: [llvm-commits] [llvm] r84038 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/phi-aa.ll Message-ID: <200910132202.n9DM2KBh023328@zion.cs.uiuc.edu> Author: evancheng Date: Tue Oct 13 17:02:20 2009 New Revision: 84038 URL: http://llvm.org/viewvc/llvm-project?rev=84038&view=rev Log: Teach basic AA about PHI nodes. If all operands of a phi NoAlias another value than it's safe to declare the PHI NoAlias the value. Ditto for MustAlias. Added: llvm/trunk/test/Analysis/BasicAA/phi-aa.ll Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84038&r1=84037&r2=84038&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Tue Oct 13 17:02:20 2009 @@ -27,6 +27,7 @@ #include "llvm/Operator.h" #include "llvm/Pass.h" #include "llvm/Target/TargetData.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" @@ -201,7 +202,10 @@ static char ID; // Class identification, replacement for typeinfo BasicAliasAnalysis() : NoAA(&ID) {} AliasResult alias(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size); + const Value *V2, unsigned V2Size) { + SmallSet VisitedPHIs; + return aliasCheck(V1, V1Size, V2, V2Size, VisitedPHIs); + } ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); ModRefResult getModRefInfo(CallSite CS1, CallSite CS2); @@ -218,7 +222,16 @@ // aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a GEP instruction // against another. AliasResult aliasGEP(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size); + const Value *V2, unsigned V2Size, + SmallSet &VisitedPHIs); + + AliasResult aliasPHI(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size, + SmallSet &VisitedPHIs); + + AliasResult aliasCheck(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size, + SmallSet &VisitedPHIs); // CheckGEPInstructions - Check two GEP instructions with known // must-aliasing base pointers. This checks to see if the index expressions @@ -339,7 +352,8 @@ // AliasAnalysis::AliasResult BasicAliasAnalysis::aliasGEP(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size) { + const Value *V2, unsigned V2Size, + SmallSet &VisitedPHIs) { // If we have two gep instructions with must-alias'ing base pointers, figure // out if the indexes to the GEP tell us anything about the derived pointer. // Note that we also handle chains of getelementptr instructions as well as @@ -359,8 +373,8 @@ GEP1->getOperand(0)->getType() == GEP2->getOperand(0)->getType() && // All operands are the same, ignoring the base. std::equal(GEP1->op_begin()+1, GEP1->op_end(), GEP2->op_begin()+1)) - return alias(GEP1->getOperand(0), V1Size, GEP2->getOperand(0), V2Size); - + return aliasCheck(GEP1->getOperand(0), V1Size, + GEP2->getOperand(0), V2Size, VisitedPHIs); // Drill down into the first non-gep value, to test for must-aliasing of // the base pointers. @@ -377,7 +391,8 @@ const Value *BasePtr2 = GEP2->getOperand(0); // Do the base pointers alias? - AliasResult BaseAlias = alias(BasePtr1, ~0U, BasePtr2, ~0U); + AliasResult BaseAlias = aliasCheck(BasePtr1, ~0U, BasePtr2, ~0U, + VisitedPHIs); if (BaseAlias == NoAlias) return NoAlias; if (BaseAlias == MustAlias) { // If the base pointers alias each other exactly, check to see if we can @@ -413,7 +428,7 @@ SmallVector GEPOperands; const Value *BasePtr = GetGEPOperands(V1, GEPOperands); - AliasResult R = alias(BasePtr, V1Size, V2, V2Size); + AliasResult R = aliasCheck(BasePtr, V1Size, V2, V2Size, VisitedPHIs); if (R == MustAlias) { // If there is at least one non-zero constant index, we know they cannot // alias. @@ -462,12 +477,47 @@ return MayAlias; } -// alias - Provide a bunch of ad-hoc rules to disambiguate in common cases, such -// as array references. +AliasAnalysis::AliasResult +BasicAliasAnalysis::aliasPHI(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size, + SmallSet &VisitedPHIs) { + // The PHI node has already been visited, avoid recursion any further. + if (!VisitedPHIs.insert(V1)) + return MayAlias; + + SmallSet UniqueSrc; + SmallVector V1Srcs; + const PHINode *PN = cast(V1); + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + Value *PV1 = PN->getIncomingValue(i); + if (isa(PV1)) + // If any of the source itself is a PHI, return MayAlias conservatively + // to avoid compile time explosion. + return MayAlias; + if (UniqueSrc.insert(PV1)) + V1Srcs.push_back(PV1); + } + + // If all sources of the PHI node NoAlias or MustAlias V2, then returns + // NoAlias / MustAlias. Otherwise, returns MayAlias. + AliasResult Alias = aliasCheck(V1Srcs[0], V1Size, V2, V2Size, VisitedPHIs); + for (unsigned i = 1, e = V1Srcs.size(); i != e; ++i) { + Value *V = V1Srcs[i]; + AliasResult ThisAlias = aliasCheck(V, V1Size, V2, V2Size, VisitedPHIs); + if (ThisAlias != Alias) + return MayAlias; + } + + return Alias; +} + +// aliasCheck - Provide a bunch of ad-hoc rules to disambiguate in common cases, +// such as array references. // AliasAnalysis::AliasResult -BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size) { +BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size, + const Value *V2, unsigned V2Size, + SmallSet &VisitedPHIs) { // Strip off any casts if they exist. V1 = V1->stripPointerCasts(); V2 = V2->stripPointerCasts(); @@ -521,7 +571,14 @@ std::swap(V1Size, V2Size); } if (isGEP(V1)) - return aliasGEP(V1, V1Size, V2, V2Size); + return aliasGEP(V1, V1Size, V2, V2Size, VisitedPHIs); + + if (isa(V2) && !isa(V1)) { + std::swap(V1, V2); + std::swap(V1Size, V2Size); + } + if (isa(V1)) + return aliasPHI(V1, V1Size, V2, V2Size, VisitedPHIs); return MayAlias; } Added: llvm/trunk/test/Analysis/BasicAA/phi-aa.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/phi-aa.ll?rev=84038&view=auto ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/phi-aa.ll (added) +++ llvm/trunk/test/Analysis/BasicAA/phi-aa.ll Tue Oct 13 17:02:20 2009 @@ -0,0 +1,86 @@ +; RUN: opt < %s -basicaa -licm -S | FileCheck %s +; rdar://7282591 + +%struct.CFRuntimeBase = type { i32, [4 x i8] } +%struct.XXXAffineTransform = type { float, float, float, float, float, float } +%struct.XXXContext = type { %struct.CFRuntimeBase, i32, i32, i32, i8*, %struct.XXXContextDelegate*, void (%struct.XXXContext*)*, void (%struct.XXXContext*)*, %struct.XXXImage* (%struct.XXXContext*, %struct.XXXRect*, %struct.XXXImage*, i8*)*, i8*, %struct.__CFDictionary*, i32, %struct.XXXGState*, %struct.XXXGStack*, %struct.XXXRenderingState*, %struct.XXXAffineTransform, %struct.XXXPath*, %struct.__CFDictionary*, %struct.XXXPixelAccess* } +%struct.XXXContextDelegate = type opaque +%struct.XXXGStack = type opaque +%struct.XXXGState = type opaque +%struct.XXXImage = type opaque +%struct.XXXPath = type opaque +%struct.XXXPixelAccess = type opaque +%struct.XXXPoint = type { float, float } +%struct.XXXRect = type { %struct.XXXPoint, %struct.XXXPoint } +%struct.XXXRenderingState = type opaque +%struct.__CFDictionary = type opaque + +define void @t(%struct.XXXContext* %context, i16* %glyphs, %struct.XXXPoint* %advances, i32 %count) nounwind optsize ssp { +; CHECK: @t +; CHECK: bb21.preheader: +; CHECK: %tmp28 = getelementptr +; CHECK: %tmp28.promoted = load +entry: + br i1 undef, label %bb1, label %bb + +bb: ; preds = %entry + br i1 undef, label %bb2, label %bb1 + +bb1: ; preds = %bb, %entry + ret void + +bb2: ; preds = %bb + br i1 undef, label %bb35, label %bb7 + +bb7: ; preds = %bb2 + br i1 undef, label %bb35, label %bb10 + +bb10: ; preds = %bb7 + %tmp18 = alloca i8, i32 undef, align 1 ; [#uses=1] + br i1 undef, label %bb35, label %bb15 + +bb15: ; preds = %bb10 + br i1 undef, label %bb17, label %bb16 + +bb16: ; preds = %bb15 + %tmp21 = bitcast i8* %tmp18 to %struct.XXXPoint* ; <%struct.XXXPoint*> [#uses=1] + br label %bb18 + +bb17: ; preds = %bb15 + %tmp22 = malloc %struct.XXXPoint, i32 %count ; <%struct.XXXPoint*> [#uses=1] + br label %bb18 + +bb18: ; preds = %bb17, %bb16 + %positions.0 = phi %struct.XXXPoint* [ %tmp21, %bb16 ], [ %tmp22, %bb17 ] ; <%struct.XXXPoint*> [#uses=1] + br i1 undef, label %bb35, label %bb20 + +bb20: ; preds = %bb18 + br i1 undef, label %bb21, label %bb25 + +bb21: ; preds = %bb21, %bb20 + %tmp28 = getelementptr inbounds %struct.XXXPoint* %positions.0, i32 undef, i32 0 ; [#uses=1] + store float undef, float* %tmp28, align 4 + %elt22 = getelementptr inbounds %struct.XXXPoint* %advances, i32 undef, i32 1 ; [#uses=1] + %val23 = load float* %elt22 ; [#uses=0] + br i1 undef, label %bb21, label %bb25 + +bb25: ; preds = %bb21, %bb20 + switch i32 undef, label %bb26 [ + i32 4, label %bb27 + i32 5, label %bb27 + i32 6, label %bb27 + i32 7, label %bb28 + ] + +bb26: ; preds = %bb25 + unreachable + +bb27: ; preds = %bb25, %bb25, %bb25 + unreachable + +bb28: ; preds = %bb25 + unreachable + +bb35: ; preds = %bb18, %bb10, %bb7, %bb2 + ret void +} From deeppatel1987 at gmail.com Tue Oct 13 17:12:13 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Tue, 13 Oct 2009 22:12:13 +0000 Subject: [llvm-commits] [llvm] r84037 - /llvm/trunk/docs/LangRef.html In-Reply-To: <200910132156.n9DLuuMX023122@zion.cs.uiuc.edu> References: <200910132156.n9DLuuMX023122@zion.cs.uiuc.edu> Message-ID: <305d6f60910131512g57fc0f87s8965d248feb97f95@mail.gmail.com> I'm trying to wrap my head around the semantics of this. Is this the same as having the containing function be naked, or is it just saying that there's no call in the asm? deep On Tue, Oct 13, 2009 at 9:56 PM, Dale Johannesen wrote: > Author: johannes > Date: Tue Oct 13 16:56:55 2009 > New Revision: 84037 > > URL: http://llvm.org/viewvc/llvm-project?rev=84037&view=rev > Log: > Documentation for the new msasm flag, which is no > worse than the rest of the asm documentation. > > > Modified: > ? ?llvm/trunk/docs/LangRef.html > > Modified: llvm/trunk/docs/LangRef.html > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=84037&r1=84036&r2=84037&view=diff > > ============================================================================== > --- llvm/trunk/docs/LangRef.html (original) > +++ llvm/trunk/docs/LangRef.html Tue Oct 13 16:56:55 2009 > @@ -2338,8 +2338,10 @@ > ? ?to Module-Level Inline Assembly) through the use of > ? ?a special value. ?This value represents the inline assembler as a string > ? ?(containing the instructions to emit), a list of operand constraints (stored > - ? as a string), and a flag that indicates whether or not the inline asm > - ? expression has side effects. ?An example inline assembler expression is:

        > + ? as a string), a flag that indicates whether or not the inline asm > + ? expression has side effects, and a flag indicating whether the asm came > + ? originally from an asm block. ?An example inline assembler > + ? expression is:

        > > ?
        > ?
        > @@ -2367,6 +2369,18 @@
        > ?
        > ?
        > > +

        Inline asms derived from asm blocks are similarly marked with the > + ? 'msasm' keyword:

        > + > +
        > +
        > +call void asm msasm "eieio", ""()
        > +
        > +
        > + > +

        If both keywords appear the 'sideeffect' keyword must come > + ? first.

        > + > ?

        TODO: The format of the asm and constraints string still need to be > ? ?documented here. ?Constraints on what can be done (e.g. duplication, moving, > ? ?etc need to be documented). ?This is probably best done by reference to > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From enderby at apple.com Tue Oct 13 17:19:02 2009 From: enderby at apple.com (Kevin Enderby) Date: Tue, 13 Oct 2009 22:19:02 -0000 Subject: [llvm-commits] [llvm] r84040 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <200910132219.n9DMJ2rW023952@zion.cs.uiuc.edu> Author: enderby Date: Tue Oct 13 17:19:02 2009 New Revision: 84040 URL: http://llvm.org/viewvc/llvm-project?rev=84040&view=rev Log: More bits of the ARM target assembler for llvm-mc to parse immediates. Also fixed a couple of coding style things that crept in. And added more to the temporary hacked up ARMAsmParser::MatchInstruction() method for testing. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=84040&r1=84039&r2=84040&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Tue Oct 13 17:19:02 2009 @@ -92,6 +92,7 @@ enum { Token, Register, + Immediate, Memory } Kind; @@ -107,6 +108,10 @@ bool Writeback; } Reg; + struct { + const MCExpr *Val; + } Imm; + // This is for all forms of ARM address expressions struct { unsigned BaseRegNum; @@ -134,6 +139,11 @@ return Reg.RegNum; } + const MCExpr *getImm() const { + assert(Kind == Immediate && "Invalid access!"); + return Imm.Val; + } + bool isToken() const {return Kind == Token; } bool isReg() const { return Kind == Register; } @@ -159,6 +169,13 @@ return Res; } + static ARMOperand CreateImm(const MCExpr *Val) { + ARMOperand Res; + Res.Kind = Immediate; + Res.Imm.Val = Val; + return Res; + } + static ARMOperand CreateMem(unsigned BaseRegNum, bool OffsetIsReg, const MCExpr *Offset, unsigned OffsetRegNum, bool OffsetRegShifted, enum ShiftType ShiftType, @@ -217,7 +234,7 @@ // for now. bool ARMAsmParser::ParseRegisterList(ARMOperand &Op) { assert(getLexer().getTok().is(AsmToken::LCurly) && - "Token is not an Left Curly Brace"); + "Token is not an Left Curly Brace"); getLexer().Lex(); // Eat left curly brace token. const AsmToken &RegTok = getLexer().getTok(); @@ -498,7 +515,8 @@ Mnemonic == "str" || Mnemonic == "ldmfd" || Mnemonic == "ldr" || - Mnemonic == "mov") + Mnemonic == "mov" || + Mnemonic == "sub") return false; return true; @@ -517,9 +535,15 @@ return false; case AsmToken::LCurly: if (!ParseRegisterList(Op)) - return(false); + return false; case AsmToken::Hash: - return Error(getLexer().getTok().getLoc(), "immediates not yet supported"); + // $42 -> immediate. + getLexer().Lex(); + const MCExpr *Val; + if (getParser().ParseExpression(Val)) + return true; + Op = ARMOperand::CreateImm(Val); + return false; default: return Error(getLexer().getTok().getLoc(), "unexpected token in operand"); } From dalej at apple.com Tue Oct 13 17:20:56 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 13 Oct 2009 15:20:56 -0700 Subject: [llvm-commits] [llvm] r84037 - /llvm/trunk/docs/LangRef.html In-Reply-To: <305d6f60910131512g57fc0f87s8965d248feb97f95@mail.gmail.com> References: <200910132156.n9DLuuMX023122@zion.cs.uiuc.edu> <305d6f60910131512g57fc0f87s8965d248feb97f95@mail.gmail.com> Message-ID: On Oct 13, 2009, at 3:12 PM, Sandeep Patel wrote: > I'm trying to wrap my head around the semantics of this. Is this the > same as having the containing function be naked, or is it just saying > that there's no call in the asm? Neither. It says the asm came originally from the 'asm blocks' extension as used by Apple GCC, MSVS and CodeWarrior (all slightly different in undocumented ways of course), as opposed to gcc-style asm. I don't think a more complete description belongs in the IR document. One effect is that functions containing only asms that are not marked as coming from asm blocks will not have the stack aligned (PR 5125). This isn't in yet. > deep > > On Tue, Oct 13, 2009 at 9:56 PM, Dale Johannesen > wrote: >> Author: johannes >> Date: Tue Oct 13 16:56:55 2009 >> New Revision: 84037 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84037&view=rev >> Log: >> Documentation for the new msasm flag, which is no >> worse than the rest of the asm documentation. >> >> >> Modified: >> llvm/trunk/docs/LangRef.html >> >> Modified: llvm/trunk/docs/LangRef.html >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=84037&r1=84036&r2=84037&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/docs/LangRef.html (original) >> +++ llvm/trunk/docs/LangRef.html Tue Oct 13 16:56:55 2009 >> @@ -2338,8 +2338,10 @@ >> to Module-Level Inline Assembly) >> through the use of >> a special value. This value represents the inline assembler as >> a string >> (containing the instructions to emit), a list of operand >> constraints (stored >> - as a string), and a flag that indicates whether or not the >> inline asm >> - expression has side effects. An example inline assembler >> expression is:

        >> + as a string), a flag that indicates whether or not the inline asm >> + expression has side effects, and a flag indicating whether the >> asm came >> + originally from an asm block. An example inline assembler >> + expression is:

        >> >>
        >>
        >> @@ -2367,6 +2369,18 @@
        >>  
        >>
        >> >> +

        Inline asms derived from asm blocks are similarly marked with the >> + 'msasm' keyword:

        >> + >> +
        >> +
        >> +call void asm msasm "eieio", ""()
        >> +
        >> +
        >> + >> +

        If both keywords appear the 'sideeffect' keyword must >> come >> + first.

        >> + >>

        TODO: The format of the asm and constraints string still need >> to be >> documented here. Constraints on what can be done (e.g. >> duplication, moving, >> etc need to be documented). This is probably best done by >> reference to >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From dpatel at apple.com Tue Oct 13 17:23:26 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 15:23:26 -0700 Subject: [llvm-commits] [llvm] r84033 - in /llvm/trunk/lib/Transforms/Scalar: InstructionCombining.cpp LICM.cpp LoopUnswitch.cpp In-Reply-To: <6019B1B7-2268-49D4-84AF-9C8CC60072F6@apple.com> References: <200910132141.n9DLfKNM022426@zion.cs.uiuc.edu> <6019B1B7-2268-49D4-84AF-9C8CC60072F6@apple.com> Message-ID: On Oct 13, 2009, at 2:50 PM, Chris Lattner wrote: > > On Oct 13, 2009, at 2:41 PM, Devang Patel wrote: > >> Author: dpatel >> Date: Tue Oct 13 16:41:20 2009 >> New Revision: 84033 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84033&view=rev >> Log: >> Do not check use_empty() before replaceAllUsesWith(). This gives >> ValueHandles a chance to get properly updated. > > Ok, but two requests: > > 1. please add a comment that this is updating the uses and the > metadata. This is not metadata specific. use_empty() by passes ValueIsRAUWd call back for VHs. 309 // Notify all ValueHandles (if present) that this value is going away. 310 if (HasValueHandle) 311 ValueHandleBase::ValueIsRAUWd(this, New); It is somewhat redundant if the value is deleted eventually, but that is not the case many times. - Devang > 2. The code may need to check to see that the call doesn't return > void. UndefValue::get(void) is not valid. > > -Chris > >> >> >> Modified: >> llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp >> llvm/trunk/lib/Transforms/Scalar/LICM.cpp >> llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp >> >> Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84033&r1=84032&r2=84033&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp >> (original) >> +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue >> Oct 13 16:41:20 2009 >> @@ -9979,8 +9979,7 @@ >> new StoreInst(ConstantInt::getTrue(*Context), >> UndefValue::get(Type::getInt1PtrTy(*Context)), >> OldCall); >> - if (!OldCall->use_empty()) >> - OldCall->replaceAllUsesWith(UndefValue::get(OldCall- >> >getType())); >> + OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType >> ())); >> if (isa(OldCall)) // Not worth removing an invoke >> here. >> return EraseInstFromFunction(*OldCall); >> return 0; >> @@ -9994,9 +9993,8 @@ >> UndefValue::get(Type::getInt1PtrTy(*Context)), >> CS.getInstruction()); >> >> - if (!CS.getInstruction()->use_empty()) >> - CS.getInstruction()-> >> - replaceAllUsesWith(UndefValue::get(CS.getInstruction()- >> >getType())); >> + CS.getInstruction()-> >> + replaceAllUsesWith(UndefValue::get(CS.getInstruction()- >> >getType())); >> >> if (InvokeInst *II = dyn_cast(CS.getInstruction())) { >> // Don't break the CFG, insert a dummy cond branch. >> @@ -10251,7 +10249,7 @@ >> } >> } >> >> - >> + >> if (!Caller->use_empty()) >> Caller->replaceAllUsesWith(NV); >> >> @@ -10398,7 +10396,7 @@ >> setCallingConv(cast(Caller)->getCallingConv()); >> cast(NewCaller)->setAttributes(NewPAL); >> } >> - if (Caller->getType() != Type::getVoidTy(*Context) && ! >> Caller->use_empty()) >> + if (Caller->getType() != Type::getVoidTy(*Context)) >> Caller->replaceAllUsesWith(NewCaller); >> Caller->eraseFromParent(); >> Worklist.Remove(Caller); >> @@ -12781,8 +12779,7 @@ >> ++NumDeadInst; >> MadeIRChange = true; >> } >> - if (!I->use_empty()) >> - I->replaceAllUsesWith(UndefValue::get(I->getType())); >> + I->replaceAllUsesWith(UndefValue::get(I->getType())); >> I->eraseFromParent(); >> } >> } >> >> Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=84033&r1=84032&r2=84033&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Tue Oct 13 16:41:20 >> 2009 >> @@ -486,8 +486,8 @@ >> if (!isExitBlockDominatedByBlockInLoop(ExitBlocks[0], I.getParent >> ())) { >> // Instruction is not used, just delete it. >> CurAST->deleteValue(&I); >> - if (!I.use_empty()) // If I has users in unreachable >> blocks, eliminate. >> - I.replaceAllUsesWith(UndefValue::get(I.getType())); >> + // If I has users in unreachable blocks, eliminate. >> + I.replaceAllUsesWith(UndefValue::get(I.getType())); >> I.eraseFromParent(); >> } else { >> // Move the instruction to the start of the exit block, after >> any PHI >> @@ -499,8 +499,8 @@ >> } else if (ExitBlocks.empty()) { >> // The instruction is actually dead if there ARE NO exit blocks. >> CurAST->deleteValue(&I); >> - if (!I.use_empty()) // If I has users in unreachable blocks, >> eliminate. >> - I.replaceAllUsesWith(UndefValue::get(I.getType())); >> + // If I has users in unreachable blocks, eliminate. >> + I.replaceAllUsesWith(UndefValue::get(I.getType())); >> I.eraseFromParent(); >> } else { >> // Otherwise, if we have multiple exits, use the PromoteMem2Reg >> function to >> >> Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=84033&r1=84032&r2=84033&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 >> 16:41:20 2009 >> @@ -781,8 +781,7 @@ >> >> // Anything that uses the instructions in this basic block >> should have their >> // uses replaced with undefs. >> - if (!I->use_empty()) >> - I->replaceAllUsesWith(UndefValue::get(I->getType())); >> + I->replaceAllUsesWith(UndefValue::get(I->getType())); >> } >> >> // If this is the edge to the header block for a loop, remove the >> loop and >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From anton at korobeynikov.info Tue Oct 13 17:25:18 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 14 Oct 2009 02:25:18 +0400 Subject: [llvm-commits] [llvm] r84040 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp In-Reply-To: <200910132219.n9DMJ2rW023952@zion.cs.uiuc.edu> References: <200910132219.n9DMJ2rW023952@zion.cs.uiuc.edu> Message-ID: Hello, Kevin > + ? ?// $42 -> immediate. #42 ? What's about modifiers (e.g. #:lower16:foo / #:upper16:foo) ? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From bob.wilson at apple.com Tue Oct 13 17:29:24 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 13 Oct 2009 22:29:24 -0000 Subject: [llvm-commits] [llvm] r84042 - in /llvm/trunk/lib/Target/ARM: ARMISelDAGToDAG.cpp ARMISelLowering.cpp Message-ID: <200910132229.n9DMTPGl024367@zion.cs.uiuc.edu> Author: bwilson Date: Tue Oct 13 17:29:24 2009 New Revision: 84042 URL: http://llvm.org/viewvc/llvm-project?rev=84042&view=rev Log: More Neon clean-up: avoid the need for custom-lowering vld/st-lane intrinsics by creating TargetConstants during instruction selection instead of during legalization. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84042&r1=84041&r2=84042&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue Oct 13 17:29:24 2009 @@ -1415,6 +1415,7 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { default: llvm_unreachable("unhandled vld2 type"); @@ -1424,7 +1425,6 @@ case MVT::v2i32: Opc = ARM::VLD2d32; break; case MVT::v1i64: Opc = ARM::VLD2d64; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; return CurDAG->getMachineNode(Opc, dl, VT, VT, MVT::Other, Ops, 4); } @@ -1437,7 +1437,6 @@ case MVT::v4f32: Opc = ARM::VLD2q32; RegVT = MVT::v2f32; break; case MVT::v4i32: Opc = ARM::VLD2q32; RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; std::vector ResTys(4, RegVT); ResTys.push_back(MVT::Other); @@ -1454,6 +1453,7 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { default: llvm_unreachable("unhandled vld3 type"); @@ -1463,7 +1463,6 @@ case MVT::v2i32: Opc = ARM::VLD3d32; break; case MVT::v1i64: Opc = ARM::VLD3d64; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; return CurDAG->getMachineNode(Opc, dl, VT, VT, VT, MVT::Other, Ops, 4); } @@ -1482,7 +1481,6 @@ case MVT::v4i32: Opc = ARM::VLD3q32a; Opc2 = ARM::VLD3q32b; RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); // Enable writeback to the address register. MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), MVT::i32); @@ -1512,6 +1510,7 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { default: llvm_unreachable("unhandled vld4 type"); @@ -1521,7 +1520,6 @@ case MVT::v2i32: Opc = ARM::VLD4d32; break; case MVT::v1i64: Opc = ARM::VLD4d64; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; std::vector ResTys(4, VT); ResTys.push_back(MVT::Other); @@ -1542,7 +1540,6 @@ case MVT::v4i32: Opc = ARM::VLD4q32a; Opc2 = ARM::VLD4q32b; RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); // Enable writeback to the address register. MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), MVT::i32); @@ -1574,6 +1571,8 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); + unsigned Lane = cast(N->getOperand(5))->getZExtValue(); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { default: llvm_unreachable("unhandled vld2lane type"); @@ -1582,10 +1581,9 @@ case MVT::v2f32: case MVT::v2i32: Opc = ARM::VLD2LNd32; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, N->getOperand(3), N->getOperand(4), - N->getOperand(5), Chain }; + getI32Imm(Lane), Chain }; return CurDAG->getMachineNode(Opc, dl, VT, VT, MVT::Other, Ops, 7); } // Quad registers are handled by extracting subregs, doing the load, @@ -1610,8 +1608,6 @@ RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(5))->getZExtValue(); unsigned NumElts = RegVT.getVectorNumElements(); int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; @@ -1641,6 +1637,8 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); + unsigned Lane = cast(N->getOperand(6))->getZExtValue(); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { default: llvm_unreachable("unhandled vld3lane type"); @@ -1649,10 +1647,9 @@ case MVT::v2f32: case MVT::v2i32: Opc = ARM::VLD3LNd32; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, N->getOperand(3), N->getOperand(4), - N->getOperand(5), N->getOperand(6), Chain }; + N->getOperand(5), getI32Imm(Lane), Chain }; return CurDAG->getMachineNode(Opc, dl, VT, VT, VT, MVT::Other, Ops, 8); } // Quad registers are handled by extracting subregs, doing the load, @@ -1677,8 +1674,6 @@ RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(6))->getZExtValue(); unsigned NumElts = RegVT.getVectorNumElements(); int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; @@ -1714,6 +1709,8 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); + unsigned Lane = cast(N->getOperand(7))->getZExtValue(); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { default: llvm_unreachable("unhandled vld4lane type"); @@ -1722,11 +1719,10 @@ case MVT::v2f32: case MVT::v2i32: Opc = ARM::VLD4LNd32; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, N->getOperand(3), N->getOperand(4), N->getOperand(5), N->getOperand(6), - N->getOperand(7), Chain }; + getI32Imm(Lane), Chain }; std::vector ResTys(4, VT); ResTys.push_back(MVT::Other); return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 9); @@ -1753,8 +1749,6 @@ RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(7))->getZExtValue(); unsigned NumElts = RegVT.getVectorNumElements(); int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; @@ -1797,6 +1791,7 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); VT = N->getOperand(3).getValueType(); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { @@ -1807,7 +1802,6 @@ case MVT::v2i32: Opc = ARM::VST2d32; break; case MVT::v1i64: Opc = ARM::VST2d64; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, N->getOperand(3), N->getOperand(4), Chain }; return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 6); @@ -1821,7 +1815,6 @@ case MVT::v4f32: Opc = ARM::VST2q32; RegVT = MVT::v2f32; break; case MVT::v4i32: Opc = ARM::VST2q32; RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); SDValue D0 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, N->getOperand(3)); SDValue D1 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, @@ -1839,6 +1832,7 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); VT = N->getOperand(3).getValueType(); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { @@ -1849,7 +1843,6 @@ case MVT::v2i32: Opc = ARM::VST3d32; break; case MVT::v1i64: Opc = ARM::VST3d64; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, N->getOperand(3), N->getOperand(4), N->getOperand(5), Chain }; @@ -1870,7 +1863,6 @@ case MVT::v4i32: Opc = ARM::VST3q32a; Opc2 = ARM::VST3q32b; RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); // Enable writeback to the address register. MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), MVT::i32); @@ -1904,6 +1896,7 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); VT = N->getOperand(3).getValueType(); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { @@ -1914,7 +1907,6 @@ case MVT::v2i32: Opc = ARM::VST4d32; break; case MVT::v1i64: Opc = ARM::VST4d64; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, N->getOperand(3), N->getOperand(4), N->getOperand(5), N->getOperand(6), Chain }; @@ -1935,7 +1927,6 @@ case MVT::v4i32: Opc = ARM::VST4q32a; Opc2 = ARM::VST4q32b; RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); // Enable writeback to the address register. MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), MVT::i32); @@ -1975,6 +1966,8 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); + unsigned Lane = cast(N->getOperand(5))->getZExtValue(); VT = N->getOperand(3).getValueType(); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { @@ -1984,10 +1977,9 @@ case MVT::v2f32: case MVT::v2i32: Opc = ARM::VST2LNd32; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, N->getOperand(3), N->getOperand(4), - N->getOperand(5), Chain }; + getI32Imm(Lane), Chain }; return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 7); } // Quad registers are handled by extracting subregs and then doing @@ -2012,8 +2004,6 @@ RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(5))->getZExtValue(); unsigned NumElts = RegVT.getVectorNumElements(); int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; @@ -2031,6 +2021,8 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); + unsigned Lane = cast(N->getOperand(6))->getZExtValue(); VT = N->getOperand(3).getValueType(); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { @@ -2040,10 +2032,9 @@ case MVT::v2f32: case MVT::v2i32: Opc = ARM::VST3LNd32; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, N->getOperand(3), N->getOperand(4), - N->getOperand(5), N->getOperand(6), Chain }; + N->getOperand(5), getI32Imm(Lane), Chain }; return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 8); } // Quad registers are handled by extracting subregs and then doing @@ -2068,8 +2059,6 @@ RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(6))->getZExtValue(); unsigned NumElts = RegVT.getVectorNumElements(); int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; @@ -2089,6 +2078,8 @@ SDValue MemAddr, MemUpdate, MemOpc; if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) return NULL; + SDValue Chain = N->getOperand(0); + unsigned Lane = cast(N->getOperand(7))->getZExtValue(); VT = N->getOperand(3).getValueType(); if (VT.is64BitVector()) { switch (VT.getSimpleVT().SimpleTy) { @@ -2098,11 +2089,10 @@ case MVT::v2f32: case MVT::v2i32: Opc = ARM::VST4LNd32; break; } - SDValue Chain = N->getOperand(0); const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, N->getOperand(3), N->getOperand(4), N->getOperand(5), N->getOperand(6), - N->getOperand(7), Chain }; + getI32Imm(Lane), Chain }; return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 9); } // Quad registers are handled by extracting subregs and then doing @@ -2127,8 +2117,6 @@ RegVT = MVT::v2i32; break; } - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(7))->getZExtValue(); unsigned NumElts = RegVT.getVectorNumElements(); int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=84042&r1=84041&r2=84042&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Oct 13 17:29:24 2009 @@ -392,8 +392,6 @@ // We want to custom lower some of our intrinsics. setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom); - setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::Other, Custom); - setOperationAction(ISD::INTRINSIC_VOID, MVT::Other, Custom); setOperationAction(ISD::SETCC, MVT::i32, Expand); setOperationAction(ISD::SETCC, MVT::f32, Expand); @@ -1369,56 +1367,6 @@ return DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel); } -static SDValue LowerNeonVLDLaneIntrinsic(SDValue Op, SelectionDAG &DAG, - unsigned NumVecs) { - // Change the lane number operand to be a TargetConstant; otherwise it - // will be legalized into a register. - SDNode *Node = Op.getNode(); - ConstantSDNode *Lane = dyn_cast(Node->getOperand(NumVecs+3)); - if (!Lane) { - assert(false && "vld lane number must be a constant"); - return SDValue(); - } - SmallVector Ops(Node->op_begin(), Node->op_end()); - Ops[NumVecs+3] = DAG.getTargetConstant(Lane->getZExtValue(), MVT::i32); - return DAG.UpdateNodeOperands(Op, &Ops[0], Ops.size()); -} - -static SDValue LowerNeonVSTLaneIntrinsic(SDValue Op, SelectionDAG &DAG, - unsigned NumVecs) { - // Change the lane number operand to be a TargetConstant; otherwise it - // will be legalized into a register. - SDNode *Node = Op.getNode(); - ConstantSDNode *Lane = dyn_cast(Node->getOperand(NumVecs+3)); - if (!Lane) { - assert(false && "vst lane number must be a constant"); - return SDValue(); - } - SmallVector Ops(Node->op_begin(), Node->op_end()); - Ops[NumVecs+3] = DAG.getTargetConstant(Lane->getZExtValue(), MVT::i32); - return DAG.UpdateNodeOperands(Op, &Ops[0], Ops.size()); -} - -SDValue -ARMTargetLowering::LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) { - unsigned IntNo = cast(Op.getOperand(1))->getZExtValue(); - switch (IntNo) { - case Intrinsic::arm_neon_vld2lane: - return LowerNeonVLDLaneIntrinsic(Op, DAG, 2); - case Intrinsic::arm_neon_vld3lane: - return LowerNeonVLDLaneIntrinsic(Op, DAG, 3); - case Intrinsic::arm_neon_vld4lane: - return LowerNeonVLDLaneIntrinsic(Op, DAG, 4); - case Intrinsic::arm_neon_vst2lane: - return LowerNeonVSTLaneIntrinsic(Op, DAG, 2); - case Intrinsic::arm_neon_vst3lane: - return LowerNeonVSTLaneIntrinsic(Op, DAG, 3); - case Intrinsic::arm_neon_vst4lane: - return LowerNeonVSTLaneIntrinsic(Op, DAG, 4); - default: return SDValue(); // Don't custom lower most intrinsics. - } -} - SDValue ARMTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) { unsigned IntNo = cast(Op.getOperand(0))->getZExtValue(); @@ -2802,8 +2750,6 @@ case ISD::RETURNADDR: break; case ISD::FRAMEADDR: return LowerFRAMEADDR(Op, DAG); case ISD::GLOBAL_OFFSET_TABLE: return LowerGLOBAL_OFFSET_TABLE(Op, DAG); - case ISD::INTRINSIC_VOID: - case ISD::INTRINSIC_W_CHAIN: return LowerINTRINSIC_W_CHAIN(Op, DAG); case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG); case ISD::BIT_CONVERT: return ExpandBIT_CONVERT(Op.getNode(), DAG); case ISD::SHL: From clattner at apple.com Tue Oct 13 17:31:41 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 13 Oct 2009 15:31:41 -0700 Subject: [llvm-commits] [llvm] r84038 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/phi-aa.ll In-Reply-To: <200910132202.n9DM2KBh023328@zion.cs.uiuc.edu> References: <200910132202.n9DM2KBh023328@zion.cs.uiuc.edu> Message-ID: On Oct 13, 2009, at 3:02 PM, Evan Cheng wrote: > Author: evancheng > Date: Tue Oct 13 17:02:20 2009 > New Revision: 84038 > > URL: http://llvm.org/viewvc/llvm-project?rev=84038&view=rev > Log: > Teach basic AA about PHI nodes. If all operands of a phi NoAlias > another value than it's safe to declare the PHI NoAlias the value. > Ditto for MustAlias. Thoughts: Please manually reduce the testcase (or better yet, synthesize one from scratch). The basicaa tests are almost all very small and precise, e.g. 2007-08-01-NoAliasAndCalls.ll. Also, please don't add new uses of the malloc instruction, use alloca instead. Something like this (in hand written IR) should be enough: int X; int Y; int Z; void foo(int cond) { int *P = cond ? &X : &Y; int tmp = Z; *P = 123; return tmp-Z; } Did you look at the compile time impact of this on something like GVN on 403.gcc? Because you only have one 'VisitedPHIs' set, you are conflating PHIs walked on the LHS with phis walked on the RHS. I guess it probably doesn't matter because if the same phi shows up on both sides, they definitely alias. This is worth mentioning in a comment somewhere. > @@ -218,7 +222,16 @@ > // aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a > GEP instruction > // against another. > AliasResult aliasGEP(const Value *V1, unsigned V1Size, > - const Value *V2, unsigned V2Size); > + const Value *V2, unsigned V2Size, > + SmallSet &VisitedPHIs); > + > + AliasResult aliasPHI(const Value *V1, unsigned V1Size, > + const Value *V2, unsigned V2Size, > + SmallSet &VisitedPHIs); > + > + AliasResult aliasCheck(const Value *V1, unsigned V1Size, > + const Value *V2, unsigned V2Size, > + SmallSet &VisitedPHIs); Somewhat gross, but I think it would be better to make VisitedPHIs be an instance variable in the BasicAA class. Just assert that it is empty on entry into and exit out of the top level "alias" method. > +AliasAnalysis::AliasResult > +BasicAliasAnalysis::aliasPHI(const Value *V1, unsigned V1Size, V1 is statically required to be a PHI, it would be better for it to be declared as 'const PHINode*'. Also, the VisitedPHI set should be PHINode not Value as element type. > + SmallSet UniqueSrc; > + SmallVector V1Srcs; > + const PHINode *PN = cast(V1); this cast<> should be removed. > + // If all sources of the PHI node NoAlias or MustAlias V2, then > returns > + // NoAlias / MustAlias. Otherwise, returns MayAlias. > + AliasResult Alias = aliasCheck(V1Srcs[0], V1Size, V2, V2Size, > VisitedPHIs); if this call returns mayalias, you should exit early. mayalias is the most common result. -Chris From clattner at apple.com Tue Oct 13 17:33:02 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 13 Oct 2009 15:33:02 -0700 Subject: [llvm-commits] [llvm] r84033 - in /llvm/trunk/lib/Transforms/Scalar: InstructionCombining.cpp LICM.cpp LoopUnswitch.cpp In-Reply-To: References: <200910132141.n9DLfKNM022426@zion.cs.uiuc.edu> <6019B1B7-2268-49D4-84AF-9C8CC60072F6@apple.com> Message-ID: <1BDF950F-DC92-4C3E-A849-E9D66A731D12@apple.com> On Oct 13, 2009, at 3:23 PM, Devang Patel wrote: > > On Oct 13, 2009, at 2:50 PM, Chris Lattner wrote: > >> >> On Oct 13, 2009, at 2:41 PM, Devang Patel wrote: >> >>> Author: dpatel >>> Date: Tue Oct 13 16:41:20 2009 >>> New Revision: 84033 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=84033&view=rev >>> Log: >>> Do not check use_empty() before replaceAllUsesWith(). This gives >>> ValueHandles a chance to get properly updated. >> >> Ok, but two requests: >> >> 1. please add a comment that this is updating the uses and the >> metadata. > > This is not metadata specific. use_empty() by passes ValueIsRAUWd > call back for VHs. > > 309 // Notify all ValueHandles (if present) that this value is > going away. > 310 if (HasValueHandle) > 311 ValueHandleBase::ValueIsRAUWd(this, New); > > It is somewhat redundant if the value is deleted eventually, but > that is not the case many times. I don't understand what you mean. -Chris > - > Devang > >> 2. The code may need to check to see that the call doesn't return >> void. UndefValue::get(void) is not valid. >> >> -Chris >> >>> >>> >>> Modified: >>> llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp >>> llvm/trunk/lib/Transforms/Scalar/LICM.cpp >>> llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp >>> >>> Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84033&r1=84032&r2=84033&view=diff >>> >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp >>> (original) >>> +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue >>> Oct 13 16:41:20 2009 >>> @@ -9979,8 +9979,7 @@ >>> new StoreInst(ConstantInt::getTrue(*Context), >>> UndefValue::get(Type::getInt1PtrTy(*Context)), >>> OldCall); >>> - if (!OldCall->use_empty()) >>> - OldCall->replaceAllUsesWith(UndefValue::get(OldCall- >>> >getType())); >>> + OldCall->replaceAllUsesWith(UndefValue::get(OldCall- >>> >getType())); >>> if (isa(OldCall)) // Not worth removing an invoke >>> here. >>> return EraseInstFromFunction(*OldCall); >>> return 0; >>> @@ -9994,9 +9993,8 @@ >>> UndefValue::get(Type::getInt1PtrTy(*Context)), >>> CS.getInstruction()); >>> >>> - if (!CS.getInstruction()->use_empty()) >>> - CS.getInstruction()-> >>> - replaceAllUsesWith(UndefValue::get(CS.getInstruction()- >>> >getType())); >>> + CS.getInstruction()-> >>> + replaceAllUsesWith(UndefValue::get(CS.getInstruction()- >>> >getType())); >>> >>> if (InvokeInst *II = dyn_cast(CS.getInstruction())) { >>> // Don't break the CFG, insert a dummy cond branch. >>> @@ -10251,7 +10249,7 @@ >>> } >>> } >>> >>> - >>> + >>> if (!Caller->use_empty()) >>> Caller->replaceAllUsesWith(NV); >>> >>> @@ -10398,7 +10396,7 @@ >>> setCallingConv(cast(Caller)->getCallingConv()); >>> cast(NewCaller)->setAttributes(NewPAL); >>> } >>> - if (Caller->getType() != Type::getVoidTy(*Context) && ! >>> Caller->use_empty()) >>> + if (Caller->getType() != Type::getVoidTy(*Context)) >>> Caller->replaceAllUsesWith(NewCaller); >>> Caller->eraseFromParent(); >>> Worklist.Remove(Caller); >>> @@ -12781,8 +12779,7 @@ >>> ++NumDeadInst; >>> MadeIRChange = true; >>> } >>> - if (!I->use_empty()) >>> - I->replaceAllUsesWith(UndefValue::get(I->getType())); >>> + I->replaceAllUsesWith(UndefValue::get(I->getType())); >>> I->eraseFromParent(); >>> } >>> } >>> >>> Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=84033&r1=84032&r2=84033&view=diff >>> >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) >>> +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Tue Oct 13 16:41:20 >>> 2009 >>> @@ -486,8 +486,8 @@ >>> if (!isExitBlockDominatedByBlockInLoop(ExitBlocks[0], >>> I.getParent())) { >>> // Instruction is not used, just delete it. >>> CurAST->deleteValue(&I); >>> - if (!I.use_empty()) // If I has users in unreachable >>> blocks, eliminate. >>> - I.replaceAllUsesWith(UndefValue::get(I.getType())); >>> + // If I has users in unreachable blocks, eliminate. >>> + I.replaceAllUsesWith(UndefValue::get(I.getType())); >>> I.eraseFromParent(); >>> } else { >>> // Move the instruction to the start of the exit block, after >>> any PHI >>> @@ -499,8 +499,8 @@ >>> } else if (ExitBlocks.empty()) { >>> // The instruction is actually dead if there ARE NO exit blocks. >>> CurAST->deleteValue(&I); >>> - if (!I.use_empty()) // If I has users in unreachable blocks, >>> eliminate. >>> - I.replaceAllUsesWith(UndefValue::get(I.getType())); >>> + // If I has users in unreachable blocks, eliminate. >>> + I.replaceAllUsesWith(UndefValue::get(I.getType())); >>> I.eraseFromParent(); >>> } else { >>> // Otherwise, if we have multiple exits, use the PromoteMem2Reg >>> function to >>> >>> Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=84033&r1=84032&r2=84033&view=diff >>> >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) >>> +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 >>> 16:41:20 2009 >>> @@ -781,8 +781,7 @@ >>> >>> // Anything that uses the instructions in this basic block >>> should have their >>> // uses replaced with undefs. >>> - if (!I->use_empty()) >>> - I->replaceAllUsesWith(UndefValue::get(I->getType())); >>> + I->replaceAllUsesWith(UndefValue::get(I->getType())); >>> } >>> >>> // If this is the edge to the header block for a loop, remove the >>> loop and >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From enderby at apple.com Tue Oct 13 17:37:06 2009 From: enderby at apple.com (Kevin Enderby) Date: Tue, 13 Oct 2009 15:37:06 -0700 Subject: [llvm-commits] [llvm] r84040 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp In-Reply-To: References: <200910132219.n9DMJ2rW023952@zion.cs.uiuc.edu> Message-ID: All in good time with respect to the modifiers. This stuff is just coming up. I'm trying to bring up bits at a time I'm trying to not code every last thing for now. Please think of this as experimental like the X86 llvm-mc stuff for now. Thanks in advance for your patience, Kev On Oct 13, 2009, at 3:25 PM, Anton Korobeynikov wrote: > Hello, Kevin >> + // $42 -> immediate. > #42 ? I'll fix the comment :) > > What's about modifiers (e.g. #:lower16:foo / #:upper16:foo) ? > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State > University From nlewycky at google.com Tue Oct 13 17:47:15 2009 From: nlewycky at google.com (Nick Lewycky) Date: Tue, 13 Oct 2009 15:47:15 -0700 Subject: [llvm-commits] [llvm] r84038 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/phi-aa.ll In-Reply-To: <200910132202.n9DM2KBh023328@zion.cs.uiuc.edu> References: <200910132202.n9DM2KBh023328@zion.cs.uiuc.edu> Message-ID: Evan, please put a recursion depth limit on the number of PHIs this code is willing to walk backwards through, otherwise pathological code will show n^2 behaviour. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091013/db7520c7/attachment.html From dpatel at apple.com Tue Oct 13 17:56:32 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 22:56:32 -0000 Subject: [llvm-commits] [llvm] r84049 - in /llvm/trunk/lib/Transforms/Scalar: InstructionCombining.cpp LICM.cpp LoopUnswitch.cpp Message-ID: <200910132256.n9DMuXJg025396@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 17:56:32 2009 New Revision: 84049 URL: http://llvm.org/viewvc/llvm-project?rev=84049&view=rev Log: Check void type before using RAUWd. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/Transforms/Scalar/LICM.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84049&r1=84048&r2=84049&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Oct 13 17:56:32 2009 @@ -9979,7 +9979,10 @@ new StoreInst(ConstantInt::getTrue(*Context), UndefValue::get(Type::getInt1PtrTy(*Context)), OldCall); - OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType())); + // If OldCall dues not return void then replaceAllUsesWith undef. + // This allows ValueHandlers and custom metadata to adjust itself. + if (OldCall->getType() != Type::getVoidTy(*Context)) + OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType())); if (isa(OldCall)) // Not worth removing an invoke here. return EraseInstFromFunction(*OldCall); return 0; @@ -9993,8 +9996,11 @@ UndefValue::get(Type::getInt1PtrTy(*Context)), CS.getInstruction()); - CS.getInstruction()-> - replaceAllUsesWith(UndefValue::get(CS.getInstruction()->getType())); + // If CS dues not return void then replaceAllUsesWith undef. + // This allows ValueHandlers and custom metadata to adjust itself. + if (CS.getInstruction()->getType() != Type::getVoidTy(*Context)) + CS.getInstruction()-> + replaceAllUsesWith(UndefValue::get(CS.getInstruction()->getType())); if (InvokeInst *II = dyn_cast(CS.getInstruction())) { // Don't break the CFG, insert a dummy cond branch. @@ -12779,7 +12785,12 @@ ++NumDeadInst; MadeIRChange = true; } - I->replaceAllUsesWith(UndefValue::get(I->getType())); + + + // If I is not void type then replaceAllUsesWith undef. + // This allows ValueHandlers and custom metadata to adjust itself. + if (I->getType() != Type::getVoidTy(*Context)) + I->replaceAllUsesWith(UndefValue::get(I->getType())); I->eraseFromParent(); } } Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=84049&r1=84048&r2=84049&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Tue Oct 13 17:56:32 2009 @@ -487,7 +487,10 @@ // Instruction is not used, just delete it. CurAST->deleteValue(&I); // If I has users in unreachable blocks, eliminate. - I.replaceAllUsesWith(UndefValue::get(I.getType())); + // If I is not void type then replaceAllUsesWith undef. + // This allows ValueHandlers and custom metadata to adjust itself. + if (I.getType() != Type::getVoidTy(I.getContext())) + I.replaceAllUsesWith(UndefValue::get(I.getType())); I.eraseFromParent(); } else { // Move the instruction to the start of the exit block, after any PHI @@ -500,7 +503,10 @@ // The instruction is actually dead if there ARE NO exit blocks. CurAST->deleteValue(&I); // If I has users in unreachable blocks, eliminate. - I.replaceAllUsesWith(UndefValue::get(I.getType())); + // If I is not void type then replaceAllUsesWith undef. + // This allows ValueHandlers and custom metadata to adjust itself. + if (I.getType() != Type::getVoidTy(I.getContext())) + I.replaceAllUsesWith(UndefValue::get(I.getType())); I.eraseFromParent(); } else { // Otherwise, if we have multiple exits, use the PromoteMem2Reg function to Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=84049&r1=84048&r2=84049&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 17:56:32 2009 @@ -781,7 +781,10 @@ // Anything that uses the instructions in this basic block should have their // uses replaced with undefs. - I->replaceAllUsesWith(UndefValue::get(I->getType())); + // If I is not void type then replaceAllUsesWith undef. + // This allows ValueHandlers and custom metadata to adjust itself. + if (I->getType() != Type::getVoidTy(I->getContext())) + I->replaceAllUsesWith(UndefValue::get(I->getType())); } // If this is the edge to the header block for a loop, remove the loop and From dpatel at apple.com Tue Oct 13 18:28:54 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 13 Oct 2009 23:28:54 -0000 Subject: [llvm-commits] [llvm] r84054 - in /llvm/trunk: include/llvm/Support/DebugLoc.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/MachineInstr.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/ExecutionEngine/JIT/JITEmitter.cpp lib/Target/PIC16/PIC16DebugInfo.cpp Message-ID: <200910132328.n9DNSs42026665@zion.cs.uiuc.edu> Author: dpatel Date: Tue Oct 13 18:28:53 2009 New Revision: 84054 URL: http://llvm.org/viewvc/llvm-project?rev=84054&view=rev Log: s/DebugLoc.CompileUnit/DebugLoc.Scope/g s/DebugLoc.InlinedLoc/DebugLoc.InlinedAtLoc/g Modified: llvm/trunk/include/llvm/Support/DebugLoc.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/MachineInstr.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Modified: llvm/trunk/include/llvm/Support/DebugLoc.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?rev=84054&r1=84053&r2=84054&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/DebugLoc.h (original) +++ llvm/trunk/include/llvm/Support/DebugLoc.h Tue Oct 13 18:28:53 2009 @@ -24,19 +24,19 @@ /// DebugLocTuple - Debug location tuple of filename id, line and column. /// struct DebugLocTuple { - MDNode *CompileUnit; - MDNode *InlinedLoc; + MDNode *Scope; + MDNode *InlinedAtLoc; unsigned Line, Col; DebugLocTuple() - : CompileUnit(0), InlinedLoc(0), Line(~0U), Col(~0U) {}; + : Scope(0), InlinedAtLoc(0), Line(~0U), Col(~0U) {}; DebugLocTuple(MDNode *n, MDNode *i, unsigned l, unsigned c) - : CompileUnit(n), InlinedLoc(i), Line(l), Col(c) {}; + : Scope(n), InlinedAtLoc(i), Line(l), Col(c) {}; bool operator==(const DebugLocTuple &DLT) const { - return CompileUnit == DLT.CompileUnit && - InlinedLoc == DLT.InlinedLoc && + return Scope == DLT.Scope && + InlinedAtLoc == DLT.InlinedAtLoc && Line == DLT.Line && Col == DLT.Col; } bool operator!=(const DebugLocTuple &DLT) const { @@ -74,16 +74,16 @@ return DebugLocTuple((MDNode*)~1U, (MDNode*)~1U, ~1U, ~1U); } static unsigned getHashValue(const DebugLocTuple &Val) { - return DenseMapInfo::getHashValue(Val.CompileUnit) ^ - DenseMapInfo::getHashValue(Val.InlinedLoc) ^ + return DenseMapInfo::getHashValue(Val.Scope) ^ + DenseMapInfo::getHashValue(Val.InlinedAtLoc) ^ DenseMapInfo::getHashValue(Val.Line) ^ DenseMapInfo::getHashValue(Val.Col); } static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) { - return LHS.CompileUnit == RHS.CompileUnit && - LHS.InlinedLoc == RHS.InlinedLoc && - LHS.Line == RHS.Line && - LHS.Col == RHS.Col; + return LHS.Scope == RHS.Scope && + LHS.InlinedAtLoc == RHS.InlinedAtLoc && + LHS.Line == RHS.Line && + LHS.Col == RHS.Col; } static bool isPod() { return true; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=84054&r1=84053&r2=84054&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Oct 13 18:28:53 2009 @@ -1362,9 +1362,9 @@ if (!DL.isUnknown()) { DebugLocTuple CurDLT = MF->getDebugLocTuple(DL); if (BeforePrintingInsn) { - if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT) { + if (CurDLT.Scope != 0 && PrevDLT != CurDLT) { unsigned L = DW->RecordSourceLine(CurDLT.Line, CurDLT.Col, - CurDLT.CompileUnit); + CurDLT.Scope); printLabel(L); #ifdef ATTACH_DEBUG_INFO_TO_AN_INSN DW->SetDbgScopeBeginLabels(MI, L); @@ -1773,9 +1773,10 @@ // Print source line info. O.PadToColumn(MAI->getCommentColumn()); O << MAI->getCommentString() << " SrcLine "; - if (DLT.CompileUnit) { - DICompileUnit CU(DLT.CompileUnit); - O << CU.getFilename() << " "; + if (DLT.Scope) { + DICompileUnit CU(DLT.Scope); + if (!CU.isNull()) + O << CU.getFilename() << " "; } O << DLT.Line; if (DLT.Col != 0) Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=84054&r1=84053&r2=84054&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Oct 13 18:28:53 2009 @@ -1842,14 +1842,14 @@ if (DL.isUnknown()) continue; DebugLocTuple DLT = MF->getDebugLocTuple(DL); - if (!DLT.CompileUnit) + if (!DLT.Scope) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. - DIDescriptor D(DLT.CompileUnit); + DIDescriptor D(DLT.Scope); if (!D.isCompileUnit()) { - DbgScope *Scope = getDbgScope(DLT.CompileUnit, MInsn); + DbgScope *Scope = getDbgScope(DLT.Scope, MInsn); Scope->setLastInsn(MInsn); } } @@ -1942,11 +1942,11 @@ if (!FDL.isUnknown()) { DebugLocTuple DLT = MF->getDebugLocTuple(FDL); unsigned LabelID = 0; - DISubprogram SP = getDISubprogram(DLT.CompileUnit); + DISubprogram SP = getDISubprogram(DLT.Scope); if (!SP.isNull()) - LabelID = RecordSourceLine(SP.getLineNumber(), 0, DLT.CompileUnit); + LabelID = RecordSourceLine(SP.getLineNumber(), 0, DLT.Scope); else - LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.CompileUnit); + LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.Scope); Asm->printLabel(LabelID); O << '\n'; } @@ -1954,7 +1954,7 @@ DebugLoc FDL = MF->getDefaultDebugLoc(); if (!FDL.isUnknown()) { DebugLocTuple DLT = MF->getDebugLocTuple(FDL); - unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.CompileUnit); + unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.Scope); Asm->printLabel(LabelID); O << '\n'; } Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=84054&r1=84053&r2=84054&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Tue Oct 13 18:28:53 2009 @@ -1082,11 +1082,12 @@ if (!debugLoc.isUnknown()) { const MachineFunction *MF = getParent()->getParent(); DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc); - DICompileUnit CU(DLT.CompileUnit); - OS << " [dbg: " - << CU.getDirectory() << '/' << CU.getFilename() << "," - << DLT.Line << "," - << DLT.Col << "]"; + DICompileUnit CU(DLT.Scope); + if (!CU.isNull()) + OS << " [dbg: " + << CU.getDirectory() << '/' << CU.getFilename() << "," + << DLT.Line << "," + << DLT.Col << "]"; } OS << "\n"; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=84054&r1=84053&r2=84054&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Oct 13 18:28:53 2009 @@ -385,10 +385,9 @@ DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc); DISubprogram SP(FSI->getSubprogram()); - unsigned LabelID = DW->RecordInlinedFnStart(SP, - DICompileUnit(PrevLocTpl.CompileUnit), - PrevLocTpl.Line, - PrevLocTpl.Col); + unsigned LabelID = + DW->RecordInlinedFnStart(SP,DICompileUnit(PrevLocTpl.Scope), + PrevLocTpl.Line, PrevLocTpl.Col); const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); BuildMI(MBB, DL, II).addImm(LabelID); return true; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=84054&r1=84053&r2=84054&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Tue Oct 13 18:28:53 2009 @@ -3910,7 +3910,7 @@ return 0; DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc); DISubprogram SP(FSI.getSubprogram()); - DICompileUnit CU(PrevLocTpl.CompileUnit); + DICompileUnit CU(PrevLocTpl.Scope); unsigned LabelID = DW->RecordInlinedFnStart(SP, CU, PrevLocTpl.Line, PrevLocTpl.Col); Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=84054&r1=84053&r2=84054&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Tue Oct 13 18:28:53 2009 @@ -710,7 +710,7 @@ DebugLocTuple CurDLT = EmissionDetails.MF->getDebugLocTuple(DL); if (BeforePrintingInsn) { - if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT) { + if (CurDLT.Scope != 0 && PrevDLT != CurDLT) { JITEvent_EmittedFunctionDetails::LineStart NextLine; NextLine.Address = getCurrentPCValue(); NextLine.Loc = DL; Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=84054&r1=84053&r2=84054&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Tue Oct 13 18:28:53 2009 @@ -258,7 +258,7 @@ if (! EmitDebugDirectives) return; assert (! DL.isUnknown() && "can't change to invalid debug loc"); - MDNode *CU = MF.getDebugLocTuple(DL).CompileUnit; + MDNode *CU = MF.getDebugLocTuple(DL).Scope; unsigned line = MF.getDebugLocTuple(DL).Line; SwitchToCU(CU); From enderby at apple.com Tue Oct 13 18:33:38 2009 From: enderby at apple.com (Kevin Enderby) Date: Tue, 13 Oct 2009 23:33:38 -0000 Subject: [llvm-commits] [llvm] r84055 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <200910132333.n9DNXcWB026831@zion.cs.uiuc.edu> Author: enderby Date: Tue Oct 13 18:33:38 2009 New Revision: 84055 URL: http://llvm.org/viewvc/llvm-project?rev=84055&view=rev Log: Correct comment about ARM immediates using '#' not '$' and TODO for modifiers. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=84055&r1=84054&r2=84055&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Tue Oct 13 18:33:38 2009 @@ -537,7 +537,8 @@ if (!ParseRegisterList(Op)) return false; case AsmToken::Hash: - // $42 -> immediate. + // #42 -> immediate. + // TODO: ":lower16:" and ":upper16:" modifiers after # before immediate getLexer().Lex(); const MCExpr *Val; if (getParser().ParseExpression(Val)) From gohman at apple.com Tue Oct 13 18:36:36 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 13 Oct 2009 23:36:36 -0000 Subject: [llvm-commits] [llvm] r84056 - /llvm/trunk/include/llvm/Analysis/InlineCost.h Message-ID: <200910132336.n9DNaaj1026970@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 18:36:36 2009 New Revision: 84056 URL: http://llvm.org/viewvc/llvm-project?rev=84056&view=rev Log: Fix resetCachedCostInfo to reset all of the cost information, instead of just the NumBlocks field. Modified: llvm/trunk/include/llvm/Analysis/InlineCost.h Modified: llvm/trunk/include/llvm/Analysis/InlineCost.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InlineCost.h?rev=84056&r1=84055&r2=84056&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/InlineCost.h (original) +++ llvm/trunk/include/llvm/Analysis/InlineCost.h Tue Oct 13 18:36:36 2009 @@ -172,7 +172,7 @@ /// resetCachedFunctionInfo - erase any cached cost info for this function. void resetCachedCostInfo(Function* Caller) { - CachedFunctionInfo[Caller].Metrics.NumBlocks = 0; + CachedFunctionInfo[Caller] = FunctionInfo(); } }; } From gohman at apple.com Tue Oct 13 18:58:05 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 13 Oct 2009 23:58:05 -0000 Subject: [llvm-commits] [llvm] r84059 - /llvm/trunk/lib/CodeGen/README.txt Message-ID: <200910132358.n9DNw5au027737@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 18:58:05 2009 New Revision: 84059 URL: http://llvm.org/viewvc/llvm-project?rev=84059&view=rev Log: Add a few README.txt items. Modified: llvm/trunk/lib/CodeGen/README.txt Modified: llvm/trunk/lib/CodeGen/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/README.txt?rev=84059&r1=84058&r2=84059&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/README.txt (original) +++ llvm/trunk/lib/CodeGen/README.txt Tue Oct 13 18:58:05 2009 @@ -206,3 +206,32 @@ not spill slots. 2. Reorder objects to fill in gaps between objects. e.g. 4, 1, , 4, 1, 1, 1, , 4 => 4, 1, 1, 1, 1, 4, 4 + +//===---------------------------------------------------------------------===// + +The scheduler should be able to sort nearby instructions by their address. For +example, in an expanded memset sequence it's not uncommon to see code like this: + + movl $0, 4(%rdi) + movl $0, 8(%rdi) + movl $0, 12(%rdi) + movl $0, 0(%rdi) + +Each of the stores is independent, and the scheduler is currently making an +arbitrary decision about the order. + +//===---------------------------------------------------------------------===// + +Another opportunitiy in this code is that the $0 could be moved to a register: + + movl $0, 4(%rdi) + movl $0, 8(%rdi) + movl $0, 12(%rdi) + movl $0, 0(%rdi) + +This would save substantial code size, especially for longer sequences like +this. It would be easy to have a rule telling isel to avoid matching MOV32mi +if the immediate has more than some fixed number of uses. It's more involved +to teach the register allocator how to do late folding to recover from +excessive register pressure. + From gohman at apple.com Tue Oct 13 19:02:02 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 14 Oct 2009 00:02:02 -0000 Subject: [llvm-commits] [llvm] r84060 - /llvm/trunk/lib/CodeGen/README.txt Message-ID: <200910140002.n9E022UK027886@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 19:02:01 2009 New Revision: 84060 URL: http://llvm.org/viewvc/llvm-project?rev=84060&view=rev Log: This remat entry is basically done. There are hooks to allow targets to remat non-load instructions as loads, and the remat code now uses the UnmodeledSideEffects flags, MachineMemOperands, and similar things to decide which instructions are valid for rematerialization. Modified: llvm/trunk/lib/CodeGen/README.txt Modified: llvm/trunk/lib/CodeGen/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/README.txt?rev=84060&r1=84059&r2=84060&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/README.txt (original) +++ llvm/trunk/lib/CodeGen/README.txt Tue Oct 13 19:02:01 2009 @@ -30,44 +30,6 @@ //===---------------------------------------------------------------------===// -I think we should have a "hasSideEffects" flag (which is automatically set for -stuff that "isLoad" "isCall" etc), and the remat pass should eventually be able -to remat any instruction that has no side effects, if it can handle it and if -profitable. - -For now, I'd suggest having the remat stuff work like this: - -1. I need to spill/reload this thing. -2. Check to see if it has side effects. -3. Check to see if it is simple enough: e.g. it only has one register -destination and no register input. -4. If so, clone the instruction, do the xform, etc. - -Advantages of this are: - -1. the .td file describes the behavior of the instructions, not the way the - algorithm should work. -2. as remat gets smarter in the future, we shouldn't have to be changing the .td - files. -3. it is easier to explain what the flag means in the .td file, because you - don't have to pull in the explanation of how the current remat algo works. - -Some potential added complexities: - -1. Some instructions have to be glued to it's predecessor or successor. All of - the PC relative instructions and condition code setting instruction. We could - mark them as hasSideEffects, but that's not quite right. PC relative loads - from constantpools can be remat'ed, for example. But it requires more than - just cloning the instruction. Some instructions can be remat'ed but it - expands to more than one instruction. But allocator will have to make a - decision. - -4. As stated in 3, not as simple as cloning in some cases. The target will have - to decide how to remat it. For example, an ARM 2-piece constant generation - instruction is remat'ed as a load from constantpool. - -//===---------------------------------------------------------------------===// - bb27 ... ... %reg1037 = ADDri %reg1039, 1 From gohman at apple.com Tue Oct 13 19:08:59 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 14 Oct 2009 00:08:59 -0000 Subject: [llvm-commits] [llvm] r84061 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Message-ID: <200910140008.n9E08x6s028170@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 19:08:59 2009 New Revision: 84061 URL: http://llvm.org/viewvc/llvm-project?rev=84061&view=rev Log: Make isSafeToClobberEFLAGS more aggressive. Teach it to scan backwards (for uses marked kill and defs marked dead) a few instructions in addition to forwards. Also, increase the maximum number of instructions to scan, as it appears to help in a fair number of cases. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=84061&r1=84060&r2=84061&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Tue Oct 13 19:08:59 2009 @@ -853,7 +853,7 @@ /// isSafeToClobberEFLAGS - Return true if it's safe insert an instruction that /// would clobber the EFLAGS condition register. Note the result may be /// conservative. If it cannot definitely determine the safety after visiting -/// two instructions it assumes it's not safe. +/// a few instructions in each direction it assumes it's not safe. static bool isSafeToClobberEFLAGS(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) { // It's always safe to clobber EFLAGS at the end of a block. @@ -861,11 +861,13 @@ return true; // For compile time consideration, if we are not able to determine the - // safety after visiting 2 instructions, we will assume it's not safe. - for (unsigned i = 0; i < 2; ++i) { + // safety after visiting 4 instructions in each direction, we will assume + // it's not safe. + MachineBasicBlock::iterator Iter = I; + for (unsigned i = 0; i < 4; ++i) { bool SeenDef = false; - for (unsigned j = 0, e = I->getNumOperands(); j != e; ++j) { - MachineOperand &MO = I->getOperand(j); + for (unsigned j = 0, e = Iter->getNumOperands(); j != e; ++j) { + MachineOperand &MO = Iter->getOperand(j); if (!MO.isReg()) continue; if (MO.getReg() == X86::EFLAGS) { @@ -878,10 +880,33 @@ if (SeenDef) // This instruction defines EFLAGS, no need to look any further. return true; - ++I; + ++Iter; // If we make it to the end of the block, it's safe to clobber EFLAGS. - if (I == MBB.end()) + if (Iter == MBB.end()) + return true; + } + + Iter = I; + for (unsigned i = 0; i < 4; ++i) { + // If we make it to the beginning of the block, it's safe to clobber + // EFLAGS iff EFLAGS is not live-in. + if (Iter == MBB.begin()) + return !MBB.isLiveIn(X86::EFLAGS); + + --Iter; + bool SawKill = false; + for (unsigned j = 0, e = Iter->getNumOperands(); j != e; ++j) { + MachineOperand &MO = Iter->getOperand(j); + if (MO.isReg() && MO.getReg() == X86::EFLAGS) { + if (MO.isDef()) return MO.isDead(); + if (MO.isKill()) SawKill = true; + } + } + + if (SawKill) + // This instruction kills EFLAGS and doesn't redefine it, so + // there's no need to look further. return true; } From dalej at apple.com Tue Oct 13 19:09:54 2009 From: dalej at apple.com (Dale Johannesen) Date: Wed, 14 Oct 2009 00:09:54 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r84062 - in /llvm-gcc-4.2/trunk/gcc: c-common.c llvm-convert.cpp tree.h Message-ID: <200910140009.n9E09sqq028212@zion.cs.uiuc.edu> Author: johannes Date: Tue Oct 13 19:09:54 2009 New Revision: 84062 URL: http://llvm.org/viewvc/llvm-project?rev=84062&view=rev Log: Set msasm bit on asm's derived from asm blocks. Modified: llvm-gcc-4.2/trunk/gcc/c-common.c llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/tree.h Modified: llvm-gcc-4.2/trunk/gcc/c-common.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-common.c?rev=84062&r1=84061&r2=84062&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/c-common.c (original) +++ llvm-gcc-4.2/trunk/gcc/c-common.c Tue Oct 13 19:09:54 2009 @@ -7959,6 +7959,8 @@ stmt = build_stmt (ASM_EXPR, sexpr, NULL_TREE, NULL_TREE, clobbers, NULL_TREE); clobbers = NULL_TREE; ASM_VOLATILE_P (stmt) = 1; + /* LLVM LOCAL */ + ASM_ASM_BLOCK (stmt) = 1; (void)add_stmt (stmt); } #endif @@ -7968,6 +7970,8 @@ sexpr = build_string (strlen (iasm_buffer), iasm_buffer); stmt = build_stmt (ASM_EXPR, sexpr, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE); ASM_VOLATILE_P (stmt) = 1; + /* LLVM LOCAL */ + ASM_ASM_BLOCK (stmt) = 1; (void)add_stmt (stmt); /* Build .line "line-number" directive. */ @@ -7975,6 +7979,8 @@ sexpr = build_string (strlen (iasm_buffer), iasm_buffer); stmt = build_stmt (ASM_EXPR, sexpr, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE); ASM_VOLATILE_P (stmt) = 1; + /* LLVM LOCAL */ + ASM_ASM_BLOCK (stmt) = 1; (void)add_stmt (stmt); iasm_buffer[0] = '\0'; @@ -8126,6 +8132,8 @@ /* Treat as volatile always. */ stmt = build_stmt (ASM_EXPR, sexpr, outputs, inputs, clobbers, uses); ASM_VOLATILE_P (stmt) = 1; + /* LLVM LOCAL */ + ASM_ASM_BLOCK (stmt) = 1; add_stmt (stmt); input_location.line = saved_lineno; return; @@ -8738,6 +8746,8 @@ /* Simple asm statements are treated as volatile. */ stmt = build_stmt (ASM_EXPR, sexpr, outputs, inputs, clobbers, NULL_TREE); ASM_VOLATILE_P (stmt) = 1; + /* LLVM LOCAL */ + ASM_ASM_BLOCK (stmt) = 1; stmt = add_stmt (stmt); #endif return stmt; @@ -8965,6 +8975,8 @@ /* Treat as volatile always. */ stmt = build_stmt (ASM_EXPR, strlab, NULL_TREE, inputs, NULL_TREE, NULL_TREE); ASM_VOLATILE_P (stmt) = 1; + /* LLVM LOCAL */ + ASM_ASM_BLOCK (stmt) = 1; add_stmt (stmt); } @@ -8972,6 +8984,8 @@ /* Treat as volatile always. */ stmt = build_stmt (ASM_EXPR, strlab, NULL_TREE, inputs, NULL_TREE, NULL_TREE); ASM_VOLATILE_P (stmt) = 1; + /* LLVM LOCAL */ + ASM_ASM_BLOCK (stmt) = 1; add_stmt (stmt); } /* APPLE LOCAL end CW asm blocks */ Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=84062&r1=84061&r2=84062&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Oct 13 19:09:54 2009 @@ -4634,7 +4634,8 @@ } Value *Asm = InlineAsm::get(FTy, NewAsmStr, ConstraintStr, - ASM_VOLATILE_P(exp) || !ASM_OUTPUTS(exp)); + ASM_VOLATILE_P(exp) || !ASM_OUTPUTS(exp), + ASM_ASM_BLOCK(exp)); CallInst *CV = Builder.CreateCall(Asm, CallOps.begin(), CallOps.end(), CallResultTypes.empty() ? "" : "asmtmp"); CV->setDoesNotThrow(); Modified: llvm-gcc-4.2/trunk/gcc/tree.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree.h?rev=84062&r1=84061&r2=84062&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/tree.h (original) +++ llvm-gcc-4.2/trunk/gcc/tree.h Tue Oct 13 19:09:54 2009 @@ -449,6 +449,10 @@ OMP_SECTION OMP_PARALLEL_COMBINED in OMP_PARALLEL + LLVM LOCAL begin msasm bit on asm + ASM_ASM_BLOCK in + ASM_EXPR + LLVM LOCAL end protected_flag: @@ -1548,6 +1552,8 @@ ASM_OPERAND with no operands. */ #define ASM_INPUT_P(NODE) (TREE_STATIC (NODE)) #define ASM_VOLATILE_P(NODE) (TREE_PUBLIC (NODE)) +/* LLVM LOCAL msasm bit in asm */ +#define ASM_ASM_BLOCK(NODE) (TREE_PRIVATE (NODE)) /* COND_EXPR accessors. */ #define COND_EXPR_COND(NODE) (TREE_OPERAND (COND_EXPR_CHECK (NODE), 0)) From dalej at apple.com Tue Oct 13 19:10:55 2009 From: dalej at apple.com (Dale Johannesen) Date: Wed, 14 Oct 2009 00:10:55 -0000 Subject: [llvm-commits] [llvm] r84063 - in /llvm/trunk/test: FrontendC++/msasm.cpp FrontendC/msasm.c Message-ID: <200910140010.n9E0AtRV028250@zion.cs.uiuc.edu> Author: johannes Date: Tue Oct 13 19:10:54 2009 New Revision: 84063 URL: http://llvm.org/viewvc/llvm-project?rev=84063&view=rev Log: Testcases for msasm bit (llvm-gcc 84062). Added: llvm/trunk/test/FrontendC++/msasm.cpp llvm/trunk/test/FrontendC/msasm.c Added: llvm/trunk/test/FrontendC++/msasm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/msasm.cpp?rev=84063&view=auto ============================================================================== --- llvm/trunk/test/FrontendC++/msasm.cpp (added) +++ llvm/trunk/test/FrontendC++/msasm.cpp Tue Oct 13 19:10:54 2009 @@ -0,0 +1,23 @@ +// RUN: %llvmgcc %s -fasm-blocks -S -o - | FileCheck %s +// Complicated expression as jump target +// XFAIL: * +// XTARGET: x86,i386,i686 + +void Method3() +{ +// CHECK: Method3 +// CHECK-NOT: msasm + asm("foo:"); +// CHECK: return +} + +void Method4() +{ +// CHECK: Method4 +// CHECK: msasm + asm { + bar: + } +// CHECK: return +} + Added: llvm/trunk/test/FrontendC/msasm.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/msasm.c?rev=84063&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/msasm.c (added) +++ llvm/trunk/test/FrontendC/msasm.c Tue Oct 13 19:10:54 2009 @@ -0,0 +1,23 @@ +// RUN: %llvmgcc %s -fasm-blocks -S -o - | FileCheck %s +// Complicated expression as jump target +// XFAIL: * +// XTARGET: x86,i386,i686 + +void Method3() +{ +// CHECK: Method3 +// CHECK-NOT: msasm + asm("foo:"); +// CHECK: return +} + +void Method4() +{ +// CHECK: Method4 +// CHECK: msasm + asm { + bar: + } +// CHECK: return +} + From gohman at apple.com Tue Oct 13 19:28:48 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 14 Oct 2009 00:28:48 -0000 Subject: [llvm-commits] [llvm] r84065 - /llvm/trunk/test/CodeGen/X86/fastcc.ll Message-ID: <200910140028.n9E0Smm6028857@zion.cs.uiuc.edu> Author: djg Date: Tue Oct 13 19:28:48 2009 New Revision: 84065 URL: http://llvm.org/viewvc/llvm-project?rev=84065&view=rev Log: Fix this test to account for a movl $0 being emitted as an xor now, and convert it to FileCheck. Modified: llvm/trunk/test/CodeGen/X86/fastcc.ll Modified: llvm/trunk/test/CodeGen/X86/fastcc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fastcc.ll?rev=84065&r1=84064&r2=84065&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fastcc.ll (original) +++ llvm/trunk/test/CodeGen/X86/fastcc.ll Tue Oct 13 19:28:48 2009 @@ -1,5 +1,6 @@ -; RUN: llc < %s -mtriple=i686-apple-darwin -mattr=+sse2 | grep mov | grep ecx | grep 0 -; RUN: llc < %s -mtriple=i686-apple-darwin -mattr=+sse2 | grep mov | grep xmm0 | grep 8 +; RUN: llc < %s -mtriple=i686-apple-darwin -mattr=+sse2 | FileCheck %s +; CHECK: movsd %xmm0, 8(%esp) +; CHECK: xorl %ecx, %ecx @d = external global double ; [#uses=1] @c = external global double ; [#uses=1] From dalej at apple.com Tue Oct 13 19:34:56 2009 From: dalej at apple.com (Dale Johannesen) Date: Wed, 14 Oct 2009 00:34:56 -0000 Subject: [llvm-commits] [llvm] r84066 - /llvm/trunk/test/FrontendC++/msasm.cpp Message-ID: <200910140034.n9E0YuKI029035@zion.cs.uiuc.edu> Author: johannes Date: Tue Oct 13 19:34:56 2009 New Revision: 84066 URL: http://llvm.org/viewvc/llvm-project?rev=84066&view=rev Log: Use llvmgxx for C++ test. Modified: llvm/trunk/test/FrontendC++/msasm.cpp Modified: llvm/trunk/test/FrontendC++/msasm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/msasm.cpp?rev=84066&r1=84065&r2=84066&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/msasm.cpp (original) +++ llvm/trunk/test/FrontendC++/msasm.cpp Tue Oct 13 19:34:56 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc %s -fasm-blocks -S -o - | FileCheck %s +// RUN: %llvmgxx %s -fasm-blocks -S -o - | FileCheck %s // Complicated expression as jump target // XFAIL: * // XTARGET: x86,i386,i686 From eocallaghan at auroraux.org Tue Oct 13 19:44:50 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Wed, 14 Oct 2009 00:44:50 -0000 Subject: [llvm-commits] [llvm] r84067 - in /llvm/trunk: autoconf/configure.ac configure Message-ID: <200910140044.n9E0ipL5029348@zion.cs.uiuc.edu> Author: evocallaghan Date: Tue Oct 13 19:44:50 2009 New Revision: 84067 URL: http://llvm.org/viewvc/llvm-project?rev=84067&view=rev Log: Provide AuroraUX triple support in configure. Credit to - Paul Davey. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/configure Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=84067&r1=84066&r2=84067&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Tue Oct 13 19:44:50 2009 @@ -165,6 +165,11 @@ llvm_cv_no_link_all_option="-Wl,-z,defaultextract" llvm_cv_os_type="SunOS" llvm_cv_platform_type="Unix" ;; + *-*-auroraux*) + llvm_cv_link_all_option="-Wl,-z,allextract" + llvm_cv_link_all_option="-Wl,-z,defaultextract" + llvm_cv_os_type="AuroraUX" + llvm_cv_platform_type="Unix" ;; *-*-win32*) llvm_cv_link_all_option="-Wl,--whole-archive" llvm_cv_no_link_all_option="-Wl,--no-whole-archive" @@ -224,6 +229,8 @@ llvm_cv_target_os_type="Linux" ;; *-*-solaris*) llvm_cv_target_os_type="SunOS" ;; + *-*-auroraux*) + llvm_cv_target_os_type="AuroraUX" ;; *-*-win32*) llvm_cv_target_os_type="Win32" ;; *-*-mingw*) Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=84067&r1=84066&r2=84067&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Tue Oct 13 19:44:50 2009 @@ -2338,6 +2338,11 @@ llvm_cv_no_link_all_option="-Wl,-z,defaultextract" llvm_cv_os_type="SunOS" llvm_cv_platform_type="Unix" ;; + *-*-auroraux*) + llvm_cv_link_all_option="-Wl,-z,allextract" + llvm_cv_link_all_option="-Wl,-z,defaultextract" + llvm_cv_os_type="AuroraUX" + llvm_cv_platform_type="Unix" ;; *-*-win32*) llvm_cv_link_all_option="-Wl,--whole-archive" llvm_cv_no_link_all_option="-Wl,--no-whole-archive" @@ -2403,6 +2408,8 @@ llvm_cv_target_os_type="Linux" ;; *-*-solaris*) llvm_cv_target_os_type="SunOS" ;; + *-*-auroraux*) + llvm_cv_target_os_type="AuroraUX" ;; *-*-win32*) llvm_cv_target_os_type="Win32" ;; *-*-mingw*) @@ -11001,7 +11008,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 13155 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14863,11 +14870,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14866: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14873: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14870: \$? = $ac_status" >&5 + echo "$as_me:14877: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15131,11 +15138,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15134: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15141: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15138: \$? = $ac_status" >&5 + echo "$as_me:15145: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -15235,11 +15242,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15238: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15245: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15242: \$? = $ac_status" >&5 + echo "$as_me:15249: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17687,7 +17694,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:20165: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:20162: \$? = $ac_status" >&5 + echo "$as_me:20169: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -20259,11 +20266,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:20262: $lt_compile\"" >&5) + (eval echo "\"\$as_me:20269: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:20266: \$? = $ac_status" >&5 + echo "$as_me:20273: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21829,11 +21836,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21832: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21839: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21836: \$? = $ac_status" >&5 + echo "$as_me:21843: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21933,11 +21940,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21936: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21943: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21940: \$? = $ac_status" >&5 + echo "$as_me:21947: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -24168,11 +24175,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24171: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24178: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24175: \$? = $ac_status" >&5 + echo "$as_me:24182: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24436,11 +24443,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24439: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24446: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24443: \$? = $ac_status" >&5 + echo "$as_me:24450: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24540,11 +24547,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24543: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24550: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24547: \$? = $ac_status" >&5 + echo "$as_me:24554: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized From clattner at apple.com Tue Oct 13 19:54:40 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 13 Oct 2009 17:54:40 -0700 Subject: [llvm-commits] [llvm] r84049 - in /llvm/trunk/lib/Transforms/Scalar: InstructionCombining.cpp LICM.cpp LoopUnswitch.cpp In-Reply-To: <200910132256.n9DMuXJg025396@zion.cs.uiuc.edu> References: <200910132256.n9DMuXJg025396@zion.cs.uiuc.edu> Message-ID: <396CC1F7-BC29-4D05-AB9E-7F504F3E8AB5@apple.com> On Oct 13, 2009, at 3:56 PM, Devang Patel wrote: > Author: dpatel > Date: Tue Oct 13 17:56:32 2009 > New Revision: 84049 > > URL: http://llvm.org/viewvc/llvm-project?rev=84049&view=rev > Log: > Check void type before using RAUWd. Hi Devang, Thanks for fixing this, please use getType()->isVoid() instead of pointer equality (it's cheaper) -Chris > > Modified: > llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > llvm/trunk/lib/Transforms/Scalar/LICM.cpp > llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84049&r1=84048&r2=84049&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > (original) > +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue > Oct 13 17:56:32 2009 > @@ -9979,7 +9979,10 @@ > new StoreInst(ConstantInt::getTrue(*Context), > UndefValue::get(Type::getInt1PtrTy(*Context)), > OldCall); > - OldCall->replaceAllUsesWith(UndefValue::get(OldCall- > >getType())); > + // If OldCall dues not return void then replaceAllUsesWith > undef. > + // This allows ValueHandlers and custom metadata to adjust > itself. > + if (OldCall->getType() != Type::getVoidTy(*Context)) > + OldCall->replaceAllUsesWith(UndefValue::get(OldCall- > >getType())); > if (isa(OldCall)) // Not worth removing an invoke > here. > return EraseInstFromFunction(*OldCall); > return 0; > @@ -9993,8 +9996,11 @@ > UndefValue::get(Type::getInt1PtrTy(*Context)), > CS.getInstruction()); > > - CS.getInstruction()-> > - replaceAllUsesWith(UndefValue::get(CS.getInstruction()- > >getType())); > + // If CS dues not return void then replaceAllUsesWith undef. > + // This allows ValueHandlers and custom metadata to adjust > itself. > + if (CS.getInstruction()->getType() != Type::getVoidTy(*Context)) > + CS.getInstruction()-> > + replaceAllUsesWith(UndefValue::get(CS.getInstruction()- > >getType())); > > if (InvokeInst *II = dyn_cast(CS.getInstruction())) { > // Don't break the CFG, insert a dummy cond branch. > @@ -12779,7 +12785,12 @@ > ++NumDeadInst; > MadeIRChange = true; > } > - I->replaceAllUsesWith(UndefValue::get(I->getType())); > + > + > + // If I is not void type then replaceAllUsesWith undef. > + // This allows ValueHandlers and custom metadata to > adjust itself. > + if (I->getType() != Type::getVoidTy(*Context)) > + I->replaceAllUsesWith(UndefValue::get(I->getType())); > I->eraseFromParent(); > } > } > > Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=84049&r1=84048&r2=84049&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Tue Oct 13 17:56:32 2009 > @@ -487,7 +487,10 @@ > // Instruction is not used, just delete it. > CurAST->deleteValue(&I); > // If I has users in unreachable blocks, eliminate. > - I.replaceAllUsesWith(UndefValue::get(I.getType())); > + // If I is not void type then replaceAllUsesWith undef. > + // This allows ValueHandlers and custom metadata to adjust > itself. > + if (I.getType() != Type::getVoidTy(I.getContext())) > + I.replaceAllUsesWith(UndefValue::get(I.getType())); > I.eraseFromParent(); > } else { > // Move the instruction to the start of the exit block, after > any PHI > @@ -500,7 +503,10 @@ > // The instruction is actually dead if there ARE NO exit blocks. > CurAST->deleteValue(&I); > // If I has users in unreachable blocks, eliminate. > - I.replaceAllUsesWith(UndefValue::get(I.getType())); > + // If I is not void type then replaceAllUsesWith undef. > + // This allows ValueHandlers and custom metadata to adjust > itself. > + if (I.getType() != Type::getVoidTy(I.getContext())) > + I.replaceAllUsesWith(UndefValue::get(I.getType())); > I.eraseFromParent(); > } else { > // Otherwise, if we have multiple exits, use the PromoteMem2Reg > function to > > Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=84049&r1=84048&r2=84049&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 > 17:56:32 2009 > @@ -781,7 +781,10 @@ > > // Anything that uses the instructions in this basic block > should have their > // uses replaced with undefs. > - I->replaceAllUsesWith(UndefValue::get(I->getType())); > + // If I is not void type then replaceAllUsesWith undef. > + // This allows ValueHandlers and custom metadata to adjust > itself. > + if (I->getType() != Type::getVoidTy(I->getContext())) > + I->replaceAllUsesWith(UndefValue::get(I->getType())); > } > > // If this is the edge to the header block for a loop, remove the > loop and > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Tue Oct 13 19:56:26 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 13 Oct 2009 17:56:26 -0700 Subject: [llvm-commits] [llvm] r84038 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/phi-aa.ll In-Reply-To: References: <200910132202.n9DM2KBh023328@zion.cs.uiuc.edu> Message-ID: On Oct 13, 2009, at 3:47 PM, Nick Lewycky wrote: > Evan, please put a recursion depth limit on the number of PHIs this code is willing to walk backwards through, otherwise pathological code will show n^2 behaviour. It stops when it sees a PHI source which is itself PHI. That should be sufficient, no? Evan > > Nick > From clattner at apple.com Tue Oct 13 20:11:40 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 13 Oct 2009 18:11:40 -0700 Subject: [llvm-commits] [llvm] r84020 - in /llvm/trunk: include/llvm/InlineAsm.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/AsmWriter.cpp lib/VMCore/Core.cpp lib/VMCore/InlineAsm.cpp test/Assembler/msasm.ll In-Reply-To: <200910132046.n9DKkvKl020165@zion.cs.uiuc.edu> References: <200910132046.n9DKkvKl020165@zion.cs.uiuc.edu> Message-ID: On Oct 13, 2009, at 1:46 PM, Dale Johannesen wrote: > Author: johannes > Date: Tue Oct 13 15:46:56 2009 > New Revision: 84020 > > URL: http://llvm.org/viewvc/llvm-project?rev=84020&view=rev > Log: > Add an "msasm" flag to inline asm as suggested in PR 5125. > A little ugliness is accepted to keep the binary file format > compatible. No functional change yet. Hi Dale, In general I think that this is a great approach. One concern I have is that "is ms asm" doesn't tell me what the flag does. Would it be possible to name this something like "might be call" or something that more accurately conveys the semantic effect of this? I'd much prefer LangRef to have a concrete description of what it does (like volatile) instead of saying "originally from an asm block" which doesn't communicate what it does or when someone would want to set it. -Chris > > > Added: > llvm/trunk/test/Assembler/msasm.ll > Modified: > llvm/trunk/include/llvm/InlineAsm.h > llvm/trunk/lib/AsmParser/LLLexer.cpp > llvm/trunk/lib/AsmParser/LLParser.cpp > llvm/trunk/lib/AsmParser/LLToken.h > llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp > llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp > llvm/trunk/lib/VMCore/AsmWriter.cpp > llvm/trunk/lib/VMCore/Core.cpp > llvm/trunk/lib/VMCore/InlineAsm.cpp > > Modified: llvm/trunk/include/llvm/InlineAsm.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InlineAsm.h?rev=84020&r1=84019&r2=84020&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/InlineAsm.h (original) > +++ llvm/trunk/include/llvm/InlineAsm.h Tue Oct 13 15:46:56 2009 > @@ -31,18 +31,22 @@ > > std::string AsmString, Constraints; > bool HasSideEffects; > + bool IsMsAsm; > > InlineAsm(const FunctionType *Ty, const StringRef &AsmString, > - const StringRef &Constraints, bool hasSideEffects); > + const StringRef &Constraints, bool hasSideEffects, > + bool isMsAsm = false); > virtual ~InlineAsm(); > public: > > /// InlineAsm::get - Return the the specified uniqued inline asm > string. > /// > static InlineAsm *get(const FunctionType *Ty, const StringRef > &AsmString, > - const StringRef &Constraints, bool > hasSideEffects); > + const StringRef &Constraints, bool > hasSideEffects, > + bool isMsAsm = false); > > bool hasSideEffects() const { return HasSideEffects; } > + bool isMsAsm() const { return IsMsAsm; } > > /// getType - InlineAsm's are always pointers. > /// > > Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=84020&r1=84019&r2=84020&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) > +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Tue Oct 13 15:46:56 2009 > @@ -529,6 +529,7 @@ > KEYWORD(module); > KEYWORD(asm); > KEYWORD(sideeffect); > + KEYWORD(msasm); > KEYWORD(gc); > > KEYWORD(ccc); > > Modified: llvm/trunk/lib/AsmParser/LLParser.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=84020&r1=84019&r2=84020&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) > +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Oct 13 15:46:56 2009 > @@ -1959,16 +1959,17 @@ > return false; > > case lltok::kw_asm: { > - // ValID ::= 'asm' SideEffect? STRINGCONSTANT ',' STRINGCONSTANT > - bool HasSideEffect; > + // ValID ::= 'asm' SideEffect? MsAsm? STRINGCONSTANT ',' > STRINGCONSTANT > + bool HasSideEffect, MsAsm; > Lex.Lex(); > if (ParseOptionalToken(lltok::kw_sideeffect, HasSideEffect) || > + ParseOptionalToken(lltok::kw_msasm, MsAsm) || > ParseStringConstant(ID.StrVal) || > ParseToken(lltok::comma, "expected comma in inline asm > expression") || > ParseToken(lltok::StringConstant, "expected constraint > string")) > return true; > ID.StrVal2 = Lex.getStrVal(); > - ID.UIntVal = HasSideEffect; > + ID.UIntVal = HasSideEffect | ((unsigned)MsAsm<<1); > ID.Kind = ValID::t_InlineAsm; > return false; > } > @@ -2368,7 +2369,7 @@ > PTy ? dyn_cast(PTy->getElementType()) : 0; > if (!FTy || !InlineAsm::Verify(FTy, ID.StrVal2)) > return Error(ID.Loc, "invalid type for inline asm constraint > string"); > - V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal); > + V = InlineAsm::get(FTy, ID.StrVal, ID.StrVal2, ID.UIntVal&1, > ID.UIntVal>>1); > return false; > } else if (ID.Kind == ValID::t_Metadata) { > V = ID.MetadataVal; > > Modified: llvm/trunk/lib/AsmParser/LLToken.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=84020&r1=84019&r2=84020&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/AsmParser/LLToken.h (original) > +++ llvm/trunk/lib/AsmParser/LLToken.h Tue Oct 13 15:46:56 2009 > @@ -62,6 +62,7 @@ > kw_module, > kw_asm, > kw_sideeffect, > + kw_msasm, > kw_gc, > kw_dbg, > kw_c, > > Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=84020&r1=84019&r2=84020&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) > +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Oct 13 > 15:46:56 2009 > @@ -1164,7 +1164,8 @@ > case bitc::CST_CODE_INLINEASM: { > if (Record.size() < 2) return Error("Invalid INLINEASM record"); > std::string AsmStr, ConstrStr; > - bool HasSideEffects = Record[0]; > + bool HasSideEffects = Record[0] & 1; > + bool IsMsAsm = Record[0] >> 1; > unsigned AsmStrSize = Record[1]; > if (2+AsmStrSize >= Record.size()) > return Error("Invalid INLINEASM record"); > @@ -1178,7 +1179,7 @@ > ConstrStr += (char)Record[3+AsmStrSize+i]; > const PointerType *PTy = cast(CurTy); > V = InlineAsm::get(cast(PTy->getElementType()), > - AsmStr, ConstrStr, HasSideEffects); > + AsmStr, ConstrStr, HasSideEffects, IsMsAsm); > break; > } > } > > Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=84020&r1=84019&r2=84020&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) > +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Oct 13 > 15:46:56 2009 > @@ -679,7 +679,8 @@ > } > > if (const InlineAsm *IA = dyn_cast(V)) { > - Record.push_back(unsigned(IA->hasSideEffects())); > + Record.push_back(unsigned(IA->hasSideEffects()) | > + unsigned(IA->isMsAsm()) << 1); > > // Add the asm string. > const std::string &AsmStr = IA->getAsmString(); > > Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=84020&r1=84019&r2=84020&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) > +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Oct 13 15:46:56 2009 > @@ -1206,6 +1206,8 @@ > Out << "asm "; > if (IA->hasSideEffects()) > Out << "sideeffect "; > + if (IA->isMsAsm()) > + Out << "msasm "; > Out << '"'; > PrintEscapedString(IA->getAsmString(), Out); > Out << "\", \""; > > Modified: llvm/trunk/lib/VMCore/Core.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=84020&r1=84019&r2=84020&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/VMCore/Core.cpp (original) > +++ llvm/trunk/lib/VMCore/Core.cpp Tue Oct 13 15:46:56 2009 > @@ -884,9 +884,10 @@ > } > > LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, > - const char *Constraints, int > HasSideEffects) { > + const char *Constraints, int > HasSideEffects, > + int IsMsAsm) { > return wrap(InlineAsm::get(dyn_cast(unwrap(Ty)), > AsmString, > - Constraints, HasSideEffects)); > + Constraints, HasSideEffects, IsMsAsm)); > } > > /*--.. Operations on global variables, functions, and aliases > (globals) ....--*/ > > Modified: llvm/trunk/lib/VMCore/InlineAsm.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/InlineAsm.cpp?rev=84020&r1=84019&r2=84020&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/VMCore/InlineAsm.cpp (original) > +++ llvm/trunk/lib/VMCore/InlineAsm.cpp Tue Oct 13 15:46:56 2009 > @@ -27,17 +27,19 @@ > // case when the type gets refined. > > InlineAsm *InlineAsm::get(const FunctionType *Ty, const StringRef > &AsmString, > - const StringRef &Constraints, bool > hasSideEffects) { > + const StringRef &Constraints, bool > hasSideEffects, > + bool isMsAsm) { > // FIXME: memoize! > - return new InlineAsm(Ty, AsmString, Constraints, hasSideEffects); > + return new InlineAsm(Ty, AsmString, Constraints, hasSideEffects, > isMsAsm); > } > > InlineAsm::InlineAsm(const FunctionType *Ty, const StringRef > &asmString, > - const StringRef &constraints, bool > hasSideEffects) > + const StringRef &constraints, bool > hasSideEffects, > + bool isMsAsm) > : Value(PointerType::getUnqual(Ty), > Value::InlineAsmVal), > AsmString(asmString), > - Constraints(constraints), HasSideEffects(hasSideEffects) { > + Constraints(constraints), HasSideEffects(hasSideEffects), > IsMsAsm(isMsAsm) { > > // Do various checks on the constraint string and type. > assert(Verify(Ty, constraints) && "Function type not legal for > constraints!"); > > Added: llvm/trunk/test/Assembler/msasm.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/msasm.ll?rev=84020&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/Assembler/msasm.ll (added) > +++ llvm/trunk/test/Assembler/msasm.ll Tue Oct 13 15:46:56 2009 > @@ -0,0 +1,36 @@ > +; RUN: llvm-as < %s | llvm-dis | FileCheck %s > +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32- > i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64- > f80:128:128" > +target triple = "i386-apple-darwin10.0" > + > +define void @test1() nounwind { > +; CHECK: test1 > +; CHECK: sideeffect > +; CHECK-NOT: msasm > + tail call void asm sideeffect "mov", > "~{dirflag},~{fpsr},~{flags}"() nounwind > + ret void > +; CHECK: ret > +} > +define void @test2() nounwind { > +; CHECK: test2 > +; CHECK: sideeffect > +; CHECK: msasm > + tail call void asm sideeffect msasm "mov", > "~{dirflag},~{fpsr},~{flags}"() nounwind > + ret void > +; CHECK: ret > +} > +define void @test3() nounwind { > +; CHECK: test3 > +; CHECK-NOT: sideeffect > +; CHECK: msasm > + tail call void asm msasm "mov", "~{dirflag},~{fpsr},~{flags}"() > nounwind > + ret void > +; CHECK: ret > +} > +define void @test4() nounwind { > +; CHECK: test4 > +; CHECK-NOT: sideeffect > +; CHECK-NOT: msasm > + tail call void asm "mov", "~{dirflag},~{fpsr},~{flags}"() nounwind > + ret void > +; CHECK: ret > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dalej at apple.com Tue Oct 13 20:28:40 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 13 Oct 2009 18:28:40 -0700 Subject: [llvm-commits] [llvm] r84020 - in /llvm/trunk: include/llvm/InlineAsm.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/AsmWriter.cpp lib/VMCore/Core.cpp lib/VMCore/InlineAsm.cpp test/Assembler/msasm.ll In-Reply-To: References: <200910132046.n9DKkvKl020165@zion.cs.uiuc.edu> Message-ID: <3001EF7C-13F1-4AC8-A2E2-D8C77DF07DCF@apple.com> On Oct 13, 2009, at 6:11 PM, Chris Lattner wrote: > > On Oct 13, 2009, at 1:46 PM, Dale Johannesen wrote: > >> Author: johannes >> Date: Tue Oct 13 15:46:56 2009 >> New Revision: 84020 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84020&view=rev >> Log: >> Add an "msasm" flag to inline asm as suggested in PR 5125. >> A little ugliness is accepted to keep the binary file format >> compatible. No functional change yet. > > Hi Dale, > > In general I think that this is a great approach. One concern I > have is that "is ms asm" doesn't tell me what the flag does. Would > it be possible to name this something like "might be call" or > something that more accurately conveys the semantic effect of this? > I'd much prefer LangRef to have a concrete description of what it > does (like volatile) instead of saying "originally from an asm > block" which doesn't communicate what it does or when someone would > want to set it. Sure, we could do that; my intent was that if any other semantic differences show up they can also key off this flag instead of adding a new one. Someone would want to set it if their source uses asm blocks. In any event I am not going to get to changing this before I disappear for a few days. From evan.cheng at apple.com Tue Oct 13 20:31:12 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 13 Oct 2009 18:31:12 -0700 Subject: [llvm-commits] [llvm] r84038 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/phi-aa.ll In-Reply-To: References: <200910132202.n9DM2KBh023328@zion.cs.uiuc.edu> Message-ID: On Oct 13, 2009, at 3:31 PM, Chris Lattner wrote: > > On Oct 13, 2009, at 3:02 PM, Evan Cheng wrote: > >> Author: evancheng >> Date: Tue Oct 13 17:02:20 2009 >> New Revision: 84038 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84038&view=rev >> Log: >> Teach basic AA about PHI nodes. If all operands of a phi NoAlias another value than it's safe to declare the PHI NoAlias the value. Ditto for MustAlias. > > Thoughts: > > Please manually reduce the testcase (or better yet, synthesize one from scratch). The basicaa tests are almost all very small and precise, e.g. 2007-08-01-NoAliasAndCalls.ll. Also, please don't add new uses of the malloc instruction, use alloca instead. Something like this (in hand written IR) should be enough: > > int X; > int Y; > int Z; > void foo(int cond) { > int *P = cond ? &X : &Y; > > int tmp = Z; > *P = 123; > return tmp-Z; > } I'll try. > > > Did you look at the compile time impact of this on something like GVN on 403.gcc? I am not seeing any compile time impact. > > Because you only have one 'VisitedPHIs' set, you are conflating PHIs walked on the LHS with phis walked on the RHS. I guess it probably doesn't matter because if the same phi shows up on both sides, they definitely alias. This is worth mentioning in a comment somewhere. The analysis stops asap it hits a phi source which is itself a phi. So the worst possible case if both LHS and RHS are phis. In that case, its m x n. > >> @@ -218,7 +222,16 @@ >> // aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a GEP instruction >> // against another. >> AliasResult aliasGEP(const Value *V1, unsigned V1Size, >> - const Value *V2, unsigned V2Size); >> + const Value *V2, unsigned V2Size, >> + SmallSet &VisitedPHIs); >> + >> + AliasResult aliasPHI(const Value *V1, unsigned V1Size, >> + const Value *V2, unsigned V2Size, >> + SmallSet &VisitedPHIs); >> + >> + AliasResult aliasCheck(const Value *V1, unsigned V1Size, >> + const Value *V2, unsigned V2Size, >> + SmallSet &VisitedPHIs); > > Somewhat gross, but I think it would be better to make VisitedPHIs be an instance variable in the BasicAA class. Just assert that it is empty on entry into and exit out of the top level "alias" method. Alright. > > >> +AliasAnalysis::AliasResult >> +BasicAliasAnalysis::aliasPHI(const Value *V1, unsigned V1Size, > > V1 is statically required to be a PHI, it would be better for it to be declared as 'const PHINode*'. Also, the VisitedPHI set should be PHINode not Value as element type. > >> + SmallSet UniqueSrc; >> + SmallVector V1Srcs; >> + const PHINode *PN = cast(V1); > > this cast<> should be removed. > >> + // If all sources of the PHI node NoAlias or MustAlias V2, then returns >> + // NoAlias / MustAlias. Otherwise, returns MayAlias. >> + AliasResult Alias = aliasCheck(V1Srcs[0], V1Size, V2, V2Size, VisitedPHIs); > > if this call returns mayalias, you should exit early. mayalias is the most common result. Ok. Evan > > -Chris > From evan.cheng at apple.com Tue Oct 13 20:45:11 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 01:45:11 -0000 Subject: [llvm-commits] [llvm] r84069 - /llvm/trunk/test/Analysis/BasicAA/phi-aa.ll Message-ID: <200910140145.n9E1jBxc031348@zion.cs.uiuc.edu> Author: evancheng Date: Tue Oct 13 20:45:10 2009 New Revision: 84069 URL: http://llvm.org/viewvc/llvm-project?rev=84069&view=rev Log: Replace test with a simpler hand crafted one. Modified: llvm/trunk/test/Analysis/BasicAA/phi-aa.ll Modified: llvm/trunk/test/Analysis/BasicAA/phi-aa.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/phi-aa.ll?rev=84069&r1=84068&r2=84069&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/phi-aa.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/phi-aa.ll Tue Oct 13 20:45:10 2009 @@ -1,86 +1,29 @@ -; RUN: opt < %s -basicaa -licm -S | FileCheck %s +; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {NoAlias:.*%P,.*@Z} ; rdar://7282591 -%struct.CFRuntimeBase = type { i32, [4 x i8] } -%struct.XXXAffineTransform = type { float, float, float, float, float, float } -%struct.XXXContext = type { %struct.CFRuntimeBase, i32, i32, i32, i8*, %struct.XXXContextDelegate*, void (%struct.XXXContext*)*, void (%struct.XXXContext*)*, %struct.XXXImage* (%struct.XXXContext*, %struct.XXXRect*, %struct.XXXImage*, i8*)*, i8*, %struct.__CFDictionary*, i32, %struct.XXXGState*, %struct.XXXGStack*, %struct.XXXRenderingState*, %struct.XXXAffineTransform, %struct.XXXPath*, %struct.__CFDictionary*, %struct.XXXPixelAccess* } -%struct.XXXContextDelegate = type opaque -%struct.XXXGStack = type opaque -%struct.XXXGState = type opaque -%struct.XXXImage = type opaque -%struct.XXXPath = type opaque -%struct.XXXPixelAccess = type opaque -%struct.XXXPoint = type { float, float } -%struct.XXXRect = type { %struct.XXXPoint, %struct.XXXPoint } -%struct.XXXRenderingState = type opaque -%struct.__CFDictionary = type opaque - -define void @t(%struct.XXXContext* %context, i16* %glyphs, %struct.XXXPoint* %advances, i32 %count) nounwind optsize ssp { -; CHECK: @t -; CHECK: bb21.preheader: -; CHECK: %tmp28 = getelementptr -; CHECK: %tmp28.promoted = load -entry: - br i1 undef, label %bb1, label %bb - -bb: ; preds = %entry - br i1 undef, label %bb2, label %bb1 - -bb1: ; preds = %bb, %entry - ret void - -bb2: ; preds = %bb - br i1 undef, label %bb35, label %bb7 + at X = common global i32 0 + at Y = common global i32 0 + at Z = common global i32 0 -bb7: ; preds = %bb2 - br i1 undef, label %bb35, label %bb10 - -bb10: ; preds = %bb7 - %tmp18 = alloca i8, i32 undef, align 1 ; [#uses=1] - br i1 undef, label %bb35, label %bb15 - -bb15: ; preds = %bb10 - br i1 undef, label %bb17, label %bb16 - -bb16: ; preds = %bb15 - %tmp21 = bitcast i8* %tmp18 to %struct.XXXPoint* ; <%struct.XXXPoint*> [#uses=1] - br label %bb18 - -bb17: ; preds = %bb15 - %tmp22 = malloc %struct.XXXPoint, i32 %count ; <%struct.XXXPoint*> [#uses=1] - br label %bb18 - -bb18: ; preds = %bb17, %bb16 - %positions.0 = phi %struct.XXXPoint* [ %tmp21, %bb16 ], [ %tmp22, %bb17 ] ; <%struct.XXXPoint*> [#uses=1] - br i1 undef, label %bb35, label %bb20 - -bb20: ; preds = %bb18 - br i1 undef, label %bb21, label %bb25 - -bb21: ; preds = %bb21, %bb20 - %tmp28 = getelementptr inbounds %struct.XXXPoint* %positions.0, i32 undef, i32 0 ; [#uses=1] - store float undef, float* %tmp28, align 4 - %elt22 = getelementptr inbounds %struct.XXXPoint* %advances, i32 undef, i32 1 ; [#uses=1] - %val23 = load float* %elt22 ; [#uses=0] - br i1 undef, label %bb21, label %bb25 - -bb25: ; preds = %bb21, %bb20 - switch i32 undef, label %bb26 [ - i32 4, label %bb27 - i32 5, label %bb27 - i32 6, label %bb27 - i32 7, label %bb28 - ] - -bb26: ; preds = %bb25 - unreachable - -bb27: ; preds = %bb25, %bb25, %bb25 - unreachable - -bb28: ; preds = %bb25 - unreachable +define void @foo(i32 %cond) nounwind ssp { +entry: + %"alloca point" = bitcast i32 0 to i32 + %tmp = icmp ne i32 %cond, 0 + br i1 %tmp, label %bb, label %bb1 + +bb: + br label %bb2 + +bb1: + br label %bb2 + +bb2: + %P = phi i32* [ @X, %bb ], [ @Y, %bb1 ] + %tmp1 = load i32* @Z, align 4 + store i32 123, i32* %P, align 4 + %tmp2 = load i32* @Z, align 4 + br label %return -bb35: ; preds = %bb18, %bb10, %bb7, %bb2 +return: ret void } From evan.cheng at apple.com Wed Oct 14 00:05:03 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 05:05:03 -0000 Subject: [llvm-commits] [llvm] r84072 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200910140505.n9E553pl005174@zion.cs.uiuc.edu> Author: evancheng Date: Wed Oct 14 00:05:02 2009 New Revision: 84072 URL: http://llvm.org/viewvc/llvm-project?rev=84072&view=rev Log: Change VisitedPHIs into an instance variable that's freed by each alias() call. Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84072&r1=84071&r2=84072&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Wed Oct 14 00:05:02 2009 @@ -203,8 +203,8 @@ BasicAliasAnalysis() : NoAA(&ID) {} AliasResult alias(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size) { - SmallSet VisitedPHIs; - return aliasCheck(V1, V1Size, V2, V2Size, VisitedPHIs); + VisitedPHIs.clear(); + return aliasCheck(V1, V1Size, V2, V2Size); } ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); @@ -219,19 +219,21 @@ bool pointsToConstantMemory(const Value *P); private: + // VisitedPHIs - Track PHI nodes visited by a aliasCheck() call. + SmallSet VisitedPHIs; + // aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a GEP instruction // against another. AliasResult aliasGEP(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size, - SmallSet &VisitedPHIs); + const Value *V2, unsigned V2Size); + // aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a PHI instruction + // against another. AliasResult aliasPHI(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size, - SmallSet &VisitedPHIs); + const Value *V2, unsigned V2Size); AliasResult aliasCheck(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size, - SmallSet &VisitedPHIs); + const Value *V2, unsigned V2Size); // CheckGEPInstructions - Check two GEP instructions with known // must-aliasing base pointers. This checks to see if the index expressions @@ -352,8 +354,7 @@ // AliasAnalysis::AliasResult BasicAliasAnalysis::aliasGEP(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size, - SmallSet &VisitedPHIs) { + const Value *V2, unsigned V2Size) { // If we have two gep instructions with must-alias'ing base pointers, figure // out if the indexes to the GEP tell us anything about the derived pointer. // Note that we also handle chains of getelementptr instructions as well as @@ -374,7 +375,7 @@ // All operands are the same, ignoring the base. std::equal(GEP1->op_begin()+1, GEP1->op_end(), GEP2->op_begin()+1)) return aliasCheck(GEP1->getOperand(0), V1Size, - GEP2->getOperand(0), V2Size, VisitedPHIs); + GEP2->getOperand(0), V2Size); // Drill down into the first non-gep value, to test for must-aliasing of // the base pointers. @@ -391,8 +392,7 @@ const Value *BasePtr2 = GEP2->getOperand(0); // Do the base pointers alias? - AliasResult BaseAlias = aliasCheck(BasePtr1, ~0U, BasePtr2, ~0U, - VisitedPHIs); + AliasResult BaseAlias = aliasCheck(BasePtr1, ~0U, BasePtr2, ~0U); if (BaseAlias == NoAlias) return NoAlias; if (BaseAlias == MustAlias) { // If the base pointers alias each other exactly, check to see if we can @@ -428,7 +428,7 @@ SmallVector GEPOperands; const Value *BasePtr = GetGEPOperands(V1, GEPOperands); - AliasResult R = aliasCheck(BasePtr, V1Size, V2, V2Size, VisitedPHIs); + AliasResult R = aliasCheck(BasePtr, V1Size, V2, V2Size); if (R == MustAlias) { // If there is at least one non-zero constant index, we know they cannot // alias. @@ -477,10 +477,11 @@ return MayAlias; } +// aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a PHI instruction +// against another. AliasAnalysis::AliasResult BasicAliasAnalysis::aliasPHI(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size, - SmallSet &VisitedPHIs) { + const Value *V2, unsigned V2Size) { // The PHI node has already been visited, avoid recursion any further. if (!VisitedPHIs.insert(V1)) return MayAlias; @@ -500,10 +501,10 @@ // If all sources of the PHI node NoAlias or MustAlias V2, then returns // NoAlias / MustAlias. Otherwise, returns MayAlias. - AliasResult Alias = aliasCheck(V1Srcs[0], V1Size, V2, V2Size, VisitedPHIs); + AliasResult Alias = aliasCheck(V1Srcs[0], V1Size, V2, V2Size); for (unsigned i = 1, e = V1Srcs.size(); i != e; ++i) { Value *V = V1Srcs[i]; - AliasResult ThisAlias = aliasCheck(V, V1Size, V2, V2Size, VisitedPHIs); + AliasResult ThisAlias = aliasCheck(V, V1Size, V2, V2Size); if (ThisAlias != Alias) return MayAlias; } @@ -516,8 +517,7 @@ // AliasAnalysis::AliasResult BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size, - const Value *V2, unsigned V2Size, - SmallSet &VisitedPHIs) { + const Value *V2, unsigned V2Size) { // Strip off any casts if they exist. V1 = V1->stripPointerCasts(); V2 = V2->stripPointerCasts(); @@ -571,14 +571,14 @@ std::swap(V1Size, V2Size); } if (isGEP(V1)) - return aliasGEP(V1, V1Size, V2, V2Size, VisitedPHIs); + return aliasGEP(V1, V1Size, V2, V2Size); if (isa(V2) && !isa(V1)) { std::swap(V1, V2); std::swap(V1Size, V2Size); } if (isa(V1)) - return aliasPHI(V1, V1Size, V2, V2Size, VisitedPHIs); + return aliasPHI(V1, V1Size, V2, V2Size); return MayAlias; } From evan.cheng at apple.com Wed Oct 14 00:22:03 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 05:22:03 -0000 Subject: [llvm-commits] [llvm] r84074 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200910140522.n9E5M3gN005768@zion.cs.uiuc.edu> Author: evancheng Date: Wed Oct 14 00:22:03 2009 New Revision: 84074 URL: http://llvm.org/viewvc/llvm-project?rev=84074&view=rev Log: More code clean up based on patch feedback. Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84074&r1=84073&r2=84074&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Wed Oct 14 00:22:03 2009 @@ -220,16 +220,16 @@ private: // VisitedPHIs - Track PHI nodes visited by a aliasCheck() call. - SmallSet VisitedPHIs; + SmallSet VisitedPHIs; // aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a GEP instruction // against another. AliasResult aliasGEP(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size); - // aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a PHI instruction + // aliasPHI - Provide a bunch of ad-hoc rules to disambiguate a PHI instruction // against another. - AliasResult aliasPHI(const Value *V1, unsigned V1Size, + AliasResult aliasPHI(const PHINode *PN, unsigned PNSize, const Value *V2, unsigned V2Size); AliasResult aliasCheck(const Value *V1, unsigned V1Size, @@ -477,18 +477,17 @@ return MayAlias; } -// aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a PHI instruction +// aliasPHI - Provide a bunch of ad-hoc rules to disambiguate a PHI instruction // against another. AliasAnalysis::AliasResult -BasicAliasAnalysis::aliasPHI(const Value *V1, unsigned V1Size, +BasicAliasAnalysis::aliasPHI(const PHINode *PN, unsigned PNSize, const Value *V2, unsigned V2Size) { // The PHI node has already been visited, avoid recursion any further. - if (!VisitedPHIs.insert(V1)) + if (!VisitedPHIs.insert(PN)) return MayAlias; SmallSet UniqueSrc; SmallVector V1Srcs; - const PHINode *PN = cast(V1); for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { Value *PV1 = PN->getIncomingValue(i); if (isa(PV1)) @@ -499,13 +498,18 @@ V1Srcs.push_back(PV1); } + AliasResult Alias = aliasCheck(V1Srcs[0], PNSize, V2, V2Size); + // Early exit if the check of the first PHI source against V2 is MayAlias. + // Other results are not possible. + if (Alias == MayAlias) + return MayAlias; + // If all sources of the PHI node NoAlias or MustAlias V2, then returns // NoAlias / MustAlias. Otherwise, returns MayAlias. - AliasResult Alias = aliasCheck(V1Srcs[0], V1Size, V2, V2Size); for (unsigned i = 1, e = V1Srcs.size(); i != e; ++i) { Value *V = V1Srcs[i]; - AliasResult ThisAlias = aliasCheck(V, V1Size, V2, V2Size); - if (ThisAlias != Alias) + AliasResult ThisAlias = aliasCheck(V, PNSize, V2, V2Size); + if (ThisAlias != Alias || ThisAlias == MayAlias) return MayAlias; } @@ -577,8 +581,8 @@ std::swap(V1, V2); std::swap(V1Size, V2Size); } - if (isa(V1)) - return aliasPHI(V1, V1Size, V2, V2Size); + if (const PHINode *PN = dyn_cast(V1)) + return aliasPHI(PN, V1Size, V2, V2Size); return MayAlias; } From eocallaghan at auroraux.org Wed Oct 14 00:55:03 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Wed, 14 Oct 2009 05:55:03 -0000 Subject: [llvm-commits] [llvm] r84076 - /llvm/trunk/Makefile.rules Message-ID: <200910140555.n9E5t3iA007209@zion.cs.uiuc.edu> Author: evocallaghan Date: Wed Oct 14 00:55:03 2009 New Revision: 84076 URL: http://llvm.org/viewvc/llvm-project?rev=84076&view=rev Log: AuroraUX needs special Solaris system header. Modified: llvm/trunk/Makefile.rules Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=84076&r1=84075&r2=84076&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Wed Oct 14 00:55:03 2009 @@ -671,6 +671,10 @@ CPP.BaseFlags += -include llvm/System/Solaris.h endif +ifeq ($(HOST_OS),AuroraUX) +CPP.BaseFlags += -include llvm/System/Solaris.h +endif # !HOST_OS - AuroraUX. + LD.Flags += -L$(LibDir) -L$(LLVMLibDir) CPP.BaseFlags += -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS # All -I flags should go here, so that they don't confuse llvm-config. From clattner at apple.com Wed Oct 14 00:58:53 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 13 Oct 2009 22:58:53 -0700 Subject: [llvm-commits] [llvm] r84069 - /llvm/trunk/test/Analysis/BasicAA/phi-aa.ll In-Reply-To: <200910140145.n9E1jBxc031348@zion.cs.uiuc.edu> References: <200910140145.n9E1jBxc031348@zion.cs.uiuc.edu> Message-ID: On Oct 13, 2009, at 6:45 PM, Evan Cheng wrote: > Author: evancheng > Date: Tue Oct 13 20:45:10 2009 > New Revision: 84069 > > URL: http://llvm.org/viewvc/llvm-project?rev=84069&view=rev > Log: > Replace test with a simpler hand crafted one. Very nice, thanks Evan. -Chris > > Modified: > llvm/trunk/test/Analysis/BasicAA/phi-aa.ll > > Modified: llvm/trunk/test/Analysis/BasicAA/phi-aa.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/phi-aa.ll?rev=84069&r1=84068&r2=84069&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/Analysis/BasicAA/phi-aa.ll (original) > +++ llvm/trunk/test/Analysis/BasicAA/phi-aa.ll Tue Oct 13 20:45:10 > 2009 > @@ -1,86 +1,29 @@ > -; RUN: opt < %s -basicaa -licm -S | FileCheck %s > +; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info - > disable-output |& grep {NoAlias:.*%P,.*@Z} > ; rdar://7282591 > > -%struct.CFRuntimeBase = type { i32, [4 x i8] } > -%struct.XXXAffineTransform = type { float, float, float, float, > float, float } > -%struct.XXXContext = type { %struct.CFRuntimeBase, i32, i32, i32, > i8*, %struct.XXXContextDelegate*, void (%struct.XXXContext*)*, void > (%struct.XXXContext*)*, %struct.XXXImage* (%struct.XXXContext*, > %struct.XXXRect*, %struct.XXXImage*, i8*)*, i8*, > %struct.__CFDictionary*, i32, %struct.XXXGState*, > %struct.XXXGStack*, %struct.XXXRenderingState*, > %struct.XXXAffineTransform, %struct.XXXPath*, > %struct.__CFDictionary*, %struct.XXXPixelAccess* } > -%struct.XXXContextDelegate = type opaque > -%struct.XXXGStack = type opaque > -%struct.XXXGState = type opaque > -%struct.XXXImage = type opaque > -%struct.XXXPath = type opaque > -%struct.XXXPixelAccess = type opaque > -%struct.XXXPoint = type { float, float } > -%struct.XXXRect = type { %struct.XXXPoint, %struct.XXXPoint } > -%struct.XXXRenderingState = type opaque > -%struct.__CFDictionary = type opaque > - > -define void @t(%struct.XXXContext* %context, i16* %glyphs, > %struct.XXXPoint* %advances, i32 %count) nounwind optsize ssp { > -; CHECK: @t > -; CHECK: bb21.preheader: > -; CHECK: %tmp28 = getelementptr > -; CHECK: %tmp28.promoted = load > -entry: > - br i1 undef, label %bb1, label %bb > - > -bb: ; preds = %entry > - br i1 undef, label %bb2, label %bb1 > - > -bb1: ; preds = %bb, > %entry > - ret void > - > -bb2: ; preds = %bb > - br i1 undef, label %bb35, label %bb7 > + at X = common global i32 0 > + at Y = common global i32 0 > + at Z = common global i32 0 > > -bb7: ; preds = %bb2 > - br i1 undef, label %bb35, label %bb10 > - > -bb10: ; preds = %bb7 > - %tmp18 = alloca i8, i32 undef, align 1 ; [#uses=1] > - br i1 undef, label %bb35, label %bb15 > - > -bb15: ; preds = %bb10 > - br i1 undef, label %bb17, label %bb16 > - > -bb16: ; preds = %bb15 > - %tmp21 = bitcast i8* %tmp18 to %struct.XXXPoint* ; < > %struct.XXXPoint*> [#uses=1] > - br label %bb18 > - > -bb17: ; preds = %bb15 > - %tmp22 = malloc %struct.XXXPoint, i32 %count ; < > %struct.XXXPoint*> [#uses=1] > - br label %bb18 > - > -bb18: ; preds = %bb17, > %bb16 > - %positions.0 = phi %struct.XXXPoint* [ %tmp21, %bb16 ], [ %tmp22, > %bb17 ] ; <%struct.XXXPoint*> [#uses=1] > - br i1 undef, label %bb35, label %bb20 > - > -bb20: ; preds = %bb18 > - br i1 undef, label %bb21, label %bb25 > - > -bb21: ; preds = %bb21, > %bb20 > - %tmp28 = getelementptr inbounds %struct.XXXPoint* %positions.0, > i32 undef, i32 0 ; [#uses=1] > - store float undef, float* %tmp28, align 4 > - %elt22 = getelementptr inbounds %struct.XXXPoint* %advances, i32 > undef, i32 1 ; [#uses=1] > - %val23 = load float* %elt22 ; [#uses=0] > - br i1 undef, label %bb21, label %bb25 > - > -bb25: ; preds = %bb21, > %bb20 > - switch i32 undef, label %bb26 [ > - i32 4, label %bb27 > - i32 5, label %bb27 > - i32 6, label %bb27 > - i32 7, label %bb28 > - ] > - > -bb26: ; preds = %bb25 > - unreachable > - > -bb27: ; preds = %bb25, > %bb25, %bb25 > - unreachable > - > -bb28: ; preds = %bb25 > - unreachable > +define void @foo(i32 %cond) nounwind ssp { > +entry: > + %"alloca point" = bitcast i32 0 to i32 > + %tmp = icmp ne i32 %cond, 0 > + br i1 %tmp, label %bb, label %bb1 > + > +bb: > + br label %bb2 > + > +bb1: > + br label %bb2 > + > +bb2: > + %P = phi i32* [ @X, %bb ], [ @Y, %bb1 ] > + %tmp1 = load i32* @Z, align 4 > + store i32 123, i32* %P, align 4 > + %tmp2 = load i32* @Z, align 4 > + br label %return > > -bb35: ; preds = %bb18, > %bb10, %bb7, %bb2 > +return: > ret void > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Wed Oct 14 01:00:34 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 13 Oct 2009 23:00:34 -0700 Subject: [llvm-commits] [llvm] r84038 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/phi-aa.ll In-Reply-To: References: <200910132202.n9DM2KBh023328@zion.cs.uiuc.edu> Message-ID: On Oct 13, 2009, at 6:31 PM, Evan Cheng wrote: >> Did you look at the compile time impact of this on something like >> GVN on 403.gcc? > > I am not seeing any compile time impact. Ok great! >> >> Because you only have one 'VisitedPHIs' set, you are conflating >> PHIs walked on the LHS with phis walked on the RHS. I guess it >> probably doesn't matter because if the same phi shows up on both >> sides, they definitely alias. This is worth mentioning in a >> comment somewhere. > > The analysis stops asap it hits a phi source which is itself a phi. > So the worst possible case if both LHS and RHS are phis. In that > case, its m x n. Yep, makes sense, please add a comment somewhere to this effect. Thanks for working on this, improving AA is a great thing to do. -Chris From clattner at apple.com Wed Oct 14 01:01:08 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 13 Oct 2009 23:01:08 -0700 Subject: [llvm-commits] [llvm] r84020 - in /llvm/trunk: include/llvm/InlineAsm.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/AsmWriter.cpp lib/VMCore/Core.cpp lib/VMCore/InlineAsm.cpp test/Assembler/msasm.ll In-Reply-To: <3001EF7C-13F1-4AC8-A2E2-D8C77DF07DCF@apple.com> References: <200910132046.n9DKkvKl020165@zion.cs.uiuc.edu> <3001EF7C-13F1-4AC8-A2E2-D8C77DF07DCF@apple.com> Message-ID: <4C1CDC80-68BD-493C-B2D2-AC43F1939D6F@apple.com> On Oct 13, 2009, at 6:28 PM, Dale Johannesen wrote: >> In general I think that this is a great approach. One concern I >> have is that "is ms asm" doesn't tell me what the flag does. Would >> it be possible to name this something like "might be call" or >> something that more accurately conveys the semantic effect of >> this? I'd much prefer LangRef to have a concrete description of >> what it does (like volatile) instead of saying "originally from an >> asm block" which doesn't communicate what it does or when someone >> would want to set it. > > > Sure, we could do that; my intent was that if any other semantic > differences show up they can also key off this flag instead of > adding a new one. Someone would want to set it if their source uses > asm blocks. > In any event I am not going to get to changing this before I > disappear for a few days. No rush, thanks for working on this! -Chris From evan.cheng at apple.com Wed Oct 14 01:41:49 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 06:41:49 -0000 Subject: [llvm-commits] [llvm] r84079 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll Message-ID: <200910140641.n9E6fndw009741@zion.cs.uiuc.edu> Author: evancheng Date: Wed Oct 14 01:41:49 2009 New Revision: 84079 URL: http://llvm.org/viewvc/llvm-project?rev=84079&view=rev Log: Another BasicAA fix. If a value does not alias a GEP's base pointer, then it cannot alias the GEP. GEP pointer alias rule states this clearly: A pointer value formed from a getelementptr instruction is associated with the addresses associated with the first operand of the getelementptr. Added: llvm/trunk/test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84079&r1=84078&r2=84079&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Wed Oct 14 01:41:49 2009 @@ -428,49 +428,54 @@ SmallVector GEPOperands; const Value *BasePtr = GetGEPOperands(V1, GEPOperands); - AliasResult R = aliasCheck(BasePtr, V1Size, V2, V2Size); - if (R == MustAlias) { - // If there is at least one non-zero constant index, we know they cannot - // alias. - bool ConstantFound = false; - bool AllZerosFound = true; - for (unsigned i = 0, e = GEPOperands.size(); i != e; ++i) - if (const Constant *C = dyn_cast(GEPOperands[i])) { - if (!C->isNullValue()) { - ConstantFound = true; - AllZerosFound = false; - break; - } - } else { + AliasResult R = aliasCheck(BasePtr, ~0U, V2, V2Size); + if (R != MustAlias) + // If V2 may alias GEP base pointer, conservatively returns MayAlias. + // If V2 is known not to alias GEP base pointer, then the two values + // cannot alias per GEP semantics: "A pointer value formed from a + // getelementptr instruction is associated with the addresses associated + // with the first operand of the getelementptr". + return R; + + // If there is at least one non-zero constant index, we know they cannot + // alias. + bool ConstantFound = false; + bool AllZerosFound = true; + for (unsigned i = 0, e = GEPOperands.size(); i != e; ++i) + if (const Constant *C = dyn_cast(GEPOperands[i])) { + if (!C->isNullValue()) { + ConstantFound = true; AllZerosFound = false; + break; } + } else { + AllZerosFound = false; + } - // If we have getelementptr , 0, 0, 0, 0, ... and V2 must aliases - // the ptr, the end result is a must alias also. - if (AllZerosFound) - return MustAlias; + // If we have getelementptr , 0, 0, 0, 0, ... and V2 must aliases + // the ptr, the end result is a must alias also. + if (AllZerosFound) + return MustAlias; - if (ConstantFound) { - if (V2Size <= 1 && V1Size <= 1) // Just pointer check? - return NoAlias; + if (ConstantFound) { + if (V2Size <= 1 && V1Size <= 1) // Just pointer check? + return NoAlias; - // Otherwise we have to check to see that the distance is more than - // the size of the argument... build an index vector that is equal to - // the arguments provided, except substitute 0's for any variable - // indexes we find... - if (TD && - cast(BasePtr->getType())->getElementType()->isSized()) { - for (unsigned i = 0; i != GEPOperands.size(); ++i) - if (!isa(GEPOperands[i])) - GEPOperands[i] = Constant::getNullValue(GEPOperands[i]->getType()); - int64_t Offset = - TD->getIndexedOffset(BasePtr->getType(), - &GEPOperands[0], - GEPOperands.size()); + // Otherwise we have to check to see that the distance is more than + // the size of the argument... build an index vector that is equal to + // the arguments provided, except substitute 0's for any variable + // indexes we find... + if (TD && + cast(BasePtr->getType())->getElementType()->isSized()) { + for (unsigned i = 0; i != GEPOperands.size(); ++i) + if (!isa(GEPOperands[i])) + GEPOperands[i] = Constant::getNullValue(GEPOperands[i]->getType()); + int64_t Offset = TD->getIndexedOffset(BasePtr->getType(), + &GEPOperands[0], + GEPOperands.size()); - if (Offset >= (int64_t)V2Size || Offset <= -(int64_t)V1Size) - return NoAlias; - } + if (Offset >= (int64_t)V2Size || Offset <= -(int64_t)V1Size) + return NoAlias; } } @@ -492,7 +497,9 @@ Value *PV1 = PN->getIncomingValue(i); if (isa(PV1)) // If any of the source itself is a PHI, return MayAlias conservatively - // to avoid compile time explosion. + // to avoid compile time explosion. The worst possible case is if both + // sides are PHI nodes. In which case, this is O(m x n) time where 'm' + // and 'n' are the number of PHI sources. return MayAlias; if (UniqueSrc.insert(PV1)) V1Srcs.push_back(PV1); Added: llvm/trunk/test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll?rev=84079&view=auto ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll (added) +++ llvm/trunk/test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll Wed Oct 14 01:41:49 2009 @@ -0,0 +1,30 @@ +; RUN: opt < %s -aa-eval -print-all-alias-modref-info -disable-output |& grep {NoAlias:.*%P,.*@Z} +; If GEP base doesn't alias Z, then GEP doesn't alias Z. +; rdar://7282591 + + at Y = common global i32 0 + at Z = common global i32 0 + +define void @foo(i32 %cond) nounwind ssp { +entry: + %a = alloca i32 + %tmp = icmp ne i32 %cond, 0 + br i1 %tmp, label %bb, label %bb1 + +bb: + %b = getelementptr i32* %a, i32 0 + br label %bb2 + +bb1: + br label %bb2 + +bb2: + %P = phi i32* [ %b, %bb ], [ @Y, %bb1 ] + %tmp1 = load i32* @Z, align 4 + store i32 123, i32* %P, align 4 + %tmp2 = load i32* @Z, align 4 + br label %return + +return: + ret void +} From evan.cheng at apple.com Wed Oct 14 01:46:26 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 06:46:26 -0000 Subject: [llvm-commits] [llvm] r84080 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200910140646.n9E6kQS6009975@zion.cs.uiuc.edu> Author: evancheng Date: Wed Oct 14 01:46:26 2009 New Revision: 84080 URL: http://llvm.org/viewvc/llvm-project?rev=84080&view=rev Log: Clear VisitedPHIs after use. Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84080&r1=84079&r2=84080&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Wed Oct 14 01:46:26 2009 @@ -203,8 +203,10 @@ BasicAliasAnalysis() : NoAA(&ID) {} AliasResult alias(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size) { + assert(VisitedPHIs.empty() && "VisitedPHIs must be cleared after use!"); + AliasResult Alias = aliasCheck(V1, V1Size, V2, V2Size); VisitedPHIs.clear(); - return aliasCheck(V1, V1Size, V2, V2Size); + return Alias; } ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); From eocallaghan at auroraux.org Wed Oct 14 06:12:33 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Wed, 14 Oct 2009 11:12:33 -0000 Subject: [llvm-commits] [llvm] r84083 - in /llvm/trunk: autoconf/configure.ac configure include/llvm/Config/config.h.in Message-ID: <200910141112.n9EBCYKd000838@zion.cs.uiuc.edu> Author: evocallaghan Date: Wed Oct 14 06:12:33 2009 New Revision: 84083 URL: http://llvm.org/viewvc/llvm-project?rev=84083&view=rev Log: Undo pthread patch from rev. 83930 & 83823. Credit to Paul Davey. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/configure llvm/trunk/include/llvm/Config/config.h.in Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=84083&r1=84082&r2=84083&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Wed Oct 14 06:12:33 2009 @@ -974,9 +974,7 @@ dnl pthread locking functions are optional - but llvm will not be thread-safe dnl without locks. if test "$ENABLE_THREADS" -eq 1 ; then - AC_SEARCH_LIBS(pthread_mutex_init,pthread, - AC_DEFINE([HAVE_PTHREAD],[1], - [Have pthread])) + AC_CHECK_LIB(pthread, pthread_mutex_init) AC_SEARCH_LIBS(pthread_mutex_lock,pthread, AC_DEFINE([HAVE_PTHREAD_MUTEX_LOCK],[1], [Have pthread_mutex_lock])) Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=84083&r1=84082&r2=84083&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Wed Oct 14 06:12:33 2009 @@ -28033,12 +28033,14 @@ if test "$ENABLE_THREADS" -eq 1 ; then - { echo "$as_me:$LINENO: checking for library containing pthread_mutex_init" >&5 -echo $ECHO_N "checking for library containing pthread_mutex_init... $ECHO_C" >&6; } -if test "${ac_cv_search_pthread_mutex_init+set}" = set; then + +{ echo "$as_me:$LINENO: checking for pthread_mutex_init in -lpthread" >&5 +echo $ECHO_N "checking for pthread_mutex_init in -lpthread... $ECHO_C" >&6; } +if test "${ac_cv_lib_pthread_pthread_mutex_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_func_search_save_LIBS=$LIBS + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -28061,14 +28063,7 @@ return 0; } _ACEOF -for ac_lib in '' pthread; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - rm -f conftest.$ac_objext conftest$ac_exeext +rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; @@ -28102,38 +28097,27 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_search_pthread_mutex_init=$ac_res + ac_cv_lib_pthread_pthread_mutex_init=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - + ac_cv_lib_pthread_pthread_mutex_init=no fi rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if test "${ac_cv_search_pthread_mutex_init+set}" = set; then - break -fi -done -if test "${ac_cv_search_pthread_mutex_init+set}" = set; then - : -else - ac_cv_search_pthread_mutex_init=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -{ echo "$as_me:$LINENO: result: $ac_cv_search_pthread_mutex_init" >&5 -echo "${ECHO_T}$ac_cv_search_pthread_mutex_init" >&6; } -ac_res=$ac_cv_search_pthread_mutex_init -if test "$ac_res" != no; then - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -cat >>confdefs.h <<\_ACEOF -#define HAVE_PTHREAD 1 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_mutex_init" >&5 +echo "${ECHO_T}$ac_cv_lib_pthread_pthread_mutex_init" >&6; } +if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPTHREAD 1 _ACEOF + LIBS="-lpthread $LIBS" + fi { echo "$as_me:$LINENO: checking for library containing pthread_mutex_lock" >&5 Modified: llvm/trunk/include/llvm/Config/config.h.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.in?rev=84083&r1=84082&r2=84083&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.in (original) +++ llvm/trunk/include/llvm/Config/config.h.in Wed Oct 14 06:12:33 2009 @@ -193,6 +193,9 @@ /* Define to 1 if you have the `psapi' library (-lpsapi). */ #undef HAVE_LIBPSAPI +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#undef HAVE_LIBPTHREAD + /* Define to 1 if you have the `udis86' library (-ludis86). */ #undef HAVE_LIBUDIS86 @@ -282,9 +285,6 @@ /* Define to have the %a format string */ #undef HAVE_PRINTF_A -/* Have pthread */ -#undef HAVE_PTHREAD - /* Have pthread_getspecific */ #undef HAVE_PTHREAD_GETSPECIFIC From edwintorok at gmail.com Wed Oct 14 08:52:45 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 14 Oct 2009 16:52:45 +0300 Subject: [llvm-commits] [llvm] r84079 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll In-Reply-To: <200910140641.n9E6fndw009741@zion.cs.uiuc.edu> References: <200910140641.n9E6fndw009741@zion.cs.uiuc.edu> Message-ID: <4AD5D7AD.6080702@gmail.com> On 2009-10-14 09:41, Evan Cheng wrote: > Author: evancheng > Date: Wed Oct 14 01:41:49 2009 > New Revision: 84079 > > URL: http://llvm.org/viewvc/llvm-project?rev=84079&view=rev > Log: > Another BasicAA fix. If a value does not alias a GEP's base pointer, then it > cannot alias the GEP. GEP pointer alias rule states this clearly: > A pointer value formed from a getelementptr instruction is associated with the > addresses associated with the first operand of the getelementptr. > > Added: > llvm/trunk/test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll > Modified: > llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp > > Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84079&r1=84078&r2=84079&view=diff > > ============================================================================== > --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) > +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Wed Oct 14 01:41:49 2009 > @@ -428,49 +428,54 @@ > SmallVector GEPOperands; > const Value *BasePtr = GetGEPOperands(V1, GEPOperands); > > - AliasResult R = aliasCheck(BasePtr, V1Size, V2, V2Size); > - if (R == MustAlias) { > - // If there is at least one non-zero constant index, we know they cannot > - // alias. > - bool ConstantFound = false; > - bool AllZerosFound = true; > - for (unsigned i = 0, e = GEPOperands.size(); i != e; ++i) > - if (const Constant *C = dyn_cast(GEPOperands[i])) { > - if (!C->isNullValue()) { > - ConstantFound = true; > - AllZerosFound = false; > - break; > - } > - } else { > + AliasResult R = aliasCheck(BasePtr, ~0U, V2, V2Size); > + if (R != MustAlias) > + // If V2 may alias GEP base pointer, conservatively returns MayAlias. > Hi Evan, This gives MayAlias for a[4] and a[5], right? I think you shouldn't exit for a MayAlias return, only for a NoAlias result: you should check whether the [index1, index1+size1), and [index2, index2+size2) ranges overlap, which you seem to be doing later. > + // If V2 is known not to alias GEP base pointer, then the two values > + // cannot alias per GEP semantics: "A pointer value formed from a > + // getelementptr instruction is associated with the addresses associated > + // with the first operand of the getelementptr". > + return R; > + > + // If there is at least one non-zero constant index, we know they cannot > + // alias. > + bool ConstantFound = false; > + bool AllZerosFound = true; > + for (unsigned i = 0, e = GEPOperands.size(); i != e; ++i) > + if (const Constant *C = dyn_cast(GEPOperands[i])) { > + if (!C->isNullValue()) { > + ConstantFound = true; > AllZerosFound = false; > + break; > } > + } else { > + AllZerosFound = false; > + } > > - // If we have getelementptr , 0, 0, 0, 0, ... and V2 must aliases > - // the ptr, the end result is a must alias also. > - if (AllZerosFound) > - return MustAlias; > + // If we have getelementptr , 0, 0, 0, 0, ... and V2 must aliases > + // the ptr, the end result is a must alias also. > + if (AllZerosFound) > + return MustAlias; > > - if (ConstantFound) { > - if (V2Size <= 1 && V1Size <= 1) // Just pointer check? > - return NoAlias; > + if (ConstantFound) { > + if (V2Size <= 1 && V1Size <= 1) // Just pointer check? > + return NoAlias; > > - // Otherwise we have to check to see that the distance is more than > - // the size of the argument... build an index vector that is equal to > - // the arguments provided, except substitute 0's for any variable > - // indexes we find... > - if (TD && > - cast(BasePtr->getType())->getElementType()->isSized()) { > - for (unsigned i = 0; i != GEPOperands.size(); ++i) > - if (!isa(GEPOperands[i])) > - GEPOperands[i] = Constant::getNullValue(GEPOperands[i]->getType()); > - int64_t Offset = > - TD->getIndexedOffset(BasePtr->getType(), > - &GEPOperands[0], > - GEPOperands.size()); > + // Otherwise we have to check to see that the distance is more than > + // the size of the argument... build an index vector that is equal to > + // the arguments provided, except substitute 0's for any variable > + // indexes we find... > However I don't see how this code is reached if the AA returns MayAlias for a[4] and a[5], as the manual states: The MayAlias response is used whenever the two pointers might refer to the same object. If the two memory objects overlap, but do not start at the same location, return MayAlias. Best regards, --Edwin From sabre at nondot.org Wed Oct 14 10:21:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 15:21:58 -0000 Subject: [llvm-commits] [llvm] r84103 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/sink_instruction.ll Message-ID: <200910141521.n9EFLw5c010255@zion.cs.uiuc.edu> Author: lattner Date: Wed Oct 14 10:21:58 2009 New Revision: 84103 URL: http://llvm.org/viewvc/llvm-project?rev=84103&view=rev Log: make instcombine's instruction sinking more aggressive in the presence of PHI nodes. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/sink_instruction.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84103&r1=84102&r2=84103&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed Oct 14 10:21:58 2009 @@ -12836,7 +12836,15 @@ // See if we can trivially sink this instruction to a successor basic block. if (I->hasOneUse()) { BasicBlock *BB = I->getParent(); - BasicBlock *UserParent = cast(I->use_back())->getParent(); + Instruction *UserInst = cast(I->use_back()); + BasicBlock *UserParent; + + // Get the block the use occurs in. + if (PHINode *PN = dyn_cast(UserInst)) + UserParent = PN->getIncomingBlock(I->use_begin().getUse()); + else + UserParent = UserInst->getParent(); + if (UserParent != BB) { bool UserIsSuccessor = false; // See if the user is one of our successors. @@ -12849,8 +12857,7 @@ // If the user is one of our immediate successors, and if that successor // only has us as a predecessors (we'd have to split the critical edge // otherwise), we can keep going. - if (UserIsSuccessor && !isa(I->use_back()) && - next(pred_begin(UserParent)) == pred_end(UserParent)) + if (UserIsSuccessor && UserParent->getSinglePredecessor()) // Okay, the CFG is simple enough, try to sink this instruction. MadeIRChange |= TryToSinkInstruction(I, UserParent); } Modified: llvm/trunk/test/Transforms/InstCombine/sink_instruction.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sink_instruction.ll?rev=84103&r1=84102&r2=84103&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sink_instruction.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/sink_instruction.ll Wed Oct 14 10:21:58 2009 @@ -3,7 +3,8 @@ ;; This tests that the instructions in the entry blocks are sunk into each ;; arm of the 'if'. -define i32 @foo(i1 %C, i32 %A, i32 %B) { +define i32 @test1(i1 %C, i32 %A, i32 %B) { +; CHECK: @test1 entry: %tmp.2 = sdiv i32 %A, %B ; [#uses=1] %tmp.9 = add i32 %B, %A ; [#uses=1] @@ -18,3 +19,38 @@ ret i32 %tmp.2 } + +;; PHI use, sink divide before call. +define i32 @test2(i32 %x) nounwind ssp { +; CHECK: @test2 +; CHECK-NOT: sdiv i32 +entry: + br label %bb + +bb: ; preds = %bb2, %entry + %x_addr.17 = phi i32 [ %x, %entry ], [ %x_addr.0, %bb2 ] ; [#uses=4] + %i.06 = phi i32 [ 0, %entry ], [ %4, %bb2 ] ; [#uses=1] + %0 = add nsw i32 %x_addr.17, 1 ; [#uses=1] + %1 = sdiv i32 %0, %x_addr.17 ; [#uses=1] + %2 = icmp eq i32 %x_addr.17, 0 ; [#uses=1] + br i1 %2, label %bb1, label %bb2 + +bb1: ; preds = %bb +; CHECK: bb1: +; CHECK-NEXT: add nsw i32 %x_addr.17, 1 +; CHECK-NEXT: sdiv i32 +; CHECK-NEXT: tail call i32 @bar() + %3 = tail call i32 @bar() nounwind ; [#uses=0] + br label %bb2 + +bb2: ; preds = %bb, %bb1 + %x_addr.0 = phi i32 [ %1, %bb1 ], [ %x_addr.17, %bb ] ; [#uses=2] + %4 = add nsw i32 %i.06, 1 ; [#uses=2] + %exitcond = icmp eq i32 %4, 1000000 ; [#uses=1] + br i1 %exitcond, label %bb4, label %bb + +bb4: ; preds = %bb2 + ret i32 %x_addr.0 +} + +declare i32 @bar() From baldrick at free.fr Wed Oct 14 11:11:37 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 14 Oct 2009 16:11:37 -0000 Subject: [llvm-commits] [llvm] r84106 - in /llvm/trunk: docs/ExceptionHandling.html include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/CodeGen/IntrinsicLowering.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/CodeGen/SjLjEHPrepare.cpp lib/VMCore/AutoUpgrade.cpp Message-ID: <200910141611.n9EGBcr0012361@zion.cs.uiuc.edu> Author: baldrick Date: Wed Oct 14 11:11:37 2009 New Revision: 84106 URL: http://llvm.org/viewvc/llvm-project?rev=84106&view=rev Log: I don't see any point in having both eh.selector.i32 and eh.selector.i64, so get rid of eh.selector.i64 and rename eh.selector.i32 to eh.selector. Likewise for eh.typeid.for. This aligns us with gcc, which always uses a 32 bit value for the selector on all platforms. My understanding is that the register allocator used to assert if the selector intrinsic size didn't match the pointer size, and this was the reason for introducing the two variants. However my testing shows that this is no longer the case (I fixed some bugs in selector lowering yesterday, and some more today in the fastisel path; these might have caused the original problems). Modified: llvm/trunk/docs/ExceptionHandling.html llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp llvm/trunk/lib/VMCore/AutoUpgrade.cpp Modified: llvm/trunk/docs/ExceptionHandling.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ExceptionHandling.html?rev=84106&r1=84105&r2=84106&view=diff ============================================================================== --- llvm/trunk/docs/ExceptionHandling.html (original) +++ llvm/trunk/docs/ExceptionHandling.html Wed Oct 14 11:11:37 2009 @@ -418,8 +418,7 @@

        -  i32 %llvm.eh.selector.i32(i8*, i8*, i8*, ...)
        -  i64 %llvm.eh.selector.i64(i8*, i8*, i8*, ...)
        +  i32 %llvm.eh.selector(i8*, i8*, i8*, ...)
         

        This intrinsic is used to compare the exception with the given type infos, @@ -451,8 +450,7 @@

        -  i32 %llvm.eh.typeid.for.i32(i8*)
        -  i64 %llvm.eh.typeid.for.i64(i8*)
        +  i32 %llvm.eh.typeid.for(i8*)
         

        This intrinsic returns the type info index in the exception table of the Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=84106&r1=84105&r2=84106&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Wed Oct 14 11:11:37 2009 @@ -313,8 +313,7 @@ // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const EHSelectorInst *) { return true; } static inline bool classof(const IntrinsicInst *I) { - return I->getIntrinsicID() == Intrinsic::eh_selector_i32 || - I->getIntrinsicID() == Intrinsic::eh_selector_i64; + return I->getIntrinsicID() == Intrinsic::eh_selector; } static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=84106&r1=84105&r2=84106&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Wed Oct 14 11:11:37 2009 @@ -289,14 +289,11 @@ //===------------------ Exception Handling Intrinsics----------------------===// // -def int_eh_exception : Intrinsic<[llvm_ptr_ty], [], [IntrReadMem]>; -def int_eh_selector_i32 : Intrinsic<[llvm_i32_ty], - [llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty]>; -def int_eh_selector_i64 : Intrinsic<[llvm_i64_ty], - [llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty]>; +def int_eh_exception : Intrinsic<[llvm_ptr_ty], [], [IntrReadMem]>; +def int_eh_selector : Intrinsic<[llvm_i32_ty], + [llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty]>; -def int_eh_typeid_for_i32 : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>; -def int_eh_typeid_for_i64 : Intrinsic<[llvm_i64_ty], [llvm_ptr_ty]>; +def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>; def int_eh_return_i32 : Intrinsic<[llvm_void_ty], [llvm_i32_ty, llvm_ptr_ty]>; def int_eh_return_i64 : Intrinsic<[llvm_void_ty], [llvm_i64_ty, llvm_ptr_ty]>; Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=84106&r1=84105&r2=84106&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Wed Oct 14 11:11:37 2009 @@ -435,13 +435,11 @@ break; // Simply strip out debugging intrinsics case Intrinsic::eh_exception: - case Intrinsic::eh_selector_i32: - case Intrinsic::eh_selector_i64: + case Intrinsic::eh_selector: CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); break; - case Intrinsic::eh_typeid_for_i32: - case Intrinsic::eh_typeid_for_i64: + case Intrinsic::eh_typeid_for: // Return something different to eh_selector. CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1)); break; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=84106&r1=84105&r2=84106&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Wed Oct 14 11:11:37 2009 @@ -442,15 +442,11 @@ } break; } - case Intrinsic::eh_selector_i32: - case Intrinsic::eh_selector_i64: { + case Intrinsic::eh_selector: { EVT VT = TLI.getValueType(I->getType()); switch (TLI.getOperationAction(ISD::EHSELECTION, VT)) { default: break; case TargetLowering::Expand: { - EVT VT = (IID == Intrinsic::eh_selector_i32 ? - MVT::i32 : MVT::i64); - if (MMI) { if (MBB->isLandingPad()) AddCatchInfo(*cast(I), MMI, MBB); @@ -464,12 +460,25 @@ } unsigned Reg = TLI.getExceptionSelectorRegister(); - const TargetRegisterClass *RC = TLI.getRegClassFor(VT); + EVT SrcVT = TLI.getPointerTy(); + const TargetRegisterClass *RC = TLI.getRegClassFor(SrcVT); unsigned ResultReg = createResultReg(RC); - bool InsertedCopy = TII.copyRegToReg(*MBB, MBB->end(), ResultReg, - Reg, RC, RC); + bool InsertedCopy = TII.copyRegToReg(*MBB, MBB->end(), ResultReg, Reg, + RC, RC); assert(InsertedCopy && "Can't copy address registers!"); InsertedCopy = InsertedCopy; + + // Cast the register to the type of the selector. + if (SrcVT.bitsGT(MVT::i32)) + ResultReg = FastEmit_r(SrcVT.getSimpleVT(), MVT::i32, ISD::TRUNCATE, + ResultReg); + else if (SrcVT.bitsLT(MVT::i32)) + ResultReg = FastEmit_r(SrcVT.getSimpleVT(), MVT::i32, + ISD::SIGN_EXTEND, ResultReg); + if (ResultReg == 0) + // Unhandled operand. Halt "fast" selection and bail. + return false; + UpdateValueMap(I, ResultReg); } else { unsigned ResultReg = Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=84106&r1=84105&r2=84106&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Wed Oct 14 11:11:37 2009 @@ -3973,8 +3973,7 @@ return 0; } - case Intrinsic::eh_selector_i32: - case Intrinsic::eh_selector_i64: { + case Intrinsic::eh_selector: { MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); if (CurMBB->isLandingPad()) @@ -3997,27 +3996,22 @@ DAG.setRoot(Op.getValue(1)); - MVT::SimpleValueType VT = - (Intrinsic == Intrinsic::eh_selector_i32 ? MVT::i32 : MVT::i64); - setValue(&I, DAG.getSExtOrTrunc(Op, dl, VT)); + setValue(&I, DAG.getSExtOrTrunc(Op, dl, MVT::i32)); return 0; } - case Intrinsic::eh_typeid_for_i32: - case Intrinsic::eh_typeid_for_i64: { + case Intrinsic::eh_typeid_for: { MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); - EVT VT = (Intrinsic == Intrinsic::eh_typeid_for_i32 ? - MVT::i32 : MVT::i64); if (MMI) { // Find the type id for the given typeinfo. GlobalVariable *GV = ExtractTypeInfo(I.getOperand(1)); unsigned TypeID = MMI->getTypeIDFor(GV); - setValue(&I, DAG.getConstant(TypeID, VT)); + setValue(&I, DAG.getConstant(TypeID, MVT::i32)); } else { // Return something different to eh_selector. - setValue(&I, DAG.getConstant(1, VT)); + setValue(&I, DAG.getConstant(1, MVT::i32)); } return 0; Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=84106&r1=84105&r2=84106&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Wed Oct 14 11:11:37 2009 @@ -50,8 +50,7 @@ Constant *FrameAddrFn; Constant *LSDAAddrFn; Value *PersonalityFn; - Constant *Selector32Fn; - Constant *Selector64Fn; + Constant *SelectorFn; Constant *ExceptionFn; Value *CallSite; @@ -116,8 +115,7 @@ FrameAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::frameaddress); BuiltinSetjmpFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_setjmp); LSDAAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_lsda); - Selector32Fn = Intrinsic::getDeclaration(&M, Intrinsic::eh_selector_i32); - Selector64Fn = Intrinsic::getDeclaration(&M, Intrinsic::eh_selector_i64); + SelectorFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_selector); ExceptionFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_exception); PersonalityFn = 0; @@ -298,8 +296,7 @@ for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { if (CallInst *CI = dyn_cast(I)) { - if (CI->getCalledFunction() == Selector32Fn || - CI->getCalledFunction() == Selector64Fn) { + if (CI->getCalledFunction() == SelectorFn) { if (!PersonalityFn) PersonalityFn = CI->getOperand(2); EH_Selectors.push_back(CI); } else if (CI->getCalledFunction() == ExceptionFn) { Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=84106&r1=84105&r2=84106&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Wed Oct 14 11:11:37 2009 @@ -120,6 +120,31 @@ } break; + case 'e': + // The old llvm.eh.selector.i32 is equivalent to the new llvm.eh.selector. + if (Name.compare("llvm.eh.selector.i32") == 0) { + F->setName("llvm.eh.selector"); + NewFn = F; + return true; + } + // The old llvm.eh.typeid.for.i32 is equivalent to llvm.eh.typeid.for. + if (Name.compare("llvm.eh.typeid.for.i32") == 0) { + F->setName("llvm.eh.typeid.for"); + NewFn = F; + return true; + } + // Convert the old llvm.eh.selector.i64 to a call to llvm.eh.selector. + if (Name.compare("llvm.eh.selector.i64") == 0) { + NewFn = Intrinsic::getDeclaration(M, Intrinsic::eh_selector); + return true; + } + // Convert the old llvm.eh.typeid.for.i64 to a call to llvm.eh.typeid.for. + if (Name.compare("llvm.eh.typeid.for.i64") == 0) { + NewFn = Intrinsic::getDeclaration(M, Intrinsic::eh_typeid_for); + return true; + } + break; + case 'p': // This upgrades the llvm.part.select overloaded intrinsic names to only // use one type specifier in the name. We only care about the old format @@ -409,6 +434,27 @@ CI->eraseFromParent(); } break; + case Intrinsic::eh_selector: + case Intrinsic::eh_typeid_for: { + // Only the return type changed. + SmallVector Operands(CI->op_begin() + 1, CI->op_end()); + CallInst *NewCI = CallInst::Create(NewFn, Operands.begin(), Operands.end(), + "upgraded." + CI->getName(), CI); + NewCI->setTailCall(CI->isTailCall()); + NewCI->setCallingConv(CI->getCallingConv()); + + // Handle any uses of the old CallInst. + if (!CI->use_empty()) { + // Construct an appropriate cast from the new return type to the old. + CastInst *RetCast = + CastInst::Create(CastInst::getCastOpcode(NewCI, true, + F->getReturnType(), true), + NewCI, F->getReturnType(), NewCI->getName(), CI); + CI->replaceAllUsesWith(RetCast); + } + CI->eraseFromParent(); + } + break; } } From baldrick at free.fr Wed Oct 14 11:15:54 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 14 Oct 2009 16:15:54 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r84108 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp tree-eh.c Message-ID: <200910141615.n9EGFsZp012539@zion.cs.uiuc.edu> Author: baldrick Date: Wed Oct 14 11:15:54 2009 New Revision: 84108 URL: http://llvm.org/viewvc/llvm-project?rev=84108&view=rev Log: There is now only one version of eh.selector and eh.typeid.for. Fix and simplify the llvm-gcc build. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/tree-eh.c Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=84108&r1=84107&r2=84108&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Oct 14 11:15:54 2009 @@ -1916,24 +1916,18 @@ // Check to see if the exception values have been constructed. if (ExceptionValue) return; - const Type *IntPtr = TD.getIntPtrType(Context); - ExceptionValue = CreateTemporary(Type::getInt8PtrTy(Context)); ExceptionValue->setName("eh_exception"); - ExceptionSelectorValue = CreateTemporary(IntPtr); + ExceptionSelectorValue = CreateTemporary(Type::getInt32Ty(Context)); ExceptionSelectorValue->setName("eh_selector"); FuncEHException = Intrinsic::getDeclaration(TheModule, Intrinsic::eh_exception); FuncEHSelector = Intrinsic::getDeclaration(TheModule, - (IntPtr == Type::getInt32Ty(Context) ? - Intrinsic::eh_selector_i32 : - Intrinsic::eh_selector_i64)); + Intrinsic::eh_selector); FuncEHGetTypeID = Intrinsic::getDeclaration(TheModule, - (IntPtr == Type::getInt32Ty(Context) ? - Intrinsic::eh_typeid_for_i32 : - Intrinsic::eh_typeid_for_i64)); + Intrinsic::eh_typeid_for); } /// getPostPad - Return the post landing pad for the given exception handling Modified: llvm-gcc-4.2/trunk/gcc/tree-eh.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree-eh.c?rev=84108&r1=84107&r2=84108&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/tree-eh.c (original) +++ llvm-gcc-4.2/trunk/gcc/tree-eh.c Wed Oct 14 11:15:54 2009 @@ -838,25 +838,12 @@ tree save_eptr, save_filt; save_eptr = create_tmp_var (ptr_type_node, "save_eptr"); - /* LLVM LOCAL begin */ -#if ENABLE_LLVM - /* LLVM exceptions use 64 bits for these on 64-bit targets. */ - save_filt = create_tmp_var (long_integer_type_node, "save_filt"); -#else save_filt = create_tmp_var (integer_type_node, "save_filt"); -#endif - /* LLVM LOCAL end */ i = tsi_start (finally); x = build0 (EXC_PTR_EXPR, ptr_type_node); x = build2 (MODIFY_EXPR, void_type_node, save_eptr, x); tsi_link_before (&i, x, TSI_CONTINUE_LINKING); - /* LLVM LOCAL begin */ -#if ENABLE_LLVM - x = build0 (FILTER_EXPR, long_integer_type_node); -#else x = build0 (FILTER_EXPR, integer_type_node); -#endif - /* LLVM LOCAL end */ x = build2 (MODIFY_EXPR, void_type_node, save_filt, x); tsi_link_before (&i, x, TSI_CONTINUE_LINKING); @@ -865,13 +852,7 @@ x = build2 (MODIFY_EXPR, void_type_node, x, save_eptr); tsi_link_after (&i, x, TSI_CONTINUE_LINKING); - /* LLVM LOCAL begin */ -#if ENABLE_LLVM - x = build0 (FILTER_EXPR, long_integer_type_node); -#else x = build0 (FILTER_EXPR, integer_type_node); -#endif - /* LLVM LOCAL end */ x = build2 (MODIFY_EXPR, void_type_node, x, save_filt); tsi_link_after (&i, x, TSI_CONTINUE_LINKING); From bob.wilson at apple.com Wed Oct 14 11:19:03 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 14 Oct 2009 16:19:03 -0000 Subject: [llvm-commits] [llvm] r84109 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <200910141619.n9EGJ3qn012630@zion.cs.uiuc.edu> Author: bwilson Date: Wed Oct 14 11:19:03 2009 New Revision: 84109 URL: http://llvm.org/viewvc/llvm-project?rev=84109&view=rev Log: Refactor code for selecting NEON load lane intrinsics. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84109&r1=84108&r2=84109&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 14 11:19:03 2009 @@ -126,6 +126,13 @@ /// SelectDYN_ALLOC - Select dynamic alloc for Thumb. SDNode *SelectDYN_ALLOC(SDValue Op); + /// SelectVLDLane - Select NEON load structure to one lane. NumVecs should + /// be 2, 3 or 4. The opcode arrays specify the instructions used for + /// loading D registers and even subregs and odd subregs of Q registers. + SDNode *SelectVLDLane(SDValue Op, unsigned NumVecs, + unsigned *DOpcodes, unsigned *QOpcodes0, + unsigned *QOpcodes1); + /// SelectV6T2BitfieldExtractOp - Select SBFX/UBFX instructions for ARM. SDNode *SelectV6T2BitfieldExtractOp(SDValue Op, unsigned Opc); @@ -970,6 +977,109 @@ VT, SDValue(Pair, 0), V1, SubReg1); } +/// GetNEONSubregVT - Given a type for a 128-bit NEON vector, return the type +/// for a 64-bit subregister of the vector. +static EVT GetNEONSubregVT(EVT VT) { + switch (VT.getSimpleVT().SimpleTy) { + default: llvm_unreachable("unhandled NEON type"); + case MVT::v16i8: return MVT::v8i8; + case MVT::v8i16: return MVT::v4i16; + case MVT::v4f32: return MVT::v2f32; + case MVT::v4i32: return MVT::v2i32; + case MVT::v2i64: return MVT::v1i64; + } +} + +SDNode *ARMDAGToDAGISel::SelectVLDLane(SDValue Op, unsigned NumVecs, + unsigned *DOpcodes, unsigned *QOpcodes0, + unsigned *QOpcodes1) { + assert(NumVecs >=2 && NumVecs <= 4 && "VLDLane NumVecs out-of-range"); + SDNode *N = Op.getNode(); + DebugLoc dl = N->getDebugLoc(); + + SDValue MemAddr, MemUpdate, MemOpc; + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) + return NULL; + + SDValue Chain = N->getOperand(0); + unsigned Lane = + cast(N->getOperand(NumVecs+3))->getZExtValue(); + EVT VT = N->getValueType(0); + bool is64BitVector = VT.is64BitVector(); + + // Quad registers are handled by extracting subregs, doing the load, + // and then inserting the results as subregs. Find the subreg info. + unsigned NumElts = 0; + int SubregIdx = 0; + EVT RegVT = VT; + if (!is64BitVector) { + RegVT = GetNEONSubregVT(VT); + NumElts = RegVT.getVectorNumElements(); + SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; + } + + unsigned OpcodeIndex; + switch (VT.getSimpleVT().SimpleTy) { + default: llvm_unreachable("unhandled vld lane type"); + // Double-register operations: + case MVT::v8i8: OpcodeIndex = 0; break; + case MVT::v4i16: OpcodeIndex = 1; break; + case MVT::v2f32: + case MVT::v2i32: OpcodeIndex = 2; break; + // Quad-register operations: + case MVT::v8i16: OpcodeIndex = 0; break; + case MVT::v4f32: + case MVT::v4i32: OpcodeIndex = 1; break; + } + + SmallVector Ops; + Ops.push_back(MemAddr); + Ops.push_back(MemUpdate); + Ops.push_back(MemOpc); + + unsigned Opc = 0; + if (is64BitVector) { + Opc = DOpcodes[OpcodeIndex]; + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) + Ops.push_back(N->getOperand(Vec+3)); + } else { + // Check if this is loading the even or odd subreg of a Q register. + if (Lane < NumElts) { + Opc = QOpcodes0[OpcodeIndex]; + } else { + Lane -= NumElts; + Opc = QOpcodes1[OpcodeIndex]; + } + // Extract the subregs of the input vector. + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) + Ops.push_back(CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, + N->getOperand(Vec+3))); + } + Ops.push_back(getI32Imm(Lane)); + Ops.push_back(Chain); + + std::vector ResTys(NumVecs, RegVT); + ResTys.push_back(MVT::Other); + SDNode *VLdLn = + CurDAG->getMachineNode(Opc, dl, ResTys, Ops.data(), NumVecs+5); + // For a 64-bit vector load to D registers, nothing more needs to be done. + if (is64BitVector) + return VLdLn; + + // For 128-bit vectors, take the 64-bit results of the load and insert them + // as subregs into the result. + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) { + SDValue QuadVec = CurDAG->getTargetInsertSubreg(SubregIdx, dl, VT, + N->getOperand(Vec+3), + SDValue(VLdLn, Vec)); + ReplaceUses(SDValue(N, Vec), QuadVec); + } + + Chain = SDValue(VLdLn, NumVecs); + ReplaceUses(SDValue(N, NumVecs), Chain); + return NULL; +} + SDNode *ARMDAGToDAGISel::SelectV6T2BitfieldExtractOp(SDValue Op, unsigned Opc) { if (!Subtarget->hasV6T2Ops()) @@ -1568,223 +1678,24 @@ } case Intrinsic::arm_neon_vld2lane: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(5))->getZExtValue(); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld2lane type"); - case MVT::v8i8: Opc = ARM::VLD2LNd8; break; - case MVT::v4i16: Opc = ARM::VLD2LNd16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VLD2LNd32; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, - N->getOperand(3), N->getOperand(4), - getI32Imm(Lane), Chain }; - return CurDAG->getMachineNode(Opc, dl, VT, VT, MVT::Other, Ops, 7); - } - // Quad registers are handled by extracting subregs, doing the load, - // and then inserting the results as subregs. - EVT RegVT; - unsigned Opc2 = 0; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld2lane type"); - case MVT::v8i16: - Opc = ARM::VLD2LNq16a; - Opc2 = ARM::VLD2LNq16b; - RegVT = MVT::v4i16; - break; - case MVT::v4f32: - Opc = ARM::VLD2LNq32a; - Opc2 = ARM::VLD2LNq32b; - RegVT = MVT::v2f32; - break; - case MVT::v4i32: - Opc = ARM::VLD2LNq32a; - Opc2 = ARM::VLD2LNq32b; - RegVT = MVT::v2i32; - break; - } - unsigned NumElts = RegVT.getVectorNumElements(); - int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; - - SDValue D0 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(3)); - SDValue D1 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(4)); - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, D0, D1, - getI32Imm(Lane % NumElts), Chain }; - SDNode *VLdLn = CurDAG->getMachineNode((Lane < NumElts) ? Opc : Opc2, - dl, RegVT, RegVT, MVT::Other, - Ops, 7); - SDValue Q0 = CurDAG->getTargetInsertSubreg(SubregIdx, dl, VT, - N->getOperand(3), - SDValue(VLdLn, 0)); - SDValue Q1 = CurDAG->getTargetInsertSubreg(SubregIdx, dl, VT, - N->getOperand(4), - SDValue(VLdLn, 1)); - Chain = SDValue(VLdLn, 2); - ReplaceUses(SDValue(N, 0), Q0); - ReplaceUses(SDValue(N, 1), Q1); - ReplaceUses(SDValue(N, 2), Chain); - return NULL; + unsigned DOpcodes[] = { ARM::VLD2LNd8, ARM::VLD2LNd16, ARM::VLD2LNd32 }; + unsigned QOpcodes0[] = { ARM::VLD2LNq16a, ARM::VLD2LNq32a }; + unsigned QOpcodes1[] = { ARM::VLD2LNq16b, ARM::VLD2LNq32b }; + return SelectVLDLane(Op, 2, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vld3lane: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(6))->getZExtValue(); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld3lane type"); - case MVT::v8i8: Opc = ARM::VLD3LNd8; break; - case MVT::v4i16: Opc = ARM::VLD3LNd16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VLD3LNd32; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, - N->getOperand(3), N->getOperand(4), - N->getOperand(5), getI32Imm(Lane), Chain }; - return CurDAG->getMachineNode(Opc, dl, VT, VT, VT, MVT::Other, Ops, 8); - } - // Quad registers are handled by extracting subregs, doing the load, - // and then inserting the results as subregs. - EVT RegVT; - unsigned Opc2 = 0; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld3lane type"); - case MVT::v8i16: - Opc = ARM::VLD3LNq16a; - Opc2 = ARM::VLD3LNq16b; - RegVT = MVT::v4i16; - break; - case MVT::v4f32: - Opc = ARM::VLD3LNq32a; - Opc2 = ARM::VLD3LNq32b; - RegVT = MVT::v2f32; - break; - case MVT::v4i32: - Opc = ARM::VLD3LNq32a; - Opc2 = ARM::VLD3LNq32b; - RegVT = MVT::v2i32; - break; - } - unsigned NumElts = RegVT.getVectorNumElements(); - int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; - - SDValue D0 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(3)); - SDValue D1 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(4)); - SDValue D2 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(5)); - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, D0, D1, D2, - getI32Imm(Lane % NumElts), Chain }; - SDNode *VLdLn = CurDAG->getMachineNode((Lane < NumElts) ? Opc : Opc2, - dl, RegVT, RegVT, RegVT, - MVT::Other, Ops, 8); - SDValue Q0 = CurDAG->getTargetInsertSubreg(SubregIdx, dl, VT, - N->getOperand(3), - SDValue(VLdLn, 0)); - SDValue Q1 = CurDAG->getTargetInsertSubreg(SubregIdx, dl, VT, - N->getOperand(4), - SDValue(VLdLn, 1)); - SDValue Q2 = CurDAG->getTargetInsertSubreg(SubregIdx, dl, VT, - N->getOperand(5), - SDValue(VLdLn, 2)); - Chain = SDValue(VLdLn, 3); - ReplaceUses(SDValue(N, 0), Q0); - ReplaceUses(SDValue(N, 1), Q1); - ReplaceUses(SDValue(N, 2), Q2); - ReplaceUses(SDValue(N, 3), Chain); - return NULL; + unsigned DOpcodes[] = { ARM::VLD3LNd8, ARM::VLD3LNd16, ARM::VLD3LNd32 }; + unsigned QOpcodes0[] = { ARM::VLD3LNq16a, ARM::VLD3LNq32a }; + unsigned QOpcodes1[] = { ARM::VLD3LNq16b, ARM::VLD3LNq32b }; + return SelectVLDLane(Op, 3, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vld4lane: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(7))->getZExtValue(); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld4lane type"); - case MVT::v8i8: Opc = ARM::VLD4LNd8; break; - case MVT::v4i16: Opc = ARM::VLD4LNd16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VLD4LNd32; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, - N->getOperand(3), N->getOperand(4), - N->getOperand(5), N->getOperand(6), - getI32Imm(Lane), Chain }; - std::vector ResTys(4, VT); - ResTys.push_back(MVT::Other); - return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 9); - } - // Quad registers are handled by extracting subregs, doing the load, - // and then inserting the results as subregs. - EVT RegVT; - unsigned Opc2 = 0; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld4lane type"); - case MVT::v8i16: - Opc = ARM::VLD4LNq16a; - Opc2 = ARM::VLD4LNq16b; - RegVT = MVT::v4i16; - break; - case MVT::v4f32: - Opc = ARM::VLD4LNq32a; - Opc2 = ARM::VLD4LNq32b; - RegVT = MVT::v2f32; - break; - case MVT::v4i32: - Opc = ARM::VLD4LNq32a; - Opc2 = ARM::VLD4LNq32b; - RegVT = MVT::v2i32; - break; - } - unsigned NumElts = RegVT.getVectorNumElements(); - int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; - - SDValue D0 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(3)); - SDValue D1 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(4)); - SDValue D2 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(5)); - SDValue D3 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(6)); - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, D0, D1, D2, D3, - getI32Imm(Lane % NumElts), Chain }; - std::vector ResTys(4, RegVT); - ResTys.push_back(MVT::Other); - SDNode *VLdLn = CurDAG->getMachineNode((Lane < NumElts) ? Opc : Opc2, - dl, ResTys, Ops, 9); - SDValue Q0 = CurDAG->getTargetInsertSubreg(SubregIdx, dl, VT, - N->getOperand(3), - SDValue(VLdLn, 0)); - SDValue Q1 = CurDAG->getTargetInsertSubreg(SubregIdx, dl, VT, - N->getOperand(4), - SDValue(VLdLn, 1)); - SDValue Q2 = CurDAG->getTargetInsertSubreg(SubregIdx, dl, VT, - N->getOperand(5), - SDValue(VLdLn, 2)); - SDValue Q3 = CurDAG->getTargetInsertSubreg(SubregIdx, dl, VT, - N->getOperand(6), - SDValue(VLdLn, 3)); - Chain = SDValue(VLdLn, 4); - ReplaceUses(SDValue(N, 0), Q0); - ReplaceUses(SDValue(N, 1), Q1); - ReplaceUses(SDValue(N, 2), Q2); - ReplaceUses(SDValue(N, 3), Q3); - ReplaceUses(SDValue(N, 4), Chain); - return NULL; + unsigned DOpcodes[] = { ARM::VLD4LNd8, ARM::VLD4LNd16, ARM::VLD4LNd32 }; + unsigned QOpcodes0[] = { ARM::VLD4LNq16a, ARM::VLD4LNq32a }; + unsigned QOpcodes1[] = { ARM::VLD4LNq16b, ARM::VLD4LNq32b }; + return SelectVLDLane(Op, 4, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vst2: { From bob.wilson at apple.com Wed Oct 14 11:46:45 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 14 Oct 2009 16:46:45 -0000 Subject: [llvm-commits] [llvm] r84110 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <200910141646.n9EGkjCt013693@zion.cs.uiuc.edu> Author: bwilson Date: Wed Oct 14 11:46:45 2009 New Revision: 84110 URL: http://llvm.org/viewvc/llvm-project?rev=84110&view=rev Log: More refactoring. NEON vst lane intrinsics can share almost all the code for vld lane intrinsics. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84110&r1=84109&r2=84110&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 14 11:46:45 2009 @@ -126,12 +126,12 @@ /// SelectDYN_ALLOC - Select dynamic alloc for Thumb. SDNode *SelectDYN_ALLOC(SDValue Op); - /// SelectVLDLane - Select NEON load structure to one lane. NumVecs should + /// SelectVLDSTLane - Select NEON load/store lane intrinsics. NumVecs should /// be 2, 3 or 4. The opcode arrays specify the instructions used for - /// loading D registers and even subregs and odd subregs of Q registers. - SDNode *SelectVLDLane(SDValue Op, unsigned NumVecs, - unsigned *DOpcodes, unsigned *QOpcodes0, - unsigned *QOpcodes1); + /// load/store of D registers and even subregs and odd subregs of Q registers. + SDNode *SelectVLDSTLane(SDValue Op, bool IsLoad, unsigned NumVecs, + unsigned *DOpcodes, unsigned *QOpcodes0, + unsigned *QOpcodes1); /// SelectV6T2BitfieldExtractOp - Select SBFX/UBFX instructions for ARM. SDNode *SelectV6T2BitfieldExtractOp(SDValue Op, unsigned Opc); @@ -990,10 +990,11 @@ } } -SDNode *ARMDAGToDAGISel::SelectVLDLane(SDValue Op, unsigned NumVecs, - unsigned *DOpcodes, unsigned *QOpcodes0, - unsigned *QOpcodes1) { - assert(NumVecs >=2 && NumVecs <= 4 && "VLDLane NumVecs out-of-range"); +SDNode *ARMDAGToDAGISel::SelectVLDSTLane(SDValue Op, bool IsLoad, + unsigned NumVecs, unsigned *DOpcodes, + unsigned *QOpcodes0, + unsigned *QOpcodes1) { + assert(NumVecs >=2 && NumVecs <= 4 && "VLDSTLane NumVecs out-of-range"); SDNode *N = Op.getNode(); DebugLoc dl = N->getDebugLoc(); @@ -1004,11 +1005,10 @@ SDValue Chain = N->getOperand(0); unsigned Lane = cast(N->getOperand(NumVecs+3))->getZExtValue(); - EVT VT = N->getValueType(0); + EVT VT = IsLoad ? N->getValueType(0) : N->getOperand(3).getValueType(); bool is64BitVector = VT.is64BitVector(); - // Quad registers are handled by extracting subregs, doing the load, - // and then inserting the results as subregs. Find the subreg info. + // Quad registers are handled by load/store of subregs. Find the subreg info. unsigned NumElts = 0; int SubregIdx = 0; EVT RegVT = VT; @@ -1020,7 +1020,7 @@ unsigned OpcodeIndex; switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld lane type"); + default: llvm_unreachable("unhandled vld/vst lane type"); // Double-register operations: case MVT::v8i8: OpcodeIndex = 0; break; case MVT::v4i16: OpcodeIndex = 1; break; @@ -1058,6 +1058,9 @@ Ops.push_back(getI32Imm(Lane)); Ops.push_back(Chain); + if (!IsLoad) + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), NumVecs+5); + std::vector ResTys(NumVecs, RegVT); ResTys.push_back(MVT::Other); SDNode *VLdLn = @@ -1084,7 +1087,7 @@ unsigned Opc) { if (!Subtarget->hasV6T2Ops()) return NULL; - + unsigned Shl_imm = 0; if (isOpcWithIntImmediate(Op.getOperand(0).getNode(), ISD::SHL, Shl_imm)){ assert(Shl_imm > 0 && Shl_imm < 32 && "bad amount in shift node!"); @@ -1681,21 +1684,21 @@ unsigned DOpcodes[] = { ARM::VLD2LNd8, ARM::VLD2LNd16, ARM::VLD2LNd32 }; unsigned QOpcodes0[] = { ARM::VLD2LNq16a, ARM::VLD2LNq32a }; unsigned QOpcodes1[] = { ARM::VLD2LNq16b, ARM::VLD2LNq32b }; - return SelectVLDLane(Op, 2, DOpcodes, QOpcodes0, QOpcodes1); + return SelectVLDSTLane(Op, true, 2, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vld3lane: { unsigned DOpcodes[] = { ARM::VLD3LNd8, ARM::VLD3LNd16, ARM::VLD3LNd32 }; unsigned QOpcodes0[] = { ARM::VLD3LNq16a, ARM::VLD3LNq32a }; unsigned QOpcodes1[] = { ARM::VLD3LNq16b, ARM::VLD3LNq32b }; - return SelectVLDLane(Op, 3, DOpcodes, QOpcodes0, QOpcodes1); + return SelectVLDSTLane(Op, true, 3, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vld4lane: { unsigned DOpcodes[] = { ARM::VLD4LNd8, ARM::VLD4LNd16, ARM::VLD4LNd32 }; unsigned QOpcodes0[] = { ARM::VLD4LNq16a, ARM::VLD4LNq32a }; unsigned QOpcodes1[] = { ARM::VLD4LNq16b, ARM::VLD4LNq32b }; - return SelectVLDLane(Op, 4, DOpcodes, QOpcodes0, QOpcodes1); + return SelectVLDSTLane(Op, true, 4, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vst2: { @@ -1874,175 +1877,24 @@ } case Intrinsic::arm_neon_vst2lane: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(5))->getZExtValue(); - VT = N->getOperand(3).getValueType(); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst2lane type"); - case MVT::v8i8: Opc = ARM::VST2LNd8; break; - case MVT::v4i16: Opc = ARM::VST2LNd16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VST2LNd32; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, - N->getOperand(3), N->getOperand(4), - getI32Imm(Lane), Chain }; - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 7); - } - // Quad registers are handled by extracting subregs and then doing - // the store. - EVT RegVT; - unsigned Opc2 = 0; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst2lane type"); - case MVT::v8i16: - Opc = ARM::VST2LNq16a; - Opc2 = ARM::VST2LNq16b; - RegVT = MVT::v4i16; - break; - case MVT::v4f32: - Opc = ARM::VST2LNq32a; - Opc2 = ARM::VST2LNq32b; - RegVT = MVT::v2f32; - break; - case MVT::v4i32: - Opc = ARM::VST2LNq32a; - Opc2 = ARM::VST2LNq32b; - RegVT = MVT::v2i32; - break; - } - unsigned NumElts = RegVT.getVectorNumElements(); - int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; - - SDValue D0 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(3)); - SDValue D1 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(4)); - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, D0, D1, - getI32Imm(Lane % NumElts), Chain }; - return CurDAG->getMachineNode((Lane < NumElts) ? Opc : Opc2, - dl, MVT::Other, Ops, 7); + unsigned DOpcodes[] = { ARM::VST2LNd8, ARM::VST2LNd16, ARM::VST2LNd32 }; + unsigned QOpcodes0[] = { ARM::VST2LNq16a, ARM::VST2LNq32a }; + unsigned QOpcodes1[] = { ARM::VST2LNq16b, ARM::VST2LNq32b }; + return SelectVLDSTLane(Op, false, 2, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vst3lane: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(6))->getZExtValue(); - VT = N->getOperand(3).getValueType(); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst3lane type"); - case MVT::v8i8: Opc = ARM::VST3LNd8; break; - case MVT::v4i16: Opc = ARM::VST3LNd16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VST3LNd32; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, - N->getOperand(3), N->getOperand(4), - N->getOperand(5), getI32Imm(Lane), Chain }; - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 8); - } - // Quad registers are handled by extracting subregs and then doing - // the store. - EVT RegVT; - unsigned Opc2 = 0; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst3lane type"); - case MVT::v8i16: - Opc = ARM::VST3LNq16a; - Opc2 = ARM::VST3LNq16b; - RegVT = MVT::v4i16; - break; - case MVT::v4f32: - Opc = ARM::VST3LNq32a; - Opc2 = ARM::VST3LNq32b; - RegVT = MVT::v2f32; - break; - case MVT::v4i32: - Opc = ARM::VST3LNq32a; - Opc2 = ARM::VST3LNq32b; - RegVT = MVT::v2i32; - break; - } - unsigned NumElts = RegVT.getVectorNumElements(); - int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; - - SDValue D0 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(3)); - SDValue D1 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(4)); - SDValue D2 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(5)); - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, D0, D1, D2, - getI32Imm(Lane % NumElts), Chain }; - return CurDAG->getMachineNode((Lane < NumElts) ? Opc : Opc2, - dl, MVT::Other, Ops, 8); + unsigned DOpcodes[] = { ARM::VST3LNd8, ARM::VST3LNd16, ARM::VST3LNd32 }; + unsigned QOpcodes0[] = { ARM::VST3LNq16a, ARM::VST3LNq32a }; + unsigned QOpcodes1[] = { ARM::VST3LNq16b, ARM::VST3LNq32b }; + return SelectVLDSTLane(Op, false, 3, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vst4lane: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - unsigned Lane = cast(N->getOperand(7))->getZExtValue(); - VT = N->getOperand(3).getValueType(); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst4lane type"); - case MVT::v8i8: Opc = ARM::VST4LNd8; break; - case MVT::v4i16: Opc = ARM::VST4LNd16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VST4LNd32; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, - N->getOperand(3), N->getOperand(4), - N->getOperand(5), N->getOperand(6), - getI32Imm(Lane), Chain }; - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 9); - } - // Quad registers are handled by extracting subregs and then doing - // the store. - EVT RegVT; - unsigned Opc2 = 0; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst4lane type"); - case MVT::v8i16: - Opc = ARM::VST4LNq16a; - Opc2 = ARM::VST4LNq16b; - RegVT = MVT::v4i16; - break; - case MVT::v4f32: - Opc = ARM::VST4LNq32a; - Opc2 = ARM::VST4LNq32b; - RegVT = MVT::v2f32; - break; - case MVT::v4i32: - Opc = ARM::VST4LNq32a; - Opc2 = ARM::VST4LNq32b; - RegVT = MVT::v2i32; - break; - } - unsigned NumElts = RegVT.getVectorNumElements(); - int SubregIdx = (Lane < NumElts) ? ARM::DSUBREG_0 : ARM::DSUBREG_1; - - SDValue D0 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(3)); - SDValue D1 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(4)); - SDValue D2 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(5)); - SDValue D3 = CurDAG->getTargetExtractSubreg(SubregIdx, dl, RegVT, - N->getOperand(6)); - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, D0, D1, D2, D3, - getI32Imm(Lane % NumElts), Chain }; - return CurDAG->getMachineNode((Lane < NumElts) ? Opc : Opc2, - dl, MVT::Other, Ops, 9); + unsigned DOpcodes[] = { ARM::VST4LNd8, ARM::VST4LNd16, ARM::VST4LNd32 }; + unsigned QOpcodes0[] = { ARM::VST4LNq16a, ARM::VST4LNq32a }; + unsigned QOpcodes1[] = { ARM::VST4LNq16b, ARM::VST4LNq32b }; + return SelectVLDSTLane(Op, false, 4, DOpcodes, QOpcodes0, QOpcodes1); } } } From dpatel at apple.com Wed Oct 14 12:02:49 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 14 Oct 2009 17:02:49 -0000 Subject: [llvm-commits] [llvm] r84113 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp Message-ID: <200910141702.n9EH2niQ014489@zion.cs.uiuc.edu> Author: dpatel Date: Wed Oct 14 12:02:49 2009 New Revision: 84113 URL: http://llvm.org/viewvc/llvm-project?rev=84113&view=rev Log: Add copyMD to copy metadata from one instruction to another instruction. Modified: llvm/trunk/include/llvm/Metadata.h llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=84113&r1=84112&r2=84113&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Wed Oct 14 12:02:49 2009 @@ -351,6 +351,10 @@ /// removeMDs - Remove all metadata attached with an instruction. void removeMDs(const Instruction *Inst); + /// copyMD - If metadata is attached with Instruction In1 then attach + /// the same metadata to In2. + void copyMD(Instruction *In1, Instruction *In2); + /// getHandlerNames - Get handler names. This is used by bitcode /// writer. const StringMap *getHandlerNames(); Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=84113&r1=84112&r2=84113&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Oct 14 12:02:49 2009 @@ -359,6 +359,20 @@ MetadataStore.erase(I); } +/// copyMD - If metadata is attached with Instruction In1 then attach +/// the same metadata to In2. +void MetadataContext::copyMD(Instruction *In1, Instruction *In2) { + assert (In1 && In2 && "Invalid instruction!"); + MDStoreTy::iterator I = MetadataStore.find(In1); + if (I == MetadataStore.end()) + return; + + MDMapTy &In1Info = I->second; + MDMapTy In2Info; + for (MDMapTy::iterator I = In1Info.begin(), E = In1Info.end(); I != E; ++I) + if (MDNode *MD = dyn_cast_or_null(I->second)) + addMD(I->first, MD, In2); +} /// getMD - Get the metadata of given kind attached with an Instruction. /// If the metadata is not found then return 0. @@ -416,3 +430,4 @@ // FIXME : Give custom handlers a chance to override this. ValueIsCloned(I1, I2); } + From johnny.chen at apple.com Wed Oct 14 12:03:58 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 14 Oct 2009 10:03:58 -0700 Subject: [llvm-commits] Add some ARM instruction encoding bits for "register" and "register-shifted register" Message-ID: For 'r', add: let Inst{4} = 0; For 's', add: let Inst{4} = 1; let Inst{7} = 0; -------------- next part -------------- A non-text attachment was scrubbed... Name: ARMInstrInfo.td.patch Type: application/octet-stream Size: 5575 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091014/0147294c/attachment.obj From bob.wilson at apple.com Wed Oct 14 12:28:52 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 14 Oct 2009 17:28:52 -0000 Subject: [llvm-commits] [llvm] r84117 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <200910141728.n9EHSqRB015596@zion.cs.uiuc.edu> Author: bwilson Date: Wed Oct 14 12:28:52 2009 New Revision: 84117 URL: http://llvm.org/viewvc/llvm-project?rev=84117&view=rev Log: Refactor code to select NEON VLD intrinsics. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84117&r1=84116&r2=84117&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 14 12:28:52 2009 @@ -126,6 +126,13 @@ /// SelectDYN_ALLOC - Select dynamic alloc for Thumb. SDNode *SelectDYN_ALLOC(SDValue Op); + /// SelectVLD - Select NEON load intrinsics. NumVecs should + /// be 2, 3 or 4. The opcode arrays specify the instructions used for + /// loads of D registers and even subregs and odd subregs of Q registers. + /// For NumVecs == 2, QOpcodes1 is not used. + SDNode *SelectVLD(SDValue Op, unsigned NumVecs, unsigned *DOpcodes, + unsigned *QOpcodes0, unsigned *QOpcodes1); + /// SelectVLDSTLane - Select NEON load/store lane intrinsics. NumVecs should /// be 2, 3 or 4. The opcode arrays specify the instructions used for /// load/store of D registers and even subregs and odd subregs of Q registers. @@ -990,6 +997,94 @@ } } +SDNode *ARMDAGToDAGISel::SelectVLD(SDValue Op, unsigned NumVecs, + unsigned *DOpcodes, unsigned *QOpcodes0, + unsigned *QOpcodes1) { + assert(NumVecs >=2 && NumVecs <= 4 && "VLD NumVecs out-of-range"); + SDNode *N = Op.getNode(); + DebugLoc dl = N->getDebugLoc(); + + SDValue MemAddr, MemUpdate, MemOpc; + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) + return NULL; + + SDValue Chain = N->getOperand(0); + EVT VT = N->getValueType(0); + bool is64BitVector = VT.is64BitVector(); + + unsigned OpcodeIndex; + switch (VT.getSimpleVT().SimpleTy) { + default: llvm_unreachable("unhandled vld type"); + // Double-register operations: + case MVT::v8i8: OpcodeIndex = 0; break; + case MVT::v4i16: OpcodeIndex = 1; break; + case MVT::v2f32: + case MVT::v2i32: OpcodeIndex = 2; break; + case MVT::v1i64: OpcodeIndex = 3; break; + // Quad-register operations: + case MVT::v16i8: OpcodeIndex = 0; break; + case MVT::v8i16: OpcodeIndex = 1; break; + case MVT::v4f32: + case MVT::v4i32: OpcodeIndex = 2; break; + } + + if (is64BitVector) { + unsigned Opc = DOpcodes[OpcodeIndex]; + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; + std::vector ResTys(NumVecs, VT); + ResTys.push_back(MVT::Other); + return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); + } + + EVT RegVT = GetNEONSubregVT(VT); + if (NumVecs == 2) { + // Quad registers are directly supported for VLD2, + // loading 2 pairs of D regs. + unsigned Opc = QOpcodes0[OpcodeIndex]; + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; + std::vector ResTys(4, VT); + ResTys.push_back(MVT::Other); + SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); + Chain = SDValue(VLd, 4); + + // Combine the even and odd subregs to produce the result. + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) { + SDNode *Q = PairDRegs(VT, SDValue(VLd, 2*Vec), SDValue(VLd, 2*Vec+1)); + ReplaceUses(SDValue(N, Vec), SDValue(Q, 0)); + } + } else { + // Otherwise, quad registers are loaded with two separate instructions, + // where one loads the even registers and the other loads the odd registers. + + // Enable writeback to the address register. + MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), MVT::i32); + + std::vector ResTys(NumVecs, RegVT); + ResTys.push_back(MemAddr.getValueType()); + ResTys.push_back(MVT::Other); + + // Load the even subreg. + unsigned Opc = QOpcodes0[OpcodeIndex]; + const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; + SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 4); + Chain = SDValue(VLdA, NumVecs+1); + + // Load the odd subreg. + Opc = QOpcodes1[OpcodeIndex]; + const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, MemOpc, Chain }; + SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 4); + Chain = SDValue(VLdB, NumVecs+1); + + // Combine the even and odd subregs to produce the result. + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) { + SDNode *Q = PairDRegs(VT, SDValue(VLdA, Vec), SDValue(VLdB, Vec)); + ReplaceUses(SDValue(N, Vec), SDValue(Q, 0)); + } + } + ReplaceUses(SDValue(N, NumVecs), Chain); + return NULL; +} + SDNode *ARMDAGToDAGISel::SelectVLDSTLane(SDValue Op, bool IsLoad, unsigned NumVecs, unsigned *DOpcodes, unsigned *QOpcodes0, @@ -1525,159 +1620,26 @@ break; case Intrinsic::arm_neon_vld2: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld2 type"); - case MVT::v8i8: Opc = ARM::VLD2d8; break; - case MVT::v4i16: Opc = ARM::VLD2d16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VLD2d32; break; - case MVT::v1i64: Opc = ARM::VLD2d64; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; - return CurDAG->getMachineNode(Opc, dl, VT, VT, MVT::Other, Ops, 4); - } - // Quad registers are loaded as pairs of double registers. - EVT RegVT; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld2 type"); - case MVT::v16i8: Opc = ARM::VLD2q8; RegVT = MVT::v8i8; break; - case MVT::v8i16: Opc = ARM::VLD2q16; RegVT = MVT::v4i16; break; - case MVT::v4f32: Opc = ARM::VLD2q32; RegVT = MVT::v2f32; break; - case MVT::v4i32: Opc = ARM::VLD2q32; RegVT = MVT::v2i32; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; - std::vector ResTys(4, RegVT); - ResTys.push_back(MVT::Other); - SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); - SDNode *Q0 = PairDRegs(VT, SDValue(VLd, 0), SDValue(VLd, 1)); - SDNode *Q1 = PairDRegs(VT, SDValue(VLd, 2), SDValue(VLd, 3)); - ReplaceUses(SDValue(N, 0), SDValue(Q0, 0)); - ReplaceUses(SDValue(N, 1), SDValue(Q1, 0)); - ReplaceUses(SDValue(N, 2), SDValue(VLd, 4)); - return NULL; + unsigned DOpcodes[] = { ARM::VLD2d8, ARM::VLD2d16, + ARM::VLD2d32, ARM::VLD2d64 }; + unsigned QOpcodes[] = { ARM::VLD2q8, ARM::VLD2q16, ARM::VLD2q32 }; + return SelectVLD(Op, 2, DOpcodes, QOpcodes, 0); } case Intrinsic::arm_neon_vld3: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld3 type"); - case MVT::v8i8: Opc = ARM::VLD3d8; break; - case MVT::v4i16: Opc = ARM::VLD3d16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VLD3d32; break; - case MVT::v1i64: Opc = ARM::VLD3d64; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; - return CurDAG->getMachineNode(Opc, dl, VT, VT, VT, MVT::Other, Ops, 4); - } - // Quad registers are loaded with two separate instructions, where one - // loads the even registers and the other loads the odd registers. - EVT RegVT; - unsigned Opc2 = 0; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld3 type"); - case MVT::v16i8: - Opc = ARM::VLD3q8a; Opc2 = ARM::VLD3q8b; RegVT = MVT::v8i8; break; - case MVT::v8i16: - Opc = ARM::VLD3q16a; Opc2 = ARM::VLD3q16b; RegVT = MVT::v4i16; break; - case MVT::v4f32: - Opc = ARM::VLD3q32a; Opc2 = ARM::VLD3q32b; RegVT = MVT::v2f32; break; - case MVT::v4i32: - Opc = ARM::VLD3q32a; Opc2 = ARM::VLD3q32b; RegVT = MVT::v2i32; break; - } - // Enable writeback to the address register. - MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), MVT::i32); - - std::vector ResTys(3, RegVT); - ResTys.push_back(MemAddr.getValueType()); - ResTys.push_back(MVT::Other); - - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; - SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 4); - Chain = SDValue(VLdA, 4); - - const SDValue OpsB[] = { SDValue(VLdA, 3), MemUpdate, MemOpc, Chain }; - SDNode *VLdB = CurDAG->getMachineNode(Opc2, dl, ResTys, OpsB, 4); - Chain = SDValue(VLdB, 4); - - SDNode *Q0 = PairDRegs(VT, SDValue(VLdA, 0), SDValue(VLdB, 0)); - SDNode *Q1 = PairDRegs(VT, SDValue(VLdA, 1), SDValue(VLdB, 1)); - SDNode *Q2 = PairDRegs(VT, SDValue(VLdA, 2), SDValue(VLdB, 2)); - ReplaceUses(SDValue(N, 0), SDValue(Q0, 0)); - ReplaceUses(SDValue(N, 1), SDValue(Q1, 0)); - ReplaceUses(SDValue(N, 2), SDValue(Q2, 0)); - ReplaceUses(SDValue(N, 3), Chain); - return NULL; + unsigned DOpcodes[] = { ARM::VLD3d8, ARM::VLD3d16, + ARM::VLD3d32, ARM::VLD3d64 }; + unsigned QOpcodes0[] = { ARM::VLD3q8a, ARM::VLD3q16a, ARM::VLD3q32a }; + unsigned QOpcodes1[] = { ARM::VLD3q8b, ARM::VLD3q16b, ARM::VLD3q32b }; + return SelectVLD(Op, 3, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vld4: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld4 type"); - case MVT::v8i8: Opc = ARM::VLD4d8; break; - case MVT::v4i16: Opc = ARM::VLD4d16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VLD4d32; break; - case MVT::v1i64: Opc = ARM::VLD4d64; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; - std::vector ResTys(4, VT); - ResTys.push_back(MVT::Other); - return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); - } - // Quad registers are loaded with two separate instructions, where one - // loads the even registers and the other loads the odd registers. - EVT RegVT; - unsigned Opc2 = 0; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vld4 type"); - case MVT::v16i8: - Opc = ARM::VLD4q8a; Opc2 = ARM::VLD4q8b; RegVT = MVT::v8i8; break; - case MVT::v8i16: - Opc = ARM::VLD4q16a; Opc2 = ARM::VLD4q16b; RegVT = MVT::v4i16; break; - case MVT::v4f32: - Opc = ARM::VLD4q32a; Opc2 = ARM::VLD4q32b; RegVT = MVT::v2f32; break; - case MVT::v4i32: - Opc = ARM::VLD4q32a; Opc2 = ARM::VLD4q32b; RegVT = MVT::v2i32; break; - } - // Enable writeback to the address register. - MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), MVT::i32); - - std::vector ResTys(4, RegVT); - ResTys.push_back(MemAddr.getValueType()); - ResTys.push_back(MVT::Other); - - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; - SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 4); - Chain = SDValue(VLdA, 5); - - const SDValue OpsB[] = { SDValue(VLdA, 4), MemUpdate, MemOpc, Chain }; - SDNode *VLdB = CurDAG->getMachineNode(Opc2, dl, ResTys, OpsB, 4); - Chain = SDValue(VLdB, 5); - - SDNode *Q0 = PairDRegs(VT, SDValue(VLdA, 0), SDValue(VLdB, 0)); - SDNode *Q1 = PairDRegs(VT, SDValue(VLdA, 1), SDValue(VLdB, 1)); - SDNode *Q2 = PairDRegs(VT, SDValue(VLdA, 2), SDValue(VLdB, 2)); - SDNode *Q3 = PairDRegs(VT, SDValue(VLdA, 3), SDValue(VLdB, 3)); - ReplaceUses(SDValue(N, 0), SDValue(Q0, 0)); - ReplaceUses(SDValue(N, 1), SDValue(Q1, 0)); - ReplaceUses(SDValue(N, 2), SDValue(Q2, 0)); - ReplaceUses(SDValue(N, 3), SDValue(Q3, 0)); - ReplaceUses(SDValue(N, 4), Chain); - return NULL; + unsigned DOpcodes[] = { ARM::VLD4d8, ARM::VLD4d16, + ARM::VLD4d32, ARM::VLD4d64 }; + unsigned QOpcodes0[] = { ARM::VLD4q8a, ARM::VLD4q16a, ARM::VLD4q32a }; + unsigned QOpcodes1[] = { ARM::VLD4q8b, ARM::VLD4q16b, ARM::VLD4q32b }; + return SelectVLD(Op, 4, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vld2lane: { From dpatel at apple.com Wed Oct 14 12:29:01 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 14 Oct 2009 17:29:01 -0000 Subject: [llvm-commits] [llvm] r84118 - in /llvm/trunk/lib/Transforms/Scalar: GVN.cpp InstructionCombining.cpp LICM.cpp LoopUnswitch.cpp Message-ID: <200910141729.n9EHT137015613@zion.cs.uiuc.edu> Author: dpatel Date: Wed Oct 14 12:29:00 2009 New Revision: 84118 URL: http://llvm.org/viewvc/llvm-project?rev=84118&view=rev Log: Use isVoidTy() Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/Transforms/Scalar/LICM.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=84118&r1=84117&r2=84118&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Oct 14 12:29:00 2009 @@ -1826,7 +1826,7 @@ if (isa(CurInst) || isa(CurInst) || isa(CurInst) || - (CurInst->getType() == Type::getVoidTy(F.getContext())) || + CurInst->getType()->isVoidTy() || CurInst->mayReadFromMemory() || CurInst->mayHaveSideEffects() || isa(CurInst)) continue; Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84118&r1=84117&r2=84118&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed Oct 14 12:29:00 2009 @@ -9981,7 +9981,7 @@ OldCall); // If OldCall dues not return void then replaceAllUsesWith undef. // This allows ValueHandlers and custom metadata to adjust itself. - if (OldCall->getType() != Type::getVoidTy(*Context)) + if (!OldCall->getType()->isVoidTy()) OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType())); if (isa(OldCall)) // Not worth removing an invoke here. return EraseInstFromFunction(*OldCall); @@ -9998,7 +9998,7 @@ // If CS dues not return void then replaceAllUsesWith undef. // This allows ValueHandlers and custom metadata to adjust itself. - if (CS.getInstruction()->getType() != Type::getVoidTy(*Context)) + if (!CS.getInstruction()->getType()->isVoidTy()) CS.getInstruction()-> replaceAllUsesWith(UndefValue::get(CS.getInstruction()->getType())); @@ -10077,7 +10077,7 @@ if (!Caller->use_empty() && // void -> non-void is handled specially - NewRetTy != Type::getVoidTy(*Context) && !CastInst::isCastable(NewRetTy, OldRetTy)) + !NewRetTy->isVoidTy() && !CastInst::isCastable(NewRetTy, OldRetTy)) return false; // Cannot transform this return value. if (!CallerPAL.isEmpty() && !Caller->use_empty()) { @@ -10209,7 +10209,7 @@ if (Attributes FnAttrs = CallerPAL.getFnAttributes()) attrVec.push_back(AttributeWithIndex::get(~0, FnAttrs)); - if (NewRetTy == Type::getVoidTy(*Context)) + if (NewRetTy->isVoidTy()) Caller->setName(""); // Void type should not have a name. const AttrListPtr &NewCallerPAL = AttrListPtr::get(attrVec.begin(), @@ -10235,7 +10235,7 @@ // Insert a cast of the return type as necessary. Value *NV = NC; if (OldRetTy != NV->getType() && !Caller->use_empty()) { - if (NV->getType() != Type::getVoidTy(*Context)) { + if (!NV->getType()->isVoidTy()) { Instruction::CastOps opcode = CastInst::getCastOpcode(NC, false, OldRetTy, false); NV = NC = CastInst::Create(opcode, NC, OldRetTy, "tmp"); @@ -10402,7 +10402,7 @@ setCallingConv(cast(Caller)->getCallingConv()); cast(NewCaller)->setAttributes(NewPAL); } - if (Caller->getType() != Type::getVoidTy(*Context)) + if (!Caller->getType()->isVoidTy()) Caller->replaceAllUsesWith(NewCaller); Caller->eraseFromParent(); Worklist.Remove(Caller); @@ -12789,7 +12789,7 @@ // If I is not void type then replaceAllUsesWith undef. // This allows ValueHandlers and custom metadata to adjust itself. - if (I->getType() != Type::getVoidTy(*Context)) + if (!I->getType()->isVoidTy()) I->replaceAllUsesWith(UndefValue::get(I->getType())); I->eraseFromParent(); } Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=84118&r1=84117&r2=84118&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Wed Oct 14 12:29:00 2009 @@ -489,7 +489,7 @@ // If I has users in unreachable blocks, eliminate. // If I is not void type then replaceAllUsesWith undef. // This allows ValueHandlers and custom metadata to adjust itself. - if (I.getType() != Type::getVoidTy(I.getContext())) + if (!I.getType()->isVoidTy()) I.replaceAllUsesWith(UndefValue::get(I.getType())); I.eraseFromParent(); } else { @@ -505,7 +505,7 @@ // If I has users in unreachable blocks, eliminate. // If I is not void type then replaceAllUsesWith undef. // This allows ValueHandlers and custom metadata to adjust itself. - if (I.getType() != Type::getVoidTy(I.getContext())) + if (!I.getType()->isVoidTy()) I.replaceAllUsesWith(UndefValue::get(I.getType())); I.eraseFromParent(); } else { @@ -516,7 +516,7 @@ // Firstly, we create a stack object to hold the value... AllocaInst *AI = 0; - if (I.getType() != Type::getVoidTy(I.getContext())) { + if (!I.getType()->isVoidTy()) { AI = new AllocaInst(I.getType(), 0, I.getName(), I.getParent()->getParent()->getEntryBlock().begin()); CurAST->add(AI); Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=84118&r1=84117&r2=84118&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Wed Oct 14 12:29:00 2009 @@ -783,7 +783,7 @@ // uses replaced with undefs. // If I is not void type then replaceAllUsesWith undef. // This allows ValueHandlers and custom metadata to adjust itself. - if (I->getType() != Type::getVoidTy(I->getContext())) + if (!I->getType()->isVoidTy()) I->replaceAllUsesWith(UndefValue::get(I->getType())); } From devang.patel at gmail.com Wed Oct 14 12:29:40 2009 From: devang.patel at gmail.com (Devang Patel) Date: Wed, 14 Oct 2009 10:29:40 -0700 Subject: [llvm-commits] [llvm] r84049 - in /llvm/trunk/lib/Transforms/Scalar: InstructionCombining.cpp LICM.cpp LoopUnswitch.cpp In-Reply-To: <396CC1F7-BC29-4D05-AB9E-7F504F3E8AB5@apple.com> References: <200910132256.n9DMuXJg025396@zion.cs.uiuc.edu> <396CC1F7-BC29-4D05-AB9E-7F504F3E8AB5@apple.com> Message-ID: <352a1fb20910141029j1efbdeck36dd85527a8b4dc0@mail.gmail.com> On Tue, Oct 13, 2009 at 5:54 PM, Chris Lattner wrote: > > On Oct 13, 2009, at 3:56 PM, Devang Patel wrote: > >> Author: dpatel >> Date: Tue Oct 13 17:56:32 2009 >> New Revision: 84049 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84049&view=rev >> Log: >> Check void type before using RAUWd. > > Hi Devang, > > Thanks for fixing this, please use getType()->isVoid() instead of > pointer equality (it's cheaper) done! - Devang From evan.cheng at apple.com Wed Oct 14 13:10:14 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 11:10:14 -0700 Subject: [llvm-commits] [llvm] r84079 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll In-Reply-To: <4AD5D7AD.6080702@gmail.com> References: <200910140641.n9E6fndw009741@zion.cs.uiuc.edu> <4AD5D7AD.6080702@gmail.com> Message-ID: On Oct 14, 2009, at 6:52 AM, T?r?k Edwin wrote: > On 2009-10-14 09:41, Evan Cheng wrote: > > Hi Evan, > > This gives MayAlias for a[4] and a[5], right? I think you shouldn't exit > for a MayAlias return, only for a NoAlias result: > you should check whether the [index1, index1+size1), and [index2, > index2+size2) ranges overlap, which you seem to be doing later. No. a[4] and a[5] case is caught earlier in if (isGEP(V1) && isGEP(V2)) { .. } Their bases MustAlias. Evan > > >> + // If V2 is known not to alias GEP base pointer, then the two values >> + // cannot alias per GEP semantics: "A pointer value formed from a >> + // getelementptr instruction is associated with the addresses associated >> + // with the first operand of the getelementptr". >> + return R; >> + >> + // If there is at least one non-zero constant index, we know they cannot >> + // alias. >> + bool ConstantFound = false; >> + bool AllZerosFound = true; >> + for (unsigned i = 0, e = GEPOperands.size(); i != e; ++i) >> + if (const Constant *C = dyn_cast(GEPOperands[i])) { >> + if (!C->isNullValue()) { >> + ConstantFound = true; >> AllZerosFound = false; >> + break; >> } >> + } else { >> + AllZerosFound = false; >> + } >> >> - // If we have getelementptr , 0, 0, 0, 0, ... and V2 must aliases >> - // the ptr, the end result is a must alias also. >> - if (AllZerosFound) >> - return MustAlias; >> + // If we have getelementptr , 0, 0, 0, 0, ... and V2 must aliases >> + // the ptr, the end result is a must alias also. >> + if (AllZerosFound) >> + return MustAlias; >> >> - if (ConstantFound) { >> - if (V2Size <= 1 && V1Size <= 1) // Just pointer check? >> - return NoAlias; >> + if (ConstantFound) { >> + if (V2Size <= 1 && V1Size <= 1) // Just pointer check? >> + return NoAlias; >> >> - // Otherwise we have to check to see that the distance is more than >> - // the size of the argument... build an index vector that is equal to >> - // the arguments provided, except substitute 0's for any variable >> - // indexes we find... >> - if (TD && >> - cast(BasePtr->getType())->getElementType()->isSized()) { >> - for (unsigned i = 0; i != GEPOperands.size(); ++i) >> - if (!isa(GEPOperands[i])) >> - GEPOperands[i] = Constant::getNullValue(GEPOperands[i]->getType()); >> - int64_t Offset = >> - TD->getIndexedOffset(BasePtr->getType(), >> - &GEPOperands[0], >> - GEPOperands.size()); >> + // Otherwise we have to check to see that the distance is more than >> + // the size of the argument... build an index vector that is equal to >> + // the arguments provided, except substitute 0's for any variable >> + // indexes we find... >> > > However I don't see how this code is reached if the AA returns MayAlias > for a[4] and a[5], as the manual states: > The MayAlias response is used whenever the two pointers might refer to > the same object. If the two memory objects overlap, but do not start at > the same location, return MayAlias. > > Best regards, > --Edwin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091014/04176218/attachment.html From bob.wilson at apple.com Wed Oct 14 13:32:29 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 14 Oct 2009 18:32:29 -0000 Subject: [llvm-commits] [llvm] r84122 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <200910141832.n9EIWTAV017693@zion.cs.uiuc.edu> Author: bwilson Date: Wed Oct 14 13:32:29 2009 New Revision: 84122 URL: http://llvm.org/viewvc/llvm-project?rev=84122&view=rev Log: Refactor code to select NEON VST intrinsics. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84122&r1=84121&r2=84122&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 14 13:32:29 2009 @@ -133,6 +133,13 @@ SDNode *SelectVLD(SDValue Op, unsigned NumVecs, unsigned *DOpcodes, unsigned *QOpcodes0, unsigned *QOpcodes1); + /// SelectVST - Select NEON store intrinsics. NumVecs should + /// be 2, 3 or 4. The opcode arrays specify the instructions used for + /// stores of D registers and even subregs and odd subregs of Q registers. + /// For NumVecs == 2, QOpcodes1 is not used. + SDNode *SelectVST(SDValue Op, unsigned NumVecs, unsigned *DOpcodes, + unsigned *QOpcodes0, unsigned *QOpcodes1); + /// SelectVLDSTLane - Select NEON load/store lane intrinsics. NumVecs should /// be 2, 3 or 4. The opcode arrays specify the instructions used for /// load/store of D registers and even subregs and odd subregs of Q registers. @@ -1063,13 +1070,13 @@ ResTys.push_back(MemAddr.getValueType()); ResTys.push_back(MVT::Other); - // Load the even subreg. + // Load the even subregs. unsigned Opc = QOpcodes0[OpcodeIndex]; const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 4); Chain = SDValue(VLdA, NumVecs+1); - // Load the odd subreg. + // Load the odd subregs. Opc = QOpcodes1[OpcodeIndex]; const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, MemOpc, Chain }; SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 4); @@ -1085,6 +1092,95 @@ return NULL; } +SDNode *ARMDAGToDAGISel::SelectVST(SDValue Op, unsigned NumVecs, + unsigned *DOpcodes, unsigned *QOpcodes0, + unsigned *QOpcodes1) { + assert(NumVecs >=2 && NumVecs <= 4 && "VST NumVecs out-of-range"); + SDNode *N = Op.getNode(); + DebugLoc dl = N->getDebugLoc(); + + SDValue MemAddr, MemUpdate, MemOpc; + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) + return NULL; + + SDValue Chain = N->getOperand(0); + EVT VT = N->getOperand(3).getValueType(); + bool is64BitVector = VT.is64BitVector(); + + unsigned OpcodeIndex; + switch (VT.getSimpleVT().SimpleTy) { + default: llvm_unreachable("unhandled vst type"); + // Double-register operations: + case MVT::v8i8: OpcodeIndex = 0; break; + case MVT::v4i16: OpcodeIndex = 1; break; + case MVT::v2f32: + case MVT::v2i32: OpcodeIndex = 2; break; + case MVT::v1i64: OpcodeIndex = 3; break; + // Quad-register operations: + case MVT::v16i8: OpcodeIndex = 0; break; + case MVT::v8i16: OpcodeIndex = 1; break; + case MVT::v4f32: + case MVT::v4i32: OpcodeIndex = 2; break; + } + + SmallVector Ops; + Ops.push_back(MemAddr); + Ops.push_back(MemUpdate); + Ops.push_back(MemOpc); + + if (is64BitVector) { + unsigned Opc = DOpcodes[OpcodeIndex]; + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) + Ops.push_back(N->getOperand(Vec+3)); + Ops.push_back(Chain); + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), NumVecs+4); + } + + EVT RegVT = GetNEONSubregVT(VT); + if (NumVecs == 2) { + // Quad registers are directly supported for VST2, + // storing 2 pairs of D regs. + unsigned Opc = QOpcodes0[OpcodeIndex]; + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) { + Ops.push_back(CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, + N->getOperand(Vec+3))); + Ops.push_back(CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, + N->getOperand(Vec+3))); + } + Ops.push_back(Chain); + return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops.data(), 8); + } + + // Otherwise, quad registers are stored with two separate instructions, + // where one stores the even registers and the other stores the odd registers. + + // Enable writeback to the address register. + MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), MVT::i32); + + // Store the even subregs. + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) + Ops.push_back(CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, + N->getOperand(Vec+3))); + Ops.push_back(Chain); + unsigned Opc = QOpcodes0[OpcodeIndex]; + SDNode *VStA = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType(), + MVT::Other, Ops.data(), NumVecs+4); + Chain = SDValue(VStA, 1); + + // Store the odd subregs. + Ops[0] = SDValue(VStA, 0); // MemAddr + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) + Ops[Vec+3] = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, + N->getOperand(Vec+3)); + Ops[NumVecs+3] = Chain; + Opc = QOpcodes1[OpcodeIndex]; + SDNode *VStB = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType(), + MVT::Other, Ops.data(), NumVecs+4); + Chain = SDValue(VStB, 1); + ReplaceUses(SDValue(N, 0), Chain); + return NULL; +} + SDNode *ARMDAGToDAGISel::SelectVLDSTLane(SDValue Op, bool IsLoad, unsigned NumVecs, unsigned *DOpcodes, unsigned *QOpcodes0, @@ -1664,178 +1760,26 @@ } case Intrinsic::arm_neon_vst2: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - VT = N->getOperand(3).getValueType(); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst2 type"); - case MVT::v8i8: Opc = ARM::VST2d8; break; - case MVT::v4i16: Opc = ARM::VST2d16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VST2d32; break; - case MVT::v1i64: Opc = ARM::VST2d64; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, - N->getOperand(3), N->getOperand(4), Chain }; - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 6); - } - // Quad registers are stored as pairs of double registers. - EVT RegVT; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst2 type"); - case MVT::v16i8: Opc = ARM::VST2q8; RegVT = MVT::v8i8; break; - case MVT::v8i16: Opc = ARM::VST2q16; RegVT = MVT::v4i16; break; - case MVT::v4f32: Opc = ARM::VST2q32; RegVT = MVT::v2f32; break; - case MVT::v4i32: Opc = ARM::VST2q32; RegVT = MVT::v2i32; break; - } - SDValue D0 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, - N->getOperand(3)); - SDValue D1 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, - N->getOperand(3)); - SDValue D2 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, - N->getOperand(4)); - SDValue D3 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, - N->getOperand(4)); - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, - D0, D1, D2, D3, Chain }; - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 8); + unsigned DOpcodes[] = { ARM::VST2d8, ARM::VST2d16, + ARM::VST2d32, ARM::VST2d64 }; + unsigned QOpcodes[] = { ARM::VST2q8, ARM::VST2q16, ARM::VST2q32 }; + return SelectVST(Op, 2, DOpcodes, QOpcodes, 0); } case Intrinsic::arm_neon_vst3: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - VT = N->getOperand(3).getValueType(); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst3 type"); - case MVT::v8i8: Opc = ARM::VST3d8; break; - case MVT::v4i16: Opc = ARM::VST3d16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VST3d32; break; - case MVT::v1i64: Opc = ARM::VST3d64; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, - N->getOperand(3), N->getOperand(4), - N->getOperand(5), Chain }; - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 7); - } - // Quad registers are stored with two separate instructions, where one - // stores the even registers and the other stores the odd registers. - EVT RegVT; - unsigned Opc2 = 0; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst3 type"); - case MVT::v16i8: - Opc = ARM::VST3q8a; Opc2 = ARM::VST3q8b; RegVT = MVT::v8i8; break; - case MVT::v8i16: - Opc = ARM::VST3q16a; Opc2 = ARM::VST3q16b; RegVT = MVT::v4i16; break; - case MVT::v4f32: - Opc = ARM::VST3q32a; Opc2 = ARM::VST3q32b; RegVT = MVT::v2f32; break; - case MVT::v4i32: - Opc = ARM::VST3q32a; Opc2 = ARM::VST3q32b; RegVT = MVT::v2i32; break; - } - // Enable writeback to the address register. - MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), MVT::i32); - - SDValue D0 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, - N->getOperand(3)); - SDValue D2 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, - N->getOperand(4)); - SDValue D4 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, - N->getOperand(5)); - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, D0, D2, D4, Chain }; - SDNode *VStA = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType(), - MVT::Other, OpsA, 7); - Chain = SDValue(VStA, 1); - - SDValue D1 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, - N->getOperand(3)); - SDValue D3 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, - N->getOperand(4)); - SDValue D5 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, - N->getOperand(5)); - MemAddr = SDValue(VStA, 0); - const SDValue OpsB[] = { MemAddr, MemUpdate, MemOpc, D1, D3, D5, Chain }; - SDNode *VStB = CurDAG->getMachineNode(Opc2, dl, MemAddr.getValueType(), - MVT::Other, OpsB, 7); - Chain = SDValue(VStB, 1); - ReplaceUses(SDValue(N, 0), Chain); - return NULL; + unsigned DOpcodes[] = { ARM::VST3d8, ARM::VST3d16, + ARM::VST3d32, ARM::VST3d64 }; + unsigned QOpcodes0[] = { ARM::VST3q8a, ARM::VST3q16a, ARM::VST3q32a }; + unsigned QOpcodes1[] = { ARM::VST3q8b, ARM::VST3q16b, ARM::VST3q32b }; + return SelectVST(Op, 3, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vst4: { - SDValue MemAddr, MemUpdate, MemOpc; - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, MemOpc)) - return NULL; - SDValue Chain = N->getOperand(0); - VT = N->getOperand(3).getValueType(); - if (VT.is64BitVector()) { - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst4 type"); - case MVT::v8i8: Opc = ARM::VST4d8; break; - case MVT::v4i16: Opc = ARM::VST4d16; break; - case MVT::v2f32: - case MVT::v2i32: Opc = ARM::VST4d32; break; - case MVT::v1i64: Opc = ARM::VST4d64; break; - } - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, - N->getOperand(3), N->getOperand(4), - N->getOperand(5), N->getOperand(6), Chain }; - return CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 8); - } - // Quad registers are stored with two separate instructions, where one - // stores the even registers and the other stores the odd registers. - EVT RegVT; - unsigned Opc2 = 0; - switch (VT.getSimpleVT().SimpleTy) { - default: llvm_unreachable("unhandled vst4 type"); - case MVT::v16i8: - Opc = ARM::VST4q8a; Opc2 = ARM::VST4q8b; RegVT = MVT::v8i8; break; - case MVT::v8i16: - Opc = ARM::VST4q16a; Opc2 = ARM::VST4q16b; RegVT = MVT::v4i16; break; - case MVT::v4f32: - Opc = ARM::VST4q32a; Opc2 = ARM::VST4q32b; RegVT = MVT::v2f32; break; - case MVT::v4i32: - Opc = ARM::VST4q32a; Opc2 = ARM::VST4q32b; RegVT = MVT::v2i32; break; - } - // Enable writeback to the address register. - MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), MVT::i32); - - SDValue D0 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, - N->getOperand(3)); - SDValue D2 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, - N->getOperand(4)); - SDValue D4 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, - N->getOperand(5)); - SDValue D6 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_0, dl, RegVT, - N->getOperand(6)); - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, - D0, D2, D4, D6, Chain }; - SDNode *VStA = CurDAG->getMachineNode(Opc, dl, MemAddr.getValueType(), - MVT::Other, OpsA, 8); - Chain = SDValue(VStA, 1); - - SDValue D1 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, - N->getOperand(3)); - SDValue D3 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, - N->getOperand(4)); - SDValue D5 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, - N->getOperand(5)); - SDValue D7 = CurDAG->getTargetExtractSubreg(ARM::DSUBREG_1, dl, RegVT, - N->getOperand(6)); - MemAddr = SDValue(VStA, 0); - const SDValue OpsB[] = { MemAddr, MemUpdate, MemOpc, - D1, D3, D5, D7, Chain }; - SDNode *VStB = CurDAG->getMachineNode(Opc2, dl, MemAddr.getValueType(), - MVT::Other, OpsB, 8); - Chain = SDValue(VStB, 1); - ReplaceUses(SDValue(N, 0), Chain); - return NULL; + unsigned DOpcodes[] = { ARM::VST4d8, ARM::VST4d16, + ARM::VST4d32, ARM::VST4d64 }; + unsigned QOpcodes0[] = { ARM::VST4q8a, ARM::VST4q16a, ARM::VST4q32a }; + unsigned QOpcodes1[] = { ARM::VST4q8b, ARM::VST4q16b, ARM::VST4q32b }; + return SelectVST(Op, 4, DOpcodes, QOpcodes0, QOpcodes1); } case Intrinsic::arm_neon_vst2lane: { From nicholas at mxc.ca Wed Oct 14 13:48:40 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 14 Oct 2009 11:48:40 -0700 Subject: [llvm-commits] [llvm] r84113 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp In-Reply-To: <200910141702.n9EH2niQ014489@zion.cs.uiuc.edu> References: <200910141702.n9EH2niQ014489@zion.cs.uiuc.edu> Message-ID: <4AD61D08.5010404@mxc.ca> Devang Patel wrote: > Author: dpatel > Date: Wed Oct 14 12:02:49 2009 > New Revision: 84113 > > URL: http://llvm.org/viewvc/llvm-project?rev=84113&view=rev > Log: > Add copyMD to copy metadata from one instruction to another instruction. > > Modified: > llvm/trunk/include/llvm/Metadata.h > llvm/trunk/lib/VMCore/Metadata.cpp > > Modified: llvm/trunk/include/llvm/Metadata.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=84113&r1=84112&r2=84113&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Metadata.h (original) > +++ llvm/trunk/include/llvm/Metadata.h Wed Oct 14 12:02:49 2009 > @@ -351,6 +351,10 @@ > /// removeMDs - Remove all metadata attached with an instruction. > void removeMDs(const Instruction *Inst); > > + /// copyMD - If metadata is attached with Instruction In1 then attach > + /// the same metadata to In2. > + void copyMD(Instruction *In1, Instruction *In2); > + > /// getHandlerNames - Get handler names. This is used by bitcode > /// writer. > const StringMap *getHandlerNames(); > > Modified: llvm/trunk/lib/VMCore/Metadata.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=84113&r1=84112&r2=84113&view=diff > > ============================================================================== > --- llvm/trunk/lib/VMCore/Metadata.cpp (original) > +++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Oct 14 12:02:49 2009 > @@ -359,6 +359,20 @@ > MetadataStore.erase(I); > } > > +/// copyMD - If metadata is attached with Instruction In1 then attach > +/// the same metadata to In2. > +void MetadataContext::copyMD(Instruction *In1, Instruction *In2) { > + assert (In1 && In2 && "Invalid instruction!"); > + MDStoreTy::iterator I = MetadataStore.find(In1); > + if (I == MetadataStore.end()) > + return; > + > + MDMapTy &In1Info = I->second; > + MDMapTy In2Info; > + for (MDMapTy::iterator I = In1Info.begin(), E = In1Info.end(); I != E; ++I) > + if (MDNode *MD = dyn_cast_or_null(I->second)) When would this be null? If it's "!metadata null" we want to push a null metadata onto the target instruction, right? Nick > + addMD(I->first, MD, In2); > +} > > /// getMD - Get the metadata of given kind attached with an Instruction. > /// If the metadata is not found then return 0. > @@ -416,3 +430,4 @@ > // FIXME : Give custom handlers a chance to override this. > ValueIsCloned(I1, I2); > } > + > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From johnny.chen at apple.com Wed Oct 14 13:50:13 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 14 Oct 2009 11:50:13 -0700 Subject: [llvm-commits] NEON VSHL (immediate) patch Message-ID: <1654DC0B-93B0-4A89-9CDF-A135FE46D039@apple.com> Hi, Inst{11-8} for vshl should be 0b0101, not 0b1111. Refs: A7-17 & A8-750. Thanks. -------------- next part -------------- A non-text attachment was scrubbed... Name: ARMInstrNEON.td.patch Type: application/octet-stream Size: 798 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091014/a621e3e0/attachment.obj From dpatel at apple.com Wed Oct 14 13:53:25 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 14 Oct 2009 11:53:25 -0700 Subject: [llvm-commits] [llvm] r84113 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp In-Reply-To: <4AD61D08.5010404@mxc.ca> References: <200910141702.n9EH2niQ014489@zion.cs.uiuc.edu> <4AD61D08.5010404@mxc.ca> Message-ID: On Oct 14, 2009, at 11:48 AM, Nick Lewycky wrote: > Devang Patel wrote: >> Author: dpatel >> Date: Wed Oct 14 12:02:49 2009 >> New Revision: 84113 >> URL: http://llvm.org/viewvc/llvm-project?rev=84113&view=rev >> Log: >> Add copyMD to copy metadata from one instruction to another >> instruction. >> Modified: >> llvm/trunk/include/llvm/Metadata.h >> llvm/trunk/lib/VMCore/Metadata.cpp >> Modified: llvm/trunk/include/llvm/Metadata.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=84113&r1=84112&r2=84113&view=diff >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/include/llvm/Metadata.h (original) >> +++ llvm/trunk/include/llvm/Metadata.h Wed Oct 14 12:02:49 2009 >> @@ -351,6 +351,10 @@ >> /// removeMDs - Remove all metadata attached with an instruction. >> void removeMDs(const Instruction *Inst); >> + /// copyMD - If metadata is attached with Instruction In1 then >> attach >> + /// the same metadata to In2. >> + void copyMD(Instruction *In1, Instruction *In2); >> + >> /// getHandlerNames - Get handler names. This is used by bitcode >> /// writer. >> const StringMap *getHandlerNames(); >> Modified: llvm/trunk/lib/VMCore/Metadata.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=84113&r1=84112&r2=84113&view=diff >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/VMCore/Metadata.cpp (original) >> +++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Oct 14 12:02:49 2009 >> @@ -359,6 +359,20 @@ >> MetadataStore.erase(I); >> } >> +/// copyMD - If metadata is attached with Instruction In1 then >> attach >> +/// the same metadata to In2. >> +void MetadataContext::copyMD(Instruction *In1, Instruction *In2) { >> + assert (In1 && In2 && "Invalid instruction!"); >> + MDStoreTy::iterator I = MetadataStore.find(In1); >> + if (I == MetadataStore.end()) >> + return; >> + >> + MDMapTy &In1Info = I->second; >> + MDMapTy In2Info; >> + for (MDMapTy::iterator I = In1Info.begin(), E = In1Info.end(); >> I != E; ++I) >> + if (MDNode *MD = dyn_cast_or_null(I->second)) > > When would this be null? If it was replaced or deleted. > If it's "!metadata null" we want to push a null metadata onto the > target instruction, right? I am not sure. - Devang -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091014/b5983e2d/attachment.html From nicholas at mxc.ca Wed Oct 14 13:57:36 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 14 Oct 2009 11:57:36 -0700 Subject: [llvm-commits] [llvm] r84038 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/phi-aa.ll In-Reply-To: References: <200910132202.n9DM2KBh023328@zion.cs.uiuc.edu> Message-ID: <4AD61F20.6080202@mxc.ca> Evan Cheng wrote: > On Oct 13, 2009, at 3:47 PM, Nick Lewycky wrote: > >> Evan, please put a recursion depth limit on the number of PHIs this code is willing to walk backwards through, otherwise pathological code will show n^2 behaviour. > > It stops when it sees a PHI source which is itself PHI. That should be sufficient, no? I misread the patch and missed that part. I thought it was only stopping on cycles of the same PHI, but there's clearly code early on to prevent visiting phi-of-phi. Nick From bob.wilson at apple.com Wed Oct 14 14:00:25 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 14 Oct 2009 19:00:25 -0000 Subject: [llvm-commits] [llvm] r84124 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <200910141900.n9EJ0PDK018836@zion.cs.uiuc.edu> Author: bwilson Date: Wed Oct 14 14:00:24 2009 New Revision: 84124 URL: http://llvm.org/viewvc/llvm-project?rev=84124&view=rev Log: Set instruction encoding bits 4 and 7 for ARM register-register and register-shifted-register instructions. Patch by Johnny Chen. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=84124&r1=84123&r2=84124&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Oct 14 14:00:24 2009 @@ -377,12 +377,15 @@ def rr : AsI1 { + let Inst{4} = 0; let Inst{25} = 0; let isCommutable = Commutable; } def rs : AsI1 { + let Inst{4} = 1; + let Inst{7} = 0; let Inst{25} = 0; } } @@ -401,11 +404,14 @@ IIC_iALUr, opc, "s $dst, $a, $b", [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> { let isCommutable = Commutable; + let Inst{4} = 0; let Inst{25} = 0; } def rs : AI1 { + let Inst{4} = 1; + let Inst{7} = 0; let Inst{25} = 0; } } @@ -426,6 +432,7 @@ def rr : AI1 { + let Inst{4} = 0; let Inst{20} = 1; let Inst{25} = 0; let isCommutable = Commutable; @@ -433,6 +440,8 @@ def rs : AI1 { + let Inst{4} = 1; + let Inst{7} = 0; let Inst{20} = 1; let Inst{25} = 0; } @@ -486,12 +495,15 @@ [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>, Requires<[IsARM, CarryDefIsUnused]> { let isCommutable = Commutable; + let Inst{4} = 0; let Inst{25} = 0; } def rs : AsI1, Requires<[IsARM, CarryDefIsUnused]> { + let Inst{4} = 1; + let Inst{7} = 0; let Inst{25} = 0; } // Carry setting variants @@ -507,6 +519,7 @@ [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>, Requires<[IsARM, CarryDefIsUsed]> { let Defs = [CPSR]; + let Inst{4} = 0; let Inst{25} = 0; } def Srs : AXI1, Requires<[IsARM, CarryDefIsUsed]> { let Defs = [CPSR]; + let Inst{4} = 1; + let Inst{7} = 0; let Inst{25} = 0; } } @@ -924,10 +939,18 @@ let neverHasSideEffects = 1 in def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr, - "mov", " $dst, $src", []>, UnaryDP; + "mov", " $dst, $src", []>, UnaryDP { + let Inst{4} = 0; + let Inst{25} = 0; +} + def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm, IIC_iMOVsr, - "mov", " $dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP; + "mov", " $dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP { + let Inst{4} = 1; + let Inst{7} = 0; + let Inst{25} = 0; +} let isReMaterializable = 1, isAsCheapAsAMove = 1 in def MOVi : AsI1<0b1101, (outs GPR:$dst), (ins so_imm:$src), DPFrm, IIC_iMOVi, @@ -1146,10 +1169,15 @@ def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr, "mvn", " $dst, $src", - [(set GPR:$dst, (not GPR:$src))]>, UnaryDP; + [(set GPR:$dst, (not GPR:$src))]>, UnaryDP { + let Inst{4} = 0; +} def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm, IIC_iMOVsr, "mvn", " $dst, $src", - [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP; + [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP { + let Inst{4} = 1; + let Inst{7} = 0; +} let isReMaterializable = 1, isAsCheapAsAMove = 1 in def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm, IIC_iMOVi, "mvn", " $dst, $imm", @@ -1461,20 +1489,27 @@ def MOVCCr : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm, IIC_iCMOVr, "mov", " $dst, $true", [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>, - RegConstraint<"$false = $dst">, UnaryDP; + RegConstraint<"$false = $dst">, UnaryDP { + let Inst{4} = 0; + let Inst{25} = 0; +} def MOVCCs : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, so_reg:$true), DPSoRegFrm, IIC_iCMOVsr, "mov", " $dst, $true", [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>, - RegConstraint<"$false = $dst">, UnaryDP; + RegConstraint<"$false = $dst">, UnaryDP { + let Inst{4} = 1; + let Inst{7} = 0; + let Inst{25} = 0; +} def MOVCCi : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, so_imm:$true), DPFrm, IIC_iCMOVi, "mov", " $dst, $true", [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>, RegConstraint<"$false = $dst">, UnaryDP { - let Inst{25} = 1; + let Inst{25} = 1; } From bob.wilson at apple.com Wed Oct 14 13:58:38 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 14 Oct 2009 11:58:38 -0700 Subject: [llvm-commits] Add some ARM instruction encoding bits for "register" and "register-shifted register" In-Reply-To: References: Message-ID: Looks good to me. I've committed it. On Oct 14, 2009, at 10:03 AM, Johnny Chen wrote: > For 'r', add: > > let Inst{4} = 0; > > For 's', add: > > let Inst{4} = 1; > let Inst{7} = 0; > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From nicholas at mxc.ca Wed Oct 14 14:02:13 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 14 Oct 2009 19:02:13 -0000 Subject: [llvm-commits] [llvm] r84125 - /llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll Message-ID: <200910141902.n9EJ2DoL018932@zion.cs.uiuc.edu> Author: nicholas Date: Wed Oct 14 14:02:13 2009 New Revision: 84125 URL: http://llvm.org/viewvc/llvm-project?rev=84125&view=rev Log: Make use of the result of the loads even though that means adding -instcombine. Modified: llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll Modified: llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll?rev=84125&r1=84124&r2=84125&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll Wed Oct 14 14:02:13 2009 @@ -1,16 +1,16 @@ -; RUN: opt -gvn -S < %s | FileCheck %s +; RUN: opt -gvn -instcombine -S < %s | FileCheck %s declare i8 @llvm.atomic.load.add.i8.p0i8(i8*, i8) -define void @foo(i8* %ptr) { +define i8 @foo(i8* %ptr) { %P = getelementptr i8* %ptr, i32 0 %Q = getelementptr i8* %ptr, i32 1 ; CHECK: getelementptr %X = load i8* %P -; CHECK: = load %Y = call i8 @llvm.atomic.load.add.i8.p0i8(i8* %Q, i8 1) %Z = load i8* %P ; CHECK-NOT: = load - ret void -; CHECK: ret void + %A = sub i8 %X, %Z + ret i8 %A +; CHECK: ret i8 0 } From nicholas at mxc.ca Wed Oct 14 14:02:20 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 14 Oct 2009 12:02:20 -0700 Subject: [llvm-commits] [llvm] r83959 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll In-Reply-To: <33FD0425-F50F-48AE-B06B-9CEC9ECC9BF9@apple.com> References: <200910130748.n9D7mdF0014001@zion.cs.uiuc.edu> <33FD0425-F50F-48AE-B06B-9CEC9ECC9BF9@apple.com> Message-ID: <4AD6203C.3070904@mxc.ca> Chris Lattner wrote: > On Oct 13, 2009, at 12:48 AM, Nick Lewycky wrote: >> URL: http://llvm.org/viewvc/llvm-project?rev=83959&view=rev >> Log: >> Teach BasicAA a little something about the atomic intrinsics: they can >> only >> modify through the pointer they're given. > > Thanks Nick, >> + >> +define void @foo(i8* %ptr) { >> + %P = getelementptr i8* %ptr, i32 0 >> + %Q = getelementptr i8* %ptr, i32 1 >> +; CHECK: getelementptr >> + %X = load i8* %P >> +; CHECK: = load >> + %Y = call i8 @llvm.atomic.load.add.i8.p0i8(i8* %Q, i8 1) >> + %Z = load i8* %P >> +; CHECK-NOT: = load >> + ret void >> +; CHECK: ret void >> +} > > Please add some uses of the loads: do: "ret sub X,Z", and FileCheck that > GVN+instcombine turn it into "ret i32 0" Done! From nicholas at mxc.ca Wed Oct 14 14:29:06 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 14 Oct 2009 12:29:06 -0700 Subject: [llvm-commits] [llvm] r83959 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll In-Reply-To: References: <200910130748.n9D7mdF0014001@zion.cs.uiuc.edu> Message-ID: <4AD62682.3080706@mxc.ca> Owen Anderson wrote: > Nick, > > This shouldn't be necessary. Duncan and I did the same things back in > r63900 andr64551. I found the difference. My code is calling: alias(CallArg, Size, P, Size) while your code is calling: alias(CallArg, ~0U, P, Size) What's the deal with the first size argument? If it's supposed to be the size of the first memory object then when is ~0U ever valid? I would say that an object so large that it fills every byte of memory may alias anything (except that it must alias itself). In the case of the atomics, we know that it never accesses beyond the pointer type, though that isn't true for other intrinsics marked AccessesArguments such as llvm.memcpy. Nick > --Owen > > On Oct 13, 2009, at 12:48 AM, Nick Lewycky wrote: > >> Author: nicholas >> Date: Tue Oct 13 02:48:38 2009 >> New Revision: 83959 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=83959&view=rev >> Log: >> Teach BasicAA a little something about the atomic intrinsics: they can >> only >> modify through the pointer they're given. >> >> Added: >> llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll >> Modified: >> llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp >> >> Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=83959&r1=83958&r2=83959&view=diff >> >> >> ============================================================================== >> >> --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) >> +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Tue Oct 13 02:48:38 >> 2009 >> @@ -284,6 +284,27 @@ >> if (!passedAsArg) >> return NoModRef; >> } >> + >> + if (IntrinsicInst *II = >> dyn_cast(CS.getInstruction())) { >> + switch (II->getIntrinsicID()) { >> + default: break; >> + case Intrinsic::atomic_cmp_swap: >> + case Intrinsic::atomic_swap: >> + case Intrinsic::atomic_load_add: >> + case Intrinsic::atomic_load_sub: >> + case Intrinsic::atomic_load_and: >> + case Intrinsic::atomic_load_nand: >> + case Intrinsic::atomic_load_or: >> + case Intrinsic::atomic_load_xor: >> + case Intrinsic::atomic_load_max: >> + case Intrinsic::atomic_load_min: >> + case Intrinsic::atomic_load_umax: >> + case Intrinsic::atomic_load_umin: >> + if (alias(II->getOperand(1), Size, P, Size) == NoAlias) >> + return NoModRef; >> + break; >> + } >> + } >> } >> >> // The AliasAnalysis base class has some smarts, lets use them. >> >> Added: llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll?rev=83959&view=auto >> >> >> ============================================================================== >> >> --- llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll (added) >> +++ llvm/trunk/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll Tue >> Oct 13 02:48:38 2009 >> @@ -0,0 +1,16 @@ >> +; RUN: opt -gvn -S < %s | FileCheck %s >> + >> +declare i8 @llvm.atomic.load.add.i8.p0i8(i8*, i8) >> + >> +define void @foo(i8* %ptr) { >> + %P = getelementptr i8* %ptr, i32 0 >> + %Q = getelementptr i8* %ptr, i32 1 >> +; CHECK: getelementptr >> + %X = load i8* %P >> +; CHECK: = load >> + %Y = call i8 @llvm.atomic.load.add.i8.p0i8(i8* %Q, i8 1) >> + %Z = load i8* %P >> +; CHECK-NOT: = load >> + ret void >> +; CHECK: ret void >> +} >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From baldrick at free.fr Wed Oct 14 15:01:40 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 14 Oct 2009 20:01:40 -0000 Subject: [llvm-commits] [llvm] r84127 - /llvm/trunk/tools/opt/opt.cpp Message-ID: <200910142001.n9EK1eI5020834@zion.cs.uiuc.edu> Author: baldrick Date: Wed Oct 14 15:01:39 2009 New Revision: 84127 URL: http://llvm.org/viewvc/llvm-project?rev=84127&view=rev Log: There seems to be no reason for opt's -S option to be hidden. Make it visible. Modified: llvm/trunk/tools/opt/opt.cpp Modified: llvm/trunk/tools/opt/opt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=84127&r1=84126&r2=84127&view=diff ============================================================================== --- llvm/trunk/tools/opt/opt.cpp (original) +++ llvm/trunk/tools/opt/opt.cpp Wed Oct 14 15:01:39 2009 @@ -66,8 +66,7 @@ cl::desc("Do not write result bitcode file"), cl::Hidden); static cl::opt -OutputAssembly("S", - cl::desc("Write output as LLVM assembly"), cl::Hidden); +OutputAssembly("S", cl::desc("Write output as LLVM assembly")); static cl::opt NoVerify("disable-verify", cl::desc("Do not verify result module"), cl::Hidden); From nicholas at mxc.ca Wed Oct 14 15:04:41 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 14 Oct 2009 20:04:41 -0000 Subject: [llvm-commits] [llvm] r84128 - /llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Message-ID: <200910142004.n9EK4fAS020943@zion.cs.uiuc.edu> Author: nicholas Date: Wed Oct 14 15:04:41 2009 New Revision: 84128 URL: http://llvm.org/viewvc/llvm-project?rev=84128&view=rev Log: The ARM and PowerPC jits are broken in this regard. Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=84128&r1=84127&r2=84128&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Wed Oct 14 15:04:41 2009 @@ -166,6 +166,7 @@ EXPECT_EQ(8, TestFunctionPtr()); } +#if !defined(__arm__) && !defined(__ppc__) // Test a function C which calls A and B which call each other. TEST_F(JITTest, NonLazyCompilationStillNeedsStubs) { TheJIT->DisableLazyCompilation(); @@ -220,6 +221,7 @@ F1Ptr(); } +#endif // Regression test for PR5162. This used to trigger an AssertingVH inside the // JIT's Function to stub mapping. From evan.cheng at apple.com Wed Oct 14 15:26:40 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 13:26:40 -0700 Subject: [llvm-commits] Add some ARM instruction encoding bits for "register" and "register-shifted register" In-Reply-To: References: Message-ID: LLVM ARM's so_reg operand can potentially encode "rrx" shifter op as well. In that case, bit 4 is 0, not 1. However, I believe it's only possible to use rrx when the instruction is a mov. So this should be ok. But please add comment to state that it's ok to set bit 4 because rrx cannot be used. Evan On Oct 14, 2009, at 10:03 AM, Johnny Chen wrote: > For 'r', add: > > let Inst{4} = 0; > > For 's', add: > > let Inst{4} = 1; > let Inst{7} = 0; > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From echristo at apple.com Wed Oct 14 15:28:33 2009 From: echristo at apple.com (Eric Christopher) Date: Wed, 14 Oct 2009 20:28:33 -0000 Subject: [llvm-commits] [llvm] r84130 - in /llvm/trunk/include/llvm: ADT/DenseMapInfo.h CodeGen/ScheduleDAG.h ExecutionEngine/JITMemoryManager.h Metadata.h Operator.h Pass.h Support/CommandLine.h Support/raw_ostream.h Message-ID: <200910142028.n9EKSXp1021686@zion.cs.uiuc.edu> Author: echristo Date: Wed Oct 14 15:28:33 2009 New Revision: 84130 URL: http://llvm.org/viewvc/llvm-project?rev=84130&view=rev Log: Remove a bunch of unused arguments from functions, silencing a warning. Modified: llvm/trunk/include/llvm/ADT/DenseMapInfo.h llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h llvm/trunk/include/llvm/Metadata.h llvm/trunk/include/llvm/Operator.h llvm/trunk/include/llvm/Pass.h llvm/trunk/include/llvm/Support/CommandLine.h llvm/trunk/include/llvm/Support/raw_ostream.h Modified: llvm/trunk/include/llvm/ADT/DenseMapInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMapInfo.h?rev=84130&r1=84129&r2=84130&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/DenseMapInfo.h (original) +++ llvm/trunk/include/llvm/ADT/DenseMapInfo.h Wed Oct 14 15:28:33 2009 @@ -89,7 +89,7 @@ static inline unsigned long long getEmptyKey() { return ~0ULL; } static inline unsigned long long getTombstoneKey() { return ~0ULL - 1ULL; } static unsigned getHashValue(const unsigned long long& Val) { - return Val * 37ULL; + return (unsigned)Val * 37ULL; } static bool isPod() { return true; } static bool isEqual(const unsigned long long& LHS, Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=84130&r1=84129&r2=84130&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Wed Oct 14 15:28:33 2009 @@ -500,8 +500,8 @@ /// ComputeOperandLatency - Override dependence edge latency using /// operand use/def information /// - virtual void ComputeOperandLatency(SUnit *Def, SUnit *Use, - SDep& dep) const { }; + virtual void ComputeOperandLatency(SUnit *, SUnit *, + SDep&) const { }; /// Schedule - Order nodes according to selected style, filling /// in the Sequence member. Modified: llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h?rev=84130&r1=84129&r2=84130&view=diff ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h (original) +++ llvm/trunk/include/llvm/ExecutionEngine/JITMemoryManager.h Wed Oct 14 15:28:33 2009 @@ -149,7 +149,7 @@ /// CheckInvariants - For testing only. Return true if all internal /// invariants are preserved, or return false and set ErrorStr to a helpful /// error message. - virtual bool CheckInvariants(std::string &ErrorStr) { + virtual bool CheckInvariants(std::string &) { return true; } Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=84130&r1=84129&r2=84130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Wed Oct 14 15:28:33 2009 @@ -181,7 +181,7 @@ /// duplicates void Profile(FoldingSetNodeID &ID) const; - virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) { + virtual void replaceUsesOfWithOnConstant(Value *, Value *, Use *) { llvm_unreachable("This should never be called because MDNodes have no ops"); } @@ -291,7 +291,7 @@ return false; } - virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) { + virtual void replaceUsesOfWithOnConstant(Value *, Value *, Use *) { llvm_unreachable( "This should never be called because NamedMDNodes have no ops"); } @@ -361,7 +361,7 @@ /// ValueIsDeleted - This handler is used to update metadata store /// when a value is deleted. - void ValueIsDeleted(const Value *V) {} + void ValueIsDeleted(const Value *) {} void ValueIsDeleted(const Instruction *Inst) { removeMDs(Inst); } Modified: llvm/trunk/include/llvm/Operator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Operator.h?rev=84130&r1=84129&r2=84130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Operator.h (original) +++ llvm/trunk/include/llvm/Operator.h Wed Oct 14 15:28:33 2009 @@ -57,8 +57,8 @@ } static inline bool classof(const Operator *) { return true; } - static inline bool classof(const Instruction *I) { return true; } - static inline bool classof(const ConstantExpr *I) { return true; } + static inline bool classof(const Instruction *) { return true; } + static inline bool classof(const ConstantExpr *) { return true; } static inline bool classof(const Value *V) { return isa(V) || isa(V); } Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=84130&r1=84129&r2=84130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Wed Oct 14 15:28:33 2009 @@ -276,7 +276,7 @@ /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// - virtual bool doInitialization(Module &M) { return false; } + virtual bool doInitialization(Module &) { return false; } /// runOnFunction - Virtual method overriden by subclasses to do the /// per-function processing of the pass. @@ -328,7 +328,7 @@ /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// - virtual bool doInitialization(Module &M) { return false; } + virtual bool doInitialization(Module &) { return false; } /// doInitialization - Virtual method overridden by BasicBlockPass subclasses /// to do any necessary per-function initialization. Modified: llvm/trunk/include/llvm/Support/CommandLine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=84130&r1=84129&r2=84130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CommandLine.h (original) +++ llvm/trunk/include/llvm/Support/CommandLine.h Wed Oct 14 15:28:33 2009 @@ -660,7 +660,7 @@ class parser : public basic_parser { public: // parse - Return true on error. - bool parse(Option &, StringRef ArgName, StringRef Arg, std::string &Value) { + bool parse(Option &, StringRef, StringRef Arg, std::string &Value) { Value = Arg.str(); return false; } @@ -681,7 +681,7 @@ class parser : public basic_parser { public: // parse - Return true on error. - bool parse(Option &, StringRef ArgName, StringRef Arg, char &Value) { + bool parse(Option &, StringRef, StringRef Arg, char &Value) { Value = Arg[0]; return false; } Modified: llvm/trunk/include/llvm/Support/raw_ostream.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=84130&r1=84129&r2=84130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/raw_ostream.h (original) +++ llvm/trunk/include/llvm/Support/raw_ostream.h Wed Oct 14 15:28:33 2009 @@ -233,8 +233,7 @@ /// @param bold bold/brighter text, default false /// @param bg if true change the background, default: change foreground /// @returns itself so it can be used within << invocations - virtual raw_ostream &changeColor(enum Colors colors, bool bold=false, - bool bg=false) { return *this; } + virtual raw_ostream &changeColor(enum Colors, bool, bool) { return *this; } /// Resets the colors to terminal defaults. Call this when you are done /// outputting colored text, or before program exit. From grosbach at apple.com Wed Oct 14 15:31:01 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 14 Oct 2009 20:31:01 -0000 Subject: [llvm-commits] [llvm] r84131 - /llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Message-ID: <200910142031.n9EKV2FG021801@zion.cs.uiuc.edu> Author: grosbach Date: Wed Oct 14 15:31:01 2009 New Revision: 84131 URL: http://llvm.org/viewvc/llvm-project?rev=84131&view=rev Log: Inst{11-8} for vshl should be 0b0101, not 0b1111. Refs: A7-17 & A8-750. Patch by Johnny Chen. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=84131&r1=84130&r2=84131&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Wed Oct 14 15:31:01 2009 @@ -2038,7 +2038,7 @@ defm VSHLu : N3VInt_QHSD<1, 0, 0b0100, 0, IIC_VSHLiD, IIC_VSHLiD, IIC_VSHLiQ, IIC_VSHLiQ, "vshl.u", int_arm_neon_vshiftu, 0>; // VSHL : Vector Shift Left (Immediate) -defm VSHLi : N2VSh_QHSD<0, 1, 0b0111, 1, IIC_VSHLiD, "vshl.i", NEONvshl>; +defm VSHLi : N2VSh_QHSD<0, 1, 0b0101, 1, IIC_VSHLiD, "vshl.i", NEONvshl>; // VSHR : Vector Shift Right (Immediate) defm VSHRs : N2VSh_QHSD<0, 1, 0b0000, 1, IIC_VSHLiD, "vshr.s", NEONvshrs>; defm VSHRu : N2VSh_QHSD<1, 1, 0b0000, 1, IIC_VSHLiD, "vshr.u", NEONvshru>; From gohman at apple.com Wed Oct 14 15:39:02 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 14 Oct 2009 20:39:02 -0000 Subject: [llvm-commits] [llvm] r84132 - in /llvm/trunk/include/llvm: ADT/ImmutableSet.h CodeGen/ScheduleDAG.h CompilerDriver/CompilationGraph.h Support/DebugLoc.h Message-ID: <200910142039.n9EKd239022086@zion.cs.uiuc.edu> Author: djg Date: Wed Oct 14 15:39:01 2009 New Revision: 84132 URL: http://llvm.org/viewvc/llvm-project?rev=84132&view=rev Log: Delete bogus semicolons. Modified: llvm/trunk/include/llvm/ADT/ImmutableSet.h llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h llvm/trunk/include/llvm/CompilerDriver/CompilationGraph.h llvm/trunk/include/llvm/Support/DebugLoc.h Modified: llvm/trunk/include/llvm/ADT/ImmutableSet.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableSet.h?rev=84132&r1=84131&r2=84132&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/ImmutableSet.h (original) +++ llvm/trunk/include/llvm/ADT/ImmutableSet.h Wed Oct 14 15:39:01 2009 @@ -988,8 +988,8 @@ BumpPtrAllocator& getAllocator() { return F.getAllocator(); } private: - Factory(const Factory& RHS) {}; - void operator=(const Factory& RHS) {}; + Factory(const Factory& RHS) {} + void operator=(const Factory& RHS) {} }; friend class Factory; Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=84132&r1=84131&r2=84132&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Wed Oct 14 15:39:01 2009 @@ -501,7 +501,7 @@ /// operand use/def information /// virtual void ComputeOperandLatency(SUnit *, SUnit *, - SDep&) const { }; + SDep&) const { } /// Schedule - Order nodes according to selected style, filling /// in the Sequence member. Modified: llvm/trunk/include/llvm/CompilerDriver/CompilationGraph.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/CompilationGraph.h?rev=84132&r1=84131&r2=84132&view=diff ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/CompilationGraph.h (original) +++ llvm/trunk/include/llvm/CompilerDriver/CompilationGraph.h Wed Oct 14 15:39:01 2009 @@ -43,7 +43,7 @@ class Edge : public llvm::RefCountedBaseVPTR { public: Edge(const std::string& T) : ToolName_(T) {} - virtual ~Edge() {}; + virtual ~Edge() {} const std::string& ToolName() const { return ToolName_; } virtual unsigned Weight(const InputLanguagesSet& InLangs) const = 0; Modified: llvm/trunk/include/llvm/Support/DebugLoc.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?rev=84132&r1=84131&r2=84132&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/DebugLoc.h (original) +++ llvm/trunk/include/llvm/Support/DebugLoc.h Wed Oct 14 15:39:01 2009 @@ -29,10 +29,10 @@ unsigned Line, Col; DebugLocTuple() - : Scope(0), InlinedAtLoc(0), Line(~0U), Col(~0U) {}; + : Scope(0), InlinedAtLoc(0), Line(~0U), Col(~0U) {} DebugLocTuple(MDNode *n, MDNode *i, unsigned l, unsigned c) - : Scope(n), InlinedAtLoc(i), Line(l), Col(c) {}; + : Scope(n), InlinedAtLoc(i), Line(l), Col(c) {} bool operator==(const DebugLocTuple &DLT) const { return Scope == DLT.Scope && From bob.wilson at apple.com Wed Oct 14 15:45:49 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 14 Oct 2009 13:45:49 -0700 Subject: [llvm-commits] Add some ARM instruction encoding bits for "register" and "register-shifted register" In-Reply-To: References: Message-ID: <0C260D95-A214-49B6-8366-5627894BFD6F@apple.com> On Oct 14, 2009, at 1:26 PM, Evan Cheng wrote: > LLVM ARM's so_reg operand can potentially encode "rrx" shifter op as > well. In that case, bit 4 is 0, not 1. However, I believe it's only > possible to use rrx when the instruction is a mov. So this should be > ok. But please add comment to state that it's ok to set bit 4 > because rrx cannot be used. Yes, it's OK -- there is a separate MOVrx instruction pattern. In fact, I don't see anything that uses rrx as a shift op, and it's not listed in the definition of so_reg: def so_reg : Operand, // reg reg imm ComplexPattern { let PrintMethod = "printSORegOperand"; let MIOperandInfo = (ops GPR, GPR, i32imm); } The only place I can see using RRX is the ARMrrx node created by LowerShift() in ARMISelLowering.cpp. Am I missing something? If not, it seems like maybe we should remove rrx from the list of shift ops. From echristo at apple.com Wed Oct 14 16:00:43 2009 From: echristo at apple.com (Eric Christopher) Date: Wed, 14 Oct 2009 14:00:43 -0700 Subject: [llvm-commits] [llvm] r84130 - in /llvm/trunk/include/llvm: ADT/DenseMapInfo.h CodeGen/ScheduleDAG.h ExecutionEngine/JITMemoryManager.h Metadata.h Operator.h Pass.h Support/CommandLine.h Support/raw_ostream.h In-Reply-To: <200910142028.n9EKSXp1021686@zion.cs.uiuc.edu> References: <200910142028.n9EKSXp1021686@zion.cs.uiuc.edu> Message-ID: On Oct 14, 2009, at 1:28 PM, Eric Christopher wrote: > - virtual raw_ostream &changeColor(enum Colors colors, bool > bold=false, > - bool bg=false) { return *this; } > + virtual raw_ostream &changeColor(enum Colors, bool, bool) > { return *this; } Yep. Clang build failure from this. Fixing. That'll teach me to forget to copy clang over when I checkout a fresh llvm. -eric From grosbach at apple.com Wed Oct 14 16:07:11 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 14 Oct 2009 21:07:11 -0000 Subject: [llvm-commits] [llvm] r84133 - /llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Message-ID: <200910142107.n9EL7BNc023277@zion.cs.uiuc.edu> Author: grosbach Date: Wed Oct 14 16:07:11 2009 New Revision: 84133 URL: http://llvm.org/viewvc/llvm-project?rev=84133&view=rev Log: quiet compiler warning Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=84133&r1=84132&r2=84133&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original) +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Wed Oct 14 16:07:11 2009 @@ -767,7 +767,7 @@ unsigned CurrentScratchReg = 0; bool havePrevValue = false; unsigned PrevScratchReg = 0; - int PrevValue; + int PrevValue = 0; MachineInstr *PrevLastUseMI = NULL; unsigned PrevLastUseOp = 0; bool trackingCurrentValue = false; From dpatel at apple.com Wed Oct 14 16:08:09 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 14 Oct 2009 21:08:09 -0000 Subject: [llvm-commits] [llvm] r84134 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <200910142108.n9EL89PR023324@zion.cs.uiuc.edu> Author: dpatel Date: Wed Oct 14 16:08:09 2009 New Revision: 84134 URL: http://llvm.org/viewvc/llvm-project?rev=84134&view=rev Log: Add support to record DbgScope as inlined scope. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=84134&r1=84133&r2=84134&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Oct 14 16:08:09 2009 @@ -145,7 +145,10 @@ class VISIBILITY_HIDDEN DbgScope { DbgScope *Parent; // Parent to this scope. DIDescriptor Desc; // Debug info descriptor for scope. - // Either subprogram or block. + // FIXME use WeakVH for Desc. + WeakVH InlinedAt; // If this scope represents inlined + // function body then this is the location + // where this body is inlined. unsigned StartLabelID; // Label ID of the beginning of scope. unsigned EndLabelID; // Label ID of the end of scope. const MachineInstr *LastInsn; // Last instruction of this scope. @@ -157,14 +160,17 @@ // Private state for dump() mutable unsigned IndentLevel; public: - DbgScope(DbgScope *P, DIDescriptor D) - : Parent(P), Desc(D), StartLabelID(0), EndLabelID(0), LastInsn(0), - FirstInsn(0), IndentLevel(0) {} + DbgScope(DbgScope *P, DIDescriptor D, MDNode *I = 0) + : Parent(P), Desc(D), InlinedAt(I), StartLabelID(0), EndLabelID(0), + LastInsn(0), FirstInsn(0), IndentLevel(0) {} virtual ~DbgScope(); // Accessors. DbgScope *getParent() const { return Parent; } DIDescriptor getDesc() const { return Desc; } + MDNode *getInlinedAt() const { + return dyn_cast_or_null(InlinedAt); + } unsigned getStartLabelID() const { return StartLabelID; } unsigned getEndLabelID() const { return EndLabelID; } SmallVector &getScopes() { return Scopes; } @@ -1296,29 +1302,39 @@ /// getOrCreateScope - Returns the scope associated with the given descriptor. /// -DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr *MI) { +DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr *MI, + MDNode *InlinedAt) { DbgScope *&Slot = DbgScopeMap[N]; if (Slot) return Slot; DbgScope *Parent = NULL; - DIDescriptor Scope(N); - if (Scope.isCompileUnit()) { - return NULL; - } else if (Scope.isSubprogram()) { - DISubprogram SP(N); - DIDescriptor ParentDesc = SP.getContext(); - if (!ParentDesc.isNull() && !ParentDesc.isCompileUnit()) - Parent = getDbgScope(ParentDesc.getNode(), MI); - } else if (Scope.isLexicalBlock()) { - DILexicalBlock DB(N); - DIDescriptor ParentDesc = DB.getContext(); - if (!ParentDesc.isNull()) - Parent = getDbgScope(ParentDesc.getNode(), MI); - } else - assert (0 && "Unexpected scope info"); + if (InlinedAt) { + DILocation IL(InlinedAt); + assert (!IL.isNull() && "Invalid InlindAt location!"); + DenseMap::iterator DSI = + DbgScopeMap.find(IL.getScope().getNode()); + assert (DSI != DbgScopeMap.end() && "Unable to find InlineAt scope!"); + Parent = DSI->second; + } else { + DIDescriptor Scope(N); + if (Scope.isCompileUnit()) { + return NULL; + } else if (Scope.isSubprogram()) { + DISubprogram SP(N); + DIDescriptor ParentDesc = SP.getContext(); + if (!ParentDesc.isNull() && !ParentDesc.isCompileUnit()) + Parent = getDbgScope(ParentDesc.getNode(), MI, InlinedAt); + } else if (Scope.isLexicalBlock()) { + DILexicalBlock DB(N); + DIDescriptor ParentDesc = DB.getContext(); + if (!ParentDesc.isNull()) + Parent = getDbgScope(ParentDesc.getNode(), MI, InlinedAt); + } else + assert (0 && "Unexpected scope info"); + } - Slot = new DbgScope(Parent, DIDescriptor(N)); + Slot = new DbgScope(Parent, DIDescriptor(N), InlinedAt); Slot->setFirstInsn(MI); if (Parent) @@ -1795,7 +1811,10 @@ DIVariable DV (Var); if (DV.isNull()) continue; unsigned VSlot = VI->second; - DbgScope *Scope = getDbgScope(DV.getContext().getNode(), NULL); + DenseMap::iterator DSI = + DbgScopeMap.find(DV.getContext().getNode()); + assert (DSI != DbgScopeMap.end() && "Unable to find variable scope!"); + DbgScope *Scope = DSI->second; Scope->AddVariable(new DbgVariable(DV, VSlot, false)); } } @@ -1849,7 +1868,7 @@ // into a scope DIE at the end. DIDescriptor D(DLT.Scope); if (!D.isCompileUnit()) { - DbgScope *Scope = getDbgScope(DLT.Scope, MInsn); + DbgScope *Scope = getDbgScope(DLT.Scope, MInsn, DLT.InlinedAtLoc); Scope->setLastInsn(MInsn); } } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=84134&r1=84133&r2=84134&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Oct 14 16:08:09 2009 @@ -364,7 +364,7 @@ /// getDbgScope - Returns the scope associated with the given descriptor. /// DbgScope *getOrCreateScope(MDNode *N); - DbgScope *getDbgScope(MDNode *N, const MachineInstr *MI); + DbgScope *getDbgScope(MDNode *N, const MachineInstr *MI, MDNode *InlinedAt); /// ConstructDbgScope - Construct the components of a scope. /// From grosbach at apple.com Wed Oct 14 16:18:32 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 14 Oct 2009 14:18:32 -0700 Subject: [llvm-commits] [llvm] r84117 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp In-Reply-To: <200910141728.n9EHSqRB015596@zion.cs.uiuc.edu> References: <200910141728.n9EHSqRB015596@zion.cs.uiuc.edu> Message-ID: Hi Bob, I think this is causing: /Volumes/Home/grosbaj/sources/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp: In member function ?llvm::SDNode*::ARMDAGToDAGISel::Select (llvm::SDValue)?: /Volumes/Home/grosbaj/sources/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp: 1712: warning: unused variable ?Opc? -Jim On Oct 14, 2009, at 10:28 AM, Bob Wilson wrote: > Author: bwilson > Date: Wed Oct 14 12:28:52 2009 > New Revision: 84117 > > URL: http://llvm.org/viewvc/llvm-project?rev=84117&view=rev > Log: > Refactor code to select NEON VLD intrinsics. > > Modified: > llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp > > Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84117&r1=84116&r2=84117&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 14 > 12:28:52 2009 > @@ -126,6 +126,13 @@ > /// SelectDYN_ALLOC - Select dynamic alloc for Thumb. > SDNode *SelectDYN_ALLOC(SDValue Op); > > + /// SelectVLD - Select NEON load intrinsics. NumVecs should > + /// be 2, 3 or 4. The opcode arrays specify the instructions > used for > + /// loads of D registers and even subregs and odd subregs of Q > registers. > + /// For NumVecs == 2, QOpcodes1 is not used. > + SDNode *SelectVLD(SDValue Op, unsigned NumVecs, unsigned *DOpcodes, > + unsigned *QOpcodes0, unsigned *QOpcodes1); > + > /// SelectVLDSTLane - Select NEON load/store lane intrinsics. > NumVecs should > /// be 2, 3 or 4. The opcode arrays specify the instructions used > for > /// load/store of D registers and even subregs and odd subregs of > Q registers. > @@ -990,6 +997,94 @@ > } > } > > +SDNode *ARMDAGToDAGISel::SelectVLD(SDValue Op, unsigned NumVecs, > + unsigned *DOpcodes, unsigned > *QOpcodes0, > + unsigned *QOpcodes1) { > + assert(NumVecs >=2 && NumVecs <= 4 && "VLD NumVecs out-of-range"); > + SDNode *N = Op.getNode(); > + DebugLoc dl = N->getDebugLoc(); > + > + SDValue MemAddr, MemUpdate, MemOpc; > + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, > MemOpc)) > + return NULL; > + > + SDValue Chain = N->getOperand(0); > + EVT VT = N->getValueType(0); > + bool is64BitVector = VT.is64BitVector(); > + > + unsigned OpcodeIndex; > + switch (VT.getSimpleVT().SimpleTy) { > + default: llvm_unreachable("unhandled vld type"); > + // Double-register operations: > + case MVT::v8i8: OpcodeIndex = 0; break; > + case MVT::v4i16: OpcodeIndex = 1; break; > + case MVT::v2f32: > + case MVT::v2i32: OpcodeIndex = 2; break; > + case MVT::v1i64: OpcodeIndex = 3; break; > + // Quad-register operations: > + case MVT::v16i8: OpcodeIndex = 0; break; > + case MVT::v8i16: OpcodeIndex = 1; break; > + case MVT::v4f32: > + case MVT::v4i32: OpcodeIndex = 2; break; > + } > + > + if (is64BitVector) { > + unsigned Opc = DOpcodes[OpcodeIndex]; > + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; > + std::vector ResTys(NumVecs, VT); > + ResTys.push_back(MVT::Other); > + return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); > + } > + > + EVT RegVT = GetNEONSubregVT(VT); > + if (NumVecs == 2) { > + // Quad registers are directly supported for VLD2, > + // loading 2 pairs of D regs. > + unsigned Opc = QOpcodes0[OpcodeIndex]; > + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; > + std::vector ResTys(4, VT); > + ResTys.push_back(MVT::Other); > + SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); > + Chain = SDValue(VLd, 4); > + > + // Combine the even and odd subregs to produce the result. > + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) { > + SDNode *Q = PairDRegs(VT, SDValue(VLd, 2*Vec), SDValue(VLd, > 2*Vec+1)); > + ReplaceUses(SDValue(N, Vec), SDValue(Q, 0)); > + } > + } else { > + // Otherwise, quad registers are loaded with two separate > instructions, > + // where one loads the even registers and the other loads the > odd registers. > + > + // Enable writeback to the address register. > + MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), > MVT::i32); > + > + std::vector ResTys(NumVecs, RegVT); > + ResTys.push_back(MemAddr.getValueType()); > + ResTys.push_back(MVT::Other); > + > + // Load the even subreg. > + unsigned Opc = QOpcodes0[OpcodeIndex]; > + const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; > + SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 4); > + Chain = SDValue(VLdA, NumVecs+1); > + > + // Load the odd subreg. > + Opc = QOpcodes1[OpcodeIndex]; > + const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, > MemOpc, Chain }; > + SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 4); > + Chain = SDValue(VLdB, NumVecs+1); > + > + // Combine the even and odd subregs to produce the result. > + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) { > + SDNode *Q = PairDRegs(VT, SDValue(VLdA, Vec), SDValue(VLdB, > Vec)); > + ReplaceUses(SDValue(N, Vec), SDValue(Q, 0)); > + } > + } > + ReplaceUses(SDValue(N, NumVecs), Chain); > + return NULL; > +} > + > SDNode *ARMDAGToDAGISel::SelectVLDSTLane(SDValue Op, bool IsLoad, > unsigned NumVecs, unsigned > *DOpcodes, > unsigned *QOpcodes0, > @@ -1525,159 +1620,26 @@ > break; > > case Intrinsic::arm_neon_vld2: { > - SDValue MemAddr, MemUpdate, MemOpc; > - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, > MemUpdate, MemOpc)) > - return NULL; > - SDValue Chain = N->getOperand(0); > - if (VT.is64BitVector()) { > - switch (VT.getSimpleVT().SimpleTy) { > - default: llvm_unreachable("unhandled vld2 type"); > - case MVT::v8i8: Opc = ARM::VLD2d8; break; > - case MVT::v4i16: Opc = ARM::VLD2d16; break; > - case MVT::v2f32: > - case MVT::v2i32: Opc = ARM::VLD2d32; break; > - case MVT::v1i64: Opc = ARM::VLD2d64; break; > - } > - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; > - return CurDAG->getMachineNode(Opc, dl, VT, VT, MVT::Other, > Ops, 4); > - } > - // Quad registers are loaded as pairs of double registers. > - EVT RegVT; > - switch (VT.getSimpleVT().SimpleTy) { > - default: llvm_unreachable("unhandled vld2 type"); > - case MVT::v16i8: Opc = ARM::VLD2q8; RegVT = MVT::v8i8; break; > - case MVT::v8i16: Opc = ARM::VLD2q16; RegVT = MVT::v4i16; break; > - case MVT::v4f32: Opc = ARM::VLD2q32; RegVT = MVT::v2f32; break; > - case MVT::v4i32: Opc = ARM::VLD2q32; RegVT = MVT::v2i32; break; > - } > - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; > - std::vector ResTys(4, RegVT); > - ResTys.push_back(MVT::Other); > - SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); > - SDNode *Q0 = PairDRegs(VT, SDValue(VLd, 0), SDValue(VLd, 1)); > - SDNode *Q1 = PairDRegs(VT, SDValue(VLd, 2), SDValue(VLd, 3)); > - ReplaceUses(SDValue(N, 0), SDValue(Q0, 0)); > - ReplaceUses(SDValue(N, 1), SDValue(Q1, 0)); > - ReplaceUses(SDValue(N, 2), SDValue(VLd, 4)); > - return NULL; > + unsigned DOpcodes[] = { ARM::VLD2d8, ARM::VLD2d16, > + ARM::VLD2d32, ARM::VLD2d64 }; > + unsigned QOpcodes[] = { ARM::VLD2q8, ARM::VLD2q16, > ARM::VLD2q32 }; > + return SelectVLD(Op, 2, DOpcodes, QOpcodes, 0); > } > > case Intrinsic::arm_neon_vld3: { > - SDValue MemAddr, MemUpdate, MemOpc; > - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, > MemUpdate, MemOpc)) > - return NULL; > - SDValue Chain = N->getOperand(0); > - if (VT.is64BitVector()) { > - switch (VT.getSimpleVT().SimpleTy) { > - default: llvm_unreachable("unhandled vld3 type"); > - case MVT::v8i8: Opc = ARM::VLD3d8; break; > - case MVT::v4i16: Opc = ARM::VLD3d16; break; > - case MVT::v2f32: > - case MVT::v2i32: Opc = ARM::VLD3d32; break; > - case MVT::v1i64: Opc = ARM::VLD3d64; break; > - } > - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; > - return CurDAG->getMachineNode(Opc, dl, VT, VT, VT, > MVT::Other, Ops, 4); > - } > - // Quad registers are loaded with two separate instructions, > where one > - // loads the even registers and the other loads the odd > registers. > - EVT RegVT; > - unsigned Opc2 = 0; > - switch (VT.getSimpleVT().SimpleTy) { > - default: llvm_unreachable("unhandled vld3 type"); > - case MVT::v16i8: > - Opc = ARM::VLD3q8a; Opc2 = ARM::VLD3q8b; RegVT = > MVT::v8i8; break; > - case MVT::v8i16: > - Opc = ARM::VLD3q16a; Opc2 = ARM::VLD3q16b; RegVT = > MVT::v4i16; break; > - case MVT::v4f32: > - Opc = ARM::VLD3q32a; Opc2 = ARM::VLD3q32b; RegVT = > MVT::v2f32; break; > - case MVT::v4i32: > - Opc = ARM::VLD3q32a; Opc2 = ARM::VLD3q32b; RegVT = > MVT::v2i32; break; > - } > - // Enable writeback to the address register. > - MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), > MVT::i32); > - > - std::vector ResTys(3, RegVT); > - ResTys.push_back(MemAddr.getValueType()); > - ResTys.push_back(MVT::Other); > - > - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; > - SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, > 4); > - Chain = SDValue(VLdA, 4); > - > - const SDValue OpsB[] = { SDValue(VLdA, 3), MemUpdate, MemOpc, > Chain }; > - SDNode *VLdB = CurDAG->getMachineNode(Opc2, dl, ResTys, OpsB, > 4); > - Chain = SDValue(VLdB, 4); > - > - SDNode *Q0 = PairDRegs(VT, SDValue(VLdA, 0), SDValue(VLdB, 0)); > - SDNode *Q1 = PairDRegs(VT, SDValue(VLdA, 1), SDValue(VLdB, 1)); > - SDNode *Q2 = PairDRegs(VT, SDValue(VLdA, 2), SDValue(VLdB, 2)); > - ReplaceUses(SDValue(N, 0), SDValue(Q0, 0)); > - ReplaceUses(SDValue(N, 1), SDValue(Q1, 0)); > - ReplaceUses(SDValue(N, 2), SDValue(Q2, 0)); > - ReplaceUses(SDValue(N, 3), Chain); > - return NULL; > + unsigned DOpcodes[] = { ARM::VLD3d8, ARM::VLD3d16, > + ARM::VLD3d32, ARM::VLD3d64 }; > + unsigned QOpcodes0[] = { ARM::VLD3q8a, ARM::VLD3q16a, > ARM::VLD3q32a }; > + unsigned QOpcodes1[] = { ARM::VLD3q8b, ARM::VLD3q16b, > ARM::VLD3q32b }; > + return SelectVLD(Op, 3, DOpcodes, QOpcodes0, QOpcodes1); > } > > case Intrinsic::arm_neon_vld4: { > - SDValue MemAddr, MemUpdate, MemOpc; > - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, > MemUpdate, MemOpc)) > - return NULL; > - SDValue Chain = N->getOperand(0); > - if (VT.is64BitVector()) { > - switch (VT.getSimpleVT().SimpleTy) { > - default: llvm_unreachable("unhandled vld4 type"); > - case MVT::v8i8: Opc = ARM::VLD4d8; break; > - case MVT::v4i16: Opc = ARM::VLD4d16; break; > - case MVT::v2f32: > - case MVT::v2i32: Opc = ARM::VLD4d32; break; > - case MVT::v1i64: Opc = ARM::VLD4d64; break; > - } > - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; > - std::vector ResTys(4, VT); > - ResTys.push_back(MVT::Other); > - return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); > - } > - // Quad registers are loaded with two separate instructions, > where one > - // loads the even registers and the other loads the odd > registers. > - EVT RegVT; > - unsigned Opc2 = 0; > - switch (VT.getSimpleVT().SimpleTy) { > - default: llvm_unreachable("unhandled vld4 type"); > - case MVT::v16i8: > - Opc = ARM::VLD4q8a; Opc2 = ARM::VLD4q8b; RegVT = > MVT::v8i8; break; > - case MVT::v8i16: > - Opc = ARM::VLD4q16a; Opc2 = ARM::VLD4q16b; RegVT = > MVT::v4i16; break; > - case MVT::v4f32: > - Opc = ARM::VLD4q32a; Opc2 = ARM::VLD4q32b; RegVT = > MVT::v2f32; break; > - case MVT::v4i32: > - Opc = ARM::VLD4q32a; Opc2 = ARM::VLD4q32b; RegVT = > MVT::v2i32; break; > - } > - // Enable writeback to the address register. > - MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), > MVT::i32); > - > - std::vector ResTys(4, RegVT); > - ResTys.push_back(MemAddr.getValueType()); > - ResTys.push_back(MVT::Other); > - > - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; > - SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, > 4); > - Chain = SDValue(VLdA, 5); > - > - const SDValue OpsB[] = { SDValue(VLdA, 4), MemUpdate, MemOpc, > Chain }; > - SDNode *VLdB = CurDAG->getMachineNode(Opc2, dl, ResTys, OpsB, > 4); > - Chain = SDValue(VLdB, 5); > - > - SDNode *Q0 = PairDRegs(VT, SDValue(VLdA, 0), SDValue(VLdB, 0)); > - SDNode *Q1 = PairDRegs(VT, SDValue(VLdA, 1), SDValue(VLdB, 1)); > - SDNode *Q2 = PairDRegs(VT, SDValue(VLdA, 2), SDValue(VLdB, 2)); > - SDNode *Q3 = PairDRegs(VT, SDValue(VLdA, 3), SDValue(VLdB, 3)); > - ReplaceUses(SDValue(N, 0), SDValue(Q0, 0)); > - ReplaceUses(SDValue(N, 1), SDValue(Q1, 0)); > - ReplaceUses(SDValue(N, 2), SDValue(Q2, 0)); > - ReplaceUses(SDValue(N, 3), SDValue(Q3, 0)); > - ReplaceUses(SDValue(N, 4), Chain); > - return NULL; > + unsigned DOpcodes[] = { ARM::VLD4d8, ARM::VLD4d16, > + ARM::VLD4d32, ARM::VLD4d64 }; > + unsigned QOpcodes0[] = { ARM::VLD4q8a, ARM::VLD4q16a, > ARM::VLD4q32a }; > + unsigned QOpcodes1[] = { ARM::VLD4q8b, ARM::VLD4q16b, > ARM::VLD4q32b }; > + return SelectVLD(Op, 4, DOpcodes, QOpcodes0, QOpcodes1); > } > > case Intrinsic::arm_neon_vld2lane: { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From grosbach at apple.com Wed Oct 14 16:22:39 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 14 Oct 2009 21:22:39 -0000 Subject: [llvm-commits] [llvm] r84138 - /llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Message-ID: <200910142122.n9ELMe0g023910@zion.cs.uiuc.edu> Author: grosbach Date: Wed Oct 14 16:22:39 2009 New Revision: 84138 URL: http://llvm.org/viewvc/llvm-project?rev=84138&view=rev Log: Make loop not recalc getNumOperands() each time around Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=84138&r1=84137&r2=84138&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original) +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Wed Oct 14 16:22:39 2009 @@ -778,9 +778,7 @@ // directly. for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) { MachineInstr *MI = I; - // Likewise, call getNumOperands() each iteration, as the MI may change - // inside the loop (with 'i' updated accordingly). - for (unsigned i = 0; i != MI->getNumOperands(); ++i) + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) if (MI->getOperand(i).isReg()) { MachineOperand &MO = MI->getOperand(i); unsigned Reg = MO.getReg(); @@ -853,6 +851,7 @@ // just calculating the value we already have. BB->erase(I, LastUseMI); MI = I = LastUseMI; + e = MI->getNumOperands(); CurrentScratchReg = PrevScratchReg; // Extend the live range of the register From johnny.chen at apple.com Wed Oct 14 16:27:31 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 14 Oct 2009 14:27:31 -0700 Subject: [llvm-commits] NEON VPADAL patch Message-ID: Hi, Inst{11-8} for vpadal should be 0b0110, not 0b0010. Refs: A7-19, A8-682, and A8-688. -------------- next part -------------- A non-text attachment was scrubbed... Name: ARMInstrNEON.td.patch2 Type: application/octet-stream Size: 785 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091014/f6ebe155/attachment.obj From bob.wilson at apple.com Wed Oct 14 16:40:45 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 14 Oct 2009 21:40:45 -0000 Subject: [llvm-commits] [llvm] r84144 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <200910142140.n9ELejFp024745@zion.cs.uiuc.edu> Author: bwilson Date: Wed Oct 14 16:40:45 2009 New Revision: 84144 URL: http://llvm.org/viewvc/llvm-project?rev=84144&view=rev Log: Remove unused variables to fix build warning. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84144&r1=84143&r2=84144&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 14 16:40:45 2009 @@ -1708,9 +1708,6 @@ case ISD::INTRINSIC_VOID: case ISD::INTRINSIC_W_CHAIN: { unsigned IntNo = cast(N->getOperand(1))->getZExtValue(); - EVT VT = N->getValueType(0); - unsigned Opc = 0; - switch (IntNo) { default: break; From bob.wilson at apple.com Wed Oct 14 16:38:52 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 14 Oct 2009 14:38:52 -0700 Subject: [llvm-commits] [llvm] r84117 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp In-Reply-To: References: <200910141728.n9EHSqRB015596@zion.cs.uiuc.edu> Message-ID: <79634C16-FF9D-4187-9ACF-BDE5050EC0E9@apple.com> Oops. Fixed in r84144 On Oct 14, 2009, at 2:18 PM, Jim Grosbach wrote: > Hi Bob, > > I think this is causing: > /Volumes/Home/grosbaj/sources/llvm/lib/Target/ARM/ > ARMISelDAGToDAG.cpp: In member function > ?llvm::SDNode*::ARMDAGToDAGISel::Select(llvm::SDValue)?: > /Volumes/Home/grosbaj/sources/llvm/lib/Target/ARM/ > ARMISelDAGToDAG.cpp:1712: warning: unused variable ?Opc? > > -Jim > > On Oct 14, 2009, at 10:28 AM, Bob Wilson wrote: > >> Author: bwilson >> Date: Wed Oct 14 12:28:52 2009 >> New Revision: 84117 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84117&view=rev >> Log: >> Refactor code to select NEON VLD intrinsics. >> >> Modified: >> llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp >> >> Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=84117&r1=84116&r2=84117&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 14 >> 12:28:52 2009 >> @@ -126,6 +126,13 @@ >> /// SelectDYN_ALLOC - Select dynamic alloc for Thumb. >> SDNode *SelectDYN_ALLOC(SDValue Op); >> >> + /// SelectVLD - Select NEON load intrinsics. NumVecs should >> + /// be 2, 3 or 4. The opcode arrays specify the instructions >> used for >> + /// loads of D registers and even subregs and odd subregs of Q >> registers. >> + /// For NumVecs == 2, QOpcodes1 is not used. >> + SDNode *SelectVLD(SDValue Op, unsigned NumVecs, unsigned >> *DOpcodes, >> + unsigned *QOpcodes0, unsigned *QOpcodes1); >> + >> /// SelectVLDSTLane - Select NEON load/store lane intrinsics. >> NumVecs should >> /// be 2, 3 or 4. The opcode arrays specify the instructions used >> for >> /// load/store of D registers and even subregs and odd subregs of >> Q registers. >> @@ -990,6 +997,94 @@ >> } >> } >> >> +SDNode *ARMDAGToDAGISel::SelectVLD(SDValue Op, unsigned NumVecs, >> + unsigned *DOpcodes, unsigned >> *QOpcodes0, >> + unsigned *QOpcodes1) { >> + assert(NumVecs >=2 && NumVecs <= 4 && "VLD NumVecs out-of-range"); >> + SDNode *N = Op.getNode(); >> + DebugLoc dl = N->getDebugLoc(); >> + >> + SDValue MemAddr, MemUpdate, MemOpc; >> + if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, MemUpdate, >> MemOpc)) >> + return NULL; >> + >> + SDValue Chain = N->getOperand(0); >> + EVT VT = N->getValueType(0); >> + bool is64BitVector = VT.is64BitVector(); >> + >> + unsigned OpcodeIndex; >> + switch (VT.getSimpleVT().SimpleTy) { >> + default: llvm_unreachable("unhandled vld type"); >> + // Double-register operations: >> + case MVT::v8i8: OpcodeIndex = 0; break; >> + case MVT::v4i16: OpcodeIndex = 1; break; >> + case MVT::v2f32: >> + case MVT::v2i32: OpcodeIndex = 2; break; >> + case MVT::v1i64: OpcodeIndex = 3; break; >> + // Quad-register operations: >> + case MVT::v16i8: OpcodeIndex = 0; break; >> + case MVT::v8i16: OpcodeIndex = 1; break; >> + case MVT::v4f32: >> + case MVT::v4i32: OpcodeIndex = 2; break; >> + } >> + >> + if (is64BitVector) { >> + unsigned Opc = DOpcodes[OpcodeIndex]; >> + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> + std::vector ResTys(NumVecs, VT); >> + ResTys.push_back(MVT::Other); >> + return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); >> + } >> + >> + EVT RegVT = GetNEONSubregVT(VT); >> + if (NumVecs == 2) { >> + // Quad registers are directly supported for VLD2, >> + // loading 2 pairs of D regs. >> + unsigned Opc = QOpcodes0[OpcodeIndex]; >> + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> + std::vector ResTys(4, VT); >> + ResTys.push_back(MVT::Other); >> + SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); >> + Chain = SDValue(VLd, 4); >> + >> + // Combine the even and odd subregs to produce the result. >> + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) { >> + SDNode *Q = PairDRegs(VT, SDValue(VLd, 2*Vec), SDValue(VLd, >> 2*Vec+1)); >> + ReplaceUses(SDValue(N, Vec), SDValue(Q, 0)); >> + } >> + } else { >> + // Otherwise, quad registers are loaded with two separate >> instructions, >> + // where one loads the even registers and the other loads the >> odd registers. >> + >> + // Enable writeback to the address register. >> + MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), >> MVT::i32); >> + >> + std::vector ResTys(NumVecs, RegVT); >> + ResTys.push_back(MemAddr.getValueType()); >> + ResTys.push_back(MVT::Other); >> + >> + // Load the even subreg. >> + unsigned Opc = QOpcodes0[OpcodeIndex]; >> + const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> + SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, 4); >> + Chain = SDValue(VLdA, NumVecs+1); >> + >> + // Load the odd subreg. >> + Opc = QOpcodes1[OpcodeIndex]; >> + const SDValue OpsB[] = { SDValue(VLdA, NumVecs), MemUpdate, >> MemOpc, Chain }; >> + SDNode *VLdB = CurDAG->getMachineNode(Opc, dl, ResTys, OpsB, 4); >> + Chain = SDValue(VLdB, NumVecs+1); >> + >> + // Combine the even and odd subregs to produce the result. >> + for (unsigned Vec = 0; Vec < NumVecs; ++Vec) { >> + SDNode *Q = PairDRegs(VT, SDValue(VLdA, Vec), SDValue(VLdB, >> Vec)); >> + ReplaceUses(SDValue(N, Vec), SDValue(Q, 0)); >> + } >> + } >> + ReplaceUses(SDValue(N, NumVecs), Chain); >> + return NULL; >> +} >> + >> SDNode *ARMDAGToDAGISel::SelectVLDSTLane(SDValue Op, bool IsLoad, >> unsigned NumVecs, unsigned >> *DOpcodes, >> unsigned *QOpcodes0, >> @@ -1525,159 +1620,26 @@ >> break; >> >> case Intrinsic::arm_neon_vld2: { >> - SDValue MemAddr, MemUpdate, MemOpc; >> - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, >> MemUpdate, MemOpc)) >> - return NULL; >> - SDValue Chain = N->getOperand(0); >> - if (VT.is64BitVector()) { >> - switch (VT.getSimpleVT().SimpleTy) { >> - default: llvm_unreachable("unhandled vld2 type"); >> - case MVT::v8i8: Opc = ARM::VLD2d8; break; >> - case MVT::v4i16: Opc = ARM::VLD2d16; break; >> - case MVT::v2f32: >> - case MVT::v2i32: Opc = ARM::VLD2d32; break; >> - case MVT::v1i64: Opc = ARM::VLD2d64; break; >> - } >> - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> - return CurDAG->getMachineNode(Opc, dl, VT, VT, MVT::Other, >> Ops, 4); >> - } >> - // Quad registers are loaded as pairs of double registers. >> - EVT RegVT; >> - switch (VT.getSimpleVT().SimpleTy) { >> - default: llvm_unreachable("unhandled vld2 type"); >> - case MVT::v16i8: Opc = ARM::VLD2q8; RegVT = MVT::v8i8; break; >> - case MVT::v8i16: Opc = ARM::VLD2q16; RegVT = MVT::v4i16; >> break; >> - case MVT::v4f32: Opc = ARM::VLD2q32; RegVT = MVT::v2f32; >> break; >> - case MVT::v4i32: Opc = ARM::VLD2q32; RegVT = MVT::v2i32; >> break; >> - } >> - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> - std::vector ResTys(4, RegVT); >> - ResTys.push_back(MVT::Other); >> - SDNode *VLd = CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); >> - SDNode *Q0 = PairDRegs(VT, SDValue(VLd, 0), SDValue(VLd, 1)); >> - SDNode *Q1 = PairDRegs(VT, SDValue(VLd, 2), SDValue(VLd, 3)); >> - ReplaceUses(SDValue(N, 0), SDValue(Q0, 0)); >> - ReplaceUses(SDValue(N, 1), SDValue(Q1, 0)); >> - ReplaceUses(SDValue(N, 2), SDValue(VLd, 4)); >> - return NULL; >> + unsigned DOpcodes[] = { ARM::VLD2d8, ARM::VLD2d16, >> + ARM::VLD2d32, ARM::VLD2d64 }; >> + unsigned QOpcodes[] = { ARM::VLD2q8, ARM::VLD2q16, >> ARM::VLD2q32 }; >> + return SelectVLD(Op, 2, DOpcodes, QOpcodes, 0); >> } >> >> case Intrinsic::arm_neon_vld3: { >> - SDValue MemAddr, MemUpdate, MemOpc; >> - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, >> MemUpdate, MemOpc)) >> - return NULL; >> - SDValue Chain = N->getOperand(0); >> - if (VT.is64BitVector()) { >> - switch (VT.getSimpleVT().SimpleTy) { >> - default: llvm_unreachable("unhandled vld3 type"); >> - case MVT::v8i8: Opc = ARM::VLD3d8; break; >> - case MVT::v4i16: Opc = ARM::VLD3d16; break; >> - case MVT::v2f32: >> - case MVT::v2i32: Opc = ARM::VLD3d32; break; >> - case MVT::v1i64: Opc = ARM::VLD3d64; break; >> - } >> - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> - return CurDAG->getMachineNode(Opc, dl, VT, VT, VT, >> MVT::Other, Ops, 4); >> - } >> - // Quad registers are loaded with two separate instructions, >> where one >> - // loads the even registers and the other loads the odd >> registers. >> - EVT RegVT; >> - unsigned Opc2 = 0; >> - switch (VT.getSimpleVT().SimpleTy) { >> - default: llvm_unreachable("unhandled vld3 type"); >> - case MVT::v16i8: >> - Opc = ARM::VLD3q8a; Opc2 = ARM::VLD3q8b; RegVT = >> MVT::v8i8; break; >> - case MVT::v8i16: >> - Opc = ARM::VLD3q16a; Opc2 = ARM::VLD3q16b; RegVT = >> MVT::v4i16; break; >> - case MVT::v4f32: >> - Opc = ARM::VLD3q32a; Opc2 = ARM::VLD3q32b; RegVT = >> MVT::v2f32; break; >> - case MVT::v4i32: >> - Opc = ARM::VLD3q32a; Opc2 = ARM::VLD3q32b; RegVT = >> MVT::v2i32; break; >> - } >> - // Enable writeback to the address register. >> - MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), >> MVT::i32); >> - >> - std::vector ResTys(3, RegVT); >> - ResTys.push_back(MemAddr.getValueType()); >> - ResTys.push_back(MVT::Other); >> - >> - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> - SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, >> 4); >> - Chain = SDValue(VLdA, 4); >> - >> - const SDValue OpsB[] = { SDValue(VLdA, 3), MemUpdate, >> MemOpc, Chain }; >> - SDNode *VLdB = CurDAG->getMachineNode(Opc2, dl, ResTys, >> OpsB, 4); >> - Chain = SDValue(VLdB, 4); >> - >> - SDNode *Q0 = PairDRegs(VT, SDValue(VLdA, 0), SDValue(VLdB, >> 0)); >> - SDNode *Q1 = PairDRegs(VT, SDValue(VLdA, 1), SDValue(VLdB, >> 1)); >> - SDNode *Q2 = PairDRegs(VT, SDValue(VLdA, 2), SDValue(VLdB, >> 2)); >> - ReplaceUses(SDValue(N, 0), SDValue(Q0, 0)); >> - ReplaceUses(SDValue(N, 1), SDValue(Q1, 0)); >> - ReplaceUses(SDValue(N, 2), SDValue(Q2, 0)); >> - ReplaceUses(SDValue(N, 3), Chain); >> - return NULL; >> + unsigned DOpcodes[] = { ARM::VLD3d8, ARM::VLD3d16, >> + ARM::VLD3d32, ARM::VLD3d64 }; >> + unsigned QOpcodes0[] = { ARM::VLD3q8a, ARM::VLD3q16a, >> ARM::VLD3q32a }; >> + unsigned QOpcodes1[] = { ARM::VLD3q8b, ARM::VLD3q16b, >> ARM::VLD3q32b }; >> + return SelectVLD(Op, 3, DOpcodes, QOpcodes0, QOpcodes1); >> } >> >> case Intrinsic::arm_neon_vld4: { >> - SDValue MemAddr, MemUpdate, MemOpc; >> - if (!SelectAddrMode6(Op, N->getOperand(2), MemAddr, >> MemUpdate, MemOpc)) >> - return NULL; >> - SDValue Chain = N->getOperand(0); >> - if (VT.is64BitVector()) { >> - switch (VT.getSimpleVT().SimpleTy) { >> - default: llvm_unreachable("unhandled vld4 type"); >> - case MVT::v8i8: Opc = ARM::VLD4d8; break; >> - case MVT::v4i16: Opc = ARM::VLD4d16; break; >> - case MVT::v2f32: >> - case MVT::v2i32: Opc = ARM::VLD4d32; break; >> - case MVT::v1i64: Opc = ARM::VLD4d64; break; >> - } >> - const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> - std::vector ResTys(4, VT); >> - ResTys.push_back(MVT::Other); >> - return CurDAG->getMachineNode(Opc, dl, ResTys, Ops, 4); >> - } >> - // Quad registers are loaded with two separate instructions, >> where one >> - // loads the even registers and the other loads the odd >> registers. >> - EVT RegVT; >> - unsigned Opc2 = 0; >> - switch (VT.getSimpleVT().SimpleTy) { >> - default: llvm_unreachable("unhandled vld4 type"); >> - case MVT::v16i8: >> - Opc = ARM::VLD4q8a; Opc2 = ARM::VLD4q8b; RegVT = >> MVT::v8i8; break; >> - case MVT::v8i16: >> - Opc = ARM::VLD4q16a; Opc2 = ARM::VLD4q16b; RegVT = >> MVT::v4i16; break; >> - case MVT::v4f32: >> - Opc = ARM::VLD4q32a; Opc2 = ARM::VLD4q32b; RegVT = >> MVT::v2f32; break; >> - case MVT::v4i32: >> - Opc = ARM::VLD4q32a; Opc2 = ARM::VLD4q32b; RegVT = >> MVT::v2i32; break; >> - } >> - // Enable writeback to the address register. >> - MemOpc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(true), >> MVT::i32); >> - >> - std::vector ResTys(4, RegVT); >> - ResTys.push_back(MemAddr.getValueType()); >> - ResTys.push_back(MVT::Other); >> - >> - const SDValue OpsA[] = { MemAddr, MemUpdate, MemOpc, Chain }; >> - SDNode *VLdA = CurDAG->getMachineNode(Opc, dl, ResTys, OpsA, >> 4); >> - Chain = SDValue(VLdA, 5); >> - >> - const SDValue OpsB[] = { SDValue(VLdA, 4), MemUpdate, >> MemOpc, Chain }; >> - SDNode *VLdB = CurDAG->getMachineNode(Opc2, dl, ResTys, >> OpsB, 4); >> - Chain = SDValue(VLdB, 5); >> - >> - SDNode *Q0 = PairDRegs(VT, SDValue(VLdA, 0), SDValue(VLdB, >> 0)); >> - SDNode *Q1 = PairDRegs(VT, SDValue(VLdA, 1), SDValue(VLdB, >> 1)); >> - SDNode *Q2 = PairDRegs(VT, SDValue(VLdA, 2), SDValue(VLdB, >> 2)); >> - SDNode *Q3 = PairDRegs(VT, SDValue(VLdA, 3), SDValue(VLdB, >> 3)); >> - ReplaceUses(SDValue(N, 0), SDValue(Q0, 0)); >> - ReplaceUses(SDValue(N, 1), SDValue(Q1, 0)); >> - ReplaceUses(SDValue(N, 2), SDValue(Q2, 0)); >> - ReplaceUses(SDValue(N, 3), SDValue(Q3, 0)); >> - ReplaceUses(SDValue(N, 4), Chain); >> - return NULL; >> + unsigned DOpcodes[] = { ARM::VLD4d8, ARM::VLD4d16, >> + ARM::VLD4d32, ARM::VLD4d64 }; >> + unsigned QOpcodes0[] = { ARM::VLD4q8a, ARM::VLD4q16a, >> ARM::VLD4q32a }; >> + unsigned QOpcodes1[] = { ARM::VLD4q8b, ARM::VLD4q16b, >> ARM::VLD4q32b }; >> + return SelectVLD(Op, 4, DOpcodes, QOpcodes0, QOpcodes1); >> } >> >> case Intrinsic::arm_neon_vld2lane: { >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From bob.wilson at apple.com Wed Oct 14 16:43:17 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 14 Oct 2009 21:43:17 -0000 Subject: [llvm-commits] [llvm] r84146 - /llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Message-ID: <200910142143.n9ELhH1N024839@zion.cs.uiuc.edu> Author: bwilson Date: Wed Oct 14 16:43:17 2009 New Revision: 84146 URL: http://llvm.org/viewvc/llvm-project?rev=84146&view=rev Log: Fix instruction encoding bits for NEON VPADAL. Patch by Johnny Chen. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=84146&r1=84145&r2=84146&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Wed Oct 14 16:43:17 2009 @@ -1951,9 +1951,9 @@ int_arm_neon_vpaddlu>; // VPADAL : Vector Pairwise Add and Accumulate Long -defm VPADALs : N2VPLInt2_QHS<0b11, 0b11, 0b00, 0b00100, 0, "vpadal.s", +defm VPADALs : N2VPLInt2_QHS<0b11, 0b11, 0b00, 0b01100, 0, "vpadal.s", int_arm_neon_vpadals>; -defm VPADALu : N2VPLInt2_QHS<0b11, 0b11, 0b00, 0b00101, 0, "vpadal.u", +defm VPADALu : N2VPLInt2_QHS<0b11, 0b11, 0b00, 0b01101, 0, "vpadal.u", int_arm_neon_vpadalu>; // VPMAX : Vector Pairwise Maximum From echristo at apple.com Wed Oct 14 16:45:49 2009 From: echristo at apple.com (Eric Christopher) Date: Wed, 14 Oct 2009 21:45:49 -0000 Subject: [llvm-commits] [llvm] r84147 - /llvm/trunk/include/llvm/Support/raw_ostream.h Message-ID: <200910142145.n9ELjnYT024931@zion.cs.uiuc.edu> Author: echristo Date: Wed Oct 14 16:45:49 2009 New Revision: 84147 URL: http://llvm.org/viewvc/llvm-project?rev=84147&view=rev Log: Fix the unused argument problem here a different way - cast to void. Modified: llvm/trunk/include/llvm/Support/raw_ostream.h Modified: llvm/trunk/include/llvm/Support/raw_ostream.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=84147&r1=84146&r2=84147&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/raw_ostream.h (original) +++ llvm/trunk/include/llvm/Support/raw_ostream.h Wed Oct 14 16:45:49 2009 @@ -233,7 +233,9 @@ /// @param bold bold/brighter text, default false /// @param bg if true change the background, default: change foreground /// @returns itself so it can be used within << invocations - virtual raw_ostream &changeColor(enum Colors, bool, bool) { return *this; } + virtual raw_ostream &changeColor(enum Colors, bool bold = false, + bool bg = false) + { (void)bold; (void)bg; return *this; } /// Resets the colors to terminal defaults. Call this when you are done /// outputting colored text, or before program exit. From evan.cheng at apple.com Wed Oct 14 16:52:27 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 14:52:27 -0700 Subject: [llvm-commits] Add some ARM instruction encoding bits for "register" and "register-shifted register" In-Reply-To: <0C260D95-A214-49B6-8366-5627894BFD6F@apple.com> References: <0C260D95-A214-49B6-8366-5627894BFD6F@apple.com> Message-ID: <460D0A04-9C76-468D-8D14-8C9486DDF87E@apple.com> On Oct 14, 2009, at 1:45 PM, Bob Wilson wrote: > > On Oct 14, 2009, at 1:26 PM, Evan Cheng wrote: > >> LLVM ARM's so_reg operand can potentially encode "rrx" shifter op as well. In that case, bit 4 is 0, not 1. However, I believe it's only possible to use rrx when the instruction is a mov. So this should be ok. But please add comment to state that it's ok to set bit 4 because rrx cannot be used. > > Yes, it's OK -- there is a separate MOVrx instruction pattern. In fact, I don't see anything that uses rrx as a shift op, and it's not listed in the definition of so_reg: > > def so_reg : Operand, // reg reg imm > ComplexPattern [shl,srl,sra,rotr]> { > let PrintMethod = "printSORegOperand"; > let MIOperandInfo = (ops GPR, GPR, i32imm); > } > > The only place I can see using RRX is the ARMrrx node created by LowerShift() in ARMISelLowering.cpp. Am I missing something? If not, it seems like maybe we should remove rrx from the list of shift ops. I would just document it for now. ARMInstrInfo.td needs some refactoring to split out instructions in the same way as ARMInstrThumb2.td. But we don't want to tackle it now. Evan From echristo at apple.com Wed Oct 14 17:14:18 2009 From: echristo at apple.com (Eric Christopher) Date: Wed, 14 Oct 2009 22:14:18 -0000 Subject: [llvm-commits] [llvm] r84150 - /llvm/trunk/include/llvm/Support/raw_ostream.h Message-ID: <200910142214.n9EMEIA7026207@zion.cs.uiuc.edu> Author: echristo Date: Wed Oct 14 17:14:18 2009 New Revision: 84150 URL: http://llvm.org/viewvc/llvm-project?rev=84150&view=rev Log: One more iteration here and a yet better way to solve it. Modified: llvm/trunk/include/llvm/Support/raw_ostream.h Modified: llvm/trunk/include/llvm/Support/raw_ostream.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=84150&r1=84149&r2=84150&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/raw_ostream.h (original) +++ llvm/trunk/include/llvm/Support/raw_ostream.h Wed Oct 14 17:14:18 2009 @@ -51,7 +51,7 @@ /// for a \see write_impl() call to handle the data which has been put into /// this buffer. char *OutBufStart, *OutBufEnd, *OutBufCur; - + enum BufferKind { Unbuffered = 0, InternalBuffer, @@ -211,7 +211,7 @@ return *this; } - raw_ostream &operator<<(double N); + raw_ostream &operator<<(double N); /// write_hex - Output \arg N in hexadecimal, without any prefix or padding. raw_ostream &write_hex(unsigned long long N); @@ -224,8 +224,8 @@ /// indent - Insert 'NumSpaces' spaces. raw_ostream &indent(unsigned NumSpaces); - - + + /// Changes the foreground color of text that will be output from this point /// forward. /// @param colors ANSI color to use, the special SAVEDCOLOR can be used to @@ -233,9 +233,8 @@ /// @param bold bold/brighter text, default false /// @param bg if true change the background, default: change foreground /// @returns itself so it can be used within << invocations - virtual raw_ostream &changeColor(enum Colors, bool bold = false, - bool bg = false) - { (void)bold; (void)bg; return *this; } + virtual raw_ostream &changeColor(enum Colors, bool = false, + bool = false) { return *this; } /// Resets the colors to terminal defaults. Call this when you are done /// outputting colored text, or before program exit. @@ -254,7 +253,7 @@ /// write_impl - The is the piece of the class that is implemented /// by subclasses. This writes the \args Size bytes starting at /// \arg Ptr to the underlying stream. - /// + /// /// This function is guaranteed to only be called at a point at which it is /// safe for the subclass to install a new buffer via SetBuffer. /// @@ -332,7 +331,7 @@ virtual size_t preferred_buffer_size(); public: - + enum { /// F_Excl - When opening a file, this flag makes raw_fd_ostream /// report an error if the file already exists. @@ -347,7 +346,7 @@ /// make this distinction. F_Binary = 4 }; - + /// raw_fd_ostream - Open the specified file for writing. If an error occurs, /// information about the error is put into ErrorInfo, and the stream should /// be immediately destroyed; the string will be empty if no error occurred. @@ -360,10 +359,10 @@ /// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If /// ShouldClose is true, this closes the file when the stream is destroyed. - raw_fd_ostream(int fd, bool shouldClose, - bool unbuffered=false) : raw_ostream(unbuffered), FD(fd), + raw_fd_ostream(int fd, bool shouldClose, + bool unbuffered=false) : raw_ostream(unbuffered), FD(fd), ShouldClose(shouldClose) {} - + ~raw_fd_ostream(); /// close - Manually flush the stream and close the file. @@ -466,7 +465,7 @@ class raw_null_ostream : public raw_ostream { /// write_impl - See raw_ostream::write_impl. virtual void write_impl(const char *Ptr, size_t size); - + /// current_pos - Return the current position within the stream, not /// counting the bytes currently in the buffer. virtual uint64_t current_pos(); From sabre at nondot.org Wed Oct 14 18:22:25 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 18:22:25 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910142322.n9ENMO6a028715@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.6 -> 1.7 --- Log message: add anton's video --- Diffs of the changes: (+4 -1) index.html | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.6 llvm-www/devmtg/2009-10/index.html:1.7 --- llvm-www/devmtg/2009-10/index.html:1.6 Mon Oct 12 17:08:39 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 18:20:01 2009 @@ -74,6 +74,9 @@ [Slides] + [LowRes Video] + [HiRes Video] + [iPhone Video] Anton Korobeynikov
        Saint Petersburg State University @@ -250,7 +253,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/12 22:08:39 $ +
        Last modified: $Date: 2009/10/14 23:20:01 $ From sabre at nondot.org Wed Oct 14 18:26:52 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 18:26:52 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/.htaccess index.html Message-ID: <200910142326.n9ENQqpR028932@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: .htaccess added (r1.1) index.html updated: 1.7 -> 1.8 --- Log message: remove a choice, clarify, stream the phone version (which also works on android and probably other phones). --- Diffs of the changes: (+8 -4) .htaccess | 5 +++++ index.html | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) Index: llvm-www/devmtg/2009-10/.htaccess diff -c /dev/null llvm-www/devmtg/2009-10/.htaccess:1.1 *** /dev/null Wed Oct 14 18:26:47 2009 --- llvm-www/devmtg/2009-10/.htaccess Wed Oct 14 18:26:37 2009 *************** *** 0 **** --- 1,5 ---- + AddType audio/mpeg mp3 + AddType audio/x-m4a m4a + AddType video/x-m4v m4v + AddType video/mp4 mp4 + AddType video/3gpp 3gp Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.7 llvm-www/devmtg/2009-10/index.html:1.8 --- llvm-www/devmtg/2009-10/index.html:1.7 Wed Oct 14 18:20:01 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 18:26:37 2009 @@ -74,9 +74,8 @@ [Slides] - [LowRes Video] - [HiRes Video] - [iPhone Video] + [Video] (Computer) + [Video] (Phone \er) Anton Korobeynikov
        Saint Petersburg State University @@ -253,7 +252,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/14 23:20:01 $ +
        Last modified: $Date: 2009/10/14 23:26:37 $ From sabre at nondot.org Wed Oct 14 18:27:37 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 18:27:37 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910142327.n9ENRbpN028982@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.8 -> 1.9 --- Log message: cleanup --- Diffs of the changes: (+3 -3) index.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.8 llvm-www/devmtg/2009-10/index.html:1.9 --- llvm-www/devmtg/2009-10/index.html:1.8 Wed Oct 14 18:26:37 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 18:27:20 2009 @@ -74,8 +74,8 @@ [Slides] - [Video] (Computer) - [Video] (Phone \er) + [Video(Computer) + [Video(Phone) Anton Korobeynikov
        Saint Petersburg State University @@ -252,7 +252,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/14 23:26:37 $ +
        Last modified: $Date: 2009/10/14 23:27:20 $ From jyasskin at gmail.com Wed Oct 14 18:28:38 2009 From: jyasskin at gmail.com (jyasskin at gmail.com) Date: Wed, 14 Oct 2009 23:28:38 +0000 Subject: [llvm-commits] [PATCH] Sanitize the JITResolver stub/callsite<->function maps Message-ID: <0016367b65c6b96c230475ed8580@google.com> Reviewers: , Message: Patch at http://codereview.appspot.com/download/issue130080_1.diff This passes check-lit. Description: The JITResolver maps Functions to their canonical stubs and all callsites for lazily-compiled functions to their target Functions. To make Function destruction work, I'm going to need to remove all callsites on destruction, so this patch also adds the reverse mapping for that. There was an incorrect assumption in here that the only stub for a function would be the one caused by needing to lazily compile it, while x86-64 far calls and dlsym-stubs could also cause such stubs, but I didn't look for a test case that the assumption broke. This also adds DenseMapInfo so I can use DenseMaps instead of std::maps. Please review this at http://codereview.appspot.com/130080 Affected files: M include/llvm/Support/ValueHandle.h M lib/ExecutionEngine/JIT/JITEmitter.cpp From sabre at nondot.org Wed Oct 14 18:31:06 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 18:31:06 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910142331.n9ENV6EL029176@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.9 -> 1.10 --- Log message: cleanup --- Diffs of the changes: (+5 -5) index.html | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.9 llvm-www/devmtg/2009-10/index.html:1.10 --- llvm-www/devmtg/2009-10/index.html:1.9 Wed Oct 14 18:27:20 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 18:30:50 2009 @@ -72,11 +72,11 @@ - - [Slides] +

        + [Slides]
        [Video(Computer) - [Video(Phone) - + [Video(Mobile) +
        Anton Korobeynikov
        Saint Petersburg State University Tutorial: Building backend in 24 hours - A step by step tutorial to @@ -252,7 +252,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/14 23:27:20 $ +
        Last modified: $Date: 2009/10/14 23:30:50 $ From sabre at nondot.org Wed Oct 14 18:31:40 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 18:31:40 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910142331.n9ENVedb029261@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.10 -> 1.11 --- Log message: try again --- Diffs of the changes: (+4 -4) index.html | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.10 llvm-www/devmtg/2009-10/index.html:1.11 --- llvm-www/devmtg/2009-10/index.html:1.10 Wed Oct 14 18:30:50 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 18:31:24 2009 @@ -72,11 +72,11 @@ -
        - [Slides]
        + + [Slides]

        [Video(Computer) [Video(Mobile) -

        + Anton Korobeynikov
        Saint Petersburg State University Tutorial: Building backend in 24 hours - A step by step tutorial to @@ -252,7 +252,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/14 23:30:50 $ +
        Last modified: $Date: 2009/10/14 23:31:24 $ From evan.cheng at apple.com Wed Oct 14 18:37:31 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 23:37:31 -0000 Subject: [llvm-commits] [llvm] r84152 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp Message-ID: <200910142337.n9ENbVlh029614@zion.cs.uiuc.edu> Author: evancheng Date: Wed Oct 14 18:37:31 2009 New Revision: 84152 URL: http://llvm.org/viewvc/llvm-project?rev=84152&view=rev Log: Print earlyclobber for implicit-defs as well. Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=84152&r1=84151&r2=84152&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Wed Oct 14 18:37:31 2009 @@ -212,17 +212,17 @@ isEarlyClobber()) { OS << '<'; bool NeedComma = false; - if (isImplicit()) { - if (NeedComma) OS << ','; - OS << (isDef() ? "imp-def" : "imp-use"); - NeedComma = true; - } else if (isDef()) { + if (isDef()) { if (NeedComma) OS << ','; if (isEarlyClobber()) OS << "earlyclobber,"; + if (isImplicit()) + OS << "imp-"; OS << "def"; NeedComma = true; - } + } else if (isImplicit()) + OS << "imp-use"; + if (isKill() || isDead() || isUndef()) { if (NeedComma) OS << ','; if (isKill()) OS << "kill"; From sabre at nondot.org Wed Oct 14 18:39:04 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 18:39:04 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910142339.n9ENd4fD029689@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.11 -> 1.12 --- Log message: add Evan's info --- Diffs of the changes: (+3 -3) index.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.11 llvm-www/devmtg/2009-10/index.html:1.12 --- llvm-www/devmtg/2009-10/index.html:1.11 Wed Oct 14 18:31:24 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 18:38:48 2009 @@ -228,9 +228,9 @@ - + [Waiting for Slides] -
        + Evan Phoenix
        Engine Yard Accelerating Ruby with LLVM - Rubinius is a ruby VM that strives to write as much of the system in ruby itself as it can. To make this practical, we're using LLVM to JIT frequently used methods. I'll cover briefly the architecture of Rubinius, spending most of the time discussing the integration points. These include: Background compilation, runtime profile guide optimization, efficient IR generation, etc. @@ -252,7 +252,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/14 23:31:24 $ +
        Last modified: $Date: 2009/10/14 23:38:48 $ From evan.cheng at apple.com Wed Oct 14 18:39:28 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 23:39:28 -0000 Subject: [llvm-commits] [llvm] r84153 - in /llvm/trunk: lib/CodeGen/LiveVariables.cpp test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll Message-ID: <200910142339.n9ENdSAw029711@zion.cs.uiuc.edu> Author: evancheng Date: Wed Oct 14 18:39:27 2009 New Revision: 84153 URL: http://llvm.org/viewvc/llvm-project?rev=84153&view=rev Log: When LiveVariables is adding implicit-def to model "partial dead", add the earlyclobber marker if the superreg def has it. Added: llvm/trunk/test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=84153&r1=84152&r2=84153&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Wed Oct 14 18:39:27 2009 @@ -323,10 +323,21 @@ // The last partial def kills the register. LastPartDef->addOperand(MachineOperand::CreateReg(Reg, false/*IsDef*/, true/*IsImp*/, true/*IsKill*/)); - else + else { + MachineOperand *MO = + LastRefOrPartRef->findRegisterDefOperand(Reg, false, TRI); + bool NeedEC = MO->isEarlyClobber() && MO->getReg() != Reg; // If the last reference is the last def, then it's not used at all. // That is, unless we are currently processing the last reference itself. LastRefOrPartRef->addRegisterDead(Reg, TRI, true); + if (NeedEC) { + // If we are adding a subreg def and the superreg def is marked early + // clobber, add an early clobber marker to the subreg def. + MO = LastRefOrPartRef->findRegisterDefOperand(Reg); + if (MO) + MO->setIsEarlyClobber(); + } + } } else if (!PhysRegUse[Reg]) { // Partial uses. Mark register def dead and add implicit def of // sub-registers which are used. Added: llvm/trunk/test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll?rev=84153&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll (added) +++ llvm/trunk/test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll Wed Oct 14 18:39:27 2009 @@ -0,0 +1,15 @@ +; RUN: llc < %s -mtriple=i386-apple-darwin +; rdar://7299435 + + at i = internal global i32 0 ; [#uses=1] + at llvm.used = appending global [1 x i8*] [i8* bitcast (void (i16)* @foo to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0] + +define void @foo(i16 signext %source) nounwind ssp { +entry: + %source_addr = alloca i16, align 2 ; [#uses=2] + store i16 %source, i16* %source_addr + store i32 4, i32* @i, align 4 + call void asm sideeffect "# top of block", "~{dirflag},~{fpsr},~{flags},~{edi},~{esi},~{edx},~{ecx},~{eax}"() nounwind + %asmtmp = call i16 asm sideeffect "movw $1, $0", "=={ax},*m,~{dirflag},~{fpsr},~{flags},~{memory}"(i16* %source_addr) nounwind ; [#uses=0] + ret void +} From sabre at nondot.org Wed Oct 14 18:40:00 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 18:40:00 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910142340.n9ENe0i6029761@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.12 -> 1.13 --- Log message: waiting for slides. --- Diffs of the changes: (+3 -3) index.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.12 llvm-www/devmtg/2009-10/index.html:1.13 --- llvm-www/devmtg/2009-10/index.html:1.12 Wed Oct 14 18:38:48 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 18:39:44 2009 @@ -126,7 +126,7 @@ - + [Waiting for Slides] Bruno Cardoso Lopes
        University of Campinas Object Code Emission and llvm-mc - @@ -136,7 +136,7 @@ - + [Waiting for Slides] David Greene
        Cray LLVM on 180k Cores - @@ -252,7 +252,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/14 23:38:48 $ +
        Last modified: $Date: 2009/10/14 23:39:44 $ From sabre at nondot.org Wed Oct 14 19:04:34 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 19:04:34 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910150004.n9F04Ycb030712@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.13 -> 1.14 --- Log message: add Nicolas Geoffray's videos --- Diffs of the changes: (+4 -2) index.html | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.13 llvm-www/devmtg/2009-10/index.html:1.14 --- llvm-www/devmtg/2009-10/index.html:1.13 Wed Oct 14 18:39:44 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 19:03:28 2009 @@ -86,7 +86,9 @@ - [Slides] + [Slides]

        + [Video(Computer) + [Video(Mobile) Nicolas Geoffray
        Universite Pierre et Marie Curie Precise and efficient garbage collection in VMKit with MMTk - @@ -252,7 +254,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/14 23:39:44 $ +
        Last modified: $Date: 2009/10/15 00:03:28 $ From sabre at nondot.org Wed Oct 14 19:23:07 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 19:23:07 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/Lopes_ObjectCodeEmission.pdf index.html Message-ID: <200910150023.n9F0N7K8031421@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: Lopes_ObjectCodeEmission.pdf added (r1.1) index.html updated: 1.14 -> 1.15 --- Log message: add Bruno's slides. --- Diffs of the changes: (+2 -2) Lopes_ObjectCodeEmission.pdf | 0 index.html | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-www/devmtg/2009-10/Lopes_ObjectCodeEmission.pdf Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.14 llvm-www/devmtg/2009-10/index.html:1.15 --- llvm-www/devmtg/2009-10/index.html:1.14 Wed Oct 14 19:03:28 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 19:22:36 2009 @@ -128,7 +128,7 @@ - [Waiting for Slides] + [Slides] Bruno Cardoso Lopes
        University of Campinas Object Code Emission and llvm-mc - @@ -254,7 +254,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 00:03:28 $ +
        Last modified: $Date: 2009/10/15 00:22:36 $ From gohman at apple.com Wed Oct 14 19:36:23 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 15 Oct 2009 00:36:23 -0000 Subject: [llvm-commits] [llvm] r84158 - in /llvm/trunk: lib/CodeGen/CodePlacementOpt.cpp test/CodeGen/X86/avoid-loop-align-2.ll test/CodeGen/X86/avoid-loop-align.ll Message-ID: <200910150036.n9F0aNZF031889@zion.cs.uiuc.edu> Author: djg Date: Wed Oct 14 19:36:22 2009 New Revision: 84158 URL: http://llvm.org/viewvc/llvm-project?rev=84158&view=rev Log: Make CodePlacementOpt align loops, rather than loop headers. The header is just the entry block to the loop, and it needn't be at the top of the loop in the code layout. Remove the code that suppressed loop alignment for outer loops, so that outer loops are aligned. Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp llvm/trunk/test/CodeGen/X86/avoid-loop-align-2.ll llvm/trunk/test/CodeGen/X86/avoid-loop-align.ll Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=84158&r1=84157&r2=84158&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Wed Oct 14 19:36:22 2009 @@ -24,7 +24,7 @@ #include "llvm/ADT/Statistic.h" using namespace llvm; -STATISTIC(NumHeaderAligned, "Number of loop header aligned"); +STATISTIC(NumLoopsAligned, "Number of loops aligned"); STATISTIC(NumIntraElim, "Number of intra loop branches eliminated"); STATISTIC(NumIntraMoved, "Number of intra loop branches moved"); @@ -42,9 +42,6 @@ SmallVector, 4> UncondJmpMBBs; - /// LoopHeaders - A list of BBs which are loop headers. - SmallVector LoopHeaders; - public: static char ID; CodePlacementOpt() : MachineFunctionPass(&ID) {} @@ -62,9 +59,8 @@ private: bool OptimizeIntraLoopEdges(); - bool HeaderShouldBeAligned(MachineBasicBlock *MBB, MachineLoop *L, - SmallPtrSet &DoNotAlign); bool AlignLoops(MachineFunction &MF); + bool AlignLoop(MachineFunction &MF, MachineLoop *L, unsigned Align); }; char CodePlacementOpt::ID = 0; @@ -233,57 +229,12 @@ ChangedMBBs.insert(FtMBB); } Changed = true; - - // If BB is the loop latch, we may have a new loop headr. - if (MBB == L->getLoopLatch()) { - assert(MLI->isLoopHeader(SuccMBB) && - "Only succ of loop latch is not the header?"); - if (HasOneIntraSucc && IntraSucc) - std::replace(LoopHeaders.begin(),LoopHeaders.end(), SuccMBB, IntraSucc); - } } ++NumIntraMoved; return Changed; } -/// HeaderShouldBeAligned - Return true if the specified loop header block -/// should be aligned. For now, we will not align it if all the predcessors -/// (i.e. loop back edges) are laid out above the header. FIXME: Do not -/// align small loops. -bool -CodePlacementOpt::HeaderShouldBeAligned(MachineBasicBlock *MBB, MachineLoop *L, - SmallPtrSet &DoNotAlign) { - if (DoNotAlign.count(MBB)) - return false; - - bool BackEdgeBelow = false; - for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(), - PE = MBB->pred_end(); PI != PE; ++PI) { - MachineBasicBlock *PredMBB = *PI; - if (PredMBB == MBB || PredMBB->getNumber() > MBB->getNumber()) { - BackEdgeBelow = true; - break; - } - } - - if (!BackEdgeBelow) - return false; - - // Ok, we are going to align this loop header. If it's an inner loop, - // do not align its outer loop. - MachineBasicBlock *PreHeader = L->getLoopPreheader(); - if (PreHeader) { - MachineLoop *L = MLI->getLoopFor(PreHeader); - if (L) { - MachineBasicBlock *HeaderBlock = L->getHeader(); - HeaderBlock->setAlignment(0); - DoNotAlign.insert(HeaderBlock); - } - } - return true; -} - /// AlignLoops - Align loop headers to target preferred alignments. /// bool CodePlacementOpt::AlignLoops(MachineFunction &MF) { @@ -295,26 +246,37 @@ if (!Align) return false; // Don't care about loop alignment. - // Make sure blocks are numbered in order - MF.RenumberBlocks(); + bool Changed = false; + + for (MachineLoopInfo::iterator I = MLI->begin(), E = MLI->end(); + I != E; ++I) + Changed |= AlignLoop(MF, *I, Align); + + return Changed; +} +bool CodePlacementOpt::AlignLoop(MachineFunction &MF, MachineLoop *L, + unsigned Align) { bool Changed = false; - SmallPtrSet DoNotAlign; - for (unsigned i = 0, e = LoopHeaders.size(); i != e; ++i) { - MachineBasicBlock *HeaderMBB = LoopHeaders[i]; - MachineBasicBlock *PredMBB = prior(MachineFunction::iterator(HeaderMBB)); - MachineLoop *L = MLI->getLoopFor(HeaderMBB); - if (L == MLI->getLoopFor(PredMBB)) - // If previously BB is in the same loop, don't align this BB. We want - // to prevent adding noop's inside a loop. - continue; - if (HeaderShouldBeAligned(HeaderMBB, L, DoNotAlign)) { - HeaderMBB->setAlignment(Align); - Changed = true; - ++NumHeaderAligned; - } + + // Do alignment for nested loops. + for (MachineLoop::iterator I = L->begin(), E = L->end(); I != E; ++I) + Changed |= AlignLoop(MF, *I, Align); + + MachineBasicBlock *TopMBB = L->getHeader(); + if (TopMBB == MF.begin()) return Changed; + + MachineBasicBlock *PredMBB = prior(MachineFunction::iterator(TopMBB)); + while (MLI->getLoopFor(PredMBB) == L) { + TopMBB = PredMBB; + if (TopMBB == MF.begin()) return Changed; + PredMBB = prior(MachineFunction::iterator(TopMBB)); } + TopMBB->setAlignment(Align); + Changed = true; + ++NumLoopsAligned; + return Changed; } @@ -326,7 +288,7 @@ TLI = MF.getTarget().getTargetLowering(); TII = MF.getTarget().getInstrInfo(); - // Analyze the BBs first and keep track of loop headers and BBs that + // Analyze the BBs first and keep track of BBs that // end with an unconditional jmp to another block in the same loop. for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { MachineBasicBlock *MBB = I; @@ -335,8 +297,6 @@ MachineLoop *L = MLI->getLoopFor(MBB); if (!L) continue; - if (MLI->isLoopHeader(MBB)) - LoopHeaders.push_back(MBB); MachineBasicBlock *TBB = 0, *FBB = 0; SmallVector Cond; @@ -352,7 +312,6 @@ ChangedMBBs.clear(); UncondJmpMBBs.clear(); - LoopHeaders.clear(); return Changed; } Modified: llvm/trunk/test/CodeGen/X86/avoid-loop-align-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avoid-loop-align-2.ll?rev=84158&r1=84157&r2=84158&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/avoid-loop-align-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/avoid-loop-align-2.ll Wed Oct 14 19:36:22 2009 @@ -1,4 +1,8 @@ -; RUN: llc < %s -march=x86 | grep align | count 3 +; RUN: llc < %s -march=x86 | grep align | count 4 + +; TODO: Is it a good idea to align inner loops? It's hard to know without +; knowing what their trip counts are, or other dynamic information. For +; now, CodeGen aligns all loops. @x = external global i32* ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/avoid-loop-align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avoid-loop-align.ll?rev=84158&r1=84157&r2=84158&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/avoid-loop-align.ll (original) +++ llvm/trunk/test/CodeGen/X86/avoid-loop-align.ll Wed Oct 14 19:36:22 2009 @@ -1,4 +1,11 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin | grep align | count 1 +; RUN: llc < %s -mtriple=i386-apple-darwin | FileCheck %s + +; CodeGen should align the top of the loop, which differs from the loop +; header in this case. + +; CHECK: jmp LBB1_2 +; CHECK: .align +; CHECK: LBB1_1: @A = common global [100 x i32] zeroinitializer, align 32 ; <[100 x i32]*> [#uses=1] From nicholas at mxc.ca Wed Oct 14 19:36:35 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 15 Oct 2009 00:36:35 -0000 Subject: [llvm-commits] [llvm] r84159 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200910150036.n9F0aaWY031906@zion.cs.uiuc.edu> Author: nicholas Date: Wed Oct 14 19:36:35 2009 New Revision: 84159 URL: http://llvm.org/viewvc/llvm-project?rev=84159&view=rev Log: Take advantage of TargetData when available; we know that the atomic intrinsics only dereference the element they point to directly with no pointer arithmetic. Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84159&r1=84158&r2=84159&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Wed Oct 14 19:36:35 2009 @@ -307,24 +307,29 @@ return NoModRef; } - if (IntrinsicInst *II = dyn_cast(CS.getInstruction())) { - switch (II->getIntrinsicID()) { - default: break; - case Intrinsic::atomic_cmp_swap: - case Intrinsic::atomic_swap: - case Intrinsic::atomic_load_add: - case Intrinsic::atomic_load_sub: - case Intrinsic::atomic_load_and: - case Intrinsic::atomic_load_nand: - case Intrinsic::atomic_load_or: - case Intrinsic::atomic_load_xor: - case Intrinsic::atomic_load_max: - case Intrinsic::atomic_load_min: - case Intrinsic::atomic_load_umax: - case Intrinsic::atomic_load_umin: - if (alias(II->getOperand(1), Size, P, Size) == NoAlias) - return NoModRef; - break; + if (TD) { + if (IntrinsicInst *II = dyn_cast(CS.getInstruction())) { + switch (II->getIntrinsicID()) { + default: break; + case Intrinsic::atomic_cmp_swap: + case Intrinsic::atomic_swap: + case Intrinsic::atomic_load_add: + case Intrinsic::atomic_load_sub: + case Intrinsic::atomic_load_and: + case Intrinsic::atomic_load_nand: + case Intrinsic::atomic_load_or: + case Intrinsic::atomic_load_xor: + case Intrinsic::atomic_load_max: + case Intrinsic::atomic_load_min: + case Intrinsic::atomic_load_umax: + case Intrinsic::atomic_load_umin: { + Value *Op1 = II->getOperand(1); + unsigned Op1Size = TD->getTypeStoreSize(Op1->getType()); + if (alias(Op1, Op1Size, P, Size) == NoAlias) + return NoModRef; + break; + } + } } } } From sabre at nondot.org Wed Oct 14 19:47:43 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 19:47:43 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910150047.n9F0lhHx032276@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.15 -> 1.16 --- Log message: add colin winter's videos --- Diffs of the changes: (+5 -3) index.html | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.15 llvm-www/devmtg/2009-10/index.html:1.16 --- llvm-www/devmtg/2009-10/index.html:1.15 Wed Oct 14 19:22:36 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 19:46:46 2009 @@ -98,7 +98,9 @@ - [Slides] + [Slides]

        + [Video(Computer) + [Video(Mobile) Colin Winter
        Google Unladen Swallow: Python on LLVM - @@ -209,7 +211,7 @@ [Slides] - [PPT Slides] + [Slides(.ppt) Santosh Nagarakatte
        University of Pennsylvania SoftBound: Highly Compatible and Complete Spatial Memory Safety for C - @@ -254,7 +256,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 00:22:36 $ +
        Last modified: $Date: 2009/10/15 00:46:46 $ From sabre at nondot.org Wed Oct 14 22:45:48 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 22:45:48 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910150345.n9F3jmIl005731@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.16 -> 1.17 --- Log message: add a bunch more videos. --- Diffs of the changes: (+22 -9) index.html | 31 ++++++++++++++++++++++--------- 1 files changed, 22 insertions(+), 9 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.16 llvm-www/devmtg/2009-10/index.html:1.17 --- llvm-www/devmtg/2009-10/index.html:1.16 Wed Oct 14 19:46:46 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 22:43:54 2009 @@ -110,7 +110,9 @@ - [Slides] + [Slides]

        + [Video(Computer) + [Video(Mobile) Duncan Sands
        Deep Blue Capital Reimplementing llvm-gcc as a gcc plugin - @@ -130,7 +132,9 @@ - [Slides] + [Slides]

        + [Video(Computer) + [Video(Mobile) Bruno Cardoso Lopes
        University of Campinas Object Code Emission and llvm-mc - @@ -150,7 +154,9 @@ - [Slides] + [Slides]

        + [Video(Computer) + [Video(Mobile) Cristina Cifuentes
        Sun Microsystems The Parfait Bug-Checker - @@ -170,7 +176,9 @@ - [Slides] + [Slides]

        + Richard Osborne
        XMOS Targeting XCore resources from LLVM - @@ -190,7 +198,9 @@ - [Slides] + [Slides]

        + Anna Zaks
        New York University CoVaC: Compiler Validation by Program Analysis of the Cross-Product - @@ -211,7 +221,9 @@ [Slides] - [Slides(.ppt) + [Slides(.ppt)

        + Santosh Nagarakatte
        University of Pennsylvania SoftBound: Highly Compatible and Complete Spatial Memory Safety for C - @@ -232,7 +244,7 @@ - [Waiting for Slides] + [Waiting for Slides]

        Evan Phoenix
        Engine Yard Accelerating Ruby with LLVM @@ -244,7 +256,8 @@

        -

        Insert blurb about attendees. +

        We had approximately 170 attendees with a huge range of different +affiliations.

        @@ -256,7 +269,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 00:46:46 $ +
        Last modified: $Date: 2009/10/15 03:43:54 $ From sabre at nondot.org Wed Oct 14 23:13:44 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 15 Oct 2009 04:13:44 -0000 Subject: [llvm-commits] [llvm] r84170 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200910150413.n9F4DjYb006698@zion.cs.uiuc.edu> Author: lattner Date: Wed Oct 14 23:13:44 2009 New Revision: 84170 URL: http://llvm.org/viewvc/llvm-project?rev=84170&view=rev Log: don't bother calling ConstantFoldInstruction unless there is a use of the instruction (which disqualifies stores, unreachable, etc) and at least the first operand is a constant. This filters out a lot of obvious cases that can't be folded. Also, switch the IRBuilder to a TargetFolder, which tries harder. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84170&r1=84169&r2=84170&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed Oct 14 23:13:44 2009 @@ -56,6 +56,7 @@ #include "llvm/Support/IRBuilder.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/PatternMatch.h" +#include "llvm/Support/TargetFolder.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -186,7 +187,7 @@ /// Builder - This is an IRBuilder that automatically inserts new /// instructions into the worklist when they are created. - typedef IRBuilder BuilderTy; + typedef IRBuilder BuilderTy; BuilderTy *Builder; static char ID; // Pass identification, replacement for typeid @@ -12704,14 +12705,15 @@ } // ConstantProp instruction if trivially constant. - if (Constant *C = ConstantFoldInstruction(Inst, BB->getContext(), TD)) { - DEBUG(errs() << "IC: ConstFold to: " << *C << " from: " - << *Inst << '\n'); - Inst->replaceAllUsesWith(C); - ++NumConstProp; - Inst->eraseFromParent(); - continue; - } + if (!Inst->use_empty() && isa(Inst->getOperand(0))) + if (Constant *C = ConstantFoldInstruction(Inst, BB->getContext(), TD)) { + DEBUG(errs() << "IC: ConstFold to: " << *C << " from: " + << *Inst << '\n'); + Inst->replaceAllUsesWith(C); + ++NumConstProp; + Inst->eraseFromParent(); + continue; + } InstrsForInstCombineWorklist.push_back(Inst); } @@ -12757,7 +12759,6 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) { MadeIRChange = false; - TD = getAnalysisIfAvailable(); DEBUG(errs() << "\n\nINSTCOMBINE ITERATION #" << Iteration << " on " << F.getNameStr() << "\n"); @@ -12810,16 +12811,17 @@ } // Instruction isn't dead, see if we can constant propagate it. - if (Constant *C = ConstantFoldInstruction(I, F.getContext(), TD)) { - DEBUG(errs() << "IC: ConstFold to: " << *C << " from: " << *I << '\n'); + if (!I->use_empty() && isa(I->getOperand(0))) + if (Constant *C = ConstantFoldInstruction(I, F.getContext(), TD)) { + DEBUG(errs() << "IC: ConstFold to: " << *C << " from: " << *I << '\n'); - // Add operands to the worklist. - ReplaceInstUsesWith(*I, C); - ++NumConstProp; - EraseInstFromFunction(*I); - MadeIRChange = true; - continue; - } + // Add operands to the worklist. + ReplaceInstUsesWith(*I, C); + ++NumConstProp; + EraseInstFromFunction(*I); + MadeIRChange = true; + continue; + } if (TD) { // See if we can constant fold its operands. @@ -12927,12 +12929,13 @@ bool InstCombiner::runOnFunction(Function &F) { MustPreserveLCSSA = mustPreserveAnalysisID(LCSSAID); Context = &F.getContext(); - + TD = getAnalysisIfAvailable(); + /// Builder - This is an IRBuilder that automatically inserts new /// instructions into the worklist when they are created. - IRBuilder - TheBuilder(F.getContext(), ConstantFolder(F.getContext()), + IRBuilder + TheBuilder(F.getContext(), TargetFolder(TD, F.getContext()), InstCombineIRInserter(Worklist)); Builder = &TheBuilder; From sabre at nondot.org Wed Oct 14 23:22:27 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 23:22:27 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910150422.n9F4MRfr007027@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.17 -> 1.18 --- Log message: add richard's talk, rename some videos --- Diffs of the changes: (+7 -5) index.html | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.17 llvm-www/devmtg/2009-10/index.html:1.18 --- llvm-www/devmtg/2009-10/index.html:1.17 Wed Oct 14 22:43:54 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 23:21:22 2009 @@ -75,7 +75,7 @@ [Slides]

        [Video(Computer) - [Video(Mobile) + [Video(Mobile) Anton Korobeynikov
        Saint Petersburg State University @@ -88,7 +88,7 @@ [Slides]

        [Video(Computer) - [Video(Mobile) + [Video(Mobile) Nicolas Geoffray
        Universite Pierre et Marie Curie Precise and efficient garbage collection in VMKit with MMTk - @@ -177,8 +177,8 @@ [Slides]

        - + [Video(Computer) + [Video(Mobile) Richard Osborne
        XMOS Targeting XCore resources from LLVM - @@ -245,6 +245,8 @@ [Waiting for Slides]

        + Evan Phoenix
        Engine Yard Accelerating Ruby with LLVM @@ -269,7 +271,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 03:43:54 $ +
        Last modified: $Date: 2009/10/15 04:21:22 $ From nicholas at mxc.ca Wed Oct 14 23:36:48 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 14 Oct 2009 21:36:48 -0700 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html In-Reply-To: <200910150422.n9F4MRfr007027@zion.cs.uiuc.edu> References: <200910150422.n9F4MRfr007027@zion.cs.uiuc.edu> Message-ID: <4AD6A6E0.9070500@mxc.ca> Chris Lattner wrote: > > Changes in directory llvm-www/devmtg/2009-10: > > index.html updated: 1.17 -> 1.18 > --- > Log message: > > add richard's talk, rename some videos > > > --- > Diffs of the changes: (+7 -5) > > index.html | 12 +++++++----- > 1 files changed, 7 insertions(+), 5 deletions(-) > > > Index: llvm-www/devmtg/2009-10/index.html > diff -u llvm-www/devmtg/2009-10/index.html:1.17 llvm-www/devmtg/2009-10/index.html:1.18 > --- llvm-www/devmtg/2009-10/index.html:1.17 Wed Oct 14 22:43:54 2009 > +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 23:21:22 2009 > @@ -75,7 +75,7 @@ > > [Slides]

        > [Video(Computer) > - [Video(Mobile) > + [Video(Mobile) > > Anton Korobeynikov
        Saint Petersburg State University > > @@ -88,7 +88,7 @@ > > [Slides]

        > [Video(Computer) > - [Video(Mobile) > + [Video(Mobile) > > Nicolas Geoffray
        Universite Pierre et Marie Curie > Precise and efficient garbage collection in VMKit with MMTk - > @@ -177,8 +177,8 @@ > > > [Slides]

        > - > + [Video(Computer) > + [Video(Mobile) > > Richard Osborne
        XMOS > Targeting XCore resources from LLVM - > @@ -245,6 +245,8 @@ > > > [Waiting for Slides]

        > + Typo: rubinius Nick > > Evan Phoenix
        Engine Yard > Accelerating Ruby with LLVM > @@ -269,7 +271,7 @@ > src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> > src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"> > -
        Last modified: $Date: 2009/10/15 03:43:54 $ > +
        Last modified: $Date: 2009/10/15 04:21:22 $ > > > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Wed Oct 14 23:47:45 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 14 Oct 2009 23:47:45 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910150447.n9F4liP8007768@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.18 -> 1.19 --- Log message: Add Santosh's videos --- Diffs of the changes: (+3 -3) index.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.18 llvm-www/devmtg/2009-10/index.html:1.19 --- llvm-www/devmtg/2009-10/index.html:1.18 Wed Oct 14 23:21:22 2009 +++ llvm-www/devmtg/2009-10/index.html Wed Oct 14 23:45:49 2009 @@ -222,8 +222,8 @@ [Slides] [Slides(.ppt)

        - + [Video(Computer) + [Video(Mobile) Santosh Nagarakatte
        University of Pennsylvania SoftBound: Highly Compatible and Complete Spatial Memory Safety for C - @@ -271,7 +271,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 04:21:22 $ +
        Last modified: $Date: 2009/10/15 04:45:49 $ From sabre at nondot.org Wed Oct 14 23:59:29 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 15 Oct 2009 04:59:29 -0000 Subject: [llvm-commits] [llvm] r84171 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200910150459.n9F4xU8k008183@zion.cs.uiuc.edu> Author: lattner Date: Wed Oct 14 23:59:28 2009 New Revision: 84171 URL: http://llvm.org/viewvc/llvm-project?rev=84171&view=rev Log: only try to fold constantexpr operands when the worklist is first populated, don't bother every time going around the main worklist. This speeds up a release-asserts opt -std-compile-opts on 403.gcc by about 4% (1.5s). It seems to speed up the most expensive instances of instcombine by ~10%. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84171&r1=84170&r2=84171&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed Oct 14 23:59:28 2009 @@ -12676,16 +12676,19 @@ /// many instructions are dead or constant). Additionally, if we find a branch /// whose condition is a known constant, we only visit the reachable successors. /// -static void AddReachableCodeToWorklist(BasicBlock *BB, +static bool AddReachableCodeToWorklist(BasicBlock *BB, SmallPtrSet &Visited, InstCombiner &IC, const TargetData *TD) { + bool MadeIRChange = false; SmallVector Worklist; Worklist.push_back(BB); std::vector InstrsForInstCombineWorklist; InstrsForInstCombineWorklist.reserve(128); + SmallPtrSet FoldedConstants; + while (!Worklist.empty()) { BB = Worklist.back(); Worklist.pop_back(); @@ -12714,6 +12717,29 @@ Inst->eraseFromParent(); continue; } + + + + if (TD) { + // See if we can constant fold its operands. + for (User::op_iterator i = Inst->op_begin(), e = Inst->op_end(); + i != e; ++i) { + ConstantExpr *CE = dyn_cast(i); + if (CE == 0) continue; + + // If we already folded this constant, don't try again. + if (!FoldedConstants.insert(CE)) + continue; + + Constant *NewC = + ConstantFoldConstantExpression(CE, BB->getContext(), TD); + if (NewC && NewC != CE) { + *i = NewC; + MadeIRChange = true; + } + } + } + InstrsForInstCombineWorklist.push_back(Inst); } @@ -12755,6 +12781,8 @@ // some N^2 behavior in pathological cases. IC.Worklist.AddInitialGroup(&InstrsForInstCombineWorklist[0], InstrsForInstCombineWorklist.size()); + + return MadeIRChange; } bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) { @@ -12768,7 +12796,7 @@ // the reachable instructions. Ignore blocks that are not reachable. Keep // track of which blocks we visit. SmallPtrSet Visited; - AddReachableCodeToWorklist(F.begin(), Visited, *this, TD); + MadeIRChange |= AddReachableCodeToWorklist(F.begin(), Visited, *this, TD); // Do a quick scan over the function. If we find any blocks that are // unreachable, remove any instructions inside of them. This prevents @@ -12787,7 +12815,6 @@ MadeIRChange = true; } - // If I is not void type then replaceAllUsesWith undef. // This allows ValueHandlers and custom metadata to adjust itself. if (!I->getType()->isVoidTy()) @@ -12823,18 +12850,6 @@ continue; } - if (TD) { - // See if we can constant fold its operands. - for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i) - if (ConstantExpr *CE = dyn_cast(i)) - if (Constant *NewC = ConstantFoldConstantExpression(CE, - F.getContext(), TD)) - if (NewC != CE) { - *i = NewC; - MadeIRChange = true; - } - } - // See if we can trivially sink this instruction to a successor basic block. if (I->hasOneUse()) { BasicBlock *BB = I->getParent(); From bob.wilson at apple.com Thu Oct 15 00:10:36 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 15 Oct 2009 05:10:36 -0000 Subject: [llvm-commits] [llvm] r84172 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910150510.n9F5AaL1008503@zion.cs.uiuc.edu> Author: bwilson Date: Thu Oct 15 00:10:36 2009 New Revision: 84172 URL: http://llvm.org/viewvc/llvm-project?rev=84172&view=rev Log: Fix another problem with ARM constant pools. Radar 7303551. When ARMConstantIslandPass cannot find any good locations (i.e., "water") to place constants, it falls back to inserting unconditional branches to make a place to put them. My recent change exposed a problem in this area. We may sometimes append to the same block more than one unconditional branch. The symptoms of this are that the generated assembly has a branch to an undefined label and running llc with -debug will cause a seg fault. This happens more easily since my change to prevent CPEs from moving from lower to higher addresses as the algorithm iterates, but it could have happened before. The end of the block may be in range for various constant pool references, but the insertion point for new CPEs is not right at the end of the block -- it is at the end of the CPEs that have already been placed at the end of the block. The insertion point could be out of range. When that happens, the fallback code will always append another unconditional branch if the end of the block is in range. The fix is to only append an unconditional branch if the block does not already end with one. I also removed a check to see if the constant pool load instruction is at the end of the block, since that is redundant with checking if the end of the block is in-range. There is more to be done here, but I think this fixes the immediate problem. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=84172&r1=84171&r2=84172&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Oct 15 00:10:36 2009 @@ -1006,14 +1006,12 @@ BBSizes[UserMBB->getNumber()]; assert(OffsetOfNextBlock== BBOffsets[UserMBB->getNumber()+1]); - // If the use is at the end of the block, or the end of the block - // is within range, make new water there. (The addition below is - // for the unconditional branch we will be adding: 4 bytes on ARM + Thumb2, - // 2 on Thumb1. Possible Thumb1 alignment padding is allowed for + // If the block does not end in an unconditional branch already, and if the + // end of the block is within range, make new water there. (The addition + // below is for the unconditional branch we will be adding: 4 bytes on ARM + + // Thumb2, 2 on Thumb1. Possible Thumb1 alignment padding is allowed for // inside OffsetIsInRange. - // If the block ends in an unconditional branch already, it is water, - // and is known to be out of range, so we'll always be adding a branch.) - if (&UserMBB->back() == UserMI || + if (BBHasFallthrough(UserMBB) && OffsetIsInRange(UserOffset, OffsetOfNextBlock + (isThumb1 ? 2: 4), U.MaxDisp, U.NegOk, U.IsSoImm)) { DEBUG(errs() << "Split at end of block\n"); From evan.cheng at apple.com Thu Oct 15 00:33:24 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 14 Oct 2009 22:33:24 -0700 Subject: [llvm-commits] [llvm] r84158 - in /llvm/trunk: lib/CodeGen/CodePlacementOpt.cpp test/CodeGen/X86/avoid-loop-align-2.ll test/CodeGen/X86/avoid-loop-align.ll In-Reply-To: <200910150036.n9F0aNZF031889@zion.cs.uiuc.edu> References: <200910150036.n9F0aNZF031889@zion.cs.uiuc.edu> Message-ID: On Oct 14, 2009, at 5:36 PM, Dan Gohman wrote: > Author: djg > Date: Wed Oct 14 19:36:22 2009 > New Revision: 84158 > > URL: http://llvm.org/viewvc/llvm-project?rev=84158&view=rev > Log: > Make CodePlacementOpt align loops, rather than loop headers. The > header is just the entry block to the loop, and it needn't be at > the top of the loop in the code layout. Thanks. This is aligning the destination of the back edge, right? Have you tested the performance and code size impact of this patch? Evan > > Remove the code that suppressed loop alignment for outer loops, > so that outer loops are aligned. > > Modified: > llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp > llvm/trunk/test/CodeGen/X86/avoid-loop-align-2.ll > llvm/trunk/test/CodeGen/X86/avoid-loop-align.ll > > Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=84158&r1=84157&r2=84158&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) > +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Wed Oct 14 19:36:22 2009 > @@ -24,7 +24,7 @@ > #include "llvm/ADT/Statistic.h" > using namespace llvm; > > -STATISTIC(NumHeaderAligned, "Number of loop header aligned"); > +STATISTIC(NumLoopsAligned, "Number of loops aligned"); > STATISTIC(NumIntraElim, "Number of intra loop branches eliminated"); > STATISTIC(NumIntraMoved, "Number of intra loop branches moved"); > > @@ -42,9 +42,6 @@ > SmallVector, 4> > UncondJmpMBBs; > > - /// LoopHeaders - A list of BBs which are loop headers. > - SmallVector LoopHeaders; > - > public: > static char ID; > CodePlacementOpt() : MachineFunctionPass(&ID) {} > @@ -62,9 +59,8 @@ > > private: > bool OptimizeIntraLoopEdges(); > - bool HeaderShouldBeAligned(MachineBasicBlock *MBB, MachineLoop *L, > - SmallPtrSet &DoNotAlign); > bool AlignLoops(MachineFunction &MF); > + bool AlignLoop(MachineFunction &MF, MachineLoop *L, unsigned Align); > }; > > char CodePlacementOpt::ID = 0; > @@ -233,57 +229,12 @@ > ChangedMBBs.insert(FtMBB); > } > Changed = true; > - > - // If BB is the loop latch, we may have a new loop headr. > - if (MBB == L->getLoopLatch()) { > - assert(MLI->isLoopHeader(SuccMBB) && > - "Only succ of loop latch is not the header?"); > - if (HasOneIntraSucc && IntraSucc) > - std::replace(LoopHeaders.begin(),LoopHeaders.end(), SuccMBB, IntraSucc); > - } > } > > ++NumIntraMoved; > return Changed; > } > > -/// HeaderShouldBeAligned - Return true if the specified loop header block > -/// should be aligned. For now, we will not align it if all the predcessors > -/// (i.e. loop back edges) are laid out above the header. FIXME: Do not > -/// align small loops. > -bool > -CodePlacementOpt::HeaderShouldBeAligned(MachineBasicBlock *MBB, MachineLoop *L, > - SmallPtrSet &DoNotAlign) { > - if (DoNotAlign.count(MBB)) > - return false; > - > - bool BackEdgeBelow = false; > - for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(), > - PE = MBB->pred_end(); PI != PE; ++PI) { > - MachineBasicBlock *PredMBB = *PI; > - if (PredMBB == MBB || PredMBB->getNumber() > MBB->getNumber()) { > - BackEdgeBelow = true; > - break; > - } > - } > - > - if (!BackEdgeBelow) > - return false; > - > - // Ok, we are going to align this loop header. If it's an inner loop, > - // do not align its outer loop. > - MachineBasicBlock *PreHeader = L->getLoopPreheader(); > - if (PreHeader) { > - MachineLoop *L = MLI->getLoopFor(PreHeader); > - if (L) { > - MachineBasicBlock *HeaderBlock = L->getHeader(); > - HeaderBlock->setAlignment(0); > - DoNotAlign.insert(HeaderBlock); > - } > - } > - return true; > -} > - > /// AlignLoops - Align loop headers to target preferred alignments. > /// > bool CodePlacementOpt::AlignLoops(MachineFunction &MF) { > @@ -295,26 +246,37 @@ > if (!Align) > return false; // Don't care about loop alignment. > > - // Make sure blocks are numbered in order > - MF.RenumberBlocks(); > + bool Changed = false; > + > + for (MachineLoopInfo::iterator I = MLI->begin(), E = MLI->end(); > + I != E; ++I) > + Changed |= AlignLoop(MF, *I, Align); > + > + return Changed; > +} > > +bool CodePlacementOpt::AlignLoop(MachineFunction &MF, MachineLoop *L, > + unsigned Align) { > bool Changed = false; > - SmallPtrSet DoNotAlign; > - for (unsigned i = 0, e = LoopHeaders.size(); i != e; ++i) { > - MachineBasicBlock *HeaderMBB = LoopHeaders[i]; > - MachineBasicBlock *PredMBB = prior(MachineFunction::iterator(HeaderMBB)); > - MachineLoop *L = MLI->getLoopFor(HeaderMBB); > - if (L == MLI->getLoopFor(PredMBB)) > - // If previously BB is in the same loop, don't align this BB. We want > - // to prevent adding noop's inside a loop. > - continue; > - if (HeaderShouldBeAligned(HeaderMBB, L, DoNotAlign)) { > - HeaderMBB->setAlignment(Align); > - Changed = true; > - ++NumHeaderAligned; > - } > + > + // Do alignment for nested loops. > + for (MachineLoop::iterator I = L->begin(), E = L->end(); I != E; ++I) > + Changed |= AlignLoop(MF, *I, Align); > + > + MachineBasicBlock *TopMBB = L->getHeader(); > + if (TopMBB == MF.begin()) return Changed; > + > + MachineBasicBlock *PredMBB = prior(MachineFunction::iterator(TopMBB)); > + while (MLI->getLoopFor(PredMBB) == L) { > + TopMBB = PredMBB; > + if (TopMBB == MF.begin()) return Changed; > + PredMBB = prior(MachineFunction::iterator(TopMBB)); > } > > + TopMBB->setAlignment(Align); > + Changed = true; > + ++NumLoopsAligned; > + > return Changed; > } > > @@ -326,7 +288,7 @@ > TLI = MF.getTarget().getTargetLowering(); > TII = MF.getTarget().getInstrInfo(); > > - // Analyze the BBs first and keep track of loop headers and BBs that > + // Analyze the BBs first and keep track of BBs that > // end with an unconditional jmp to another block in the same loop. > for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { > MachineBasicBlock *MBB = I; > @@ -335,8 +297,6 @@ > MachineLoop *L = MLI->getLoopFor(MBB); > if (!L) > continue; > - if (MLI->isLoopHeader(MBB)) > - LoopHeaders.push_back(MBB); > > MachineBasicBlock *TBB = 0, *FBB = 0; > SmallVector Cond; > @@ -352,7 +312,6 @@ > > ChangedMBBs.clear(); > UncondJmpMBBs.clear(); > - LoopHeaders.clear(); > > return Changed; > } > > Modified: llvm/trunk/test/CodeGen/X86/avoid-loop-align-2.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avoid-loop-align-2.ll?rev=84158&r1=84157&r2=84158&view=diff > > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/avoid-loop-align-2.ll (original) > +++ llvm/trunk/test/CodeGen/X86/avoid-loop-align-2.ll Wed Oct 14 19:36:22 2009 > @@ -1,4 +1,8 @@ > -; RUN: llc < %s -march=x86 | grep align | count 3 > +; RUN: llc < %s -march=x86 | grep align | count 4 > + > +; TODO: Is it a good idea to align inner loops? It's hard to know without > +; knowing what their trip counts are, or other dynamic information. For > +; now, CodeGen aligns all loops. > > @x = external global i32* ; [#uses=1] > > > Modified: llvm/trunk/test/CodeGen/X86/avoid-loop-align.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avoid-loop-align.ll?rev=84158&r1=84157&r2=84158&view=diff > > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/avoid-loop-align.ll (original) > +++ llvm/trunk/test/CodeGen/X86/avoid-loop-align.ll Wed Oct 14 19:36:22 2009 > @@ -1,4 +1,11 @@ > -; RUN: llc < %s -mtriple=i386-apple-darwin | grep align | count 1 > +; RUN: llc < %s -mtriple=i386-apple-darwin | FileCheck %s > + > +; CodeGen should align the top of the loop, which differs from the loop > +; header in this case. > + > +; CHECK: jmp LBB1_2 > +; CHECK: .align > +; CHECK: LBB1_1: > > @A = common global [100 x i32] zeroinitializer, align 32 ; <[100 x i32]*> [#uses=1] > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Thu Oct 15 00:36:44 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 15 Oct 2009 00:36:44 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910150536.n9F5aiHO009460@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.19 -> 1.20 --- Log message: add rubinius videos --- Diffs of the changes: (+3 -3) index.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.19 llvm-www/devmtg/2009-10/index.html:1.20 --- llvm-www/devmtg/2009-10/index.html:1.19 Wed Oct 14 23:45:49 2009 +++ llvm-www/devmtg/2009-10/index.html Thu Oct 15 00:35:37 2009 @@ -245,8 +245,8 @@ [Waiting for Slides]

        - + [Video(Computer) + [Video(Mobile) Evan Phoenix
        Engine Yard Accelerating Ruby with LLVM @@ -271,7 +271,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 04:45:49 $ +
        Last modified: $Date: 2009/10/15 05:35:37 $ From bob.wilson at apple.com Thu Oct 15 00:52:32 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 15 Oct 2009 05:52:32 -0000 Subject: [llvm-commits] [llvm] r84173 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910150552.n9F5qWOv009962@zion.cs.uiuc.edu> Author: bwilson Date: Thu Oct 15 00:52:29 2009 New Revision: 84173 URL: http://llvm.org/viewvc/llvm-project?rev=84173&view=rev Log: Be smarter about reusing constant pool entries. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=84173&r1=84172&r2=84173&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Oct 15 00:52:29 2009 @@ -74,16 +74,28 @@ /// CPUser - One user of a constant pool, keeping the machine instruction /// pointer, the constant pool being referenced, and the max displacement - /// allowed from the instruction to the CP. + /// allowed from the instruction to the CP. The HighWaterMark records the + /// highest basic block where a new CPEntry can be placed. To ensure this + /// pass terminates, the CP entries are initially placed at the end of the + /// function and then move monotonically to lower addresses. The + /// exception to this rule is when the current CP entry for a particular + /// CPUser is out of range, but there is another CP entry for the same + /// constant value in range. We want to use the existing in-range CP + /// entry, but if it later moves out of range, the search for new water + /// should resume where it left off. The HighWaterMark is used to record + /// that point. struct CPUser { MachineInstr *MI; MachineInstr *CPEMI; + MachineBasicBlock *HighWaterMark; unsigned MaxDisp; bool NegOk; bool IsSoImm; CPUser(MachineInstr *mi, MachineInstr *cpemi, unsigned maxdisp, bool neg, bool soimm) - : MI(mi), CPEMI(cpemi), MaxDisp(maxdisp), NegOk(neg), IsSoImm(soimm) {} + : MI(mi), CPEMI(cpemi), MaxDisp(maxdisp), NegOk(neg), IsSoImm(soimm) { + HighWaterMark = CPEMI->getParent(); + } }; /// CPUsers - Keep track of all of the machine instructions that use various @@ -962,8 +974,8 @@ B = WaterList.begin();; --IP) { MachineBasicBlock* WaterBB = *IP; // Check if water is in range and at a lower address than the current one. - if (WaterIsInRange(UserOffset, WaterBB, U) && - WaterBB->getNumber() < U.CPEMI->getParent()->getNumber()) { + if (WaterBB->getNumber() < U.HighWaterMark->getNumber() && + WaterIsInRange(UserOffset, WaterBB, U)) { unsigned WBBId = WaterBB->getNumber(); if (isThumb && (BBOffsets[WBBId] + BBSizes[WBBId])%4 != 0) { @@ -1129,6 +1141,7 @@ // Now that we have an island to add the CPE to, clone the original CPE and // add it to the island. + U.HighWaterMark = NewIsland; U.CPEMI = BuildMI(NewIsland, DebugLoc::getUnknownLoc(), TII->get(ARM::CONSTPOOL_ENTRY)) .addImm(ID).addConstantPoolIndex(CPI).addImm(Size); From sabre at nondot.org Thu Oct 15 01:00:28 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 15 Oct 2009 01:00:28 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910150600.n9F60SFB010213@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.20 -> 1.21 --- Log message: add scott peterson's talk --- Diffs of the changes: (+9 -3) index.html | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.20 llvm-www/devmtg/2009-10/index.html:1.21 --- llvm-www/devmtg/2009-10/index.html:1.20 Thu Oct 15 00:35:37 2009 +++ llvm-www/devmtg/2009-10/index.html Thu Oct 15 00:59:12 2009 @@ -144,7 +144,9 @@ - [Waiting for Slides] + [Waiting for Slides]

        + David Greene
        Cray LLVM on 180k Cores - @@ -166,7 +168,9 @@ - [Slides] + [Slides]

        + [Video(Computer) + [Video(Mobile) Scott Petersen
        Adobe Systems, Inc. Optimizing ActionScript Bytecode using LLVM - @@ -234,6 +238,8 @@ [Slides] + Vinod Grover
        NVIDIA PLANG: Translating NVIDIA PTX language to LLVM IR @@ -271,7 +277,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 05:35:37 $ +
        Last modified: $Date: 2009/10/15 05:59:12 $ From nicholas at mxc.ca Thu Oct 15 01:12:13 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 15 Oct 2009 06:12:13 -0000 Subject: [llvm-commits] [llvm] r84174 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200910150612.n9F6CEfp010584@zion.cs.uiuc.edu> Author: nicholas Date: Thu Oct 15 01:12:11 2009 New Revision: 84174 URL: http://llvm.org/viewvc/llvm-project?rev=84174&view=rev Log: Teach BasicAA to use the size parameter of the memory use marker intrinsics. Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84174&r1=84173&r2=84174&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Thu Oct 15 01:12:11 2009 @@ -307,29 +307,40 @@ return NoModRef; } - if (TD) { - if (IntrinsicInst *II = dyn_cast(CS.getInstruction())) { - switch (II->getIntrinsicID()) { - default: break; - case Intrinsic::atomic_cmp_swap: - case Intrinsic::atomic_swap: - case Intrinsic::atomic_load_add: - case Intrinsic::atomic_load_sub: - case Intrinsic::atomic_load_and: - case Intrinsic::atomic_load_nand: - case Intrinsic::atomic_load_or: - case Intrinsic::atomic_load_xor: - case Intrinsic::atomic_load_max: - case Intrinsic::atomic_load_min: - case Intrinsic::atomic_load_umax: - case Intrinsic::atomic_load_umin: { + if (IntrinsicInst *II = dyn_cast(CS.getInstruction())) { + switch (II->getIntrinsicID()) { + default: break; + case Intrinsic::atomic_cmp_swap: + case Intrinsic::atomic_swap: + case Intrinsic::atomic_load_add: + case Intrinsic::atomic_load_sub: + case Intrinsic::atomic_load_and: + case Intrinsic::atomic_load_nand: + case Intrinsic::atomic_load_or: + case Intrinsic::atomic_load_xor: + case Intrinsic::atomic_load_max: + case Intrinsic::atomic_load_min: + case Intrinsic::atomic_load_umax: + case Intrinsic::atomic_load_umin: + if (TD) { Value *Op1 = II->getOperand(1); unsigned Op1Size = TD->getTypeStoreSize(Op1->getType()); if (alias(Op1, Op1Size, P, Size) == NoAlias) return NoModRef; - break; - } } + break; + case Intrinsic::lifetime_start: + case Intrinsic::lifetime_end: + case Intrinsic::invariant_start: { + unsigned PtrSize = cast(II->getOperand(1))->getZExtValue(); + if (alias(II->getOperand(2), PtrSize, P, Size) == NoAlias) + return NoModRef; + } + case Intrinsic::invariant_end: { + unsigned PtrSize = cast(II->getOperand(2))->getZExtValue(); + if (alias(II->getOperand(3), PtrSize, P, Size) == NoAlias) + return NoModRef; + } } } } From sabre at nondot.org Thu Oct 15 01:20:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 15 Oct 2009 01:20:11 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910150620.n9F6KBn4010868@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.21 -> 1.22 --- Log message: add vinod's video --- Diffs of the changes: (+3 -3) index.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.21 llvm-www/devmtg/2009-10/index.html:1.22 --- llvm-www/devmtg/2009-10/index.html:1.21 Thu Oct 15 00:59:12 2009 +++ llvm-www/devmtg/2009-10/index.html Thu Oct 15 01:17:56 2009 @@ -238,8 +238,8 @@ [Slides] - + [Video(Computer) + [Video(Mobile) Vinod Grover
        NVIDIA PLANG: Translating NVIDIA PTX language to LLVM IR @@ -277,7 +277,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 05:59:12 $ +
        Last modified: $Date: 2009/10/15 06:17:56 $ From sabre at nondot.org Thu Oct 15 01:51:18 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 15 Oct 2009 01:51:18 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910150651.n9F6pI77012141@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.22 -> 1.23 --- Log message: add anna's talk. --- Diffs of the changes: (+3 -3) index.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.22 llvm-www/devmtg/2009-10/index.html:1.23 --- llvm-www/devmtg/2009-10/index.html:1.22 Thu Oct 15 01:17:56 2009 +++ llvm-www/devmtg/2009-10/index.html Thu Oct 15 01:50:28 2009 @@ -203,8 +203,8 @@ [Slides]

        - + [Video(Computer) + [Video(Mobile) Anna Zaks
        New York University CoVaC: Compiler Validation by Program Analysis of the Cross-Product - @@ -277,7 +277,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 06:17:56 $ +
        Last modified: $Date: 2009/10/15 06:50:28 $ From sabre at nondot.org Thu Oct 15 02:05:24 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 15 Oct 2009 02:05:24 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910150705.n9F75OaA012637@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.23 -> 1.24 --- Log message: add david's talk. --- Diffs of the changes: (+3 -3) index.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.23 llvm-www/devmtg/2009-10/index.html:1.24 --- llvm-www/devmtg/2009-10/index.html:1.23 Thu Oct 15 01:50:28 2009 +++ llvm-www/devmtg/2009-10/index.html Thu Oct 15 02:04:54 2009 @@ -145,8 +145,8 @@ [Waiting for Slides]

        - + [Video(Computer) + [Video(Mobile) David Greene
        Cray LLVM on 180k Cores - @@ -277,7 +277,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 06:50:28 $ +
        Last modified: $Date: 2009/10/15 07:04:54 $ From nicholas at mxc.ca Thu Oct 15 02:11:25 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 15 Oct 2009 07:11:25 -0000 Subject: [llvm-commits] [llvm] r84175 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200910150711.n9F7BPF2012926@zion.cs.uiuc.edu> Author: nicholas Date: Thu Oct 15 02:11:24 2009 New Revision: 84175 URL: http://llvm.org/viewvc/llvm-project?rev=84175&view=rev Log: Teach basicaa about memcpy/memmove/memset. The length argument can be used to improve alias results if constant, and the source pointer can't be modified. Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84175&r1=84174&r2=84175&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Thu Oct 15 02:11:24 2009 @@ -310,6 +310,28 @@ if (IntrinsicInst *II = dyn_cast(CS.getInstruction())) { switch (II->getIntrinsicID()) { default: break; + case Intrinsic::memcpy: + case Intrinsic::memmove: { + unsigned Len = ~0U; + if (ConstantInt *LenCI = dyn_cast(II->getOperand(3))) + Len = LenCI->getZExtValue(); + Value *Dest = II->getOperand(1); + Value *Src = II->getOperand(2); + if (alias(Dest, Len, P, Size) == NoAlias) { + if (alias(Src, Len, P, Size) == NoAlias) + return NoModRef; + return Ref; + } + } + break; + case Intrinsic::memset: + if (ConstantInt *LenCI = dyn_cast(II->getOperand(3))) { + unsigned Len = LenCI->getZExtValue(); + Value *Dest = II->getOperand(1); + if (alias(Dest, Len, P, Size) == NoAlias) + return NoModRef; + } + break; case Intrinsic::atomic_cmp_swap: case Intrinsic::atomic_swap: case Intrinsic::atomic_load_add: From baldrick at free.fr Thu Oct 15 03:17:58 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 15 Oct 2009 08:17:58 -0000 Subject: [llvm-commits] [llvm] r84177 - /llvm/trunk/docs/ReleaseNotes.html Message-ID: <200910150818.n9F8IAnC028717@zion.cs.uiuc.edu> Author: baldrick Date: Thu Oct 15 03:17:44 2009 New Revision: 84177 URL: http://llvm.org/viewvc/llvm-project?rev=84177&view=rev Log: The gcc plugin is now called dragonegg.so and no longer llvm.so. Pointed out by Gabor. Modified: llvm/trunk/docs/ReleaseNotes.html Modified: llvm/trunk/docs/ReleaseNotes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=84177&r1=84176&r2=84177&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes.html (original) +++ llvm/trunk/docs/ReleaseNotes.html Thu Oct 15 03:17:44 2009 @@ -246,7 +246,7 @@

        The goal of DragonEgg is to make gcc-4.5 act like llvm-gcc without requiring any gcc modifications whatsoever. -DragonEgg is a shared library (llvm.so) +DragonEgg is a shared library (dragonegg.so) that is loaded by gcc at runtime. It uses the new gcc plugin architecture to disable the GCC optimizers and code generators, and schedule the LLVM optimizers and code generators (or direct output of LLVM IR) instead. Currently only Linux From baldrick at free.fr Thu Oct 15 03:30:16 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 15 Oct 2009 10:30:16 +0200 Subject: [llvm-commits] [llvm] r84159 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp In-Reply-To: <200910150036.n9F0aaWY031906@zion.cs.uiuc.edu> References: <200910150036.n9F0aaWY031906@zion.cs.uiuc.edu> Message-ID: <4AD6DD98.5010904@free.fr> Hi Nick, > Take advantage of TargetData when available; we know that the atomic intrinsics > only dereference the element they point to directly with no pointer arithmetic. if there's no target data available, I guess there's no point in using ~0U for the size because the generic code already handles this case since the intrinsics are marked IntrWriteArgMem? Ciao, Duncan. From baldrick at free.fr Thu Oct 15 03:43:44 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 15 Oct 2009 10:43:44 +0200 Subject: [llvm-commits] [llvm] r84174 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp In-Reply-To: <200910150612.n9F6CEfp010584@zion.cs.uiuc.edu> References: <200910150612.n9F6CEfp010584@zion.cs.uiuc.edu> Message-ID: <4AD6E0C0.6040108@free.fr> Hi Nick, > + case Intrinsic::lifetime_start: > + case Intrinsic::lifetime_end: > + case Intrinsic::invariant_start: { > + unsigned PtrSize = cast(II->getOperand(1))->getZExtValue(); > + if (alias(II->getOperand(2), PtrSize, P, Size) == NoAlias) > + return NoModRef; > + } did you mean to fall through here? > + case Intrinsic::invariant_end: { > + unsigned PtrSize = cast(II->getOperand(2))->getZExtValue(); > + if (alias(II->getOperand(3), PtrSize, P, Size) == NoAlias) > + return NoModRef; > + } Ciao, Duncan. From sanjiv.gupta at microchip.com Thu Oct 15 04:48:29 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Thu, 15 Oct 2009 09:48:29 -0000 Subject: [llvm-commits] [llvm] r84179 - /llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Message-ID: <200910150948.n9F9mVHj032278@zion.cs.uiuc.edu> Author: sgupta Date: Thu Oct 15 04:48:25 2009 New Revision: 84179 URL: http://llvm.org/viewvc/llvm-project?rev=84179&view=rev Log: Few changes to comply with new DebugInfo Metadata representation. Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=84179&r1=84178&r2=84179&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Thu Oct 15 04:48:25 2009 @@ -30,10 +30,10 @@ std::string &TagName) { if (Ty.isBasicType()) PopulateBasicTypeInfo (Ty, TypeNo); - else if (Ty.isDerivedType()) - PopulateDerivedTypeInfo (Ty, TypeNo, HasAux, Aux, TagName); else if (Ty.isCompositeType()) PopulateCompositeTypeInfo (Ty, TypeNo, HasAux, Aux, TagName); + else if (Ty.isDerivedType()) + PopulateDerivedTypeInfo (Ty, TypeNo, HasAux, Aux, TagName); else { TypeNo = PIC16Dbg::T_NULL; HasAux = false; @@ -190,7 +190,7 @@ /// short PIC16DbgInfo::getStorageClass(DIGlobalVariable DIGV) { short ClassNo; - if (PAN::isLocalName(DIGV.getGlobal()->getName())) { + if (PAN::isLocalName(DIGV.getName())) { // Generating C_AUTO here fails due to error in linker. Change it once // linker is fixed. ClassNo = PIC16Dbg::C_STAT; @@ -446,7 +446,8 @@ bool HasAux = false; int Aux[PIC16Dbg::AuxSize] = { 0 }; std::string TagName = ""; - std::string VarName = MAI->getGlobalPrefix()+DIGV.getGlobal()->getNameStr(); + std::string VarName = DIGV.getName(); + VarName = MAI->getGlobalPrefix() + VarName; PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TagName); // Emit debug info only if type information is availaible. if (TypeNo != PIC16Dbg::T_NULL) { From sanjiv.gupta at microchip.com Thu Oct 15 05:10:44 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Thu, 15 Oct 2009 10:10:44 -0000 Subject: [llvm-commits] [llvm] r84180 - in /llvm/trunk/lib/Target/PIC16: AsmPrinter/PIC16AsmPrinter.cpp AsmPrinter/PIC16AsmPrinter.h PIC16.h PIC16ABINames.h PIC16DebugInfo.cpp PIC16ISelLowering.cpp PIC16InstrInfo.cpp PIC16MCAsmInfo.cpp PIC16MemSelOpt.cpp PIC16Section.cpp PIC16Section.h PIC16TargetObjectFile.cpp PIC16TargetObjectFile.h Message-ID: <200910151010.n9FAAjfE000588@zion.cs.uiuc.edu> Author: sgupta Date: Thu Oct 15 05:10:43 2009 New Revision: 84180 URL: http://llvm.org/viewvc/llvm-project?rev=84180&view=rev Log: Complete Rewrite of AsmPrinter, TargetObjectFile based on new PIC16Section class derived from MCSection. Added: llvm/trunk/lib/Target/PIC16/PIC16ABINames.h llvm/trunk/lib/Target/PIC16/PIC16Section.cpp llvm/trunk/lib/Target/PIC16/PIC16Section.h Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h llvm/trunk/lib/Target/PIC16/PIC16.h llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=84180&r1=84179&r2=84180&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Thu Oct 15 05:10:43 2009 @@ -12,8 +12,9 @@ // //===----------------------------------------------------------------------===// +#include "PIC16ABINames.h" #include "PIC16AsmPrinter.h" -#include "MCSectionPIC16.h" +#include "PIC16Section.h" #include "PIC16MCAsmInfo.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" @@ -39,7 +40,7 @@ : AsmPrinter(O, TM, T, V), DbgInfo(O, T) { PTLI = static_cast(TM.getTargetLowering()); PMAI = static_cast(T); - PTOF = (PIC16TargetObjectFile*)&PTLI->getObjFileLowering(); + PTOF = (PIC16TargetObjectFile *)&PTLI->getObjFileLowering(); } bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) { @@ -73,11 +74,12 @@ DbgInfo.BeginFunction(MF); // Emit the autos section of function. - EmitAutos(CurrentFnName); + // EmitAutos(CurrentFnName); // Now emit the instructions of function in its code section. - const MCSection *fCodeSection = - getObjFileLowering().getSectionForFunction(CurrentFnName); + const MCSection *fCodeSection + = getObjFileLowering().SectionForCode(CurrentFnName); + // Start the Code Section. O << "\n"; OutStreamer.SwitchSection(fCodeSection); @@ -229,12 +231,26 @@ // Set the section names for all globals. for (Module::global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) - if (!I->isDeclaration() && !I->hasAvailableExternallyLinkage()) { + I != E; ++I) { + + // Record External Var Decls. + if (I->isDeclaration()) { + ExternalVarDecls.push_back(I); + continue; + } + + // Record Exteranl Var Defs. + if (I->hasExternalLinkage() || I->hasCommonLinkage()) { + ExternalVarDefs.push_back(I); + } + + // Sectionify actual data. + if (!I->hasAvailableExternallyLinkage()) { const MCSection *S = getObjFileLowering().SectionForGlobal(I, Mang, TM); - I->setSection(((const MCSectionPIC16*)S)->getName()); + I->setSection(((const PIC16Section *)S)->getName()); } + } DbgInfo.BeginModule(M); EmitFunctionDecls(M); @@ -242,7 +258,9 @@ EmitDefinedVars(M); EmitIData(M); EmitUData(M); + EmitAllAutos(M); EmitRomData(M); + EmitUserSections(M); return Result; } @@ -287,7 +305,7 @@ // Emit variables imported from other Modules. void PIC16AsmPrinter::EmitUndefinedVars(Module &M) { - std::vector Items = PTOF->ExternalVarDecls->Items; + std::vector Items = ExternalVarDecls; if (!Items.size()) return; O << "\n" << MAI->getCommentString() << "Imported Variables - BEGIN" << "\n"; @@ -299,7 +317,7 @@ // Emit variables defined in this module and are available to other modules. void PIC16AsmPrinter::EmitDefinedVars(Module &M) { - std::vector Items = PTOF->ExternalVarDefs->Items; + std::vector Items = ExternalVarDefs; if (!Items.size()) return; O << "\n" << MAI->getCommentString() << "Exported Variables - BEGIN" << "\n"; @@ -312,24 +330,14 @@ // Emit initialized data placed in ROM. void PIC16AsmPrinter::EmitRomData(Module &M) { // Print ROM Data section. - const std::vector &ROSections = PTOF->ROSections; - for (unsigned i = 0; i < ROSections.size(); i++) { - const std::vector &Items = ROSections[i]->Items; - if (!Items.size()) continue; - O << "\n"; - OutStreamer.SwitchSection(PTOF->ROSections[i]->S_); - for (unsigned j = 0; j < Items.size(); j++) { - O << Mang->getMangledName(Items[j]); - Constant *C = Items[j]->getInitializer(); - int AddrSpace = Items[j]->getType()->getAddressSpace(); - EmitGlobalConstant(C, AddrSpace); - } - } + const PIC16Section *ROSection = PTOF->ROMDATASection(); + if (ROSection == NULL) return; + EmitInitializedDataSection(ROSection); } bool PIC16AsmPrinter::doFinalization(Module &M) { printLibcallDecls(); - EmitRemainingAutos(); + // EmitRemainingAutos(); DbgInfo.EndModule(M); O << "\n\t" << "END\n"; return AsmPrinter::doFinalization(M); @@ -343,7 +351,7 @@ O << "\n"; const MCSection *fPDataSection = - getObjFileLowering().getSectionForFunctionFrame(CurrentFnName); + getObjFileLowering().SectionForFrame(CurrentFnName); OutStreamer.SwitchSection(fPDataSection); // Emit function frame label @@ -379,103 +387,79 @@ O << PAN::getTempdataLabel(CurrentFnName) << " RES " << TempSize << '\n'; } -void PIC16AsmPrinter::EmitIData(Module &M) { - // Print all IDATA sections. - const std::vector &IDATASections = PTOF->IDATASections; - for (unsigned i = 0; i < IDATASections.size(); i++) { - O << "\n"; - if (IDATASections[i]->S_->getName().find("llvm.") != std::string::npos) - continue; - OutStreamer.SwitchSection(IDATASections[i]->S_); - std::vector Items = IDATASections[i]->Items; +void PIC16AsmPrinter::EmitInitializedDataSection(const PIC16Section *S) { + /// Emit Section header. + OutStreamer.SwitchSection(S); + + std::vector Items = S->Items; for (unsigned j = 0; j < Items.size(); j++) { std::string Name = Mang->getMangledName(Items[j]); Constant *C = Items[j]->getInitializer(); int AddrSpace = Items[j]->getType()->getAddressSpace(); O << Name; EmitGlobalConstant(C, AddrSpace); - } - } + } } -void PIC16AsmPrinter::EmitUData(Module &M) { - const TargetData *TD = TM.getTargetData(); +void PIC16AsmPrinter::EmitIData(Module &M) { - // Print all BSS sections. - const std::vector &BSSSections = PTOF->BSSSections; - for (unsigned i = 0; i < BSSSections.size(); i++) { + // Print all IDATA sections. + const std::vector &IDATASections = PTOF->IDATASections(); + for (unsigned i = 0; i < IDATASections.size(); i++) { O << "\n"; - OutStreamer.SwitchSection(BSSSections[i]->S_); - std::vector Items = BSSSections[i]->Items; + if (IDATASections[i]->getName().find("llvm.") != std::string::npos) + continue; + + EmitInitializedDataSection(IDATASections[i]); + } +} + +void PIC16AsmPrinter::EmitUninitializedDataSection(const PIC16Section *S) { + const TargetData *TD = TM.getTargetData(); + OutStreamer.SwitchSection(S); + std::vector Items = S->Items; for (unsigned j = 0; j < Items.size(); j++) { std::string Name = Mang->getMangledName(Items[j]); Constant *C = Items[j]->getInitializer(); const Type *Ty = C->getType(); unsigned Size = TD->getTypeAllocSize(Ty); - O << Name << " RES " << Size << "\n"; } - } } -void PIC16AsmPrinter::EmitAutos(std::string FunctName) { - // Section names for all globals are already set. - const TargetData *TD = TM.getTargetData(); - - // Now print Autos section for this function. - std::string SectionName = PAN::getAutosSectionName(FunctName); - const std::vector &AutosSections = PTOF->AutosSections; - for (unsigned i = 0; i < AutosSections.size(); i++) { +void PIC16AsmPrinter::EmitUData(Module &M) { + // Print all UDATA sections. + const std::vector &UDATASections = PTOF->UDATASections(); + for (unsigned i = 0; i < UDATASections.size(); i++) { O << "\n"; - if (AutosSections[i]->S_->getName() == SectionName) { - // Set the printing status to true - AutosSections[i]->setPrintedStatus(true); - OutStreamer.SwitchSection(AutosSections[i]->S_); - const std::vector &Items = AutosSections[i]->Items; - for (unsigned j = 0; j < Items.size(); j++) { - std::string VarName = Mang->getMangledName(Items[j]); - Constant *C = Items[j]->getInitializer(); - const Type *Ty = C->getType(); - unsigned Size = TD->getTypeAllocSize(Ty); - // Emit memory reserve directive. - O << VarName << " RES " << Size << "\n"; - } - break; - } + EmitUninitializedDataSection(UDATASections[i]); } } -// Print autos that were not printed during the code printing of functions. -// As the functions might themselves would have got deleted by the optimizer. -void PIC16AsmPrinter::EmitRemainingAutos() { - const TargetData *TD = TM.getTargetData(); - - // Now print Autos section for this function. - std::vector AutosSections = PTOF->AutosSections; - for (unsigned i = 0; i < AutosSections.size(); i++) { - - // if the section is already printed then don't print again - if (AutosSections[i]->isPrinted()) - continue; - - // Set status as printed - AutosSections[i]->setPrintedStatus(true); - +void PIC16AsmPrinter::EmitUserSections(Module &M) { + const std::vector &USERSections = PTOF->USERSections(); + for (unsigned i = 0; i < USERSections.size(); i++) { O << "\n"; - OutStreamer.SwitchSection(AutosSections[i]->S_); - const std::vector &Items = AutosSections[i]->Items; - for (unsigned j = 0; j < Items.size(); j++) { - std::string VarName = Mang->getMangledName(Items[j]); - Constant *C = Items[j]->getInitializer(); - const Type *Ty = C->getType(); - unsigned Size = TD->getTypeAllocSize(Ty); - // Emit memory reserve directive. - O << VarName << " RES " << Size << "\n"; + const PIC16Section *S = USERSections[i]; + if (S->isUDATA_Type()) { + EmitUninitializedDataSection(S); + } else if (S->isIDATA_Type() || S->isROMDATA_Type()) { + EmitInitializedDataSection(S); + } else { + llvm_unreachable ("unknow user section type"); } } } +void PIC16AsmPrinter::EmitAllAutos(Module &M) { + // Print all AUTO sections. + const std::vector &AUTOSections = PTOF->AUTOSections(); + for (unsigned i = 0; i < AUTOSections.size(); i++) { + O << "\n"; + EmitUninitializedDataSection(AUTOSections[i]); + } +} extern "C" void LLVMInitializePIC16AsmPrinter() { RegisterAsmPrinter X(ThePIC16Target); Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h?rev=84180&r1=84179&r2=84180&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h Thu Oct 15 05:10:43 2009 @@ -53,11 +53,13 @@ void EmitDefinedVars (Module &M); void EmitIData (Module &M); void EmitUData (Module &M); - void EmitAutos (std::string FunctName); - void EmitRemainingAutos (); + void EmitAllAutos (Module &M); void EmitRomData (Module &M); + void EmitUserSections (Module &M); void EmitFunctionFrame(MachineFunction &MF); void printLibcallDecls(); + void EmitUninitializedDataSection(const PIC16Section *S); + void EmitInitializedDataSection(const PIC16Section *S); protected: bool doInitialization(Module &M); bool doFinalization(Module &M); @@ -74,6 +76,8 @@ PIC16DbgInfo DbgInfo; const PIC16MCAsmInfo *PMAI; std::list LibcallDecls; // List of extern decls. + std::vector ExternalVarDecls; + std::vector ExternalVarDefs; }; } // end of namespace Modified: llvm/trunk/lib/Target/PIC16/PIC16.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16.h?rev=84180&r1=84179&r2=84180&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16.h Thu Oct 15 05:10:43 2009 @@ -42,266 +42,15 @@ UGE }; } - // A Central class to manage all ABI naming conventions. - // PAN - [P]ic16 [A]BI [N]ames - class PAN { - public: - // Map the name of the symbol to its section name. - // Current ABI: - // ----------------------------------------------------- - // ALL Names are prefixed with the symobl '@'. - // ------------------------------------------------------ - // Global variables do not have any '.' in their names. - // These are maily function names and global variable names. - // Example - @foo, @i - // ------------------------------------------------------- - // Functions and auto variables. - // Names are mangled as .. - // Where is '@' and is any one of - // the following - // .auto. - an automatic var of a function. - // .temp. - temproray data of a function. - // .ret. - return value label for a function. - // .frame. - Frame label for a function where retval, args - // and temps are stored. - // .args. - Label used to pass arguments to a direct call. - // Example - Function name: @foo - // Its frame: @foo.frame. - // Its retval: @foo.ret. - // Its local vars: @foo.auto.a - // Its temp data: @foo.temp. - // Its arg passing: @foo.args. - //---------------------------------------------- - // Libcall - compiler generated libcall names must start with .lib. - // This id will be used to emit extern decls for libcalls. - // Example - libcall name: @.lib.sra.i8 - // To pass args: @.lib.sra.i8.args. - // To return val: @.lib.sra.i8.ret. - //---------------------------------------------- - // SECTION Names - // uninitialized globals - @udata..# - // initialized globals - @idata..# - // Function frame - @.frame_section. - // Function autos - @.autos_section. - // Declarations - Enclosed in comments. No section for them. - //---------------------------------------------------------- - - // Tags used to mangle different names. - enum TAGS { - PREFIX_SYMBOL, - GLOBAL, - STATIC_LOCAL, - AUTOS_LABEL, - FRAME_LABEL, - RET_LABEL, - ARGS_LABEL, - TEMPS_LABEL, - - LIBCALL, - - FRAME_SECTION, - AUTOS_SECTION, - CODE_SECTION - }; - - // Textual names of the tags. - inline static const char *getTagName(TAGS tag) { - switch (tag) { - default: return ""; - case PREFIX_SYMBOL: return "@"; - case AUTOS_LABEL: return ".auto."; - case FRAME_LABEL: return ".frame."; - case TEMPS_LABEL: return ".temp."; - case ARGS_LABEL: return ".args."; - case RET_LABEL: return ".ret."; - case LIBCALL: return ".lib."; - case FRAME_SECTION: return ".frame_section."; - case AUTOS_SECTION: return ".autos_section."; - case CODE_SECTION: return ".code_section."; - } - } - - // Get tag type for the Symbol. - inline static TAGS getSymbolTag(const std::string &Sym) { - if (Sym.find(getTagName(TEMPS_LABEL)) != std::string::npos) - return TEMPS_LABEL; - - if (Sym.find(getTagName(FRAME_LABEL)) != std::string::npos) - return FRAME_LABEL; - - if (Sym.find(getTagName(RET_LABEL)) != std::string::npos) - return RET_LABEL; - - if (Sym.find(getTagName(ARGS_LABEL)) != std::string::npos) - return ARGS_LABEL; - - if (Sym.find(getTagName(AUTOS_LABEL)) != std::string::npos) - return AUTOS_LABEL; - - if (Sym.find(getTagName(LIBCALL)) != std::string::npos) - return LIBCALL; - - // It does not have any Tag. So its a true global or static local. - if (Sym.find(".") == std::string::npos) - return GLOBAL; - - // If a . is there, then it may be static local. - // We should mangle these as well in clang. - if (Sym.find(".") != std::string::npos) - return STATIC_LOCAL; - - assert (0 && "Could not determine Symbol's tag"); - return PREFIX_SYMBOL; // Silence warning when assertions are turned off. - } - - // addPrefix - add prefix symbol to a name if there isn't one already. - inline static std::string addPrefix (const std::string &Name) { - std::string prefix = getTagName (PREFIX_SYMBOL); - - // If this name already has a prefix, nothing to do. - if (Name.compare(0, prefix.size(), prefix) == 0) - return Name; - - return prefix + Name; - } - - // Get mangled func name from a mangled sym name. - // In all cases func name is the first component before a '.'. - static inline std::string getFuncNameForSym(const std::string &Sym1) { - assert (getSymbolTag(Sym1) != GLOBAL && "not belongs to a function"); - - std::string Sym = addPrefix(Sym1); - - // Position of the . after func name. That's where func name ends. - size_t func_name_end = Sym.find ('.'); - - return Sym.substr (0, func_name_end); - } - - // Get Frame start label for a func. - static std::string getFrameLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(FRAME_LABEL); - return Func1 + tag; - } - - static std::string getRetvalLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(RET_LABEL); - return Func1 + tag; - } - - static std::string getArgsLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(ARGS_LABEL); - return Func1 + tag; - } - - static std::string getTempdataLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(TEMPS_LABEL); - return Func1 + tag; - } - - static std::string getFrameSectionName(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(FRAME_SECTION); - return Func1 + tag + "# UDATA_OVR"; - } - static std::string getAutosSectionName(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(AUTOS_SECTION); - return Func1 + tag + "# UDATA_OVR"; - } - - static std::string getCodeSectionName(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(CODE_SECTION); - return Func1 + tag + "# CODE"; - } - - // udata, romdata and idata section names are generated by a given number. - // @udata..# - static std::string getUdataSectionName(unsigned num, - std::string prefix = "") { - std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << prefix << "udata." << num - << ".# UDATA"; - return o.str(); - } - - static std::string getRomdataSectionName(unsigned num, - std::string prefix = "") { - std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << prefix << "romdata." << num - << ".# ROMDATA"; - return o.str(); - } - - static std::string getIdataSectionName(unsigned num, - std::string prefix = "") { - std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << prefix << "idata." << num - << ".# IDATA"; - return o.str(); - } - - inline static bool isLocalName (const std::string &Name) { - if (getSymbolTag(Name) == AUTOS_LABEL) - return true; - - return false; - } - - inline static bool isMemIntrinsic (const std::string &Name) { - if (Name.compare("@memcpy") == 0 || Name.compare("@memset") == 0 || - Name.compare("@memmove") == 0) { - return true; - } - - return false; - } - - inline static bool isLocalToFunc (std::string &Func, std::string &Var) { - if (! isLocalName(Var)) return false; - - std::string Func1 = addPrefix(Func); - // Extract func name of the varilable. - const std::string &fname = getFuncNameForSym(Var); - - if (fname.compare(Func1) == 0) - return true; - - return false; - } - - - // Get the section for the given external symbol names. - // This tries to find the type (Tag) of the symbol from its mangled name - // and return appropriate section name for it. - static inline std::string getSectionNameForSym(const std::string &Sym1) { - std::string Sym = addPrefix(Sym1); - - std::string SectionName; - - std::string Fname = getFuncNameForSym (Sym); - TAGS id = getSymbolTag (Sym); - - switch (id) { - default : assert (0 && "Could not determine external symbol type"); - case FRAME_LABEL: - case RET_LABEL: - case TEMPS_LABEL: - case ARGS_LABEL: { - return getFrameSectionName(Fname); - } - case AUTOS_LABEL: { - return getAutosSectionName(Fname); - } - } - } - }; // class PAN. + enum PIC16SectionType { + CODE, + UDATA, + IDATA, + ROMDATA, + UDATA_OVR, + UDATA_SHR + }; // External symbol names require memory to live till the program end. Added: llvm/trunk/lib/Target/PIC16/PIC16ABINames.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ABINames.h?rev=84180&view=auto ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ABINames.h (added) +++ llvm/trunk/lib/Target/PIC16/PIC16ABINames.h Thu Oct 15 05:10:43 2009 @@ -0,0 +1,305 @@ +//===-- PIC16ABINames.h - PIC16 Naming conventios for ABI----- --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the functions to manage ABI Naming conventions for PIC16. +// +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TARGET_PIC16ABINAMES_H +#define LLVM_TARGET_PIC16ABINAMES_H + +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Target/TargetMachine.h" +#include +#include +#include +#include + +namespace llvm { + class PIC16TargetMachine; + class FunctionPass; + class MachineCodeEmitter; + class formatted_raw_ostream; + + // A Central class to manage all ABI naming conventions. + // PAN - [P]ic16 [A]BI [N]ames + class PAN { + public: + // Map the name of the symbol to its section name. + // Current ABI: + // ----------------------------------------------------- + // ALL Names are prefixed with the symobl '@'. + // ------------------------------------------------------ + // Global variables do not have any '.' in their names. + // These are maily function names and global variable names. + // Example - @foo, @i + // ------------------------------------------------------- + // Functions and auto variables. + // Names are mangled as .. + // Where is '@' and is any one of + // the following + // .auto. - an automatic var of a function. + // .temp. - temproray data of a function. + // .ret. - return value label for a function. + // .frame. - Frame label for a function where retval, args + // and temps are stored. + // .args. - Label used to pass arguments to a direct call. + // Example - Function name: @foo + // Its frame: @foo.frame. + // Its retval: @foo.ret. + // Its local vars: @foo.auto.a + // Its temp data: @foo.temp. + // Its arg passing: @foo.args. + //---------------------------------------------- + // Libcall - compiler generated libcall names must start with .lib. + // This id will be used to emit extern decls for libcalls. + // Example - libcall name: @.lib.sra.i8 + // To pass args: @.lib.sra.i8.args. + // To return val: @.lib.sra.i8.ret. + //---------------------------------------------- + // SECTION Names + // uninitialized globals - @udata..# + // initialized globals - @idata..# + // Function frame - @.frame_section. + // Function autos - @.autos_section. + // Declarations - Enclosed in comments. No section for them. + //---------------------------------------------------------- + + // Tags used to mangle different names. + enum TAGS { + PREFIX_SYMBOL, + GLOBAL, + STATIC_LOCAL, + AUTOS_LABEL, + FRAME_LABEL, + RET_LABEL, + ARGS_LABEL, + TEMPS_LABEL, + + LIBCALL, + + FRAME_SECTION, + AUTOS_SECTION, + CODE_SECTION, + USER_SECTION + }; + + // Textual names of the tags. + inline static const char *getTagName(TAGS tag) { + switch (tag) { + default: return ""; + case PREFIX_SYMBOL: return "@"; + case AUTOS_LABEL: return ".auto."; + case FRAME_LABEL: return ".frame."; + case TEMPS_LABEL: return ".temp."; + case ARGS_LABEL: return ".args."; + case RET_LABEL: return ".ret."; + case LIBCALL: return ".lib."; + case FRAME_SECTION: return ".frame_section."; + case AUTOS_SECTION: return ".autos_section."; + case CODE_SECTION: return ".code_section."; + case USER_SECTION: return ".user_section."; + } + } + + // Get tag type for the Symbol. + inline static TAGS getSymbolTag(const std::string &Sym) { + if (Sym.find(getTagName(TEMPS_LABEL)) != std::string::npos) + return TEMPS_LABEL; + + if (Sym.find(getTagName(FRAME_LABEL)) != std::string::npos) + return FRAME_LABEL; + + if (Sym.find(getTagName(RET_LABEL)) != std::string::npos) + return RET_LABEL; + + if (Sym.find(getTagName(ARGS_LABEL)) != std::string::npos) + return ARGS_LABEL; + + if (Sym.find(getTagName(AUTOS_LABEL)) != std::string::npos) + return AUTOS_LABEL; + + if (Sym.find(getTagName(LIBCALL)) != std::string::npos) + return LIBCALL; + + // It does not have any Tag. So its a true global or static local. + if (Sym.find(".") == std::string::npos) + return GLOBAL; + + // If a . is there, then it may be static local. + // We should mangle these as well in clang. + if (Sym.find(".") != std::string::npos) + return STATIC_LOCAL; + + assert (0 && "Could not determine Symbol's tag"); + return PREFIX_SYMBOL; // Silence warning when assertions are turned off. + } + + // addPrefix - add prefix symbol to a name if there isn't one already. + inline static std::string addPrefix (const std::string &Name) { + std::string prefix = getTagName (PREFIX_SYMBOL); + + // If this name already has a prefix, nothing to do. + if (Name.compare(0, prefix.size(), prefix) == 0) + return Name; + + return prefix + Name; + } + + // Get mangled func name from a mangled sym name. + // In all cases func name is the first component before a '.'. + static inline std::string getFuncNameForSym(const std::string &Sym1) { + assert (getSymbolTag(Sym1) != GLOBAL && "not belongs to a function"); + + std::string Sym = addPrefix(Sym1); + + // Position of the . after func name. That's where func name ends. + size_t func_name_end = Sym.find ('.'); + + return Sym.substr (0, func_name_end); + } + + // Get Frame start label for a func. + static std::string getFrameLabel(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(FRAME_LABEL); + return Func1 + tag; + } + + static std::string getRetvalLabel(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(RET_LABEL); + return Func1 + tag; + } + + static std::string getArgsLabel(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(ARGS_LABEL); + return Func1 + tag; + } + + static std::string getTempdataLabel(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(TEMPS_LABEL); + return Func1 + tag; + } + + static std::string getFrameSectionName(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(FRAME_SECTION); + return Func1 + tag + "#"; + } + + static std::string getAutosSectionName(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(AUTOS_SECTION); + return Func1 + tag + "#"; + } + + static std::string getCodeSectionName(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(CODE_SECTION); + return Func1 + tag + "#"; + } + + static std::string getUserSectionName(const std::string &Name) { + std::string sname = addPrefix(Name);; + std::string tag = getTagName(USER_SECTION); + return sname + tag + "#"; + } + + // udata, romdata and idata section names are generated by a given number. + // @udata..# + static std::string getUdataSectionName(unsigned num, + std::string prefix = "") { + std::ostringstream o; + o << getTagName(PREFIX_SYMBOL) << prefix << "udata." << num + << ".#"; + return o.str(); + } + + static std::string getRomdataSectionName() { + return "romdata.#"; + } + + static std::string getRomdataSectionName(unsigned num, + std::string prefix = "") { + std::ostringstream o; + o << getTagName(PREFIX_SYMBOL) << prefix << "romdata." << num + << ".#"; + return o.str(); + } + + static std::string getIdataSectionName(unsigned num, + std::string prefix = "") { + std::ostringstream o; + o << getTagName(PREFIX_SYMBOL) << prefix << "idata." << num + << ".#"; + return o.str(); + } + + inline static bool isLocalName (const std::string &Name) { + if (getSymbolTag(Name) == AUTOS_LABEL) + return true; + + return false; + } + + inline static bool isMemIntrinsic (const std::string &Name) { + if (Name.compare("@memcpy") == 0 || Name.compare("@memset") == 0 || + Name.compare("@memmove") == 0) { + return true; + } + + return false; + } + + inline static bool isLocalToFunc (std::string &Func, std::string &Var) { + if (! isLocalName(Var)) return false; + + std::string Func1 = addPrefix(Func); + // Extract func name of the varilable. + const std::string &fname = getFuncNameForSym(Var); + + if (fname.compare(Func1) == 0) + return true; + + return false; + } + + + // Get the section for the given external symbol names. + // This tries to find the type (Tag) of the symbol from its mangled name + // and return appropriate section name for it. + static inline std::string getSectionNameForSym(const std::string &Sym1) { + std::string Sym = addPrefix(Sym1); + + std::string SectionName; + + std::string Fname = getFuncNameForSym (Sym); + TAGS id = getSymbolTag (Sym); + + switch (id) { + default : assert (0 && "Could not determine external symbol type"); + case FRAME_LABEL: + case RET_LABEL: + case TEMPS_LABEL: + case ARGS_LABEL: { + return getFrameSectionName(Fname); + } + case AUTOS_LABEL: { + return getAutosSectionName(Fname); + } + } + } + }; // class PAN. +} // end namespace llvm; + +#endif Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=84180&r1=84179&r2=84180&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Thu Oct 15 05:10:43 2009 @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "PIC16.h" +#include "PIC16ABINames.h" #include "PIC16DebugInfo.h" #include "llvm/GlobalVariable.h" #include "llvm/CodeGen/MachineFunction.h" Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=84180&r1=84179&r2=84180&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Thu Oct 15 05:10:43 2009 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "pic16-lower" +#include "PIC16ABINames.h" #include "PIC16ISelLowering.h" #include "PIC16TargetObjectFile.h" #include "PIC16TargetMachine.h" Modified: llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp?rev=84180&r1=84179&r2=84180&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp Thu Oct 15 05:10:43 2009 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "PIC16.h" +#include "PIC16ABINames.h" #include "PIC16InstrInfo.h" #include "PIC16TargetMachine.h" #include "PIC16GenInstrInfo.inc" Modified: llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp?rev=84180&r1=84179&r2=84180&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp Thu Oct 15 05:10:43 2009 @@ -16,6 +16,7 @@ // FIXME: Layering violation to get enums and static function, should be moved // to separate headers. #include "PIC16.h" +#include "PIC16ABINames.h" #include "PIC16ISelLowering.h" using namespace llvm; Modified: llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp?rev=84180&r1=84179&r2=84180&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp Thu Oct 15 05:10:43 2009 @@ -21,6 +21,7 @@ #define DEBUG_TYPE "pic16-codegen" #include "PIC16.h" +#include "PIC16ABINames.h" #include "PIC16InstrInfo.h" #include "PIC16MCAsmInfo.h" #include "PIC16TargetMachine.h" Added: llvm/trunk/lib/Target/PIC16/PIC16Section.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Section.cpp?rev=84180&view=auto ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Section.cpp (added) +++ llvm/trunk/lib/Target/PIC16/PIC16Section.cpp Thu Oct 15 05:10:43 2009 @@ -0,0 +1,91 @@ +//===-- PIC16Section.cpp - PIC16 Section ----------- --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "PIC16.h" +#include "PIC16ABINames.h" +#include "PIC16Section.h" +#include "llvm/MC/MCContext.h" +#include "llvm/Support/raw_ostream.h" +using namespace llvm; + + +// This is the only way to create a PIC16Section. Sections created here +// do not need to be explicitly deleted as they are managed by auto_ptrs. +PIC16Section *PIC16Section::Create(const StringRef &Name, + PIC16SectionType Ty, + const std::string &Address, + int Color, MCContext &Ctx) { + + /// Determine the internal SectionKind info. + /// Users of PIC16Section class should not need to know the internal + /// SectionKind. They should work only with PIC16SectionType. + /// + /// PIC16 Terminology for section kinds is as below. + /// UDATA - BSS + /// IDATA - initialized data (equiv to Metadata) + /// ROMDATA - ReadOnly. + /// UDATA_OVR - Sections that can be overlaid. Section of such type is + /// used to contain function autos an frame. We can think of + /// it as equiv to llvm ThreadBSS) + /// UDATA_SHR - Shared RAM. Memory area that is mapped to all banks. + + SectionKind K; + switch (Ty) { + default: llvm_unreachable ("can not create unknown section type"); + case UDATA_OVR: { + K = SectionKind::getThreadBSS(); + break; + } + case UDATA_SHR: + case UDATA: { + K = SectionKind::getBSS(); + break; + } + case ROMDATA: + case IDATA: { + K = SectionKind::getMetadata(); + break; + } + case CODE: { + K = SectionKind::getText(); + break; + } + + } + + // Create the Section. + PIC16Section *S = new (Ctx) PIC16Section(Name, K, Address, Color); + S->T = Ty; + return S; +} + +// A generic way to print all types of sections. +void PIC16Section::PrintSwitchToSection(const MCAsmInfo &MAI, + raw_ostream &OS) const { + // Print name. + OS << getName() << '\t'; + + // Print type. + switch (getType()) { + default : llvm_unreachable ("unknown section type"); + case UDATA: OS << "UDATA"; break; + case IDATA: OS << "IDATA"; break; + case ROMDATA: OS << "ROMDATA"; break; + case UDATA_SHR: OS << "UDATA_SHR"; break; + case UDATA_OVR: OS << "UDATA_OVR"; break; + case CODE: OS << "CODE"; break; + } + + OS << '\t'; + + // Print Address. + OS << Address; + + OS << '\n'; +} Added: llvm/trunk/lib/Target/PIC16/PIC16Section.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Section.h?rev=84180&view=auto ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Section.h (added) +++ llvm/trunk/lib/Target/PIC16/PIC16Section.h Thu Oct 15 05:10:43 2009 @@ -0,0 +1,91 @@ +//===- PIC16Section.h - PIC16-specific section representation -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the PIC16Section class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_PIC16SECTION_H +#define LLVM_PIC16SECTION_H + +#include "llvm/MC/MCSection.h" +#include "llvm/GlobalVariable.h" +#include + +namespace llvm { + /// PIC16Section - Represents a physical section in PIC16 COFF. + /// Contains data objects. + /// + class PIC16Section : public MCSection { + /// PIC16 Sections does not really use the SectionKind class to + /// to distinguish between various types of sections. PIC16 maintain + /// its own Section Type info. See the PIC16SectionType enum in PIC16.h + /// for various section types. + PIC16SectionType T; + + /// Name of the section to uniquely identify it. + std::string Name; + + /// User can specify an address at which a section should be placed. + /// Negative value here means user hasn't specified any. + std::string Address; + + /// Overlay information - Sections with same color can be overlaid on + /// one another. + int Color; + + /// Total size of all data objects contained here. + unsigned Size; + + PIC16Section(const StringRef &name, SectionKind K, const std::string &addr, + int color) + : MCSection(K), Name(name), Address(addr), Color(color) { + } + + public: + /// Return the name of the section. + const std::string &getName() const { return Name; } + + /// Return the Address of the section. + const std::string &getAddress() const { return Address; } + + /// Return the Color of the section. + int getColor() const { return Color; } + + /// Return the size of the section. + unsigned getSize() const { return Size; } + void setSize(unsigned size) { Size = size; } + + /// Conatined data objects. + std::vectorItems; + + /// Check section type. + bool isUDATA_Type() const { return T == UDATA; } + bool isIDATA_Type() const { return T == IDATA; } + bool isROMDATA_Type() const { return T == ROMDATA; } + bool isUDATA_OVR_Type() const { return T == UDATA_OVR; } + bool isUDATA_SHR_Type() const { return T == UDATA_SHR; } + bool isCODE_Type() const { return T == CODE; } + + PIC16SectionType getType() const { return T; } + + /// This would be the only way to create a section. + static PIC16Section *Create(const StringRef &Name, PIC16SectionType Ty, + const std::string &Address, int Color, + MCContext &Ctx); + + /// Override this as PIC16 has its own way of printing switching + /// to a section. + virtual void PrintSwitchToSection(const MCAsmInfo &MAI, + raw_ostream &OS) const; + }; + +} // end namespace llvm + +#endif Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp?rev=84180&r1=84179&r2=84180&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp Thu Oct 15 05:10:43 2009 @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// #include "PIC16TargetObjectFile.h" -#include "MCSectionPIC16.h" #include "PIC16ISelLowering.h" #include "PIC16TargetMachine.h" +#include "PIC16Section.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/MC/MCSection.h" @@ -19,75 +19,111 @@ using namespace llvm; -MCSectionPIC16 *MCSectionPIC16::Create(const StringRef &Name, SectionKind K, - int Address, int Color, MCContext &Ctx) { - return new (Ctx) MCSectionPIC16(Name, K, Address, Color); +PIC16TargetObjectFile::PIC16TargetObjectFile() { } +/// Find a pic16 section. If not found, create one. +PIC16Section *PIC16TargetObjectFile:: +getPIC16Section(const std::string &Name, PIC16SectionType Ty, + const std::string &Address, int Color) const { -void MCSectionPIC16::PrintSwitchToSection(const MCAsmInfo &MAI, - raw_ostream &OS) const { - OS << getName() << '\n'; + /// Return if we have an already existing one. + PIC16Section *&Entry = SectionsByName[Name]; + if (Entry) + return Entry; + + + Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); + return Entry; } +/// Find a standard pic16 data section. If not found, create one and keep +/// track of it by adding it to appropriate std section list. +PIC16Section *PIC16TargetObjectFile:: +getPIC16DataSection(const std::string &Name, PIC16SectionType Ty, + const std::string &Address, int Color) const { + + /// Return if we have an already existing one. + PIC16Section *&Entry = SectionsByName[Name]; + if (Entry) + return Entry; + + /// Else create a new one and add it to appropriate section list. + Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); + switch (Ty) { + default: llvm_unreachable ("unknow standard section type."); + case UDATA: UDATASections_.push_back(Entry); break; + case IDATA: IDATASections_.push_back(Entry); break; + case ROMDATA: ROMDATASection_ = Entry; break; + } -PIC16TargetObjectFile::PIC16TargetObjectFile() - : ExternalVarDecls(0), ExternalVarDefs(0) { + return Entry; } + + +/// Find a standard pic16 autos section. If not found, create one and keep +/// track of it by adding it to appropriate std section list. +PIC16Section *PIC16TargetObjectFile:: +getPIC16AutoSection(const std::string &Name, PIC16SectionType Ty, + const std::string &Address, int Color) const { -const MCSectionPIC16 *PIC16TargetObjectFile:: -getPIC16Section(const char *Name, SectionKind Kind, - int Address, int Color) const { - MCSectionPIC16 *&Entry = SectionsByName[Name]; + /// Return if we have an already existing one. + PIC16Section *&Entry = SectionsByName[Name]; if (Entry) return Entry; - return Entry = MCSectionPIC16::Create(Name, Kind, Address, Color, - getContext()); + + /// Else create a new one and add it to appropriate section list. + Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); + + assert (Ty == UDATA_OVR && "incorrect section type for autos"); + AUTOSections_.push_back(Entry); + + return Entry; } + +/// Find a pic16 user section. If not found, create one and keep +/// track of it by adding it to appropriate std section list. +PIC16Section *PIC16TargetObjectFile:: +getPIC16UserSection(const std::string &Name, PIC16SectionType Ty, + const std::string &Address, int Color) const { + + /// Return if we have an already existing one. + PIC16Section *&Entry = SectionsByName[Name]; + if (Entry) + return Entry; + /// Else create a new one and add it to appropriate section list. + Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); + + USERSections_.push_back(Entry); + + return Entry; +} + +/// Do some standard llvm stuff. PIC16 really does not need any of this. void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){ TargetLoweringObjectFile::Initialize(Ctx, tm); TM = &tm; - BSSSection = getPIC16Section("udata.# UDATA", MCSectionPIC16::UDATA_Kind()); - ReadOnlySection = getPIC16Section("romdata.# ROMDATA", - MCSectionPIC16::ROMDATA_Kind()); - DataSection = getPIC16Section("idata.# IDATA", MCSectionPIC16::IDATA_Kind()); + // BSSSection = getPIC16DataSection("udata.#", UDATA); + // ReadOnlySection = getPIC16DataSection("romdata.#", ROMDATA); + // DataSection = getPIC16DataSection("idata.#", IDATA); // Need because otherwise a .text symbol is emitted by DwarfWriter // in BeginModule, and gpasm cribbs for that .text symbol. - TextSection = getPIC16Section("", SectionKind::getText()); - - ROSections.push_back(new PIC16Section((MCSectionPIC16*)ReadOnlySection)); - - // FIXME: I don't know what the classification of these sections really is. - // These aren't really objects belonging to any section. Just emit them - // in AsmPrinter and remove this code from here. - ExternalVarDecls = new PIC16Section(getPIC16Section("ExternalVarDecls", - SectionKind::getMetadata())); - ExternalVarDefs = new PIC16Section(getPIC16Section("ExternalVarDefs", - SectionKind::getMetadata())); -} - -const MCSection *PIC16TargetObjectFile:: -getSectionForFunction(const std::string &FnName) const { - std::string T = PAN::getCodeSectionName(FnName); - return getPIC16Section(T.c_str(), SectionKind::getText()); -} - - -const MCSection *PIC16TargetObjectFile:: -getSectionForFunctionFrame(const std::string &FnName) const { - std::string T = PAN::getFrameSectionName(FnName); - return getPIC16Section(T.c_str(), SectionKind::getDataRel()); + // FIXME: below + // TextSection = getPIC16DataSection("", UDATA); + ROMDATASection_ = NULL; } +/// allocateUDATA - Allocate a un-initialized global to an existing or new UDATA +/// section and return that section. const MCSection * -PIC16TargetObjectFile::getBSSSectionForGlobal(const GlobalVariable *GV) const { +PIC16TargetObjectFile::allocateUDATA(const GlobalVariable *GV) const { assert(GV->hasInitializer() && "This global doesn't need space"); Constant *C = GV->getInitializer(); assert(C->isNullValue() && "Unitialized globals has non-zero initializer"); @@ -97,41 +133,37 @@ const Type *Ty = C->getType(); unsigned ValSize = TD->getTypeAllocSize(Ty); - // Go through all BSS Sections and assign this variable + // Go through all UDATA Sections and assign this variable // to the first available section having enough space. - PIC16Section *FoundBSS = NULL; - for (unsigned i = 0; i < BSSSections.size(); i++) { - if (DataBankSize - BSSSections[i]->Size >= ValSize) { - FoundBSS = BSSSections[i]; + PIC16Section *Found = NULL; + for (unsigned i = 0; i < UDATASections_.size(); i++) { + if (DataBankSize - UDATASections_[i]->getSize() >= ValSize) { + Found = UDATASections_[i]; break; } } - // No BSS section spacious enough was found. Crate a new one. - if (!FoundBSS) { - std::string name = PAN::getUdataSectionName(BSSSections.size()); - const MCSectionPIC16 *NewSection - = getPIC16Section(name.c_str(), MCSectionPIC16::UDATA_Kind()); - - FoundBSS = new PIC16Section(NewSection); - - // Add this newly created BSS section to the list of BSSSections. - BSSSections.push_back(FoundBSS); + // No UDATA section spacious enough was found. Crate a new one. + if (!Found) { + std::string name = PAN::getUdataSectionName(UDATASections_.size()); + Found = getPIC16DataSection(name.c_str(), UDATA); } - // Insert the GV into this BSS. - FoundBSS->Items.push_back(GV); - FoundBSS->Size += ValSize; - return FoundBSS->S_; + // Insert the GV into this UDATA section. + Found->Items.push_back(GV); + Found->setSize(Found->getSize() + ValSize); + return Found; } +/// allocateIDATA - allocate an initialized global into an existing +/// or new section and return that section. const MCSection * -PIC16TargetObjectFile::getIDATASectionForGlobal(const GlobalVariable *GV) const{ +PIC16TargetObjectFile::allocateIDATA(const GlobalVariable *GV) const{ assert(GV->hasInitializer() && "This global doesn't need space"); Constant *C = GV->getInitializer(); assert(!C->isNullValue() && "initialized globals has zero initializer"); assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE && - "can split initialized RAM data only"); + "can allocate initialized RAM data only"); // Find how much space this global needs. const TargetData *TD = TM->getTargetData(); @@ -140,64 +172,47 @@ // Go through all IDATA Sections and assign this variable // to the first available section having enough space. - PIC16Section *FoundIDATA = NULL; - for (unsigned i = 0; i < IDATASections.size(); i++) { - if (DataBankSize - IDATASections[i]->Size >= ValSize) { - FoundIDATA = IDATASections[i]; + PIC16Section *Found = NULL; + for (unsigned i = 0; i < IDATASections_.size(); i++) { + if (DataBankSize - IDATASections_[i]->getSize() >= ValSize) { + Found = IDATASections_[i]; break; } } // No IDATA section spacious enough was found. Crate a new one. - if (!FoundIDATA) { - std::string name = PAN::getIdataSectionName(IDATASections.size()); - const MCSectionPIC16 *NewSection = - getPIC16Section(name.c_str(), MCSectionPIC16::IDATA_Kind()); - - FoundIDATA = new PIC16Section(NewSection); - - // Add this newly created IDATA section to the list of IDATASections. - IDATASections.push_back(FoundIDATA); + if (!Found) { + std::string name = PAN::getIdataSectionName(IDATASections_.size()); + Found = getPIC16DataSection(name.c_str(), IDATA); } // Insert the GV into this IDATA. - FoundIDATA->Items.push_back(GV); - FoundIDATA->Size += ValSize; - return FoundIDATA->S_; + Found->Items.push_back(GV); + Found->setSize(Found->getSize() + ValSize); + return Found; } -// Get the section for an automatic variable of a function. -// For PIC16 they are globals only with mangled names. +// Allocate a program memory variable into ROMDATA section. const MCSection * -PIC16TargetObjectFile::getSectionForAuto(const GlobalVariable *GV) const { - - const std::string name = PAN::getSectionNameForSym(GV->getName()); - - // Go through all Auto Sections and assign this variable - // to the appropriate section. - PIC16Section *FoundAutoSec = NULL; - for (unsigned i = 0; i < AutosSections.size(); i++) { - if (AutosSections[i]->S_->getName() == name) { - FoundAutoSec = AutosSections[i]; - break; - } - } +PIC16TargetObjectFile::allocateROMDATA(const GlobalVariable *GV) const { - // No Auto section was found. Crate a new one. - if (!FoundAutoSec) { - const MCSectionPIC16 *NewSection = - getPIC16Section(name.c_str(), MCSectionPIC16::UDATA_OVR_Kind()); + std::string name = PAN::getRomdataSectionName(); + PIC16Section *S = getPIC16DataSection(name.c_str(), ROMDATA); - FoundAutoSec = new PIC16Section(NewSection); + S->Items.push_back(GV); + return S; +} - // Add this newly created autos section to the list of AutosSections. - AutosSections.push_back(FoundAutoSec); - } +// Get the section for an automatic variable of a function. +// For PIC16 they are globals only with mangled names. +const MCSection * +PIC16TargetObjectFile::allocateAUTO(const GlobalVariable *GV) const { - // Insert the auto into this section. - FoundAutoSec->Items.push_back(GV); + const std::string name = PAN::getSectionNameForSym(GV->getName()); + PIC16Section *S = getPIC16AutoSection(name.c_str()); - return FoundAutoSec->S_; + S->Items.push_back(GV); + return S; } @@ -214,56 +229,50 @@ if (!GV) return TargetLoweringObjectFile::SelectSectionForGlobal(GV1, Kind, Mang,TM); - // Record External Var Decls. - if (GV->isDeclaration()) { - ExternalVarDecls->Items.push_back(GV); - return ExternalVarDecls->S_; - } - assert(GV->hasInitializer() && "A def without initializer?"); // First, if this is an automatic variable for a function, get the section // name for it and return. std::string name = GV->getName(); if (PAN::isLocalName(name)) - return getSectionForAuto(GV); - - // Record Exteranl Var Defs. - if (GV->hasExternalLinkage() || GV->hasCommonLinkage()) - ExternalVarDefs->Items.push_back(GV); + return allocateAUTO(GV); // See if this is an uninitialized global. const Constant *C = GV->getInitializer(); if (C->isNullValue()) - return getBSSSectionForGlobal(GV); + return allocateUDATA(GV); // If this is initialized data in RAM. Put it in the correct IDATA section. if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) - return getIDATASectionForGlobal(GV); + return allocateIDATA(GV); // This is initialized data in rom, put it in the readonly section. if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) - return getROSectionForGlobal(GV); + return allocateROMDATA(GV); // Else let the default implementation take care of it. return TargetLoweringObjectFile::SelectSectionForGlobal(GV, Kind, Mang,TM); } PIC16TargetObjectFile::~PIC16TargetObjectFile() { - for (unsigned i = 0; i < BSSSections.size(); i++) - delete BSSSections[i]; - for (unsigned i = 0; i < IDATASections.size(); i++) - delete IDATASections[i]; - for (unsigned i = 0; i < AutosSections.size(); i++) - delete AutosSections[i]; - for (unsigned i = 0; i < ROSections.size(); i++) - delete ROSections[i]; - delete ExternalVarDecls; - delete ExternalVarDefs; +#if 0 + for (unsigned i = 0; i < UDATASections_.size(); i++) + delete UDATASections_[i]; + for (unsigned i = 0; i < IDATASections_.size(); i++) + delete IDATASections_[i]; + + delete ROMDATASection_; + + for (unsigned i = 0; i < AUTOSections_.size(); i++) + delete AUTOSections_[i]; + + for (unsigned i = 0; i < USERSections_.size(); i++) + delete USERSections_[i]; +#endif } -/// getSpecialCasedSectionGlobals - Allow the target to completely override +/// getExplicitSectionGlobal - Allow the target to completely override /// section assignment of a global. const MCSection *PIC16TargetObjectFile:: getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, @@ -274,167 +283,83 @@ std::string SectName = GVar->getSection(); // If address for a variable is specified, get the address and create // section. + // FIXME: move this attribute checking in PAN. std::string AddrStr = "Address="; if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) { std::string SectAddr = SectName.substr(AddrStr.length()); - return CreateSectionForGlobal(GVar, Mang, SectAddr); + return allocateAtGivenAddress(GVar, SectAddr); } // Create the section specified with section attribute. - return CreateSectionForGlobal(GVar, Mang); + return allocateInGivenSection(GVar); } - return getPIC16Section(GV->getSection().c_str(), Kind); + return getPIC16DataSection(GV->getSection().c_str(), UDATA); +} + +// Interface used by AsmPrinter to get a code section for a function. +const PIC16Section * +PIC16TargetObjectFile::SectionForCode(const std::string &FnName) const { + const std::string &sec_name = PAN::getCodeSectionName(FnName); + return getPIC16Section(sec_name, CODE); } -// Create a new section for global variable. If Addr is given then create -// section at that address else create by name. +// Interface used by AsmPrinter to get a frame section for a function. +const PIC16Section * +PIC16TargetObjectFile::SectionForFrame(const std::string &FnName) const { + const std::string &sec_name = PAN::getFrameSectionName(FnName); + return getPIC16Section(sec_name, UDATA_OVR); +} + +// Allocate a global var in existing or new section of given name. const MCSection * -PIC16TargetObjectFile::CreateSectionForGlobal(const GlobalVariable *GV, - Mangler *Mang, - const std::string &Addr) const { +PIC16TargetObjectFile::allocateInGivenSection(const GlobalVariable *GV) const { + // Determine the type of section that we need to create. + PIC16SectionType SecTy; + // See if this is an uninitialized global. const Constant *C = GV->getInitializer(); if (C->isNullValue()) - return CreateBSSSectionForGlobal(GV, Addr); - + SecTy = UDATA; // If this is initialized data in RAM. Put it in the correct IDATA section. - if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) - return CreateIDATASectionForGlobal(GV, Addr); - + else if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) + SecTy = IDATA; // This is initialized data in rom, put it in the readonly section. - if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) - return CreateROSectionForGlobal(GV, Addr); - - // Else let the default implementation take care of it. - return TargetLoweringObjectFile::SectionForGlobal(GV, Mang, *TM); -} - -// Create uninitialized section for a variable. -const MCSection * -PIC16TargetObjectFile::CreateBSSSectionForGlobal(const GlobalVariable *GV, - std::string Addr) const { - assert(GV->hasInitializer() && "This global doesn't need space"); - assert(GV->getInitializer()->isNullValue() && - "Unitialized global has non-zero initializer"); - std::string Name; - // If address is given then create a section at that address else create a - // section by section name specified in GV. - PIC16Section *FoundBSS = NULL; - if (Addr.empty()) { - Name = GV->getSection() + " UDATA"; - for (unsigned i = 0; i < BSSSections.size(); i++) { - if (BSSSections[i]->S_->getName() == Name) { - FoundBSS = BSSSections[i]; - break; - } - } - } else { - std::string Prefix = GV->getNameStr() + "." + Addr + "."; - Name = PAN::getUdataSectionName(BSSSections.size(), Prefix) + " " + Addr; - } - - PIC16Section *NewBSS = FoundBSS; - if (NewBSS == NULL) { - const MCSectionPIC16 *NewSection = - getPIC16Section(Name.c_str(), MCSectionPIC16::UDATA_Kind()); - NewBSS = new PIC16Section(NewSection); - BSSSections.push_back(NewBSS); - } - - // Insert the GV into this BSS. - NewBSS->Items.push_back(GV); + else if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) + SecTy = ROMDATA; + else + llvm_unreachable ("Could not determine section type for global"); - // We do not want to put any GV without explicit section into this section - // so set its size to DatabankSize. - NewBSS->Size = DataBankSize; - return NewBSS->S_; -} - -// Get rom section for a variable. Currently there can be only one rom section -// unless a variable explicitly requests a section. -const MCSection * -PIC16TargetObjectFile::getROSectionForGlobal(const GlobalVariable *GV) const { - ROSections[0]->Items.push_back(GV); - return ROSections[0]->S_; + PIC16Section *S = getPIC16UserSection(GV->getSection().c_str(), SecTy); + S->Items.push_back(GV); + return S; } -// Create initialized data section for a variable. +// Allocate a global var in a new absolute sections at given address. const MCSection * -PIC16TargetObjectFile::CreateIDATASectionForGlobal(const GlobalVariable *GV, - std::string Addr) const { - assert(GV->hasInitializer() && "This global doesn't need space"); - assert(!GV->getInitializer()->isNullValue() && - "initialized global has zero initializer"); - assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE && - "can be used for initialized RAM data only"); - - std::string Name; - // If address is given then create a section at that address else create a - // section by section name specified in GV. - PIC16Section *FoundIDATASec = NULL; - if (Addr.empty()) { - Name = GV->getSection() + " IDATA"; - for (unsigned i = 0; i < IDATASections.size(); i++) { - if (IDATASections[i]->S_->getName() == Name) { - FoundIDATASec = IDATASections[i]; - break; - } - } - } else { - std::string Prefix = GV->getNameStr() + "." + Addr + "."; - Name = PAN::getIdataSectionName(IDATASections.size(), Prefix) + " " + Addr; - } +PIC16TargetObjectFile::allocateAtGivenAddress(const GlobalVariable *GV, + const std::string &Addr) const { + // Determine the type of section that we need to create. + PIC16SectionType SecTy; - PIC16Section *NewIDATASec = FoundIDATASec; - if (NewIDATASec == NULL) { - const MCSectionPIC16 *NewSection = - getPIC16Section(Name.c_str(), MCSectionPIC16::IDATA_Kind()); - NewIDATASec = new PIC16Section(NewSection); - IDATASections.push_back(NewIDATASec); - } - // Insert the GV into this IDATA Section. - NewIDATASec->Items.push_back(GV); - // We do not want to put any GV without explicit section into this section - // so set its size to DatabankSize. - NewIDATASec->Size = DataBankSize; - return NewIDATASec->S_; + // See if this is an uninitialized global. + const Constant *C = GV->getInitializer(); + if (C->isNullValue()) + SecTy = UDATA; + // If this is initialized data in RAM. Put it in the correct IDATA section. + else if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) + SecTy = IDATA; + // This is initialized data in rom, put it in the readonly section. + else if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) + SecTy = ROMDATA; + else + llvm_unreachable ("Could not determine section type for global"); + + std::string Prefix = GV->getNameStr() + "." + Addr + "."; + std::string SName = PAN::getUserSectionName(Prefix); + PIC16Section *S = getPIC16UserSection(SName.c_str(), SecTy, Addr.c_str()); + S->Items.push_back(GV); + return S; } -// Create a section in rom for a variable. -const MCSection * -PIC16TargetObjectFile::CreateROSectionForGlobal(const GlobalVariable *GV, - std::string Addr) const { - assert(GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE && - "can be used for ROM data only"); - - std::string Name; - // If address is given then create a section at that address else create a - // section by section name specified in GV. - PIC16Section *FoundROSec = NULL; - if (Addr.empty()) { - Name = GV->getSection() + " ROMDATA"; - for (unsigned i = 1; i < ROSections.size(); i++) { - if (ROSections[i]->S_->getName() == Name) { - FoundROSec = ROSections[i]; - break; - } - } - } else { - std::string Prefix = GV->getNameStr() + "." + Addr + "."; - Name = PAN::getRomdataSectionName(ROSections.size(), Prefix) + " " + Addr; - } - - PIC16Section *NewRomSec = FoundROSec; - if (NewRomSec == NULL) { - const MCSectionPIC16 *NewSection = - getPIC16Section(Name.c_str(), MCSectionPIC16::ROMDATA_Kind()); - NewRomSec = new PIC16Section(NewSection); - ROSections.push_back(NewRomSec); - } - - // Insert the GV into this ROM Section. - NewRomSec->Items.push_back(GV); - return NewRomSec->S_; -} Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h?rev=84180&r1=84179&r2=84180&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Thu Oct 15 05:10:43 2009 @@ -10,6 +10,8 @@ #ifndef LLVM_TARGET_PIC16_TARGETOBJECTFILE_H #define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H +#include "PIC16.h" +#include "PIC16ABINames.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/ADT/StringMap.h" #include @@ -19,7 +21,7 @@ class GlobalVariable; class Module; class PIC16TargetMachine; - class MCSectionPIC16; + class PIC16Section; enum { DataBankSize = 80 }; @@ -29,91 +31,124 @@ /// again and printing only those that match the current section. /// Keeping values inside the sections make printing a section much easier. /// - /// FIXME: MOVE ALL THIS STUFF TO MCSectionPIC16. + /// FIXME: MOVE ALL THIS STUFF TO PIC16Section. /// - struct PIC16Section { - const MCSectionPIC16 *S_; // Connection to actual Section. - unsigned Size; // Total size of the objects contained. - bool SectionPrinted; - std::vector Items; - - PIC16Section(const MCSectionPIC16 *s) { - S_ = s; - Size = 0; - SectionPrinted = false; - } - bool isPrinted() const { return SectionPrinted; } - void setPrintedStatus(bool status) { SectionPrinted = status; } - }; - + + /// PIC16TargetObjectFile - PIC16 Object file. Contains data and code + /// sections. + // PIC16 Object File has two types of sections. + // 1. Standard Sections + // 1.1 un-initialized global data + // 1.2 initialized global data + // 1.3 program memory data + // 1.4 local variables of functions. + // 2. User defined sections + // 2.1 Objects placed in a specific section. (By _Section() macro) + // 2.2 Objects placed at a specific address. (By _Address() macro) class PIC16TargetObjectFile : public TargetLoweringObjectFile { /// SectionsByName - Bindings of names to allocated sections. - mutable StringMap SectionsByName; + mutable StringMap SectionsByName; const TargetMachine *TM; - const MCSectionPIC16 *getPIC16Section(const char *Name, - SectionKind K, - int Address = -1, - int Color = -1) const; - public: - mutable std::vector BSSSections; - mutable std::vector IDATASections; - mutable std::vector AutosSections; - mutable std::vector ROSections; - mutable PIC16Section *ExternalVarDecls; - mutable PIC16Section *ExternalVarDefs; - + /// Lists of sections. + /// Standard Data Sections. + mutable std::vector UDATASections_; + mutable std::vector IDATASections_; + mutable PIC16Section * ROMDATASection_; + + /// Standard Auto Sections. + mutable std::vector AUTOSections_; + + /// User specified sections. + mutable std::vector USERSections_; + + + /// Find or Create a PIC16 Section, without adding it to any + /// section list. + PIC16Section *getPIC16Section(const std::string &Name, + PIC16SectionType Ty, + const std::string &Address = "", + int Color = -1) const; + + /// Convenience functions. These wrappers also take care of adding + /// the newly created section to the appropriate sections list. + + /// Find or Create PIC16 Standard Data Section. + PIC16Section *getPIC16DataSection(const std::string &Name, + PIC16SectionType Ty, + const std::string &Address = "", + int Color = -1) const; + + /// Find or Create PIC16 Standard Auto Section. + PIC16Section *getPIC16AutoSection(const std::string &Name, + PIC16SectionType Ty = UDATA_OVR, + const std::string &Address = "", + int Color = -1) const; + + /// Find or Create PIC16 Standard Auto Section. + PIC16Section *getPIC16UserSection(const std::string &Name, + PIC16SectionType Ty, + const std::string &Address = "", + int Color = -1) const; + + /// Allocate Un-initialized data to a standard UDATA section. + const MCSection *allocateUDATA(const GlobalVariable *GV) const; + + /// Allocate Initialized data to a standard IDATA section. + const MCSection *allocateIDATA(const GlobalVariable *GV) const; + + /// Allocate ROM data to the standard ROMDATA section. + const MCSection *allocateROMDATA(const GlobalVariable *GV) const; + + /// Allocate an AUTO variable to an AUTO section. + const MCSection *allocateAUTO(const GlobalVariable *GV) const; + + /// Allocate DATA in user specified section. + const MCSection *allocateInGivenSection(const GlobalVariable *GV) const; + + /// Allocate DATA at user specified address. + const MCSection *allocateAtGivenAddress(const GlobalVariable *GV, + const std::string &Addr) const; + + public: PIC16TargetObjectFile(); ~PIC16TargetObjectFile(); - void Initialize(MCContext &Ctx, const TargetMachine &TM); - + /// Override section allocations for user specified sections. virtual const MCSection * getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; + /// Select sections for Data and Auto variables(globals). virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine&) const; - const MCSection *getSectionForFunction(const std::string &FnName) const; - const MCSection *getSectionForFunctionFrame(const std::string &FnName)const; - - - private: - std::string getSectionNameForSym(const std::string &Sym) const; + /// Return a code section for a function. + const PIC16Section *SectionForCode (const std::string &FnName) const; - const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const; - const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const; - const MCSection *getSectionForAuto(const GlobalVariable *GV) const; - const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV, - std::string Addr = "") const; - const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV, - std::string Addr = "") const; - const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const; - const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV, - std::string Addr = "") const; - const MCSection *CreateSectionForGlobal(const GlobalVariable *GV, - Mangler *Mang, - const std::string &Addr = "") const; - public: - void SetSectionForGVs(Module &M); - const std::vector &getBSSSections() const { - return BSSSections; + /// Return a frame section for a function. + const PIC16Section *SectionForFrame (const std::string &FnName) const; + + /// Accessors for various section lists. + const std::vector &UDATASections() const { + return UDATASections_; } - const std::vector &getIDATASections() const { - return IDATASections; + const std::vector &IDATASections() const { + return IDATASections_; } - const std::vector &getAutosSections() const { - return AutosSections; + const PIC16Section *ROMDATASection() const { + return ROMDATASection_; } - const std::vector &getROSections() const { - return ROSections; + const std::vector &AUTOSections() const { + return AUTOSections_; + } + const std::vector &USERSections() const { + return USERSections_; } - }; } // end namespace llvm From daniel at zuster.org Thu Oct 15 10:02:17 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 15 Oct 2009 15:02:17 -0000 Subject: [llvm-commits] [llvm] r84184 - in /llvm/trunk/lib/Target/PIC16: AsmPrinter/PIC16AsmPrinter.cpp AsmPrinter/PIC16AsmPrinter.h PIC16.h PIC16ABINames.h PIC16DebugInfo.cpp PIC16ISelLowering.cpp PIC16InstrInfo.cpp PIC16MCAsmInfo.cpp PIC16MemSelOpt.cpp PIC16Section.cpp PIC16Section.h PIC16TargetObjectFile.cpp PIC16TargetObjectFile.h Message-ID: <200910151502.n9FF2IUn010873@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Oct 15 10:02:14 2009 New Revision: 84184 URL: http://llvm.org/viewvc/llvm-project?rev=84184&view=rev Log: Revert "Complete Rewrite of AsmPrinter, TargetObjectFile based on new PIC16Section class", it breaks globals.ll. Removed: llvm/trunk/lib/Target/PIC16/PIC16ABINames.h llvm/trunk/lib/Target/PIC16/PIC16Section.cpp llvm/trunk/lib/Target/PIC16/PIC16Section.h Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h llvm/trunk/lib/Target/PIC16/PIC16.h llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=84184&r1=84183&r2=84184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Thu Oct 15 10:02:14 2009 @@ -12,9 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "PIC16ABINames.h" #include "PIC16AsmPrinter.h" -#include "PIC16Section.h" +#include "MCSectionPIC16.h" #include "PIC16MCAsmInfo.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" @@ -40,7 +39,7 @@ : AsmPrinter(O, TM, T, V), DbgInfo(O, T) { PTLI = static_cast(TM.getTargetLowering()); PMAI = static_cast(T); - PTOF = (PIC16TargetObjectFile *)&PTLI->getObjFileLowering(); + PTOF = (PIC16TargetObjectFile*)&PTLI->getObjFileLowering(); } bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) { @@ -74,12 +73,11 @@ DbgInfo.BeginFunction(MF); // Emit the autos section of function. - // EmitAutos(CurrentFnName); + EmitAutos(CurrentFnName); // Now emit the instructions of function in its code section. - const MCSection *fCodeSection - = getObjFileLowering().SectionForCode(CurrentFnName); - + const MCSection *fCodeSection = + getObjFileLowering().getSectionForFunction(CurrentFnName); // Start the Code Section. O << "\n"; OutStreamer.SwitchSection(fCodeSection); @@ -231,26 +229,12 @@ // Set the section names for all globals. for (Module::global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) { - - // Record External Var Decls. - if (I->isDeclaration()) { - ExternalVarDecls.push_back(I); - continue; - } - - // Record Exteranl Var Defs. - if (I->hasExternalLinkage() || I->hasCommonLinkage()) { - ExternalVarDefs.push_back(I); - } - - // Sectionify actual data. - if (!I->hasAvailableExternallyLinkage()) { + I != E; ++I) + if (!I->isDeclaration() && !I->hasAvailableExternallyLinkage()) { const MCSection *S = getObjFileLowering().SectionForGlobal(I, Mang, TM); - I->setSection(((const PIC16Section *)S)->getName()); + I->setSection(((const MCSectionPIC16*)S)->getName()); } - } DbgInfo.BeginModule(M); EmitFunctionDecls(M); @@ -258,9 +242,7 @@ EmitDefinedVars(M); EmitIData(M); EmitUData(M); - EmitAllAutos(M); EmitRomData(M); - EmitUserSections(M); return Result; } @@ -305,7 +287,7 @@ // Emit variables imported from other Modules. void PIC16AsmPrinter::EmitUndefinedVars(Module &M) { - std::vector Items = ExternalVarDecls; + std::vector Items = PTOF->ExternalVarDecls->Items; if (!Items.size()) return; O << "\n" << MAI->getCommentString() << "Imported Variables - BEGIN" << "\n"; @@ -317,7 +299,7 @@ // Emit variables defined in this module and are available to other modules. void PIC16AsmPrinter::EmitDefinedVars(Module &M) { - std::vector Items = ExternalVarDefs; + std::vector Items = PTOF->ExternalVarDefs->Items; if (!Items.size()) return; O << "\n" << MAI->getCommentString() << "Exported Variables - BEGIN" << "\n"; @@ -330,14 +312,24 @@ // Emit initialized data placed in ROM. void PIC16AsmPrinter::EmitRomData(Module &M) { // Print ROM Data section. - const PIC16Section *ROSection = PTOF->ROMDATASection(); - if (ROSection == NULL) return; - EmitInitializedDataSection(ROSection); + const std::vector &ROSections = PTOF->ROSections; + for (unsigned i = 0; i < ROSections.size(); i++) { + const std::vector &Items = ROSections[i]->Items; + if (!Items.size()) continue; + O << "\n"; + OutStreamer.SwitchSection(PTOF->ROSections[i]->S_); + for (unsigned j = 0; j < Items.size(); j++) { + O << Mang->getMangledName(Items[j]); + Constant *C = Items[j]->getInitializer(); + int AddrSpace = Items[j]->getType()->getAddressSpace(); + EmitGlobalConstant(C, AddrSpace); + } + } } bool PIC16AsmPrinter::doFinalization(Module &M) { printLibcallDecls(); - // EmitRemainingAutos(); + EmitRemainingAutos(); DbgInfo.EndModule(M); O << "\n\t" << "END\n"; return AsmPrinter::doFinalization(M); @@ -351,7 +343,7 @@ O << "\n"; const MCSection *fPDataSection = - getObjFileLowering().SectionForFrame(CurrentFnName); + getObjFileLowering().getSectionForFunctionFrame(CurrentFnName); OutStreamer.SwitchSection(fPDataSection); // Emit function frame label @@ -387,80 +379,104 @@ O << PAN::getTempdataLabel(CurrentFnName) << " RES " << TempSize << '\n'; } +void PIC16AsmPrinter::EmitIData(Module &M) { -void PIC16AsmPrinter::EmitInitializedDataSection(const PIC16Section *S) { - /// Emit Section header. - OutStreamer.SwitchSection(S); - - std::vector Items = S->Items; + // Print all IDATA sections. + const std::vector &IDATASections = PTOF->IDATASections; + for (unsigned i = 0; i < IDATASections.size(); i++) { + O << "\n"; + if (IDATASections[i]->S_->getName().find("llvm.") != std::string::npos) + continue; + OutStreamer.SwitchSection(IDATASections[i]->S_); + std::vector Items = IDATASections[i]->Items; for (unsigned j = 0; j < Items.size(); j++) { std::string Name = Mang->getMangledName(Items[j]); Constant *C = Items[j]->getInitializer(); int AddrSpace = Items[j]->getType()->getAddressSpace(); O << Name; EmitGlobalConstant(C, AddrSpace); - } + } + } } -void PIC16AsmPrinter::EmitIData(Module &M) { +void PIC16AsmPrinter::EmitUData(Module &M) { + const TargetData *TD = TM.getTargetData(); - // Print all IDATA sections. - const std::vector &IDATASections = PTOF->IDATASections(); - for (unsigned i = 0; i < IDATASections.size(); i++) { + // Print all BSS sections. + const std::vector &BSSSections = PTOF->BSSSections; + for (unsigned i = 0; i < BSSSections.size(); i++) { O << "\n"; - if (IDATASections[i]->getName().find("llvm.") != std::string::npos) - continue; - - EmitInitializedDataSection(IDATASections[i]); - } -} - -void PIC16AsmPrinter::EmitUninitializedDataSection(const PIC16Section *S) { - const TargetData *TD = TM.getTargetData(); - OutStreamer.SwitchSection(S); - std::vector Items = S->Items; + OutStreamer.SwitchSection(BSSSections[i]->S_); + std::vector Items = BSSSections[i]->Items; for (unsigned j = 0; j < Items.size(); j++) { std::string Name = Mang->getMangledName(Items[j]); Constant *C = Items[j]->getInitializer(); const Type *Ty = C->getType(); unsigned Size = TD->getTypeAllocSize(Ty); + O << Name << " RES " << Size << "\n"; } -} - -void PIC16AsmPrinter::EmitUData(Module &M) { - // Print all UDATA sections. - const std::vector &UDATASections = PTOF->UDATASections(); - for (unsigned i = 0; i < UDATASections.size(); i++) { - O << "\n"; - EmitUninitializedDataSection(UDATASections[i]); } } -void PIC16AsmPrinter::EmitUserSections(Module &M) { - const std::vector &USERSections = PTOF->USERSections(); - for (unsigned i = 0; i < USERSections.size(); i++) { +void PIC16AsmPrinter::EmitAutos(std::string FunctName) { + // Section names for all globals are already set. + const TargetData *TD = TM.getTargetData(); + + // Now print Autos section for this function. + std::string SectionName = PAN::getAutosSectionName(FunctName); + const std::vector &AutosSections = PTOF->AutosSections; + for (unsigned i = 0; i < AutosSections.size(); i++) { O << "\n"; - const PIC16Section *S = USERSections[i]; - if (S->isUDATA_Type()) { - EmitUninitializedDataSection(S); - } else if (S->isIDATA_Type() || S->isROMDATA_Type()) { - EmitInitializedDataSection(S); - } else { - llvm_unreachable ("unknow user section type"); + if (AutosSections[i]->S_->getName() == SectionName) { + // Set the printing status to true + AutosSections[i]->setPrintedStatus(true); + OutStreamer.SwitchSection(AutosSections[i]->S_); + const std::vector &Items = AutosSections[i]->Items; + for (unsigned j = 0; j < Items.size(); j++) { + std::string VarName = Mang->getMangledName(Items[j]); + Constant *C = Items[j]->getInitializer(); + const Type *Ty = C->getType(); + unsigned Size = TD->getTypeAllocSize(Ty); + // Emit memory reserve directive. + O << VarName << " RES " << Size << "\n"; + } + break; } } } -void PIC16AsmPrinter::EmitAllAutos(Module &M) { - // Print all AUTO sections. - const std::vector &AUTOSections = PTOF->AUTOSections(); - for (unsigned i = 0; i < AUTOSections.size(); i++) { +// Print autos that were not printed during the code printing of functions. +// As the functions might themselves would have got deleted by the optimizer. +void PIC16AsmPrinter::EmitRemainingAutos() { + const TargetData *TD = TM.getTargetData(); + + // Now print Autos section for this function. + std::vector AutosSections = PTOF->AutosSections; + for (unsigned i = 0; i < AutosSections.size(); i++) { + + // if the section is already printed then don't print again + if (AutosSections[i]->isPrinted()) + continue; + + // Set status as printed + AutosSections[i]->setPrintedStatus(true); + O << "\n"; - EmitUninitializedDataSection(AUTOSections[i]); + OutStreamer.SwitchSection(AutosSections[i]->S_); + const std::vector &Items = AutosSections[i]->Items; + for (unsigned j = 0; j < Items.size(); j++) { + std::string VarName = Mang->getMangledName(Items[j]); + Constant *C = Items[j]->getInitializer(); + const Type *Ty = C->getType(); + unsigned Size = TD->getTypeAllocSize(Ty); + // Emit memory reserve directive. + O << VarName << " RES " << Size << "\n"; + } } } + extern "C" void LLVMInitializePIC16AsmPrinter() { RegisterAsmPrinter X(ThePIC16Target); } Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h?rev=84184&r1=84183&r2=84184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h Thu Oct 15 10:02:14 2009 @@ -53,13 +53,11 @@ void EmitDefinedVars (Module &M); void EmitIData (Module &M); void EmitUData (Module &M); - void EmitAllAutos (Module &M); + void EmitAutos (std::string FunctName); + void EmitRemainingAutos (); void EmitRomData (Module &M); - void EmitUserSections (Module &M); void EmitFunctionFrame(MachineFunction &MF); void printLibcallDecls(); - void EmitUninitializedDataSection(const PIC16Section *S); - void EmitInitializedDataSection(const PIC16Section *S); protected: bool doInitialization(Module &M); bool doFinalization(Module &M); @@ -76,8 +74,6 @@ PIC16DbgInfo DbgInfo; const PIC16MCAsmInfo *PMAI; std::list LibcallDecls; // List of extern decls. - std::vector ExternalVarDecls; - std::vector ExternalVarDefs; }; } // end of namespace Modified: llvm/trunk/lib/Target/PIC16/PIC16.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16.h?rev=84184&r1=84183&r2=84184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16.h Thu Oct 15 10:02:14 2009 @@ -42,16 +42,267 @@ UGE }; } - - enum PIC16SectionType { - CODE, - UDATA, - IDATA, - ROMDATA, - UDATA_OVR, - UDATA_SHR + // A Central class to manage all ABI naming conventions. + // PAN - [P]ic16 [A]BI [N]ames + class PAN { + public: + // Map the name of the symbol to its section name. + // Current ABI: + // ----------------------------------------------------- + // ALL Names are prefixed with the symobl '@'. + // ------------------------------------------------------ + // Global variables do not have any '.' in their names. + // These are maily function names and global variable names. + // Example - @foo, @i + // ------------------------------------------------------- + // Functions and auto variables. + // Names are mangled as .. + // Where is '@' and is any one of + // the following + // .auto. - an automatic var of a function. + // .temp. - temproray data of a function. + // .ret. - return value label for a function. + // .frame. - Frame label for a function where retval, args + // and temps are stored. + // .args. - Label used to pass arguments to a direct call. + // Example - Function name: @foo + // Its frame: @foo.frame. + // Its retval: @foo.ret. + // Its local vars: @foo.auto.a + // Its temp data: @foo.temp. + // Its arg passing: @foo.args. + //---------------------------------------------- + // Libcall - compiler generated libcall names must start with .lib. + // This id will be used to emit extern decls for libcalls. + // Example - libcall name: @.lib.sra.i8 + // To pass args: @.lib.sra.i8.args. + // To return val: @.lib.sra.i8.ret. + //---------------------------------------------- + // SECTION Names + // uninitialized globals - @udata..# + // initialized globals - @idata..# + // Function frame - @.frame_section. + // Function autos - @.autos_section. + // Declarations - Enclosed in comments. No section for them. + //---------------------------------------------------------- + + // Tags used to mangle different names. + enum TAGS { + PREFIX_SYMBOL, + GLOBAL, + STATIC_LOCAL, + AUTOS_LABEL, + FRAME_LABEL, + RET_LABEL, + ARGS_LABEL, + TEMPS_LABEL, + + LIBCALL, + + FRAME_SECTION, + AUTOS_SECTION, + CODE_SECTION }; + // Textual names of the tags. + inline static const char *getTagName(TAGS tag) { + switch (tag) { + default: return ""; + case PREFIX_SYMBOL: return "@"; + case AUTOS_LABEL: return ".auto."; + case FRAME_LABEL: return ".frame."; + case TEMPS_LABEL: return ".temp."; + case ARGS_LABEL: return ".args."; + case RET_LABEL: return ".ret."; + case LIBCALL: return ".lib."; + case FRAME_SECTION: return ".frame_section."; + case AUTOS_SECTION: return ".autos_section."; + case CODE_SECTION: return ".code_section."; + } + } + + // Get tag type for the Symbol. + inline static TAGS getSymbolTag(const std::string &Sym) { + if (Sym.find(getTagName(TEMPS_LABEL)) != std::string::npos) + return TEMPS_LABEL; + + if (Sym.find(getTagName(FRAME_LABEL)) != std::string::npos) + return FRAME_LABEL; + + if (Sym.find(getTagName(RET_LABEL)) != std::string::npos) + return RET_LABEL; + + if (Sym.find(getTagName(ARGS_LABEL)) != std::string::npos) + return ARGS_LABEL; + + if (Sym.find(getTagName(AUTOS_LABEL)) != std::string::npos) + return AUTOS_LABEL; + + if (Sym.find(getTagName(LIBCALL)) != std::string::npos) + return LIBCALL; + + // It does not have any Tag. So its a true global or static local. + if (Sym.find(".") == std::string::npos) + return GLOBAL; + + // If a . is there, then it may be static local. + // We should mangle these as well in clang. + if (Sym.find(".") != std::string::npos) + return STATIC_LOCAL; + + assert (0 && "Could not determine Symbol's tag"); + return PREFIX_SYMBOL; // Silence warning when assertions are turned off. + } + + // addPrefix - add prefix symbol to a name if there isn't one already. + inline static std::string addPrefix (const std::string &Name) { + std::string prefix = getTagName (PREFIX_SYMBOL); + + // If this name already has a prefix, nothing to do. + if (Name.compare(0, prefix.size(), prefix) == 0) + return Name; + + return prefix + Name; + } + + // Get mangled func name from a mangled sym name. + // In all cases func name is the first component before a '.'. + static inline std::string getFuncNameForSym(const std::string &Sym1) { + assert (getSymbolTag(Sym1) != GLOBAL && "not belongs to a function"); + + std::string Sym = addPrefix(Sym1); + + // Position of the . after func name. That's where func name ends. + size_t func_name_end = Sym.find ('.'); + + return Sym.substr (0, func_name_end); + } + + // Get Frame start label for a func. + static std::string getFrameLabel(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(FRAME_LABEL); + return Func1 + tag; + } + + static std::string getRetvalLabel(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(RET_LABEL); + return Func1 + tag; + } + + static std::string getArgsLabel(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(ARGS_LABEL); + return Func1 + tag; + } + + static std::string getTempdataLabel(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(TEMPS_LABEL); + return Func1 + tag; + } + + static std::string getFrameSectionName(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(FRAME_SECTION); + return Func1 + tag + "# UDATA_OVR"; + } + + static std::string getAutosSectionName(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(AUTOS_SECTION); + return Func1 + tag + "# UDATA_OVR"; + } + + static std::string getCodeSectionName(const std::string &Func) { + std::string Func1 = addPrefix(Func); + std::string tag = getTagName(CODE_SECTION); + return Func1 + tag + "# CODE"; + } + + // udata, romdata and idata section names are generated by a given number. + // @udata..# + static std::string getUdataSectionName(unsigned num, + std::string prefix = "") { + std::ostringstream o; + o << getTagName(PREFIX_SYMBOL) << prefix << "udata." << num + << ".# UDATA"; + return o.str(); + } + + static std::string getRomdataSectionName(unsigned num, + std::string prefix = "") { + std::ostringstream o; + o << getTagName(PREFIX_SYMBOL) << prefix << "romdata." << num + << ".# ROMDATA"; + return o.str(); + } + + static std::string getIdataSectionName(unsigned num, + std::string prefix = "") { + std::ostringstream o; + o << getTagName(PREFIX_SYMBOL) << prefix << "idata." << num + << ".# IDATA"; + return o.str(); + } + + inline static bool isLocalName (const std::string &Name) { + if (getSymbolTag(Name) == AUTOS_LABEL) + return true; + + return false; + } + + inline static bool isMemIntrinsic (const std::string &Name) { + if (Name.compare("@memcpy") == 0 || Name.compare("@memset") == 0 || + Name.compare("@memmove") == 0) { + return true; + } + + return false; + } + + inline static bool isLocalToFunc (std::string &Func, std::string &Var) { + if (! isLocalName(Var)) return false; + + std::string Func1 = addPrefix(Func); + // Extract func name of the varilable. + const std::string &fname = getFuncNameForSym(Var); + + if (fname.compare(Func1) == 0) + return true; + + return false; + } + + + // Get the section for the given external symbol names. + // This tries to find the type (Tag) of the symbol from its mangled name + // and return appropriate section name for it. + static inline std::string getSectionNameForSym(const std::string &Sym1) { + std::string Sym = addPrefix(Sym1); + + std::string SectionName; + + std::string Fname = getFuncNameForSym (Sym); + TAGS id = getSymbolTag (Sym); + + switch (id) { + default : assert (0 && "Could not determine external symbol type"); + case FRAME_LABEL: + case RET_LABEL: + case TEMPS_LABEL: + case ARGS_LABEL: { + return getFrameSectionName(Fname); + } + case AUTOS_LABEL: { + return getAutosSectionName(Fname); + } + } + } + }; // class PAN. + // External symbol names require memory to live till the program end. // So we have to allocate it and keep. Removed: llvm/trunk/lib/Target/PIC16/PIC16ABINames.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ABINames.h?rev=84183&view=auto ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ABINames.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ABINames.h (removed) @@ -1,305 +0,0 @@ -//===-- PIC16ABINames.h - PIC16 Naming conventios for ABI----- --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains the functions to manage ABI Naming conventions for PIC16. -// -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TARGET_PIC16ABINAMES_H -#define LLVM_TARGET_PIC16ABINAMES_H - -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Target/TargetMachine.h" -#include -#include -#include -#include - -namespace llvm { - class PIC16TargetMachine; - class FunctionPass; - class MachineCodeEmitter; - class formatted_raw_ostream; - - // A Central class to manage all ABI naming conventions. - // PAN - [P]ic16 [A]BI [N]ames - class PAN { - public: - // Map the name of the symbol to its section name. - // Current ABI: - // ----------------------------------------------------- - // ALL Names are prefixed with the symobl '@'. - // ------------------------------------------------------ - // Global variables do not have any '.' in their names. - // These are maily function names and global variable names. - // Example - @foo, @i - // ------------------------------------------------------- - // Functions and auto variables. - // Names are mangled as .. - // Where is '@' and is any one of - // the following - // .auto. - an automatic var of a function. - // .temp. - temproray data of a function. - // .ret. - return value label for a function. - // .frame. - Frame label for a function where retval, args - // and temps are stored. - // .args. - Label used to pass arguments to a direct call. - // Example - Function name: @foo - // Its frame: @foo.frame. - // Its retval: @foo.ret. - // Its local vars: @foo.auto.a - // Its temp data: @foo.temp. - // Its arg passing: @foo.args. - //---------------------------------------------- - // Libcall - compiler generated libcall names must start with .lib. - // This id will be used to emit extern decls for libcalls. - // Example - libcall name: @.lib.sra.i8 - // To pass args: @.lib.sra.i8.args. - // To return val: @.lib.sra.i8.ret. - //---------------------------------------------- - // SECTION Names - // uninitialized globals - @udata..# - // initialized globals - @idata..# - // Function frame - @.frame_section. - // Function autos - @.autos_section. - // Declarations - Enclosed in comments. No section for them. - //---------------------------------------------------------- - - // Tags used to mangle different names. - enum TAGS { - PREFIX_SYMBOL, - GLOBAL, - STATIC_LOCAL, - AUTOS_LABEL, - FRAME_LABEL, - RET_LABEL, - ARGS_LABEL, - TEMPS_LABEL, - - LIBCALL, - - FRAME_SECTION, - AUTOS_SECTION, - CODE_SECTION, - USER_SECTION - }; - - // Textual names of the tags. - inline static const char *getTagName(TAGS tag) { - switch (tag) { - default: return ""; - case PREFIX_SYMBOL: return "@"; - case AUTOS_LABEL: return ".auto."; - case FRAME_LABEL: return ".frame."; - case TEMPS_LABEL: return ".temp."; - case ARGS_LABEL: return ".args."; - case RET_LABEL: return ".ret."; - case LIBCALL: return ".lib."; - case FRAME_SECTION: return ".frame_section."; - case AUTOS_SECTION: return ".autos_section."; - case CODE_SECTION: return ".code_section."; - case USER_SECTION: return ".user_section."; - } - } - - // Get tag type for the Symbol. - inline static TAGS getSymbolTag(const std::string &Sym) { - if (Sym.find(getTagName(TEMPS_LABEL)) != std::string::npos) - return TEMPS_LABEL; - - if (Sym.find(getTagName(FRAME_LABEL)) != std::string::npos) - return FRAME_LABEL; - - if (Sym.find(getTagName(RET_LABEL)) != std::string::npos) - return RET_LABEL; - - if (Sym.find(getTagName(ARGS_LABEL)) != std::string::npos) - return ARGS_LABEL; - - if (Sym.find(getTagName(AUTOS_LABEL)) != std::string::npos) - return AUTOS_LABEL; - - if (Sym.find(getTagName(LIBCALL)) != std::string::npos) - return LIBCALL; - - // It does not have any Tag. So its a true global or static local. - if (Sym.find(".") == std::string::npos) - return GLOBAL; - - // If a . is there, then it may be static local. - // We should mangle these as well in clang. - if (Sym.find(".") != std::string::npos) - return STATIC_LOCAL; - - assert (0 && "Could not determine Symbol's tag"); - return PREFIX_SYMBOL; // Silence warning when assertions are turned off. - } - - // addPrefix - add prefix symbol to a name if there isn't one already. - inline static std::string addPrefix (const std::string &Name) { - std::string prefix = getTagName (PREFIX_SYMBOL); - - // If this name already has a prefix, nothing to do. - if (Name.compare(0, prefix.size(), prefix) == 0) - return Name; - - return prefix + Name; - } - - // Get mangled func name from a mangled sym name. - // In all cases func name is the first component before a '.'. - static inline std::string getFuncNameForSym(const std::string &Sym1) { - assert (getSymbolTag(Sym1) != GLOBAL && "not belongs to a function"); - - std::string Sym = addPrefix(Sym1); - - // Position of the . after func name. That's where func name ends. - size_t func_name_end = Sym.find ('.'); - - return Sym.substr (0, func_name_end); - } - - // Get Frame start label for a func. - static std::string getFrameLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(FRAME_LABEL); - return Func1 + tag; - } - - static std::string getRetvalLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(RET_LABEL); - return Func1 + tag; - } - - static std::string getArgsLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(ARGS_LABEL); - return Func1 + tag; - } - - static std::string getTempdataLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(TEMPS_LABEL); - return Func1 + tag; - } - - static std::string getFrameSectionName(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(FRAME_SECTION); - return Func1 + tag + "#"; - } - - static std::string getAutosSectionName(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(AUTOS_SECTION); - return Func1 + tag + "#"; - } - - static std::string getCodeSectionName(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(CODE_SECTION); - return Func1 + tag + "#"; - } - - static std::string getUserSectionName(const std::string &Name) { - std::string sname = addPrefix(Name);; - std::string tag = getTagName(USER_SECTION); - return sname + tag + "#"; - } - - // udata, romdata and idata section names are generated by a given number. - // @udata..# - static std::string getUdataSectionName(unsigned num, - std::string prefix = "") { - std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << prefix << "udata." << num - << ".#"; - return o.str(); - } - - static std::string getRomdataSectionName() { - return "romdata.#"; - } - - static std::string getRomdataSectionName(unsigned num, - std::string prefix = "") { - std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << prefix << "romdata." << num - << ".#"; - return o.str(); - } - - static std::string getIdataSectionName(unsigned num, - std::string prefix = "") { - std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << prefix << "idata." << num - << ".#"; - return o.str(); - } - - inline static bool isLocalName (const std::string &Name) { - if (getSymbolTag(Name) == AUTOS_LABEL) - return true; - - return false; - } - - inline static bool isMemIntrinsic (const std::string &Name) { - if (Name.compare("@memcpy") == 0 || Name.compare("@memset") == 0 || - Name.compare("@memmove") == 0) { - return true; - } - - return false; - } - - inline static bool isLocalToFunc (std::string &Func, std::string &Var) { - if (! isLocalName(Var)) return false; - - std::string Func1 = addPrefix(Func); - // Extract func name of the varilable. - const std::string &fname = getFuncNameForSym(Var); - - if (fname.compare(Func1) == 0) - return true; - - return false; - } - - - // Get the section for the given external symbol names. - // This tries to find the type (Tag) of the symbol from its mangled name - // and return appropriate section name for it. - static inline std::string getSectionNameForSym(const std::string &Sym1) { - std::string Sym = addPrefix(Sym1); - - std::string SectionName; - - std::string Fname = getFuncNameForSym (Sym); - TAGS id = getSymbolTag (Sym); - - switch (id) { - default : assert (0 && "Could not determine external symbol type"); - case FRAME_LABEL: - case RET_LABEL: - case TEMPS_LABEL: - case ARGS_LABEL: { - return getFrameSectionName(Fname); - } - case AUTOS_LABEL: { - return getAutosSectionName(Fname); - } - } - } - }; // class PAN. -} // end namespace llvm; - -#endif Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=84184&r1=84183&r2=84184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Thu Oct 15 10:02:14 2009 @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "PIC16.h" -#include "PIC16ABINames.h" #include "PIC16DebugInfo.h" #include "llvm/GlobalVariable.h" #include "llvm/CodeGen/MachineFunction.h" Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=84184&r1=84183&r2=84184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Thu Oct 15 10:02:14 2009 @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "pic16-lower" -#include "PIC16ABINames.h" #include "PIC16ISelLowering.h" #include "PIC16TargetObjectFile.h" #include "PIC16TargetMachine.h" Modified: llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp?rev=84184&r1=84183&r2=84184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp Thu Oct 15 10:02:14 2009 @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "PIC16.h" -#include "PIC16ABINames.h" #include "PIC16InstrInfo.h" #include "PIC16TargetMachine.h" #include "PIC16GenInstrInfo.inc" Modified: llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp?rev=84184&r1=84183&r2=84184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp Thu Oct 15 10:02:14 2009 @@ -16,7 +16,6 @@ // FIXME: Layering violation to get enums and static function, should be moved // to separate headers. #include "PIC16.h" -#include "PIC16ABINames.h" #include "PIC16ISelLowering.h" using namespace llvm; Modified: llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp?rev=84184&r1=84183&r2=84184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp Thu Oct 15 10:02:14 2009 @@ -21,7 +21,6 @@ #define DEBUG_TYPE "pic16-codegen" #include "PIC16.h" -#include "PIC16ABINames.h" #include "PIC16InstrInfo.h" #include "PIC16MCAsmInfo.h" #include "PIC16TargetMachine.h" Removed: llvm/trunk/lib/Target/PIC16/PIC16Section.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Section.cpp?rev=84183&view=auto ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Section.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16Section.cpp (removed) @@ -1,91 +0,0 @@ -//===-- PIC16Section.cpp - PIC16 Section ----------- --------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "PIC16.h" -#include "PIC16ABINames.h" -#include "PIC16Section.h" -#include "llvm/MC/MCContext.h" -#include "llvm/Support/raw_ostream.h" -using namespace llvm; - - -// This is the only way to create a PIC16Section. Sections created here -// do not need to be explicitly deleted as they are managed by auto_ptrs. -PIC16Section *PIC16Section::Create(const StringRef &Name, - PIC16SectionType Ty, - const std::string &Address, - int Color, MCContext &Ctx) { - - /// Determine the internal SectionKind info. - /// Users of PIC16Section class should not need to know the internal - /// SectionKind. They should work only with PIC16SectionType. - /// - /// PIC16 Terminology for section kinds is as below. - /// UDATA - BSS - /// IDATA - initialized data (equiv to Metadata) - /// ROMDATA - ReadOnly. - /// UDATA_OVR - Sections that can be overlaid. Section of such type is - /// used to contain function autos an frame. We can think of - /// it as equiv to llvm ThreadBSS) - /// UDATA_SHR - Shared RAM. Memory area that is mapped to all banks. - - SectionKind K; - switch (Ty) { - default: llvm_unreachable ("can not create unknown section type"); - case UDATA_OVR: { - K = SectionKind::getThreadBSS(); - break; - } - case UDATA_SHR: - case UDATA: { - K = SectionKind::getBSS(); - break; - } - case ROMDATA: - case IDATA: { - K = SectionKind::getMetadata(); - break; - } - case CODE: { - K = SectionKind::getText(); - break; - } - - } - - // Create the Section. - PIC16Section *S = new (Ctx) PIC16Section(Name, K, Address, Color); - S->T = Ty; - return S; -} - -// A generic way to print all types of sections. -void PIC16Section::PrintSwitchToSection(const MCAsmInfo &MAI, - raw_ostream &OS) const { - // Print name. - OS << getName() << '\t'; - - // Print type. - switch (getType()) { - default : llvm_unreachable ("unknown section type"); - case UDATA: OS << "UDATA"; break; - case IDATA: OS << "IDATA"; break; - case ROMDATA: OS << "ROMDATA"; break; - case UDATA_SHR: OS << "UDATA_SHR"; break; - case UDATA_OVR: OS << "UDATA_OVR"; break; - case CODE: OS << "CODE"; break; - } - - OS << '\t'; - - // Print Address. - OS << Address; - - OS << '\n'; -} Removed: llvm/trunk/lib/Target/PIC16/PIC16Section.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Section.h?rev=84183&view=auto ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Section.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16Section.h (removed) @@ -1,91 +0,0 @@ -//===- PIC16Section.h - PIC16-specific section representation -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the PIC16Section class. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_PIC16SECTION_H -#define LLVM_PIC16SECTION_H - -#include "llvm/MC/MCSection.h" -#include "llvm/GlobalVariable.h" -#include - -namespace llvm { - /// PIC16Section - Represents a physical section in PIC16 COFF. - /// Contains data objects. - /// - class PIC16Section : public MCSection { - /// PIC16 Sections does not really use the SectionKind class to - /// to distinguish between various types of sections. PIC16 maintain - /// its own Section Type info. See the PIC16SectionType enum in PIC16.h - /// for various section types. - PIC16SectionType T; - - /// Name of the section to uniquely identify it. - std::string Name; - - /// User can specify an address at which a section should be placed. - /// Negative value here means user hasn't specified any. - std::string Address; - - /// Overlay information - Sections with same color can be overlaid on - /// one another. - int Color; - - /// Total size of all data objects contained here. - unsigned Size; - - PIC16Section(const StringRef &name, SectionKind K, const std::string &addr, - int color) - : MCSection(K), Name(name), Address(addr), Color(color) { - } - - public: - /// Return the name of the section. - const std::string &getName() const { return Name; } - - /// Return the Address of the section. - const std::string &getAddress() const { return Address; } - - /// Return the Color of the section. - int getColor() const { return Color; } - - /// Return the size of the section. - unsigned getSize() const { return Size; } - void setSize(unsigned size) { Size = size; } - - /// Conatined data objects. - std::vectorItems; - - /// Check section type. - bool isUDATA_Type() const { return T == UDATA; } - bool isIDATA_Type() const { return T == IDATA; } - bool isROMDATA_Type() const { return T == ROMDATA; } - bool isUDATA_OVR_Type() const { return T == UDATA_OVR; } - bool isUDATA_SHR_Type() const { return T == UDATA_SHR; } - bool isCODE_Type() const { return T == CODE; } - - PIC16SectionType getType() const { return T; } - - /// This would be the only way to create a section. - static PIC16Section *Create(const StringRef &Name, PIC16SectionType Ty, - const std::string &Address, int Color, - MCContext &Ctx); - - /// Override this as PIC16 has its own way of printing switching - /// to a section. - virtual void PrintSwitchToSection(const MCAsmInfo &MAI, - raw_ostream &OS) const; - }; - -} // end namespace llvm - -#endif Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp?rev=84184&r1=84183&r2=84184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp Thu Oct 15 10:02:14 2009 @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// #include "PIC16TargetObjectFile.h" +#include "MCSectionPIC16.h" #include "PIC16ISelLowering.h" #include "PIC16TargetMachine.h" -#include "PIC16Section.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/MC/MCSection.h" @@ -19,111 +19,75 @@ using namespace llvm; -PIC16TargetObjectFile::PIC16TargetObjectFile() { +MCSectionPIC16 *MCSectionPIC16::Create(const StringRef &Name, SectionKind K, + int Address, int Color, MCContext &Ctx) { + return new (Ctx) MCSectionPIC16(Name, K, Address, Color); } -/// Find a pic16 section. If not found, create one. -PIC16Section *PIC16TargetObjectFile:: -getPIC16Section(const std::string &Name, PIC16SectionType Ty, - const std::string &Address, int Color) const { - /// Return if we have an already existing one. - PIC16Section *&Entry = SectionsByName[Name]; - if (Entry) - return Entry; - - - Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); - return Entry; +void MCSectionPIC16::PrintSwitchToSection(const MCAsmInfo &MAI, + raw_ostream &OS) const { + OS << getName() << '\n'; } -/// Find a standard pic16 data section. If not found, create one and keep -/// track of it by adding it to appropriate std section list. -PIC16Section *PIC16TargetObjectFile:: -getPIC16DataSection(const std::string &Name, PIC16SectionType Ty, - const std::string &Address, int Color) const { - - /// Return if we have an already existing one. - PIC16Section *&Entry = SectionsByName[Name]; - if (Entry) - return Entry; - - /// Else create a new one and add it to appropriate section list. - Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); - switch (Ty) { - default: llvm_unreachable ("unknow standard section type."); - case UDATA: UDATASections_.push_back(Entry); break; - case IDATA: IDATASections_.push_back(Entry); break; - case ROMDATA: ROMDATASection_ = Entry; break; - } - return Entry; +PIC16TargetObjectFile::PIC16TargetObjectFile() + : ExternalVarDecls(0), ExternalVarDefs(0) { } - - -/// Find a standard pic16 autos section. If not found, create one and keep -/// track of it by adding it to appropriate std section list. -PIC16Section *PIC16TargetObjectFile:: -getPIC16AutoSection(const std::string &Name, PIC16SectionType Ty, - const std::string &Address, int Color) const { - /// Return if we have an already existing one. - PIC16Section *&Entry = SectionsByName[Name]; +const MCSectionPIC16 *PIC16TargetObjectFile:: +getPIC16Section(const char *Name, SectionKind Kind, + int Address, int Color) const { + MCSectionPIC16 *&Entry = SectionsByName[Name]; if (Entry) return Entry; - - /// Else create a new one and add it to appropriate section list. - Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); - - assert (Ty == UDATA_OVR && "incorrect section type for autos"); - AUTOSections_.push_back(Entry); - - return Entry; + return Entry = MCSectionPIC16::Create(Name, Kind, Address, Color, + getContext()); } - -/// Find a pic16 user section. If not found, create one and keep -/// track of it by adding it to appropriate std section list. -PIC16Section *PIC16TargetObjectFile:: -getPIC16UserSection(const std::string &Name, PIC16SectionType Ty, - const std::string &Address, int Color) const { - - /// Return if we have an already existing one. - PIC16Section *&Entry = SectionsByName[Name]; - if (Entry) - return Entry; - /// Else create a new one and add it to appropriate section list. - Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); - - USERSections_.push_back(Entry); - - return Entry; -} - -/// Do some standard llvm stuff. PIC16 really does not need any of this. void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){ TargetLoweringObjectFile::Initialize(Ctx, tm); TM = &tm; - // BSSSection = getPIC16DataSection("udata.#", UDATA); - // ReadOnlySection = getPIC16DataSection("romdata.#", ROMDATA); - // DataSection = getPIC16DataSection("idata.#", IDATA); + BSSSection = getPIC16Section("udata.# UDATA", MCSectionPIC16::UDATA_Kind()); + ReadOnlySection = getPIC16Section("romdata.# ROMDATA", + MCSectionPIC16::ROMDATA_Kind()); + DataSection = getPIC16Section("idata.# IDATA", MCSectionPIC16::IDATA_Kind()); // Need because otherwise a .text symbol is emitted by DwarfWriter // in BeginModule, and gpasm cribbs for that .text symbol. - // FIXME: below - // TextSection = getPIC16DataSection("", UDATA); - ROMDATASection_ = NULL; + TextSection = getPIC16Section("", SectionKind::getText()); + + ROSections.push_back(new PIC16Section((MCSectionPIC16*)ReadOnlySection)); + + // FIXME: I don't know what the classification of these sections really is. + // These aren't really objects belonging to any section. Just emit them + // in AsmPrinter and remove this code from here. + ExternalVarDecls = new PIC16Section(getPIC16Section("ExternalVarDecls", + SectionKind::getMetadata())); + ExternalVarDefs = new PIC16Section(getPIC16Section("ExternalVarDefs", + SectionKind::getMetadata())); +} + +const MCSection *PIC16TargetObjectFile:: +getSectionForFunction(const std::string &FnName) const { + std::string T = PAN::getCodeSectionName(FnName); + return getPIC16Section(T.c_str(), SectionKind::getText()); +} + + +const MCSection *PIC16TargetObjectFile:: +getSectionForFunctionFrame(const std::string &FnName) const { + std::string T = PAN::getFrameSectionName(FnName); + return getPIC16Section(T.c_str(), SectionKind::getDataRel()); } -/// allocateUDATA - Allocate a un-initialized global to an existing or new UDATA -/// section and return that section. const MCSection * -PIC16TargetObjectFile::allocateUDATA(const GlobalVariable *GV) const { +PIC16TargetObjectFile::getBSSSectionForGlobal(const GlobalVariable *GV) const { assert(GV->hasInitializer() && "This global doesn't need space"); Constant *C = GV->getInitializer(); assert(C->isNullValue() && "Unitialized globals has non-zero initializer"); @@ -133,37 +97,41 @@ const Type *Ty = C->getType(); unsigned ValSize = TD->getTypeAllocSize(Ty); - // Go through all UDATA Sections and assign this variable + // Go through all BSS Sections and assign this variable // to the first available section having enough space. - PIC16Section *Found = NULL; - for (unsigned i = 0; i < UDATASections_.size(); i++) { - if (DataBankSize - UDATASections_[i]->getSize() >= ValSize) { - Found = UDATASections_[i]; + PIC16Section *FoundBSS = NULL; + for (unsigned i = 0; i < BSSSections.size(); i++) { + if (DataBankSize - BSSSections[i]->Size >= ValSize) { + FoundBSS = BSSSections[i]; break; } } - // No UDATA section spacious enough was found. Crate a new one. - if (!Found) { - std::string name = PAN::getUdataSectionName(UDATASections_.size()); - Found = getPIC16DataSection(name.c_str(), UDATA); + // No BSS section spacious enough was found. Crate a new one. + if (!FoundBSS) { + std::string name = PAN::getUdataSectionName(BSSSections.size()); + const MCSectionPIC16 *NewSection + = getPIC16Section(name.c_str(), MCSectionPIC16::UDATA_Kind()); + + FoundBSS = new PIC16Section(NewSection); + + // Add this newly created BSS section to the list of BSSSections. + BSSSections.push_back(FoundBSS); } - // Insert the GV into this UDATA section. - Found->Items.push_back(GV); - Found->setSize(Found->getSize() + ValSize); - return Found; + // Insert the GV into this BSS. + FoundBSS->Items.push_back(GV); + FoundBSS->Size += ValSize; + return FoundBSS->S_; } -/// allocateIDATA - allocate an initialized global into an existing -/// or new section and return that section. const MCSection * -PIC16TargetObjectFile::allocateIDATA(const GlobalVariable *GV) const{ +PIC16TargetObjectFile::getIDATASectionForGlobal(const GlobalVariable *GV) const{ assert(GV->hasInitializer() && "This global doesn't need space"); Constant *C = GV->getInitializer(); assert(!C->isNullValue() && "initialized globals has zero initializer"); assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE && - "can allocate initialized RAM data only"); + "can split initialized RAM data only"); // Find how much space this global needs. const TargetData *TD = TM->getTargetData(); @@ -172,47 +140,64 @@ // Go through all IDATA Sections and assign this variable // to the first available section having enough space. - PIC16Section *Found = NULL; - for (unsigned i = 0; i < IDATASections_.size(); i++) { - if (DataBankSize - IDATASections_[i]->getSize() >= ValSize) { - Found = IDATASections_[i]; + PIC16Section *FoundIDATA = NULL; + for (unsigned i = 0; i < IDATASections.size(); i++) { + if (DataBankSize - IDATASections[i]->Size >= ValSize) { + FoundIDATA = IDATASections[i]; break; } } // No IDATA section spacious enough was found. Crate a new one. - if (!Found) { - std::string name = PAN::getIdataSectionName(IDATASections_.size()); - Found = getPIC16DataSection(name.c_str(), IDATA); + if (!FoundIDATA) { + std::string name = PAN::getIdataSectionName(IDATASections.size()); + const MCSectionPIC16 *NewSection = + getPIC16Section(name.c_str(), MCSectionPIC16::IDATA_Kind()); + + FoundIDATA = new PIC16Section(NewSection); + + // Add this newly created IDATA section to the list of IDATASections. + IDATASections.push_back(FoundIDATA); } // Insert the GV into this IDATA. - Found->Items.push_back(GV); - Found->setSize(Found->getSize() + ValSize); - return Found; + FoundIDATA->Items.push_back(GV); + FoundIDATA->Size += ValSize; + return FoundIDATA->S_; } -// Allocate a program memory variable into ROMDATA section. -const MCSection * -PIC16TargetObjectFile::allocateROMDATA(const GlobalVariable *GV) const { - - std::string name = PAN::getRomdataSectionName(); - PIC16Section *S = getPIC16DataSection(name.c_str(), ROMDATA); - - S->Items.push_back(GV); - return S; -} - // Get the section for an automatic variable of a function. // For PIC16 they are globals only with mangled names. const MCSection * -PIC16TargetObjectFile::allocateAUTO(const GlobalVariable *GV) const { +PIC16TargetObjectFile::getSectionForAuto(const GlobalVariable *GV) const { const std::string name = PAN::getSectionNameForSym(GV->getName()); - PIC16Section *S = getPIC16AutoSection(name.c_str()); - S->Items.push_back(GV); - return S; + // Go through all Auto Sections and assign this variable + // to the appropriate section. + PIC16Section *FoundAutoSec = NULL; + for (unsigned i = 0; i < AutosSections.size(); i++) { + if (AutosSections[i]->S_->getName() == name) { + FoundAutoSec = AutosSections[i]; + break; + } + } + + // No Auto section was found. Crate a new one. + if (!FoundAutoSec) { + const MCSectionPIC16 *NewSection = + getPIC16Section(name.c_str(), MCSectionPIC16::UDATA_OVR_Kind()); + + FoundAutoSec = new PIC16Section(NewSection); + + // Add this newly created autos section to the list of AutosSections. + AutosSections.push_back(FoundAutoSec); + } + + // Insert the auto into this section. + FoundAutoSec->Items.push_back(GV); + + return FoundAutoSec->S_; } @@ -229,50 +214,56 @@ if (!GV) return TargetLoweringObjectFile::SelectSectionForGlobal(GV1, Kind, Mang,TM); + // Record External Var Decls. + if (GV->isDeclaration()) { + ExternalVarDecls->Items.push_back(GV); + return ExternalVarDecls->S_; + } + assert(GV->hasInitializer() && "A def without initializer?"); // First, if this is an automatic variable for a function, get the section // name for it and return. std::string name = GV->getName(); if (PAN::isLocalName(name)) - return allocateAUTO(GV); + return getSectionForAuto(GV); + + // Record Exteranl Var Defs. + if (GV->hasExternalLinkage() || GV->hasCommonLinkage()) + ExternalVarDefs->Items.push_back(GV); // See if this is an uninitialized global. const Constant *C = GV->getInitializer(); if (C->isNullValue()) - return allocateUDATA(GV); + return getBSSSectionForGlobal(GV); // If this is initialized data in RAM. Put it in the correct IDATA section. if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) - return allocateIDATA(GV); + return getIDATASectionForGlobal(GV); // This is initialized data in rom, put it in the readonly section. if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) - return allocateROMDATA(GV); + return getROSectionForGlobal(GV); // Else let the default implementation take care of it. return TargetLoweringObjectFile::SelectSectionForGlobal(GV, Kind, Mang,TM); } PIC16TargetObjectFile::~PIC16TargetObjectFile() { -#if 0 - for (unsigned i = 0; i < UDATASections_.size(); i++) - delete UDATASections_[i]; - for (unsigned i = 0; i < IDATASections_.size(); i++) - delete IDATASections_[i]; - - delete ROMDATASection_; - - for (unsigned i = 0; i < AUTOSections_.size(); i++) - delete AUTOSections_[i]; - - for (unsigned i = 0; i < USERSections_.size(); i++) - delete USERSections_[i]; -#endif + for (unsigned i = 0; i < BSSSections.size(); i++) + delete BSSSections[i]; + for (unsigned i = 0; i < IDATASections.size(); i++) + delete IDATASections[i]; + for (unsigned i = 0; i < AutosSections.size(); i++) + delete AutosSections[i]; + for (unsigned i = 0; i < ROSections.size(); i++) + delete ROSections[i]; + delete ExternalVarDecls; + delete ExternalVarDefs; } -/// getExplicitSectionGlobal - Allow the target to completely override +/// getSpecialCasedSectionGlobals - Allow the target to completely override /// section assignment of a global. const MCSection *PIC16TargetObjectFile:: getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, @@ -283,83 +274,167 @@ std::string SectName = GVar->getSection(); // If address for a variable is specified, get the address and create // section. - // FIXME: move this attribute checking in PAN. std::string AddrStr = "Address="; if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) { std::string SectAddr = SectName.substr(AddrStr.length()); - return allocateAtGivenAddress(GVar, SectAddr); + return CreateSectionForGlobal(GVar, Mang, SectAddr); } // Create the section specified with section attribute. - return allocateInGivenSection(GVar); + return CreateSectionForGlobal(GVar, Mang); } - return getPIC16DataSection(GV->getSection().c_str(), UDATA); -} - -// Interface used by AsmPrinter to get a code section for a function. -const PIC16Section * -PIC16TargetObjectFile::SectionForCode(const std::string &FnName) const { - const std::string &sec_name = PAN::getCodeSectionName(FnName); - return getPIC16Section(sec_name, CODE); + return getPIC16Section(GV->getSection().c_str(), Kind); } -// Interface used by AsmPrinter to get a frame section for a function. -const PIC16Section * -PIC16TargetObjectFile::SectionForFrame(const std::string &FnName) const { - const std::string &sec_name = PAN::getFrameSectionName(FnName); - return getPIC16Section(sec_name, UDATA_OVR); -} - -// Allocate a global var in existing or new section of given name. +// Create a new section for global variable. If Addr is given then create +// section at that address else create by name. const MCSection * -PIC16TargetObjectFile::allocateInGivenSection(const GlobalVariable *GV) const { - // Determine the type of section that we need to create. - PIC16SectionType SecTy; - +PIC16TargetObjectFile::CreateSectionForGlobal(const GlobalVariable *GV, + Mangler *Mang, + const std::string &Addr) const { // See if this is an uninitialized global. const Constant *C = GV->getInitializer(); if (C->isNullValue()) - SecTy = UDATA; + return CreateBSSSectionForGlobal(GV, Addr); + // If this is initialized data in RAM. Put it in the correct IDATA section. - else if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) - SecTy = IDATA; + if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) + return CreateIDATASectionForGlobal(GV, Addr); + // This is initialized data in rom, put it in the readonly section. - else if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) - SecTy = ROMDATA; - else - llvm_unreachable ("Could not determine section type for global"); + if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) + return CreateROSectionForGlobal(GV, Addr); - PIC16Section *S = getPIC16UserSection(GV->getSection().c_str(), SecTy); - S->Items.push_back(GV); - return S; + // Else let the default implementation take care of it. + return TargetLoweringObjectFile::SectionForGlobal(GV, Mang, *TM); } -// Allocate a global var in a new absolute sections at given address. +// Create uninitialized section for a variable. const MCSection * -PIC16TargetObjectFile::allocateAtGivenAddress(const GlobalVariable *GV, - const std::string &Addr) const { - // Determine the type of section that we need to create. - PIC16SectionType SecTy; +PIC16TargetObjectFile::CreateBSSSectionForGlobal(const GlobalVariable *GV, + std::string Addr) const { + assert(GV->hasInitializer() && "This global doesn't need space"); + assert(GV->getInitializer()->isNullValue() && + "Unitialized global has non-zero initializer"); + std::string Name; + // If address is given then create a section at that address else create a + // section by section name specified in GV. + PIC16Section *FoundBSS = NULL; + if (Addr.empty()) { + Name = GV->getSection() + " UDATA"; + for (unsigned i = 0; i < BSSSections.size(); i++) { + if (BSSSections[i]->S_->getName() == Name) { + FoundBSS = BSSSections[i]; + break; + } + } + } else { + std::string Prefix = GV->getNameStr() + "." + Addr + "."; + Name = PAN::getUdataSectionName(BSSSections.size(), Prefix) + " " + Addr; + } + + PIC16Section *NewBSS = FoundBSS; + if (NewBSS == NULL) { + const MCSectionPIC16 *NewSection = + getPIC16Section(Name.c_str(), MCSectionPIC16::UDATA_Kind()); + NewBSS = new PIC16Section(NewSection); + BSSSections.push_back(NewBSS); + } - // See if this is an uninitialized global. - const Constant *C = GV->getInitializer(); - if (C->isNullValue()) - SecTy = UDATA; - // If this is initialized data in RAM. Put it in the correct IDATA section. - else if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) - SecTy = IDATA; - // This is initialized data in rom, put it in the readonly section. - else if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) - SecTy = ROMDATA; - else - llvm_unreachable ("Could not determine section type for global"); - - std::string Prefix = GV->getNameStr() + "." + Addr + "."; - std::string SName = PAN::getUserSectionName(Prefix); - PIC16Section *S = getPIC16UserSection(SName.c_str(), SecTy, Addr.c_str()); - S->Items.push_back(GV); - return S; + // Insert the GV into this BSS. + NewBSS->Items.push_back(GV); + + // We do not want to put any GV without explicit section into this section + // so set its size to DatabankSize. + NewBSS->Size = DataBankSize; + return NewBSS->S_; +} + +// Get rom section for a variable. Currently there can be only one rom section +// unless a variable explicitly requests a section. +const MCSection * +PIC16TargetObjectFile::getROSectionForGlobal(const GlobalVariable *GV) const { + ROSections[0]->Items.push_back(GV); + return ROSections[0]->S_; +} + +// Create initialized data section for a variable. +const MCSection * +PIC16TargetObjectFile::CreateIDATASectionForGlobal(const GlobalVariable *GV, + std::string Addr) const { + assert(GV->hasInitializer() && "This global doesn't need space"); + assert(!GV->getInitializer()->isNullValue() && + "initialized global has zero initializer"); + assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE && + "can be used for initialized RAM data only"); + + std::string Name; + // If address is given then create a section at that address else create a + // section by section name specified in GV. + PIC16Section *FoundIDATASec = NULL; + if (Addr.empty()) { + Name = GV->getSection() + " IDATA"; + for (unsigned i = 0; i < IDATASections.size(); i++) { + if (IDATASections[i]->S_->getName() == Name) { + FoundIDATASec = IDATASections[i]; + break; + } + } + } else { + std::string Prefix = GV->getNameStr() + "." + Addr + "."; + Name = PAN::getIdataSectionName(IDATASections.size(), Prefix) + " " + Addr; + } + + PIC16Section *NewIDATASec = FoundIDATASec; + if (NewIDATASec == NULL) { + const MCSectionPIC16 *NewSection = + getPIC16Section(Name.c_str(), MCSectionPIC16::IDATA_Kind()); + NewIDATASec = new PIC16Section(NewSection); + IDATASections.push_back(NewIDATASec); + } + // Insert the GV into this IDATA Section. + NewIDATASec->Items.push_back(GV); + // We do not want to put any GV without explicit section into this section + // so set its size to DatabankSize. + NewIDATASec->Size = DataBankSize; + return NewIDATASec->S_; } +// Create a section in rom for a variable. +const MCSection * +PIC16TargetObjectFile::CreateROSectionForGlobal(const GlobalVariable *GV, + std::string Addr) const { + assert(GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE && + "can be used for ROM data only"); + + std::string Name; + // If address is given then create a section at that address else create a + // section by section name specified in GV. + PIC16Section *FoundROSec = NULL; + if (Addr.empty()) { + Name = GV->getSection() + " ROMDATA"; + for (unsigned i = 1; i < ROSections.size(); i++) { + if (ROSections[i]->S_->getName() == Name) { + FoundROSec = ROSections[i]; + break; + } + } + } else { + std::string Prefix = GV->getNameStr() + "." + Addr + "."; + Name = PAN::getRomdataSectionName(ROSections.size(), Prefix) + " " + Addr; + } + + PIC16Section *NewRomSec = FoundROSec; + if (NewRomSec == NULL) { + const MCSectionPIC16 *NewSection = + getPIC16Section(Name.c_str(), MCSectionPIC16::ROMDATA_Kind()); + NewRomSec = new PIC16Section(NewSection); + ROSections.push_back(NewRomSec); + } + + // Insert the GV into this ROM Section. + NewRomSec->Items.push_back(GV); + return NewRomSec->S_; +} Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h?rev=84184&r1=84183&r2=84184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Thu Oct 15 10:02:14 2009 @@ -10,8 +10,6 @@ #ifndef LLVM_TARGET_PIC16_TARGETOBJECTFILE_H #define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H -#include "PIC16.h" -#include "PIC16ABINames.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/ADT/StringMap.h" #include @@ -21,7 +19,7 @@ class GlobalVariable; class Module; class PIC16TargetMachine; - class PIC16Section; + class MCSectionPIC16; enum { DataBankSize = 80 }; @@ -31,124 +29,91 @@ /// again and printing only those that match the current section. /// Keeping values inside the sections make printing a section much easier. /// - /// FIXME: MOVE ALL THIS STUFF TO PIC16Section. + /// FIXME: MOVE ALL THIS STUFF TO MCSectionPIC16. /// - - /// PIC16TargetObjectFile - PIC16 Object file. Contains data and code - /// sections. - // PIC16 Object File has two types of sections. - // 1. Standard Sections - // 1.1 un-initialized global data - // 1.2 initialized global data - // 1.3 program memory data - // 1.4 local variables of functions. - // 2. User defined sections - // 2.1 Objects placed in a specific section. (By _Section() macro) - // 2.2 Objects placed at a specific address. (By _Address() macro) + struct PIC16Section { + const MCSectionPIC16 *S_; // Connection to actual Section. + unsigned Size; // Total size of the objects contained. + bool SectionPrinted; + std::vector Items; + + PIC16Section(const MCSectionPIC16 *s) { + S_ = s; + Size = 0; + SectionPrinted = false; + } + bool isPrinted() const { return SectionPrinted; } + void setPrintedStatus(bool status) { SectionPrinted = status; } + }; + class PIC16TargetObjectFile : public TargetLoweringObjectFile { /// SectionsByName - Bindings of names to allocated sections. - mutable StringMap SectionsByName; + mutable StringMap SectionsByName; const TargetMachine *TM; - /// Lists of sections. - /// Standard Data Sections. - mutable std::vector UDATASections_; - mutable std::vector IDATASections_; - mutable PIC16Section * ROMDATASection_; - - /// Standard Auto Sections. - mutable std::vector AUTOSections_; - - /// User specified sections. - mutable std::vector USERSections_; - - - /// Find or Create a PIC16 Section, without adding it to any - /// section list. - PIC16Section *getPIC16Section(const std::string &Name, - PIC16SectionType Ty, - const std::string &Address = "", - int Color = -1) const; - - /// Convenience functions. These wrappers also take care of adding - /// the newly created section to the appropriate sections list. - - /// Find or Create PIC16 Standard Data Section. - PIC16Section *getPIC16DataSection(const std::string &Name, - PIC16SectionType Ty, - const std::string &Address = "", - int Color = -1) const; - - /// Find or Create PIC16 Standard Auto Section. - PIC16Section *getPIC16AutoSection(const std::string &Name, - PIC16SectionType Ty = UDATA_OVR, - const std::string &Address = "", - int Color = -1) const; - - /// Find or Create PIC16 Standard Auto Section. - PIC16Section *getPIC16UserSection(const std::string &Name, - PIC16SectionType Ty, - const std::string &Address = "", - int Color = -1) const; - - /// Allocate Un-initialized data to a standard UDATA section. - const MCSection *allocateUDATA(const GlobalVariable *GV) const; - - /// Allocate Initialized data to a standard IDATA section. - const MCSection *allocateIDATA(const GlobalVariable *GV) const; - - /// Allocate ROM data to the standard ROMDATA section. - const MCSection *allocateROMDATA(const GlobalVariable *GV) const; - - /// Allocate an AUTO variable to an AUTO section. - const MCSection *allocateAUTO(const GlobalVariable *GV) const; - - /// Allocate DATA in user specified section. - const MCSection *allocateInGivenSection(const GlobalVariable *GV) const; - - /// Allocate DATA at user specified address. - const MCSection *allocateAtGivenAddress(const GlobalVariable *GV, - const std::string &Addr) const; - - public: + const MCSectionPIC16 *getPIC16Section(const char *Name, + SectionKind K, + int Address = -1, + int Color = -1) const; + public: + mutable std::vector BSSSections; + mutable std::vector IDATASections; + mutable std::vector AutosSections; + mutable std::vector ROSections; + mutable PIC16Section *ExternalVarDecls; + mutable PIC16Section *ExternalVarDefs; + PIC16TargetObjectFile(); ~PIC16TargetObjectFile(); + void Initialize(MCContext &Ctx, const TargetMachine &TM); - /// Override section allocations for user specified sections. + virtual const MCSection * getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; - /// Select sections for Data and Auto variables(globals). virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine&) const; - /// Return a code section for a function. - const PIC16Section *SectionForCode (const std::string &FnName) const; - - /// Return a frame section for a function. - const PIC16Section *SectionForFrame (const std::string &FnName) const; + const MCSection *getSectionForFunction(const std::string &FnName) const; + const MCSection *getSectionForFunctionFrame(const std::string &FnName)const; + + + private: + std::string getSectionNameForSym(const std::string &Sym) const; - /// Accessors for various section lists. - const std::vector &UDATASections() const { - return UDATASections_; - } - const std::vector &IDATASections() const { - return IDATASections_; + const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const; + const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const; + const MCSection *getSectionForAuto(const GlobalVariable *GV) const; + const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV, + std::string Addr = "") const; + const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV, + std::string Addr = "") const; + const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const; + const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV, + std::string Addr = "") const; + const MCSection *CreateSectionForGlobal(const GlobalVariable *GV, + Mangler *Mang, + const std::string &Addr = "") const; + public: + void SetSectionForGVs(Module &M); + const std::vector &getBSSSections() const { + return BSSSections; } - const PIC16Section *ROMDATASection() const { - return ROMDATASection_; + const std::vector &getIDATASections() const { + return IDATASections; } - const std::vector &AUTOSections() const { - return AUTOSections_; + const std::vector &getAutosSections() const { + return AutosSections; } - const std::vector &USERSections() const { - return USERSections_; + const std::vector &getROSections() const { + return ROSections; } + }; } // end namespace llvm From daniel at zuster.org Thu Oct 15 10:08:24 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 15 Oct 2009 08:08:24 -0700 Subject: [llvm-commits] [llvm] r84180 - in /llvm/trunk/lib/Target/PIC16: AsmPrinter/PIC16AsmPrinter.cpp AsmPrinter/PIC16AsmPrinter.h PIC16.h PIC16ABINames.h PIC16DebugInfo.cpp PIC16ISelLowering.cpp PIC16InstrInfo.cpp PIC16MCAsmInfo.cpp PIC16MemSelOpt.cpp Message-ID: <6a8523d60910150808o7b39c40bi5bd13a6c72c93c77@mail.gmail.com> Hi Sanjiv, I reverted this in r84184, it was breaking the PIC16/globals.ll test. I think perhaps just the test needs to be updated, but I'm not sure. - Daniel On Thu, Oct 15, 2009 at 3:10 AM, Sanjiv Gupta wrote: > Author: sgupta > Date: Thu Oct 15 05:10:43 2009 > New Revision: 84180 > > URL: http://llvm.org/viewvc/llvm-project?rev=84180&view=rev > Log: > Complete Rewrite of AsmPrinter, TargetObjectFile based on new PIC16Section class > derived from MCSection. > > Added: > ? ?llvm/trunk/lib/Target/PIC16/PIC16ABINames.h > ? ?llvm/trunk/lib/Target/PIC16/PIC16Section.cpp > ? ?llvm/trunk/lib/Target/PIC16/PIC16Section.h > Modified: > ? ?llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp > ? ?llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h > ? ?llvm/trunk/lib/Target/PIC16/PIC16.h > ? ?llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp > ? ?llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp > ? ?llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp > ? ?llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp > ? ?llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp > ? ?llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp > ? ?llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h > > Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=84180&r1=84179&r2=84180&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original) > +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Thu Oct 15 05:10:43 2009 > @@ -12,8 +12,9 @@ > ?// > ?//===----------------------------------------------------------------------===// > > +#include "PIC16ABINames.h" > ?#include "PIC16AsmPrinter.h" > -#include "MCSectionPIC16.h" > +#include "PIC16Section.h" > ?#include "PIC16MCAsmInfo.h" > ?#include "llvm/DerivedTypes.h" > ?#include "llvm/Function.h" > @@ -39,7 +40,7 @@ > ?: AsmPrinter(O, TM, T, V), DbgInfo(O, T) { > ? PTLI = static_cast(TM.getTargetLowering()); > ? PMAI = static_cast(T); > - ?PTOF = (PIC16TargetObjectFile*)&PTLI->getObjFileLowering(); > + ?PTOF = (PIC16TargetObjectFile *)&PTLI->getObjFileLowering(); > ?} > > ?bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) { > @@ -73,11 +74,12 @@ > ? DbgInfo.BeginFunction(MF); > > ? // Emit the autos section of function. > - ?EmitAutos(CurrentFnName); > + ?// EmitAutos(CurrentFnName); > > ? // Now emit the instructions of function in its code section. > - ?const MCSection *fCodeSection = > - ? ?getObjFileLowering().getSectionForFunction(CurrentFnName); > + ?const MCSection *fCodeSection > + ? ?= getObjFileLowering().SectionForCode(CurrentFnName); > + > ? // Start the Code Section. > ? O << ?"\n"; > ? OutStreamer.SwitchSection(fCodeSection); > @@ -229,12 +231,26 @@ > > ? // Set the section names for all globals. > ? for (Module::global_iterator I = M.global_begin(), E = M.global_end(); > - ? ? ? I != E; ++I) > - ? ?if (!I->isDeclaration() && !I->hasAvailableExternallyLinkage()) { > + ? ? ? I != E; ++I) { > + > + ? ?// Record External Var Decls. > + ? ?if (I->isDeclaration()) { > + ? ? ?ExternalVarDecls.push_back(I); > + ? ? ?continue; > + ? ?} > + > + ? ?// Record Exteranl Var Defs. > + ? ?if (I->hasExternalLinkage() || I->hasCommonLinkage()) { > + ? ? ?ExternalVarDefs.push_back(I); > + ? ?} > + > + ? ?// Sectionify actual data. > + ? ?if (!I->hasAvailableExternallyLinkage()) { > ? ? ? const MCSection *S = getObjFileLowering().SectionForGlobal(I, Mang, TM); > > - ? ? ?I->setSection(((const MCSectionPIC16*)S)->getName()); > + ? ? ?I->setSection(((const PIC16Section *)S)->getName()); > ? ? } > + ?} > > ? DbgInfo.BeginModule(M); > ? EmitFunctionDecls(M); > @@ -242,7 +258,9 @@ > ? EmitDefinedVars(M); > ? EmitIData(M); > ? EmitUData(M); > + ?EmitAllAutos(M); > ? EmitRomData(M); > + ?EmitUserSections(M); > ? return Result; > ?} > > @@ -287,7 +305,7 @@ > > ?// Emit variables imported from other Modules. > ?void PIC16AsmPrinter::EmitUndefinedVars(Module &M) { > - ?std::vector Items = PTOF->ExternalVarDecls->Items; > + ?std::vector Items = ExternalVarDecls; > ? if (!Items.size()) return; > > ? O << "\n" << MAI->getCommentString() << "Imported Variables - BEGIN" << "\n"; > @@ -299,7 +317,7 @@ > > ?// Emit variables defined in this module and are available to other modules. > ?void PIC16AsmPrinter::EmitDefinedVars(Module &M) { > - ?std::vector Items = PTOF->ExternalVarDefs->Items; > + ?std::vector Items = ExternalVarDefs; > ? if (!Items.size()) return; > > ? O << "\n" << MAI->getCommentString() << "Exported Variables - BEGIN" << "\n"; > @@ -312,24 +330,14 @@ > ?// Emit initialized data placed in ROM. > ?void PIC16AsmPrinter::EmitRomData(Module &M) { > ? // Print ROM Data section. > - ?const std::vector &ROSections = PTOF->ROSections; > - ?for (unsigned i = 0; i < ROSections.size(); i++) { > - ? ?const std::vector &Items = ROSections[i]->Items; > - ? ?if (!Items.size()) continue; > - ? ?O << "\n"; > - ? ?OutStreamer.SwitchSection(PTOF->ROSections[i]->S_); > - ? ?for (unsigned j = 0; j < Items.size(); j++) { > - ? ? ?O << Mang->getMangledName(Items[j]); > - ? ? ?Constant *C = Items[j]->getInitializer(); > - ? ? ?int AddrSpace = Items[j]->getType()->getAddressSpace(); > - ? ? ?EmitGlobalConstant(C, AddrSpace); > - ? ?} > - ?} > + ?const PIC16Section *ROSection = PTOF->ROMDATASection(); > + ?if (ROSection == NULL) return; > + ?EmitInitializedDataSection(ROSection); > ?} > > ?bool PIC16AsmPrinter::doFinalization(Module &M) { > ? printLibcallDecls(); > - ?EmitRemainingAutos(); > + ?// EmitRemainingAutos(); > ? DbgInfo.EndModule(M); > ? O << "\n\t" << "END\n"; > ? return AsmPrinter::doFinalization(M); > @@ -343,7 +351,7 @@ > ? O << "\n"; > > ? const MCSection *fPDataSection = > - ? ?getObjFileLowering().getSectionForFunctionFrame(CurrentFnName); > + ? ?getObjFileLowering().SectionForFrame(CurrentFnName); > ? OutStreamer.SwitchSection(fPDataSection); > > ? // Emit function frame label > @@ -379,103 +387,79 @@ > ? ? O << PAN::getTempdataLabel(CurrentFnName) << " RES ?" << TempSize << '\n'; > ?} > > -void PIC16AsmPrinter::EmitIData(Module &M) { > > - ?// Print all IDATA sections. > - ?const std::vector &IDATASections = PTOF->IDATASections; > - ?for (unsigned i = 0; i < IDATASections.size(); i++) { > - ? ?O << "\n"; > - ? ?if (IDATASections[i]->S_->getName().find("llvm.") != std::string::npos) > - ? ? ?continue; > - ? ?OutStreamer.SwitchSection(IDATASections[i]->S_); > - ? ?std::vector Items = IDATASections[i]->Items; > +void PIC16AsmPrinter::EmitInitializedDataSection(const PIC16Section *S) { > + ?/// Emit Section header. > + ?OutStreamer.SwitchSection(S); > + > + ? ?std::vector Items = S->Items; > ? ? for (unsigned j = 0; j < Items.size(); j++) { > ? ? ? std::string Name = Mang->getMangledName(Items[j]); > ? ? ? Constant *C = Items[j]->getInitializer(); > ? ? ? int AddrSpace = Items[j]->getType()->getAddressSpace(); > ? ? ? O << Name; > ? ? ? EmitGlobalConstant(C, AddrSpace); > - ? ?} > - ?} > + ? } > ?} > > -void PIC16AsmPrinter::EmitUData(Module &M) { > - ?const TargetData *TD = TM.getTargetData(); > +void PIC16AsmPrinter::EmitIData(Module &M) { > > - ?// Print all BSS sections. > - ?const std::vector &BSSSections = PTOF->BSSSections; > - ?for (unsigned i = 0; i < BSSSections.size(); i++) { > + ?// Print all IDATA sections. > + ?const std::vector &IDATASections = PTOF->IDATASections(); > + ?for (unsigned i = 0; i < IDATASections.size(); i++) { > ? ? O << "\n"; > - ? ?OutStreamer.SwitchSection(BSSSections[i]->S_); > - ? ?std::vector Items = BSSSections[i]->Items; > + ? ?if (IDATASections[i]->getName().find("llvm.") != std::string::npos) > + ? ? ?continue; > + > + ? ?EmitInitializedDataSection(IDATASections[i]); > + ? ?} > +} > + > +void PIC16AsmPrinter::EmitUninitializedDataSection(const PIC16Section *S) { > + ? ?const TargetData *TD = TM.getTargetData(); > + ? ?OutStreamer.SwitchSection(S); > + ? ?std::vector Items = S->Items; > ? ? for (unsigned j = 0; j < Items.size(); j++) { > ? ? ? std::string Name = Mang->getMangledName(Items[j]); > ? ? ? Constant *C = Items[j]->getInitializer(); > ? ? ? const Type *Ty = C->getType(); > ? ? ? unsigned Size = TD->getTypeAllocSize(Ty); > - > ? ? ? O << Name << " RES " << Size << "\n"; > ? ? } > - ?} > ?} > > -void PIC16AsmPrinter::EmitAutos(std::string FunctName) { > - ?// Section names for all globals are already set. > - ?const TargetData *TD = TM.getTargetData(); > - > - ?// Now print Autos section for this function. > - ?std::string SectionName = PAN::getAutosSectionName(FunctName); > - ?const std::vector &AutosSections = PTOF->AutosSections; > - ?for (unsigned i = 0; i < AutosSections.size(); i++) { > +void PIC16AsmPrinter::EmitUData(Module &M) { > + ?// Print all UDATA sections. > + ?const std::vector &UDATASections = PTOF->UDATASections(); > + ?for (unsigned i = 0; i < UDATASections.size(); i++) { > ? ? O << "\n"; > - ? ?if (AutosSections[i]->S_->getName() == SectionName) { > - ? ? ?// Set the printing status to true > - ? ? ?AutosSections[i]->setPrintedStatus(true); > - ? ? ?OutStreamer.SwitchSection(AutosSections[i]->S_); > - ? ? ?const std::vector &Items = AutosSections[i]->Items; > - ? ? ?for (unsigned j = 0; j < Items.size(); j++) { > - ? ? ? ?std::string VarName = Mang->getMangledName(Items[j]); > - ? ? ? ?Constant *C = Items[j]->getInitializer(); > - ? ? ? ?const Type *Ty = C->getType(); > - ? ? ? ?unsigned Size = TD->getTypeAllocSize(Ty); > - ? ? ? ?// Emit memory reserve directive. > - ? ? ? ?O << VarName << " ?RES ?" << Size << "\n"; > - ? ? ?} > - ? ? ?break; > - ? ?} > + ? ?EmitUninitializedDataSection(UDATASections[i]); > ? } > ?} > > -// Print autos that were not printed during the code printing of functions. > -// As the functions might themselves would have got deleted by the optimizer. > -void PIC16AsmPrinter::EmitRemainingAutos() { > - ?const TargetData *TD = TM.getTargetData(); > - > - ?// Now print Autos section for this function. > - ?std::vector AutosSections = PTOF->AutosSections; > - ?for (unsigned i = 0; i < AutosSections.size(); i++) { > - > - ? ?// if the section is already printed then don't print again > - ? ?if (AutosSections[i]->isPrinted()) > - ? ? ?continue; > - > - ? ?// Set status as printed > - ? ?AutosSections[i]->setPrintedStatus(true); > - > +void PIC16AsmPrinter::EmitUserSections(Module &M) { > + ?const std::vector &USERSections = PTOF->USERSections(); > + ?for (unsigned i = 0; i < USERSections.size(); i++) { > ? ? O << "\n"; > - ? ?OutStreamer.SwitchSection(AutosSections[i]->S_); > - ? ?const std::vector &Items = AutosSections[i]->Items; > - ? ?for (unsigned j = 0; j < Items.size(); j++) { > - ? ? ?std::string VarName = Mang->getMangledName(Items[j]); > - ? ? ?Constant *C = Items[j]->getInitializer(); > - ? ? ?const Type *Ty = C->getType(); > - ? ? ?unsigned Size = TD->getTypeAllocSize(Ty); > - ? ? ?// Emit memory reserve directive. > - ? ? ?O << VarName << " ?RES ?" << Size << "\n"; > + ? ?const PIC16Section *S = USERSections[i]; > + ? ?if (S->isUDATA_Type()) { > + ? ? ?EmitUninitializedDataSection(S); > + ? ?} else if (S->isIDATA_Type() || S->isROMDATA_Type()) { > + ? ? ?EmitInitializedDataSection(S); > + ? ?} else { > + ? ? ?llvm_unreachable ("unknow user section type"); > ? ? } > ? } > ?} > > +void PIC16AsmPrinter::EmitAllAutos(Module &M) { > + ?// Print all AUTO sections. > + ?const std::vector &AUTOSections = PTOF->AUTOSections(); > + ?for (unsigned i = 0; i < AUTOSections.size(); i++) { > + ? ?O << "\n"; > + ? ?EmitUninitializedDataSection(AUTOSections[i]); > + ?} > +} > > ?extern "C" void LLVMInitializePIC16AsmPrinter() { > ? RegisterAsmPrinter X(ThePIC16Target); > > Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h?rev=84180&r1=84179&r2=84180&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h (original) > +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h Thu Oct 15 05:10:43 2009 > @@ -53,11 +53,13 @@ > ? ? void EmitDefinedVars (Module &M); > ? ? void EmitIData (Module &M); > ? ? void EmitUData (Module &M); > - ? ?void EmitAutos (std::string FunctName); > - ? ?void EmitRemainingAutos (); > + ? ?void EmitAllAutos (Module &M); > ? ? void EmitRomData (Module &M); > + ? ?void EmitUserSections (Module &M); > ? ? void EmitFunctionFrame(MachineFunction &MF); > ? ? void printLibcallDecls(); > + ? ?void EmitUninitializedDataSection(const PIC16Section *S); > + ? ?void EmitInitializedDataSection(const PIC16Section *S); > ? protected: > ? ? bool doInitialization(Module &M); > ? ? bool doFinalization(Module &M); > @@ -74,6 +76,8 @@ > ? ? PIC16DbgInfo DbgInfo; > ? ? const PIC16MCAsmInfo *PMAI; > ? ? std::list LibcallDecls; // List of extern decls. > + ? ?std::vector ExternalVarDecls; > + ? ?std::vector ExternalVarDefs; > ? }; > ?} // end of namespace > > > Modified: llvm/trunk/lib/Target/PIC16/PIC16.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16.h?rev=84180&r1=84179&r2=84180&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16.h (original) > +++ llvm/trunk/lib/Target/PIC16/PIC16.h Thu Oct 15 05:10:43 2009 > @@ -42,266 +42,15 @@ > ? ? UGE > ? }; > ?} > - ?// A Central class to manage all ABI naming conventions. > - ?// PAN - [P]ic16 [A]BI [N]ames > - ?class PAN { > - ? ?public: > - ? ?// Map the name of the symbol to its section name. > - ? ?// Current ABI: > - ? ?// ----------------------------------------------------- > - ? ?// ALL Names are prefixed with the symobl '@'. > - ? ?// ------------------------------------------------------ > - ? ?// Global variables do not have any '.' in their names. > - ? ?// These are maily function names and global variable names. > - ? ?// Example - @foo, ?@i > - ? ?// ------------------------------------------------------- > - ? ?// Functions and auto variables. > - ? ?// Names are mangled as .. > - ? ?// Where is '@' and is any one of > - ? ?// the following > - ? ?// .auto. - an automatic var of a function. > - ? ?// .temp. - temproray data of a function. > - ? ?// .ret. ?- return value label for a function. > - ? ?// .frame. - Frame label for a function where retval, args > - ? ?// ? ? ? ? ? and temps are stored. > - ? ?// .args. - Label used to pass arguments to a direct call. > - ? ?// Example - Function name: ? @foo > - ? ?// ? ? ? ? ? Its frame: ? ? ? @foo.frame. > - ? ?// ? ? ? ? ? Its retval: ? ? ?@foo.ret. > - ? ?// ? ? ? ? ? Its local vars: ?@foo.auto.a > - ? ?// ? ? ? ? ? Its temp data: ? @foo.temp. > - ? ?// ? ? ? ? ? Its arg passing: @foo.args. > - ? ?//---------------------------------------------- > - ? ?// Libcall - compiler generated libcall names must start with .lib. > - ? ?// ? ? ? ? ? This id will be used to emit extern decls for libcalls. > - ? ?// Example - libcall name: ? @.lib.sra.i8 > - ? ?// ? ? ? ? ? To pass args: ? @.lib.sra.i8.args. > - ? ?// ? ? ? ? ? To return val: ?@.lib.sra.i8.ret. > - ? ?//---------------------------------------------- > - ? ?// SECTION Names > - ? ?// uninitialized globals - @udata..# > - ? ?// initialized globals - @idata..# > - ? ?// Function frame - @.frame_section. > - ? ?// Function autos - @.autos_section. > - ? ?// Declarations - Enclosed in comments. No section for them. > - ? ?//---------------------------------------------------------- > - > - ? ?// Tags used to mangle different names. > - ? ?enum TAGS { > - ? ? ?PREFIX_SYMBOL, > - ? ? ?GLOBAL, > - ? ? ?STATIC_LOCAL, > - ? ? ?AUTOS_LABEL, > - ? ? ?FRAME_LABEL, > - ? ? ?RET_LABEL, > - ? ? ?ARGS_LABEL, > - ? ? ?TEMPS_LABEL, > - > - ? ? ?LIBCALL, > - > - ? ? ?FRAME_SECTION, > - ? ? ?AUTOS_SECTION, > - ? ? ?CODE_SECTION > - ? ?}; > - > - ? ?// Textual names of the tags. > - ? ?inline static const char *getTagName(TAGS tag) { > - ? ? ?switch (tag) { > - ? ? ?default: return ""; > - ? ? ?case PREFIX_SYMBOL: ? ?return "@"; > - ? ? ?case AUTOS_LABEL: ? ? ? return ".auto."; > - ? ? ?case FRAME_LABEL: ? ? ? return ".frame."; > - ? ? ?case TEMPS_LABEL: ? ? ? return ".temp."; > - ? ? ?case ARGS_LABEL: ? ? ? return ".args."; > - ? ? ?case RET_LABEL: ? ? ? return ".ret."; > - ? ? ?case LIBCALL: ? ? ? return ".lib."; > - ? ? ?case FRAME_SECTION: ? ? ? return ".frame_section."; > - ? ? ?case AUTOS_SECTION: ? ? ? return ".autos_section."; > - ? ? ?case CODE_SECTION: ? ? ? return ".code_section."; > - ? ? ?} > - ? ?} > - > - ? ?// Get tag type for the Symbol. > - ? ?inline static TAGS getSymbolTag(const std::string &Sym) { > - ? ? ?if (Sym.find(getTagName(TEMPS_LABEL)) != std::string::npos) > - ? ? ? ?return TEMPS_LABEL; > - > - ? ? ?if (Sym.find(getTagName(FRAME_LABEL)) != std::string::npos) > - ? ? ? ?return FRAME_LABEL; > - > - ? ? ?if (Sym.find(getTagName(RET_LABEL)) != std::string::npos) > - ? ? ? ?return RET_LABEL; > - > - ? ? ?if (Sym.find(getTagName(ARGS_LABEL)) != std::string::npos) > - ? ? ? ?return ARGS_LABEL; > - > - ? ? ?if (Sym.find(getTagName(AUTOS_LABEL)) != std::string::npos) > - ? ? ? ?return AUTOS_LABEL; > - > - ? ? ?if (Sym.find(getTagName(LIBCALL)) != std::string::npos) > - ? ? ? ?return LIBCALL; > - > - ? ? ?// It does not have any Tag. So its a true global or static local. > - ? ? ?if (Sym.find(".") == std::string::npos) > - ? ? ? ?return GLOBAL; > - > - ? ? ?// If a . is there, then it may be static local. > - ? ? ?// We should mangle these as well in clang. > - ? ? ?if (Sym.find(".") != std::string::npos) > - ? ? ? ?return STATIC_LOCAL; > - > - ? ? ?assert (0 && "Could not determine Symbol's tag"); > - ? ? ?return PREFIX_SYMBOL; // Silence warning when assertions are turned off. > - ? ?} > - > - ? ?// addPrefix - add prefix symbol to a name if there isn't one already. > - ? ?inline static std::string addPrefix (const std::string &Name) { > - ? ? ?std::string prefix = getTagName (PREFIX_SYMBOL); > - > - ? ? ?// If this name already has a prefix, nothing to do. > - ? ? ?if (Name.compare(0, prefix.size(), prefix) == 0) > - ? ? ? ?return Name; > - > - ? ? ?return prefix + Name; > - ? ?} > - > - ? ?// Get mangled func name from a mangled sym name. > - ? ?// In all cases func name is the first component before a '.'. > - ? ?static inline std::string getFuncNameForSym(const std::string &Sym1) { > - ? ? ?assert (getSymbolTag(Sym1) != GLOBAL && "not belongs to a function"); > - > - ? ? ?std::string Sym = addPrefix(Sym1); > - > - ? ? ?// Position of the . after func name. That's where func name ends. > - ? ? ?size_t func_name_end = Sym.find ('.'); > - > - ? ? ?return Sym.substr (0, func_name_end); > - ? ?} > - > - ? ?// Get Frame start label for a func. > - ? ?static std::string getFrameLabel(const std::string &Func) { > - ? ? ?std::string Func1 = addPrefix(Func); > - ? ? ?std::string tag = getTagName(FRAME_LABEL); > - ? ? ?return Func1 + tag; > - ? ?} > - > - ? ?static std::string getRetvalLabel(const std::string &Func) { > - ? ? ?std::string Func1 = addPrefix(Func); > - ? ? ?std::string tag = getTagName(RET_LABEL); > - ? ? ?return Func1 + tag; > - ? ?} > - > - ? ?static std::string getArgsLabel(const std::string &Func) { > - ? ? ?std::string Func1 = addPrefix(Func); > - ? ? ?std::string tag = getTagName(ARGS_LABEL); > - ? ? ?return Func1 + tag; > - ? ?} > - > - ? ?static std::string getTempdataLabel(const std::string &Func) { > - ? ? ?std::string Func1 = addPrefix(Func); > - ? ? ?std::string tag = getTagName(TEMPS_LABEL); > - ? ? ?return Func1 + tag; > - ? ?} > - > - ? ?static std::string getFrameSectionName(const std::string &Func) { > - ? ? ?std::string Func1 = addPrefix(Func); > - ? ? ?std::string tag = getTagName(FRAME_SECTION); > - ? ? ?return Func1 + tag + "# UDATA_OVR"; > - ? ?} > > - ? ?static std::string getAutosSectionName(const std::string &Func) { > - ? ? ?std::string Func1 = addPrefix(Func); > - ? ? ?std::string tag = getTagName(AUTOS_SECTION); > - ? ? ?return Func1 + tag + "# UDATA_OVR"; > - ? ?} > - > - ? ?static std::string getCodeSectionName(const std::string &Func) { > - ? ? ?std::string Func1 = addPrefix(Func); > - ? ? ?std::string tag = getTagName(CODE_SECTION); > - ? ? ?return Func1 + tag + "# CODE"; > - ? ?} > - > - ? ?// udata, romdata and idata section names are generated by a given number. > - ? ?// @udata..# > - ? ?static std::string getUdataSectionName(unsigned num, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::string prefix = "") { > - ? ? ? std::ostringstream o; > - ? ? ? o << getTagName(PREFIX_SYMBOL) << prefix << "udata." << num > - ? ? ? ? << ".# UDATA"; > - ? ? ? return o.str(); > - ? ?} > - > - ? ?static std::string getRomdataSectionName(unsigned num, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::string prefix = "") { > - ? ? ? std::ostringstream o; > - ? ? ? o << getTagName(PREFIX_SYMBOL) << prefix << "romdata." << num > - ? ? ? ? << ".# ROMDATA"; > - ? ? ? return o.str(); > - ? ?} > - > - ? ?static std::string getIdataSectionName(unsigned num, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::string prefix = "") { > - ? ? ? std::ostringstream o; > - ? ? ? o << getTagName(PREFIX_SYMBOL) << prefix << "idata." << num > - ? ? ? ? << ".# IDATA"; > - ? ? ? return o.str(); > - ? ?} > - > - ? ?inline static bool isLocalName (const std::string &Name) { > - ? ? ?if (getSymbolTag(Name) == AUTOS_LABEL) > - ? ? ? ?return true; > - > - ? ? ?return false; > - ? ?} > - > - ? ?inline static bool isMemIntrinsic (const std::string &Name) { > - ? ? ?if (Name.compare("@memcpy") == 0 || Name.compare("@memset") == 0 || > - ? ? ? ? ?Name.compare("@memmove") == 0) { > - ? ? ? ?return true; > - ? ? ?} > - > - ? ? ?return false; > - ? ?} > - > - ? ?inline static bool isLocalToFunc (std::string &Func, std::string &Var) { > - ? ? ?if (! isLocalName(Var)) return false; > - > - ? ? ?std::string Func1 = addPrefix(Func); > - ? ? ?// Extract func name of the varilable. > - ? ? ?const std::string &fname = getFuncNameForSym(Var); > - > - ? ? ?if (fname.compare(Func1) == 0) > - ? ? ? ?return true; > - > - ? ? ?return false; > - ? ?} > - > - > - ? ?// Get the section for the given external symbol names. > - ? ?// This tries to find the type (Tag) of the symbol from its mangled name > - ? ?// and return appropriate section name for it. > - ? ?static inline std::string getSectionNameForSym(const std::string &Sym1) { > - ? ? ?std::string Sym = addPrefix(Sym1); > - > - ? ? ?std::string SectionName; > - > - ? ? ?std::string Fname = getFuncNameForSym (Sym); > - ? ? ?TAGS id = getSymbolTag (Sym); > - > - ? ? ?switch (id) { > - ? ? ? ?default : assert (0 && "Could not determine external symbol type"); > - ? ? ? ?case FRAME_LABEL: > - ? ? ? ?case RET_LABEL: > - ? ? ? ?case TEMPS_LABEL: > - ? ? ? ?case ARGS_LABEL: ?{ > - ? ? ? ? ?return getFrameSectionName(Fname); > - ? ? ? ?} > - ? ? ? ?case AUTOS_LABEL: { > - ? ? ? ? ?return getAutosSectionName(Fname); > - ? ? ? ?} > - ? ? ?} > - ? ?} > - ?}; // class PAN. > + ?enum PIC16SectionType { > + ? ? ?CODE, > + ? ? ?UDATA, > + ? ? ?IDATA, > + ? ? ?ROMDATA, > + ? ? ?UDATA_OVR, > + ? ? ?UDATA_SHR > + ? ?}; > > > ? // External symbol names require memory to live till the program end. > > Added: llvm/trunk/lib/Target/PIC16/PIC16ABINames.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ABINames.h?rev=84180&view=auto > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16ABINames.h (added) > +++ llvm/trunk/lib/Target/PIC16/PIC16ABINames.h Thu Oct 15 05:10:43 2009 > @@ -0,0 +1,305 @@ > +//===-- PIC16ABINames.h - PIC16 Naming conventios for ABI----- --*- C++ -*-===// > +// > +// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// This file contains the functions to manage ABI Naming conventions for PIC16. > +// > +// > +//===----------------------------------------------------------------------===// > + > +#ifndef LLVM_TARGET_PIC16ABINAMES_H > +#define LLVM_TARGET_PIC16ABINAMES_H > + > +#include "llvm/Support/ErrorHandling.h" > +#include "llvm/Target/TargetMachine.h" > +#include > +#include > +#include > +#include > + > +namespace llvm { > + ?class PIC16TargetMachine; > + ?class FunctionPass; > + ?class MachineCodeEmitter; > + ?class formatted_raw_ostream; > + > + ?// A Central class to manage all ABI naming conventions. > + ?// PAN - [P]ic16 [A]BI [N]ames > + ?class PAN { > + ? ?public: > + ? ?// Map the name of the symbol to its section name. > + ? ?// Current ABI: > + ? ?// ----------------------------------------------------- > + ? ?// ALL Names are prefixed with the symobl '@'. > + ? ?// ------------------------------------------------------ > + ? ?// Global variables do not have any '.' in their names. > + ? ?// These are maily function names and global variable names. > + ? ?// Example - @foo, ?@i > + ? ?// ------------------------------------------------------- > + ? ?// Functions and auto variables. > + ? ?// Names are mangled as .. > + ? ?// Where is '@' and is any one of > + ? ?// the following > + ? ?// .auto. - an automatic var of a function. > + ? ?// .temp. - temproray data of a function. > + ? ?// .ret. ?- return value label for a function. > + ? ?// .frame. - Frame label for a function where retval, args > + ? ?// ? ? ? ? ? and temps are stored. > + ? ?// .args. - Label used to pass arguments to a direct call. > + ? ?// Example - Function name: ? @foo > + ? ?// ? ? ? ? ? Its frame: ? ? ? @foo.frame. > + ? ?// ? ? ? ? ? Its retval: ? ? ?@foo.ret. > + ? ?// ? ? ? ? ? Its local vars: ?@foo.auto.a > + ? ?// ? ? ? ? ? Its temp data: ? @foo.temp. > + ? ?// ? ? ? ? ? Its arg passing: @foo.args. > + ? ?//---------------------------------------------- > + ? ?// Libcall - compiler generated libcall names must start with .lib. > + ? ?// ? ? ? ? ? This id will be used to emit extern decls for libcalls. > + ? ?// Example - libcall name: ? @.lib.sra.i8 > + ? ?// ? ? ? ? ? To pass args: ? @.lib.sra.i8.args. > + ? ?// ? ? ? ? ? To return val: ?@.lib.sra.i8.ret. > + ? ?//---------------------------------------------- > + ? ?// SECTION Names > + ? ?// uninitialized globals - @udata..# > + ? ?// initialized globals - @idata..# > + ? ?// Function frame - @.frame_section. > + ? ?// Function autos - @.autos_section. > + ? ?// Declarations - Enclosed in comments. No section for them. > + ? ?//---------------------------------------------------------- > + > + ? ?// Tags used to mangle different names. > + ? ?enum TAGS { > + ? ? ?PREFIX_SYMBOL, > + ? ? ?GLOBAL, > + ? ? ?STATIC_LOCAL, > + ? ? ?AUTOS_LABEL, > + ? ? ?FRAME_LABEL, > + ? ? ?RET_LABEL, > + ? ? ?ARGS_LABEL, > + ? ? ?TEMPS_LABEL, > + > + ? ? ?LIBCALL, > + > + ? ? ?FRAME_SECTION, > + ? ? ?AUTOS_SECTION, > + ? ? ?CODE_SECTION, > + ? ? ?USER_SECTION > + ? ?}; > + > + ? ?// Textual names of the tags. > + ? ?inline static const char *getTagName(TAGS tag) { > + ? ? ?switch (tag) { > + ? ? ?default: return ""; > + ? ? ?case PREFIX_SYMBOL: ? ?return "@"; > + ? ? ?case AUTOS_LABEL: ? ? ? return ".auto."; > + ? ? ?case FRAME_LABEL: ? ? ? return ".frame."; > + ? ? ?case TEMPS_LABEL: ? ? ? return ".temp."; > + ? ? ?case ARGS_LABEL: ? ? ? return ".args."; > + ? ? ?case RET_LABEL: ? ? ? return ".ret."; > + ? ? ?case LIBCALL: ? ? ? return ".lib."; > + ? ? ?case FRAME_SECTION: ? ? ? return ".frame_section."; > + ? ? ?case AUTOS_SECTION: ? ? ? return ".autos_section."; > + ? ? ?case CODE_SECTION: ? ? ? return ".code_section."; > + ? ? ?case USER_SECTION: ? ? ? return ".user_section."; > + ? ? ?} > + ? ?} > + > + ? ?// Get tag type for the Symbol. > + ? ?inline static TAGS getSymbolTag(const std::string &Sym) { > + ? ? ?if (Sym.find(getTagName(TEMPS_LABEL)) != std::string::npos) > + ? ? ? ?return TEMPS_LABEL; > + > + ? ? ?if (Sym.find(getTagName(FRAME_LABEL)) != std::string::npos) > + ? ? ? ?return FRAME_LABEL; > + > + ? ? ?if (Sym.find(getTagName(RET_LABEL)) != std::string::npos) > + ? ? ? ?return RET_LABEL; > + > + ? ? ?if (Sym.find(getTagName(ARGS_LABEL)) != std::string::npos) > + ? ? ? ?return ARGS_LABEL; > + > + ? ? ?if (Sym.find(getTagName(AUTOS_LABEL)) != std::string::npos) > + ? ? ? ?return AUTOS_LABEL; > + > + ? ? ?if (Sym.find(getTagName(LIBCALL)) != std::string::npos) > + ? ? ? ?return LIBCALL; > + > + ? ? ?// It does not have any Tag. So its a true global or static local. > + ? ? ?if (Sym.find(".") == std::string::npos) > + ? ? ? ?return GLOBAL; > + > + ? ? ?// If a . is there, then it may be static local. > + ? ? ?// We should mangle these as well in clang. > + ? ? ?if (Sym.find(".") != std::string::npos) > + ? ? ? ?return STATIC_LOCAL; > + > + ? ? ?assert (0 && "Could not determine Symbol's tag"); > + ? ? ?return PREFIX_SYMBOL; // Silence warning when assertions are turned off. > + ? ?} > + > + ? ?// addPrefix - add prefix symbol to a name if there isn't one already. > + ? ?inline static std::string addPrefix (const std::string &Name) { > + ? ? ?std::string prefix = getTagName (PREFIX_SYMBOL); > + > + ? ? ?// If this name already has a prefix, nothing to do. > + ? ? ?if (Name.compare(0, prefix.size(), prefix) == 0) > + ? ? ? ?return Name; > + > + ? ? ?return prefix + Name; > + ? ?} > + > + ? ?// Get mangled func name from a mangled sym name. > + ? ?// In all cases func name is the first component before a '.'. > + ? ?static inline std::string getFuncNameForSym(const std::string &Sym1) { > + ? ? ?assert (getSymbolTag(Sym1) != GLOBAL && "not belongs to a function"); > + > + ? ? ?std::string Sym = addPrefix(Sym1); > + > + ? ? ?// Position of the . after func name. That's where func name ends. > + ? ? ?size_t func_name_end = Sym.find ('.'); > + > + ? ? ?return Sym.substr (0, func_name_end); > + ? ?} > + > + ? ?// Get Frame start label for a func. > + ? ?static std::string getFrameLabel(const std::string &Func) { > + ? ? ?std::string Func1 = addPrefix(Func); > + ? ? ?std::string tag = getTagName(FRAME_LABEL); > + ? ? ?return Func1 + tag; > + ? ?} > + > + ? ?static std::string getRetvalLabel(const std::string &Func) { > + ? ? ?std::string Func1 = addPrefix(Func); > + ? ? ?std::string tag = getTagName(RET_LABEL); > + ? ? ?return Func1 + tag; > + ? ?} > + > + ? ?static std::string getArgsLabel(const std::string &Func) { > + ? ? ?std::string Func1 = addPrefix(Func); > + ? ? ?std::string tag = getTagName(ARGS_LABEL); > + ? ? ?return Func1 + tag; > + ? ?} > + > + ? ?static std::string getTempdataLabel(const std::string &Func) { > + ? ? ?std::string Func1 = addPrefix(Func); > + ? ? ?std::string tag = getTagName(TEMPS_LABEL); > + ? ? ?return Func1 + tag; > + ? ?} > + > + ? ?static std::string getFrameSectionName(const std::string &Func) { > + ? ? ?std::string Func1 = addPrefix(Func); > + ? ? ?std::string tag = getTagName(FRAME_SECTION); > + ? ? ?return Func1 + tag + "#"; > + ? ?} > + > + ? ?static std::string getAutosSectionName(const std::string &Func) { > + ? ? ?std::string Func1 = addPrefix(Func); > + ? ? ?std::string tag = getTagName(AUTOS_SECTION); > + ? ? ?return Func1 + tag + "#"; > + ? ?} > + > + ? ?static std::string getCodeSectionName(const std::string &Func) { > + ? ? ?std::string Func1 = addPrefix(Func); > + ? ? ?std::string tag = getTagName(CODE_SECTION); > + ? ? ?return Func1 + tag + "#"; > + ? ?} > + > + ? ?static std::string getUserSectionName(const std::string &Name) { > + ? ? ?std::string sname = addPrefix(Name);; > + ? ? ?std::string tag = getTagName(USER_SECTION); > + ? ? ?return sname + tag + "#"; > + ? ?} > + > + ? ?// udata, romdata and idata section names are generated by a given number. > + ? ?// @udata..# > + ? ?static std::string getUdataSectionName(unsigned num, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::string prefix = "") { > + ? ? ? std::ostringstream o; > + ? ? ? o << getTagName(PREFIX_SYMBOL) << prefix << "udata." << num > + ? ? ? ? << ".#"; > + ? ? ? return o.str(); > + ? ?} > + > + ? ?static std::string getRomdataSectionName() { > + ? ? ?return "romdata.#"; > + ? ?} > + > + ? ?static std::string getRomdataSectionName(unsigned num, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::string prefix = "") { > + ? ? ? std::ostringstream o; > + ? ? ? o << getTagName(PREFIX_SYMBOL) << prefix << "romdata." << num > + ? ? ? ? << ".#"; > + ? ? ? return o.str(); > + ? ?} > + > + ? ?static std::string getIdataSectionName(unsigned num, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::string prefix = "") { > + ? ? ? std::ostringstream o; > + ? ? ? o << getTagName(PREFIX_SYMBOL) << prefix << "idata." << num > + ? ? ? ? << ".#"; > + ? ? ? return o.str(); > + ? ?} > + > + ? ?inline static bool isLocalName (const std::string &Name) { > + ? ? ?if (getSymbolTag(Name) == AUTOS_LABEL) > + ? ? ? ?return true; > + > + ? ? ?return false; > + ? ?} > + > + ? ?inline static bool isMemIntrinsic (const std::string &Name) { > + ? ? ?if (Name.compare("@memcpy") == 0 || Name.compare("@memset") == 0 || > + ? ? ? ? ?Name.compare("@memmove") == 0) { > + ? ? ? ?return true; > + ? ? ?} > + > + ? ? ?return false; > + ? ?} > + > + ? ?inline static bool isLocalToFunc (std::string &Func, std::string &Var) { > + ? ? ?if (! isLocalName(Var)) return false; > + > + ? ? ?std::string Func1 = addPrefix(Func); > + ? ? ?// Extract func name of the varilable. > + ? ? ?const std::string &fname = getFuncNameForSym(Var); > + > + ? ? ?if (fname.compare(Func1) == 0) > + ? ? ? ?return true; > + > + ? ? ?return false; > + ? ?} > + > + > + ? ?// Get the section for the given external symbol names. > + ? ?// This tries to find the type (Tag) of the symbol from its mangled name > + ? ?// and return appropriate section name for it. > + ? ?static inline std::string getSectionNameForSym(const std::string &Sym1) { > + ? ? ?std::string Sym = addPrefix(Sym1); > + > + ? ? ?std::string SectionName; > + > + ? ? ?std::string Fname = getFuncNameForSym (Sym); > + ? ? ?TAGS id = getSymbolTag (Sym); > + > + ? ? ?switch (id) { > + ? ? ? ?default : assert (0 && "Could not determine external symbol type"); > + ? ? ? ?case FRAME_LABEL: > + ? ? ? ?case RET_LABEL: > + ? ? ? ?case TEMPS_LABEL: > + ? ? ? ?case ARGS_LABEL: ?{ > + ? ? ? ? ?return getFrameSectionName(Fname); > + ? ? ? ?} > + ? ? ? ?case AUTOS_LABEL: { > + ? ? ? ? ?return getAutosSectionName(Fname); > + ? ? ? ?} > + ? ? ?} > + ? ?} > + ?}; // class PAN. > +} // end namespace llvm; > + > +#endif > > Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=84180&r1=84179&r2=84180&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) > +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Thu Oct 15 05:10:43 2009 > @@ -13,6 +13,7 @@ > ?//===----------------------------------------------------------------------===// > > ?#include "PIC16.h" > +#include "PIC16ABINames.h" > ?#include "PIC16DebugInfo.h" > ?#include "llvm/GlobalVariable.h" > ?#include "llvm/CodeGen/MachineFunction.h" > > Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=84180&r1=84179&r2=84180&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Thu Oct 15 05:10:43 2009 > @@ -12,6 +12,7 @@ > ?//===----------------------------------------------------------------------===// > > ?#define DEBUG_TYPE "pic16-lower" > +#include "PIC16ABINames.h" > ?#include "PIC16ISelLowering.h" > ?#include "PIC16TargetObjectFile.h" > ?#include "PIC16TargetMachine.h" > > Modified: llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp?rev=84180&r1=84179&r2=84180&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp (original) > +++ llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp Thu Oct 15 05:10:43 2009 > @@ -12,6 +12,7 @@ > ?//===----------------------------------------------------------------------===// > > ?#include "PIC16.h" > +#include "PIC16ABINames.h" > ?#include "PIC16InstrInfo.h" > ?#include "PIC16TargetMachine.h" > ?#include "PIC16GenInstrInfo.inc" > > Modified: llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp?rev=84180&r1=84179&r2=84180&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp (original) > +++ llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp Thu Oct 15 05:10:43 2009 > @@ -16,6 +16,7 @@ > ?// FIXME: Layering violation to get enums and static function, should be moved > ?// to separate headers. > ?#include "PIC16.h" > +#include "PIC16ABINames.h" > ?#include "PIC16ISelLowering.h" > ?using namespace llvm; > > > Modified: llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp?rev=84180&r1=84179&r2=84180&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp (original) > +++ llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp Thu Oct 15 05:10:43 2009 > @@ -21,6 +21,7 @@ > > ?#define DEBUG_TYPE "pic16-codegen" > ?#include "PIC16.h" > +#include "PIC16ABINames.h" > ?#include "PIC16InstrInfo.h" > ?#include "PIC16MCAsmInfo.h" > ?#include "PIC16TargetMachine.h" > > Added: llvm/trunk/lib/Target/PIC16/PIC16Section.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Section.cpp?rev=84180&view=auto > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16Section.cpp (added) > +++ llvm/trunk/lib/Target/PIC16/PIC16Section.cpp Thu Oct 15 05:10:43 2009 > @@ -0,0 +1,91 @@ > +//===-- PIC16Section.cpp - PIC16 Section ----------- --------------------===// > +// > +// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > + > +#include "PIC16.h" > +#include "PIC16ABINames.h" > +#include "PIC16Section.h" > +#include "llvm/MC/MCContext.h" > +#include "llvm/Support/raw_ostream.h" > +using namespace llvm; > + > + > +// This is the only way to create a PIC16Section. Sections created here > +// do not need to be explicitly deleted as they are managed by auto_ptrs. > +PIC16Section *PIC16Section::Create(const StringRef &Name, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PIC16SectionType Ty, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const std::string &Address, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int Color, MCContext &Ctx) { > + > + ?/// Determine the internal SectionKind info. > + ?/// Users of PIC16Section class should not need to know the internal > + ?/// SectionKind. They should work only with PIC16SectionType. > + ?/// > + ?/// PIC16 Terminology for section kinds is as below. > + ?/// UDATA - BSS > + ?/// IDATA - initialized data (equiv to Metadata) > + ?/// ROMDATA - ReadOnly. > + ?/// UDATA_OVR - Sections that can be overlaid. Section of such type is > + ?/// ? ? ? ? ? ? used to contain function autos an frame. We can think of > + ?/// ? ? ? ? ? ? it as equiv to llvm ThreadBSS) > + ?/// UDATA_SHR - Shared RAM. Memory area that is mapped to all banks. > + > + ?SectionKind K; > + ?switch (Ty) { > + ? ?default: llvm_unreachable ("can not create unknown section type"); > + ? ?case UDATA_OVR: { > + ? ? ?K = SectionKind::getThreadBSS(); > + ? ? ?break; > + ? ?} > + ? ?case UDATA_SHR: > + ? ?case UDATA: { > + ? ? ?K = SectionKind::getBSS(); > + ? ? ?break; > + ? ?} > + ? ?case ROMDATA: > + ? ?case IDATA: { > + ? ? ?K = SectionKind::getMetadata(); > + ? ? ?break; > + ? ?} > + ? ?case CODE: { > + ? ? ?K = SectionKind::getText(); > + ? ? ?break; > + ? ?} > + > + ?} > + > + ?// Create the Section. > + ?PIC16Section *S = new (Ctx) PIC16Section(Name, K, Address, Color); > + ?S->T = Ty; > + ?return S; > +} > + > +// A generic way to print all types of sections. > +void PIC16Section::PrintSwitchToSection(const MCAsmInfo &MAI, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?raw_ostream &OS) const { > + ?// Print name. > + ?OS << getName() << '\t'; > + > + ?// Print type. > + ?switch (getType()) { > + ?default : llvm_unreachable ("unknown section type"); > + ?case UDATA: OS << "UDATA"; break; > + ?case IDATA: OS << "IDATA"; break; > + ?case ROMDATA: OS << "ROMDATA"; break; > + ?case UDATA_SHR: OS << "UDATA_SHR"; break; > + ?case UDATA_OVR: OS << "UDATA_OVR"; break; > + ?case CODE: OS << "CODE"; break; > + ?} > + > + ?OS << '\t'; > + > + ?// Print Address. > + ?OS << Address; > + > + ?OS << '\n'; > +} > > Added: llvm/trunk/lib/Target/PIC16/PIC16Section.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Section.h?rev=84180&view=auto > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16Section.h (added) > +++ llvm/trunk/lib/Target/PIC16/PIC16Section.h Thu Oct 15 05:10:43 2009 > @@ -0,0 +1,91 @@ > +//===- PIC16Section.h - PIC16-specific section representation -*- C++ -*-===// > +// > +// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// This file declares the PIC16Section class. > +// > +//===----------------------------------------------------------------------===// > + > +#ifndef LLVM_PIC16SECTION_H > +#define LLVM_PIC16SECTION_H > + > +#include "llvm/MC/MCSection.h" > +#include "llvm/GlobalVariable.h" > +#include > + > +namespace llvm { > + ?/// PIC16Section - Represents a physical section in PIC16 COFF. > + ?/// Contains data objects. > + ?/// > + ?class PIC16Section : public MCSection { > + ? ?/// PIC16 Sections does not really use the SectionKind class to > + ? ?/// to distinguish between various types of sections. PIC16 maintain > + ? ?/// its own Section Type info. See the PIC16SectionType enum in PIC16.h > + ? ?/// for various section types. > + ? ?PIC16SectionType T; > + > + ? ?/// Name of the section to uniquely identify it. > + ? ?std::string Name; > + > + ? ?/// User can specify an address at which a section should be placed. > + ? ?/// Negative value here means user hasn't specified any. > + ? ?std::string Address; > + > + ? ?/// Overlay information - Sections with same color can be overlaid on > + ? ?/// one another. > + ? ?int Color; > + > + ? ?/// Total size of all data objects contained here. > + ? ?unsigned Size; > + > + ? ?PIC16Section(const StringRef &name, SectionKind K, const std::string &addr, > + ? ? ? ? ? ? ? ? int color) > + ? ? ?: MCSection(K), Name(name), Address(addr), Color(color) { > + ? ?} > + > + ?public: > + ? ?/// Return the name of the section. > + ? ?const std::string &getName() const { return Name; } > + > + ? ?/// Return the Address of the section. > + ? ?const std::string &getAddress() const { return Address; } > + > + ? ?/// Return the Color of the section. > + ? ?int getColor() const { return Color; } > + > + ? ?/// Return the size of the section. > + ? ?unsigned getSize() const { return Size; } > + ? ?void setSize(unsigned size) { Size = size; } > + > + ? ?/// Conatined data objects. > + ? ?std::vectorItems; > + > + ? ?/// Check section type. > + ? ?bool isUDATA_Type() const { return T == UDATA; } > + ? ?bool isIDATA_Type() const { return T == IDATA; } > + ? ?bool isROMDATA_Type() const { return T == ROMDATA; } > + ? ?bool isUDATA_OVR_Type() const { return T == UDATA_OVR; } > + ? ?bool isUDATA_SHR_Type() const { return T == UDATA_SHR; } > + ? ?bool isCODE_Type() const { return T == CODE; } > + > + ? ?PIC16SectionType getType() const { return T; } > + > + ? ?/// This would be the only way to create a section. > + ? ?static PIC16Section *Create(const StringRef &Name, PIC16SectionType Ty, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const std::string &Address, int Color, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MCContext &Ctx); > + > + ? ?/// Override this as PIC16 has its own way of printing switching > + ? ?/// to a section. > + ? ?virtual void PrintSwitchToSection(const MCAsmInfo &MAI, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?raw_ostream &OS) const; > + ?}; > + > +} // end namespace llvm > + > +#endif > > Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp?rev=84180&r1=84179&r2=84180&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp (original) > +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp Thu Oct 15 05:10:43 2009 > @@ -8,9 +8,9 @@ > ?//===----------------------------------------------------------------------===// > > ?#include "PIC16TargetObjectFile.h" > -#include "MCSectionPIC16.h" > ?#include "PIC16ISelLowering.h" > ?#include "PIC16TargetMachine.h" > +#include "PIC16Section.h" > ?#include "llvm/DerivedTypes.h" > ?#include "llvm/Module.h" > ?#include "llvm/MC/MCSection.h" > @@ -19,75 +19,111 @@ > ?using namespace llvm; > > > -MCSectionPIC16 *MCSectionPIC16::Create(const StringRef &Name, SectionKind K, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int Address, int Color, MCContext &Ctx) { > - ?return new (Ctx) MCSectionPIC16(Name, K, Address, Color); > +PIC16TargetObjectFile::PIC16TargetObjectFile() { > ?} > > +/// Find a pic16 section. If not found, create one. > +PIC16Section *PIC16TargetObjectFile:: > +getPIC16Section(const std::string &Name, PIC16SectionType Ty, > + ? ? ? ? ? ? ? ?const std::string &Address, int Color) const { > > -void MCSectionPIC16::PrintSwitchToSection(const MCAsmInfo &MAI, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?raw_ostream &OS) const { > - ?OS << getName() << '\n'; > + ?/// Return if we have an already existing one. > + ?PIC16Section *&Entry = SectionsByName[Name]; > + ?if (Entry) > + ? ?return Entry; > + > + > + ?Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); > + ?return Entry; > ?} > > +/// Find a standard pic16 data section. If not found, create one and keep > +/// track of it by adding it to appropriate std section list. > +PIC16Section *PIC16TargetObjectFile:: > +getPIC16DataSection(const std::string &Name, PIC16SectionType Ty, > + ? ? ? ? ? ? ? ? ? ?const std::string &Address, int Color) const { > + > + ?/// Return if we have an already existing one. > + ?PIC16Section *&Entry = SectionsByName[Name]; > + ?if (Entry) > + ? ?return Entry; > + > > + ?/// Else create a new one and add it to appropriate section list. > + ?Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); > > + ?switch (Ty) { > + ?default: llvm_unreachable ("unknow standard section type."); > + ?case UDATA: UDATASections_.push_back(Entry); break; > + ?case IDATA: IDATASections_.push_back(Entry); break; > + ?case ROMDATA: ROMDATASection_ = Entry; break; > + ?} > > -PIC16TargetObjectFile::PIC16TargetObjectFile() > - ?: ExternalVarDecls(0), ExternalVarDefs(0) { > + ?return Entry; > ?} > + > + > +/// Find a standard pic16 autos section. If not found, create one and keep > +/// track of it by adding it to appropriate std section list. > +PIC16Section *PIC16TargetObjectFile:: > +getPIC16AutoSection(const std::string &Name, PIC16SectionType Ty, > + ? ? ? ? ? ? ? ? ? ?const std::string &Address, int Color) const { > > -const MCSectionPIC16 *PIC16TargetObjectFile:: > -getPIC16Section(const char *Name, SectionKind Kind, > - ? ? ? ? ? ? ? ?int Address, int Color) const { > - ?MCSectionPIC16 *&Entry = SectionsByName[Name]; > + ?/// Return if we have an already existing one. > + ?PIC16Section *&Entry = SectionsByName[Name]; > ? if (Entry) > ? ? return Entry; > > - ?return Entry = MCSectionPIC16::Create(Name, Kind, Address, Color, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?getContext()); > + > + ?/// Else create a new one and add it to appropriate section list. > + ?Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); > + > + ?assert (Ty == UDATA_OVR && "incorrect section type for autos"); > + ?AUTOSections_.push_back(Entry); > + > + ?return Entry; > ?} > + > +/// Find a pic16 user section. If not found, create one and keep > +/// track of it by adding it to appropriate std section list. > +PIC16Section *PIC16TargetObjectFile:: > +getPIC16UserSection(const std::string &Name, PIC16SectionType Ty, > + ? ? ? ? ? ? ? ? ? ?const std::string &Address, int Color) const { > + > + ?/// Return if we have an already existing one. > + ?PIC16Section *&Entry = SectionsByName[Name]; > + ?if (Entry) > + ? ?return Entry; > > > + ?/// Else create a new one and add it to appropriate section list. > + ?Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); > + > + ?USERSections_.push_back(Entry); > + > + ?return Entry; > +} > + > +/// Do some standard llvm stuff. PIC16 really does not need any of this. > ?void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){ > ? TargetLoweringObjectFile::Initialize(Ctx, tm); > ? TM = &tm; > > - ?BSSSection = getPIC16Section("udata.# UDATA", MCSectionPIC16::UDATA_Kind()); > - ?ReadOnlySection = getPIC16Section("romdata.# ROMDATA", > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?MCSectionPIC16::ROMDATA_Kind()); > - ?DataSection = getPIC16Section("idata.# IDATA", MCSectionPIC16::IDATA_Kind()); > + ?// BSSSection = getPIC16DataSection("udata.#", UDATA); > + ?// ReadOnlySection = getPIC16DataSection("romdata.#", ROMDATA); > + ?// DataSection = getPIC16DataSection("idata.#", IDATA); > > ? // Need because otherwise a .text symbol is emitted by DwarfWriter > ? // in BeginModule, and gpasm cribbs for that .text symbol. > - ?TextSection = getPIC16Section("", SectionKind::getText()); > - > - ?ROSections.push_back(new PIC16Section((MCSectionPIC16*)ReadOnlySection)); > - > - ?// FIXME: I don't know what the classification of these sections really is. > - ?// These aren't really objects belonging to any section. Just emit them > - ?// in AsmPrinter and remove this code from here. > - ?ExternalVarDecls = new PIC16Section(getPIC16Section("ExternalVarDecls", > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SectionKind::getMetadata())); > - ?ExternalVarDefs = new PIC16Section(getPIC16Section("ExternalVarDefs", > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SectionKind::getMetadata())); > -} > - > -const MCSection *PIC16TargetObjectFile:: > -getSectionForFunction(const std::string &FnName) const { > - ?std::string T = PAN::getCodeSectionName(FnName); > - ?return getPIC16Section(T.c_str(), SectionKind::getText()); > -} > - > - > -const MCSection *PIC16TargetObjectFile:: > -getSectionForFunctionFrame(const std::string &FnName) const { > - ?std::string T = PAN::getFrameSectionName(FnName); > - ?return getPIC16Section(T.c_str(), SectionKind::getDataRel()); > + ?// FIXME: below > + ?// TextSection = getPIC16DataSection("", UDATA); > + ?ROMDATASection_ = NULL; > ?} > > +/// allocateUDATA - Allocate a un-initialized global to an existing or new UDATA > +/// section and return that section. > ?const MCSection * > -PIC16TargetObjectFile::getBSSSectionForGlobal(const GlobalVariable *GV) const { > +PIC16TargetObjectFile::allocateUDATA(const GlobalVariable *GV) const { > ? assert(GV->hasInitializer() && "This global doesn't need space"); > ? Constant *C = GV->getInitializer(); > ? assert(C->isNullValue() && "Unitialized globals has non-zero initializer"); > @@ -97,41 +133,37 @@ > ? const Type *Ty = C->getType(); > ? unsigned ValSize = TD->getTypeAllocSize(Ty); > > - ?// Go through all BSS Sections and assign this variable > + ?// Go through all UDATA Sections and assign this variable > ? // to the first available section having enough space. > - ?PIC16Section *FoundBSS = NULL; > - ?for (unsigned i = 0; i < BSSSections.size(); i++) { > - ? ?if (DataBankSize - BSSSections[i]->Size >= ValSize) { > - ? ? ?FoundBSS = BSSSections[i]; > + ?PIC16Section *Found = NULL; > + ?for (unsigned i = 0; i < UDATASections_.size(); i++) { > + ? ?if (DataBankSize - UDATASections_[i]->getSize() >= ValSize) { > + ? ? ?Found = UDATASections_[i]; > ? ? ? break; > ? ? } > ? } > > - ?// No BSS section spacious enough was found. Crate a new one. > - ?if (!FoundBSS) { > - ? ?std::string name = PAN::getUdataSectionName(BSSSections.size()); > - ? ?const MCSectionPIC16 *NewSection > - ? ? ?= getPIC16Section(name.c_str(), MCSectionPIC16::UDATA_Kind()); > - > - ? ?FoundBSS = new PIC16Section(NewSection); > - > - ? ?// Add this newly created BSS section to the list of BSSSections. > - ? ?BSSSections.push_back(FoundBSS); > + ?// No UDATA section spacious enough was found. Crate a new one. > + ?if (!Found) { > + ? ?std::string name = PAN::getUdataSectionName(UDATASections_.size()); > + ? ?Found = getPIC16DataSection(name.c_str(), UDATA); > ? } > > - ?// Insert the GV into this BSS. > - ?FoundBSS->Items.push_back(GV); > - ?FoundBSS->Size += ValSize; > - ?return FoundBSS->S_; > + ?// Insert the GV into this UDATA section. > + ?Found->Items.push_back(GV); > + ?Found->setSize(Found->getSize() + ValSize); > + ?return Found; > ?} > > +/// allocateIDATA - allocate an initialized global into an existing > +/// or new section and return that section. > ?const MCSection * > -PIC16TargetObjectFile::getIDATASectionForGlobal(const GlobalVariable *GV) const{ > +PIC16TargetObjectFile::allocateIDATA(const GlobalVariable *GV) const{ > ? assert(GV->hasInitializer() && "This global doesn't need space"); > ? Constant *C = GV->getInitializer(); > ? assert(!C->isNullValue() && "initialized globals has zero initializer"); > ? assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE && > - ? ? ? ? "can split initialized RAM data only"); > + ? ? ? ? "can allocate initialized RAM data only"); > > ? // Find how much space this global needs. > ? const TargetData *TD = TM->getTargetData(); > @@ -140,64 +172,47 @@ > > ? // Go through all IDATA Sections and assign this variable > ? // to the first available section having enough space. > - ?PIC16Section *FoundIDATA = NULL; > - ?for (unsigned i = 0; i < IDATASections.size(); i++) { > - ? ?if (DataBankSize - IDATASections[i]->Size >= ValSize) { > - ? ? ?FoundIDATA = IDATASections[i]; > + ?PIC16Section *Found = NULL; > + ?for (unsigned i = 0; i < IDATASections_.size(); i++) { > + ? ?if (DataBankSize - IDATASections_[i]->getSize() >= ValSize) { > + ? ? ?Found = IDATASections_[i]; > ? ? ? break; > ? ? } > ? } > > ? // No IDATA section spacious enough was found. Crate a new one. > - ?if (!FoundIDATA) { > - ? ?std::string name = PAN::getIdataSectionName(IDATASections.size()); > - ? ?const MCSectionPIC16 *NewSection = > - ? ? ?getPIC16Section(name.c_str(), MCSectionPIC16::IDATA_Kind()); > - > - ? ?FoundIDATA = new PIC16Section(NewSection); > - > - ? ?// Add this newly created IDATA section to the list of IDATASections. > - ? ?IDATASections.push_back(FoundIDATA); > + ?if (!Found) { > + ? ?std::string name = PAN::getIdataSectionName(IDATASections_.size()); > + ? ?Found = getPIC16DataSection(name.c_str(), IDATA); > ? } > > ? // Insert the GV into this IDATA. > - ?FoundIDATA->Items.push_back(GV); > - ?FoundIDATA->Size += ValSize; > - ?return FoundIDATA->S_; > + ?Found->Items.push_back(GV); > + ?Found->setSize(Found->getSize() + ValSize); > + ?return Found; > ?} > > -// Get the section for an automatic variable of a function. > -// For PIC16 they are globals only with mangled names. > +// Allocate a program memory variable into ROMDATA section. > ?const MCSection * > -PIC16TargetObjectFile::getSectionForAuto(const GlobalVariable *GV) const { > - > - ?const std::string name = PAN::getSectionNameForSym(GV->getName()); > - > - ?// Go through all Auto Sections and assign this variable > - ?// to the appropriate section. > - ?PIC16Section *FoundAutoSec = NULL; > - ?for (unsigned i = 0; i < AutosSections.size(); i++) { > - ? ?if (AutosSections[i]->S_->getName() == name) { > - ? ? ?FoundAutoSec = AutosSections[i]; > - ? ? ?break; > - ? ?} > - ?} > +PIC16TargetObjectFile::allocateROMDATA(const GlobalVariable *GV) const { > > - ?// No Auto section was found. Crate a new one. > - ?if (!FoundAutoSec) { > - ? ?const MCSectionPIC16 *NewSection = > - ? ? ?getPIC16Section(name.c_str(), MCSectionPIC16::UDATA_OVR_Kind()); > + ?std::string name = PAN::getRomdataSectionName(); > + ?PIC16Section *S = getPIC16DataSection(name.c_str(), ROMDATA); > > - ? ?FoundAutoSec = new PIC16Section(NewSection); > + ?S->Items.push_back(GV); > + ?return S; > +} > > - ? ?// Add this newly created autos section to the list of AutosSections. > - ? ?AutosSections.push_back(FoundAutoSec); > - ?} > +// Get the section for an automatic variable of a function. > +// For PIC16 they are globals only with mangled names. > +const MCSection * > +PIC16TargetObjectFile::allocateAUTO(const GlobalVariable *GV) const { > > - ?// Insert the auto into this section. > - ?FoundAutoSec->Items.push_back(GV); > + ?const std::string name = PAN::getSectionNameForSym(GV->getName()); > + ?PIC16Section *S = getPIC16AutoSection(name.c_str()); > > - ?return FoundAutoSec->S_; > + ?S->Items.push_back(GV); > + ?return S; > ?} > > > @@ -214,56 +229,50 @@ > ? if (!GV) > ? ? return TargetLoweringObjectFile::SelectSectionForGlobal(GV1, Kind, Mang,TM); > > - ?// Record External Var Decls. > - ?if (GV->isDeclaration()) { > - ? ?ExternalVarDecls->Items.push_back(GV); > - ? ?return ExternalVarDecls->S_; > - ?} > - > ? assert(GV->hasInitializer() && "A def without initializer?"); > > ? // First, if this is an automatic variable for a function, get the section > ? // name for it and return. > ? std::string name = GV->getName(); > ? if (PAN::isLocalName(name)) > - ? ?return getSectionForAuto(GV); > - > - ?// Record Exteranl Var Defs. > - ?if (GV->hasExternalLinkage() || GV->hasCommonLinkage()) > - ? ?ExternalVarDefs->Items.push_back(GV); > + ? ?return allocateAUTO(GV); > > ? // See if this is an uninitialized global. > ? const Constant *C = GV->getInitializer(); > ? if (C->isNullValue()) > - ? ?return getBSSSectionForGlobal(GV); > + ? ?return allocateUDATA(GV); > > ? // If this is initialized data in RAM. Put it in the correct IDATA section. > ? if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) > - ? ?return getIDATASectionForGlobal(GV); > + ? ?return allocateIDATA(GV); > > ? // This is initialized data in rom, put it in the readonly section. > ? if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) > - ? ?return getROSectionForGlobal(GV); > + ? ?return allocateROMDATA(GV); > > ? // Else let the default implementation take care of it. > ? return TargetLoweringObjectFile::SelectSectionForGlobal(GV, Kind, Mang,TM); > ?} > > ?PIC16TargetObjectFile::~PIC16TargetObjectFile() { > - ?for (unsigned i = 0; i < BSSSections.size(); i++) > - ? ?delete BSSSections[i]; > - ?for (unsigned i = 0; i < IDATASections.size(); i++) > - ? ?delete IDATASections[i]; > - ?for (unsigned i = 0; i < AutosSections.size(); i++) > - ? ?delete AutosSections[i]; > - ?for (unsigned i = 0; i < ROSections.size(); i++) > - ? ?delete ROSections[i]; > - ?delete ExternalVarDecls; > - ?delete ExternalVarDefs; > +#if 0 > + ?for (unsigned i = 0; i < UDATASections_.size(); i++) > + ? ?delete UDATASections_[i]; > + ?for (unsigned i = 0; i < IDATASections_.size(); i++) > + ? ?delete IDATASections_[i]; > + > + ?delete ROMDATASection_; > + > + ?for (unsigned i = 0; i < AUTOSections_.size(); i++) > + ? ?delete AUTOSections_[i]; > + > + ?for (unsigned i = 0; i < USERSections_.size(); i++) > + ? ?delete USERSections_[i]; > +#endif > ?} > > > -/// getSpecialCasedSectionGlobals - Allow the target to completely override > +/// getExplicitSectionGlobal - Allow the target to completely override > ?/// section assignment of a global. > ?const MCSection *PIC16TargetObjectFile:: > ?getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, > @@ -274,167 +283,83 @@ > ? ? std::string SectName = GVar->getSection(); > ? ? // If address for a variable is specified, get the address and create > ? ? // section. > + ? ?// FIXME: move this attribute checking in PAN. > ? ? std::string AddrStr = "Address="; > ? ? if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) { > ? ? ? std::string SectAddr = SectName.substr(AddrStr.length()); > - ? ? ?return CreateSectionForGlobal(GVar, Mang, SectAddr); > + ? ? ?return allocateAtGivenAddress(GVar, SectAddr); > ? ? } > > ? ? // Create the section specified with section attribute. > - ? ?return CreateSectionForGlobal(GVar, Mang); > + ? ?return allocateInGivenSection(GVar); > ? } > > - ?return getPIC16Section(GV->getSection().c_str(), Kind); > + ?return getPIC16DataSection(GV->getSection().c_str(), UDATA); > +} > + > +// Interface used by AsmPrinter to get a code section for a function. > +const PIC16Section * > +PIC16TargetObjectFile::SectionForCode(const std::string &FnName) const { > + ?const std::string &sec_name = PAN::getCodeSectionName(FnName); > + ?return getPIC16Section(sec_name, CODE); > ?} > > -// Create a new section for global variable. If Addr is given then create > -// section at that address else create by name. > +// Interface used by AsmPrinter to get a frame section for a function. > +const PIC16Section * > +PIC16TargetObjectFile::SectionForFrame(const std::string &FnName) const { > + ?const std::string &sec_name = PAN::getFrameSectionName(FnName); > + ?return getPIC16Section(sec_name, UDATA_OVR); > +} > + > +// Allocate a global var in existing or new section of given name. > ?const MCSection * > -PIC16TargetObjectFile::CreateSectionForGlobal(const GlobalVariable *GV, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Mangler *Mang, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const std::string &Addr) const { > +PIC16TargetObjectFile::allocateInGivenSection(const GlobalVariable *GV) const { > + ?// Determine the type of section that we need to create. > + ?PIC16SectionType SecTy; > + > ? // See if this is an uninitialized global. > ? const Constant *C = GV->getInitializer(); > ? if (C->isNullValue()) > - ? ?return CreateBSSSectionForGlobal(GV, Addr); > - > + ? ?SecTy = UDATA; > ? // If this is initialized data in RAM. Put it in the correct IDATA section. > - ?if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) > - ? ?return CreateIDATASectionForGlobal(GV, Addr); > - > + ?else if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) > + ? ?SecTy = IDATA; > ? // This is initialized data in rom, put it in the readonly section. > - ?if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) > - ? ?return CreateROSectionForGlobal(GV, Addr); > - > - ?// Else let the default implementation take care of it. > - ?return TargetLoweringObjectFile::SectionForGlobal(GV, Mang, *TM); > -} > - > -// Create uninitialized section for a variable. > -const MCSection * > -PIC16TargetObjectFile::CreateBSSSectionForGlobal(const GlobalVariable *GV, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::string Addr) const { > - ?assert(GV->hasInitializer() && "This global doesn't need space"); > - ?assert(GV->getInitializer()->isNullValue() && > - ? ? ? ? "Unitialized global has non-zero initializer"); > - ?std::string Name; > - ?// If address is given then create a section at that address else create a > - ?// section by section name specified in GV. > - ?PIC16Section *FoundBSS = NULL; > - ?if (Addr.empty()) { > - ? ?Name = GV->getSection() + " UDATA"; > - ? ?for (unsigned i = 0; i < BSSSections.size(); i++) { > - ? ? ?if (BSSSections[i]->S_->getName() == Name) { > - ? ? ? ?FoundBSS = BSSSections[i]; > - ? ? ? ?break; > - ? ? ?} > - ? ?} > - ?} else { > - ? ?std::string Prefix = GV->getNameStr() + "." + Addr + "."; > - ? ?Name = PAN::getUdataSectionName(BSSSections.size(), Prefix) + " " + Addr; > - ?} > - > - ?PIC16Section *NewBSS = FoundBSS; > - ?if (NewBSS == NULL) { > - ? ?const MCSectionPIC16 *NewSection = > - ? ? ?getPIC16Section(Name.c_str(), MCSectionPIC16::UDATA_Kind()); > - ? ?NewBSS = new PIC16Section(NewSection); > - ? ?BSSSections.push_back(NewBSS); > - ?} > - > - ?// Insert the GV into this BSS. > - ?NewBSS->Items.push_back(GV); > + ?else if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) > + ? ?SecTy = ROMDATA; > + ?else > + ? ?llvm_unreachable ("Could not determine section type for global"); > > - ?// We do not want to put any ?GV without explicit section into this section > - ?// so set its size to DatabankSize. > - ?NewBSS->Size = DataBankSize; > - ?return NewBSS->S_; > -} > - > -// Get rom section for a variable. Currently there can be only one rom section > -// unless a variable explicitly requests a section. > -const MCSection * > -PIC16TargetObjectFile::getROSectionForGlobal(const GlobalVariable *GV) const { > - ?ROSections[0]->Items.push_back(GV); > - ?return ROSections[0]->S_; > + ?PIC16Section *S = getPIC16UserSection(GV->getSection().c_str(), SecTy); > + ?S->Items.push_back(GV); > + ?return S; > ?} > > -// Create initialized data section for a variable. > +// Allocate a global var in a new absolute sections at given address. > ?const MCSection * > -PIC16TargetObjectFile::CreateIDATASectionForGlobal(const GlobalVariable *GV, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::string Addr) const { > - ?assert(GV->hasInitializer() && "This global doesn't need space"); > - ?assert(!GV->getInitializer()->isNullValue() && > - ? ? ? ? "initialized global has zero initializer"); > - ?assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE && > - ? ? ? ? "can be used for initialized RAM data only"); > - > - ?std::string Name; > - ?// If address is given then create a section at that address else create a > - ?// section by section name specified in GV. > - ?PIC16Section *FoundIDATASec = NULL; > - ?if (Addr.empty()) { > - ? ?Name = GV->getSection() + " IDATA"; > - ? ?for (unsigned i = 0; i < IDATASections.size(); i++) { > - ? ? ?if (IDATASections[i]->S_->getName() == Name) { > - ? ? ? ?FoundIDATASec = IDATASections[i]; > - ? ? ? ?break; > - ? ? ?} > - ? ?} > - ?} else { > - ? ?std::string Prefix = GV->getNameStr() + "." + Addr + "."; > - ? ?Name = PAN::getIdataSectionName(IDATASections.size(), Prefix) + " " + Addr; > - ?} > +PIC16TargetObjectFile::allocateAtGivenAddress(const GlobalVariable *GV, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const std::string &Addr) const { > + ?// Determine the type of section that we need to create. > + ?PIC16SectionType SecTy; > > - ?PIC16Section *NewIDATASec = FoundIDATASec; > - ?if (NewIDATASec == NULL) { > - ? ?const MCSectionPIC16 *NewSection = > - ? ? ?getPIC16Section(Name.c_str(), MCSectionPIC16::IDATA_Kind()); > - ? ?NewIDATASec = new PIC16Section(NewSection); > - ? ?IDATASections.push_back(NewIDATASec); > - ?} > - ?// Insert the GV into this IDATA Section. > - ?NewIDATASec->Items.push_back(GV); > - ?// We do not want to put any ?GV without explicit section into this section > - ?// so set its size to DatabankSize. > - ?NewIDATASec->Size = DataBankSize; > - ?return NewIDATASec->S_; > + ?// See if this is an uninitialized global. > + ?const Constant *C = GV->getInitializer(); > + ?if (C->isNullValue()) > + ? ?SecTy = UDATA; > + ?// If this is initialized data in RAM. Put it in the correct IDATA section. > + ?else if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) > + ? ?SecTy = IDATA; > + ?// This is initialized data in rom, put it in the readonly section. > + ?else if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) > + ? ?SecTy = ROMDATA; > + ?else > + ? ?llvm_unreachable ("Could not determine section type for global"); > + > + ?std::string Prefix = GV->getNameStr() + "." + Addr + "."; > + ?std::string SName = PAN::getUserSectionName(Prefix); > + ?PIC16Section *S = getPIC16UserSection(SName.c_str(), SecTy, Addr.c_str()); > + ?S->Items.push_back(GV); > + ?return S; > ?} > > -// Create a section in rom for a variable. > -const MCSection * > -PIC16TargetObjectFile::CreateROSectionForGlobal(const GlobalVariable *GV, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?std::string Addr) const { > - ?assert(GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE && > - ? ? ? ? "can be used for ROM data only"); > - > - ?std::string Name; > - ?// If address is given then create a section at that address else create a > - ?// section by section name specified in GV. > - ?PIC16Section *FoundROSec = NULL; > - ?if (Addr.empty()) { > - ? ?Name = GV->getSection() + " ROMDATA"; > - ? ?for (unsigned i = 1; i < ROSections.size(); i++) { > - ? ? ?if (ROSections[i]->S_->getName() == Name) { > - ? ? ? ?FoundROSec = ROSections[i]; > - ? ? ? ?break; > - ? ? ?} > - ? ?} > - ?} else { > - ? ?std::string Prefix = GV->getNameStr() + "." + Addr + "."; > - ? ?Name = PAN::getRomdataSectionName(ROSections.size(), Prefix) + " " + Addr; > - ?} > - > - ?PIC16Section *NewRomSec = FoundROSec; > - ?if (NewRomSec == NULL) { > - ? ?const MCSectionPIC16 *NewSection = > - ? ? ?getPIC16Section(Name.c_str(), MCSectionPIC16::ROMDATA_Kind()); > - ? ?NewRomSec = new PIC16Section(NewSection); > - ? ?ROSections.push_back(NewRomSec); > - ?} > - > - ?// Insert the GV into this ROM Section. > - ?NewRomSec->Items.push_back(GV); > - ?return NewRomSec->S_; > -} > > > Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h?rev=84180&r1=84179&r2=84180&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h (original) > +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Thu Oct 15 05:10:43 2009 > @@ -10,6 +10,8 @@ > ?#ifndef LLVM_TARGET_PIC16_TARGETOBJECTFILE_H > ?#define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H > > +#include "PIC16.h" > +#include "PIC16ABINames.h" > ?#include "llvm/Target/TargetLoweringObjectFile.h" > ?#include "llvm/ADT/StringMap.h" > ?#include > @@ -19,7 +21,7 @@ > ? class GlobalVariable; > ? class Module; > ? class PIC16TargetMachine; > - ?class MCSectionPIC16; > + ?class PIC16Section; > > ? enum { DataBankSize = 80 }; > > @@ -29,91 +31,124 @@ > ? /// again and printing only those that match the current section. > ? /// Keeping values inside the sections make printing a section much easier. > ? /// > - ?/// FIXME: MOVE ALL THIS STUFF TO MCSectionPIC16. > + ?/// FIXME: MOVE ALL THIS STUFF TO PIC16Section. > ? /// > - ?struct PIC16Section { > - ? ?const MCSectionPIC16 *S_; // Connection to actual Section. > - ? ?unsigned Size; ?// Total size of the objects contained. > - ? ?bool SectionPrinted; > - ? ?std::vector Items; > - > - ? ?PIC16Section(const MCSectionPIC16 *s) { > - ? ? ?S_ = s; > - ? ? ?Size = 0; > - ? ? ?SectionPrinted = false; > - ? ?} > - ? ?bool isPrinted() const { return SectionPrinted; } > - ? ?void setPrintedStatus(bool status) { SectionPrinted = status; } > - ?}; > - > + > + ?/// PIC16TargetObjectFile - PIC16 Object file. Contains data and code > + ?/// sections. > + ?// PIC16 Object File has two types of sections. > + ?// 1. Standard Sections > + ?// ? ?1.1 un-initialized global data > + ?// ? ?1.2 initialized global data > + ?// ? ?1.3 program memory data > + ?// ? ?1.4 local variables of functions. > + ?// 2. User defined sections > + ?// ? ?2.1 Objects placed in a specific section. (By _Section() macro) > + ?// ? ?2.2 Objects placed at a specific address. (By _Address() macro) > ? class PIC16TargetObjectFile : public TargetLoweringObjectFile { > ? ? /// SectionsByName - Bindings of names to allocated sections. > - ? ?mutable StringMap SectionsByName; > + ? ?mutable StringMap SectionsByName; > > ? ? const TargetMachine *TM; > > - ? ?const MCSectionPIC16 *getPIC16Section(const char *Name, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SectionKind K, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?int Address = -1, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?int Color = -1) const; > - ?public: > - ? ?mutable std::vector BSSSections; > - ? ?mutable std::vector IDATASections; > - ? ?mutable std::vector AutosSections; > - ? ?mutable std::vector ROSections; > - ? ?mutable PIC16Section *ExternalVarDecls; > - ? ?mutable PIC16Section *ExternalVarDefs; > - > + ? ?/// Lists of sections. > + ? ?/// Standard Data Sections. > + ? ?mutable std::vector UDATASections_; > + ? ?mutable std::vector IDATASections_; > + ? ?mutable PIC16Section * ROMDATASection_; > + > + ? ?/// Standard Auto Sections. > + ? ?mutable std::vector AUTOSections_; > + > + ? ?/// User specified sections. > + ? ?mutable std::vector USERSections_; > + > + > + ? ?/// Find or Create a PIC16 Section, without adding it to any > + ? ?/// section list. > + ? ?PIC16Section *getPIC16Section(const std::string &Name, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PIC16SectionType Ty, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const std::string &Address = "", > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int Color = -1) const; > + > + ? ?/// Convenience functions. These wrappers also take care of adding > + ? ?/// the newly created section to the appropriate sections list. > + > + ? ?/// Find or Create PIC16 Standard Data Section. > + ? ?PIC16Section *getPIC16DataSection(const std::string &Name, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PIC16SectionType Ty, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const std::string &Address = "", > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int Color = -1) const; > + > + ? ?/// Find or Create PIC16 Standard Auto Section. > + ? ?PIC16Section *getPIC16AutoSection(const std::string &Name, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PIC16SectionType Ty = UDATA_OVR, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const std::string &Address = "", > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int Color = -1) const; > + > + ? ?/// Find or Create PIC16 Standard Auto Section. > + ? ?PIC16Section *getPIC16UserSection(const std::string &Name, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PIC16SectionType Ty, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const std::string &Address = "", > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int Color = -1) const; > + > + ? ?/// Allocate Un-initialized data to a standard UDATA section. > + ? ?const MCSection *allocateUDATA(const GlobalVariable *GV) const; > + > + ? ?/// Allocate Initialized data to a standard IDATA section. > + ? ?const MCSection *allocateIDATA(const GlobalVariable *GV) const; > + > + ? ?/// Allocate ROM data to the standard ROMDATA section. > + ? ?const MCSection *allocateROMDATA(const GlobalVariable *GV) const; > + > + ? ?/// Allocate an AUTO variable to an AUTO section. > + ? ?const MCSection *allocateAUTO(const GlobalVariable *GV) const; > + > + ? ?/// Allocate DATA in user specified section. > + ? ?const MCSection *allocateInGivenSection(const GlobalVariable *GV) const; > + > + ? ?/// Allocate DATA at user specified address. > + ? ?const MCSection *allocateAtGivenAddress(const GlobalVariable *GV, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const std::string &Addr) const; > + > + ? ?public: > ? ? PIC16TargetObjectFile(); > ? ? ~PIC16TargetObjectFile(); > - > ? ? void Initialize(MCContext &Ctx, const TargetMachine &TM); > > - > + ? ?/// Override section allocations for user specified sections. > ? ? virtual const MCSection * > ? ? getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Mangler *Mang, const TargetMachine &TM) const; > > + ? ?/// Select sections for Data and Auto variables(globals). > ? ? virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SectionKind Kind, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Mangler *Mang, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const TargetMachine&) const; > > - ? ?const MCSection *getSectionForFunction(const std::string &FnName) const; > - ? ?const MCSection *getSectionForFunctionFrame(const std::string &FnName)const; > - > - > - ?private: > - ? ?std::string getSectionNameForSym(const std::string &Sym) const; > + ? ?/// Return a code section for a function. > + ? ?const PIC16Section *SectionForCode (const std::string &FnName) const; > > - ? ?const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const; > - ? ?const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const; > - ? ?const MCSection *getSectionForAuto(const GlobalVariable *GV) const; > - ? ?const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::string Addr = "") const; > - ? ?const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? std::string Addr = "") const; > - ? ?const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const; > - ? ?const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?std::string Addr = "") const; > - ? ?const MCSection *CreateSectionForGlobal(const GlobalVariable *GV, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Mangler *Mang, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const std::string &Addr = "") const; > - ?public: > - ? ?void SetSectionForGVs(Module &M); > - ? ?const std::vector &getBSSSections() const { > - ? ? ?return BSSSections; > + ? ?/// Return a frame section for a function. > + ? ?const PIC16Section *SectionForFrame (const std::string &FnName) const; > + > + ? ?/// Accessors for various section lists. > + ? ?const std::vector &UDATASections() const { > + ? ? ?return UDATASections_; > ? ? } > - ? ?const std::vector &getIDATASections() const { > - ? ? ?return IDATASections; > + ? ?const std::vector &IDATASections() const { > + ? ? ?return IDATASections_; > ? ? } > - ? ?const std::vector &getAutosSections() const { > - ? ? ?return AutosSections; > + ? ?const PIC16Section *ROMDATASection() const { > + ? ? ?return ROMDATASection_; > ? ? } > - ? ?const std::vector &getROSections() const { > - ? ? ?return ROSections; > + ? ?const std::vector &AUTOSections() const { > + ? ? ?return AUTOSections_; > + ? ?} > + ? ?const std::vector &USERSections() const { > + ? ? ?return USERSections_; > ? ? } > - > ? }; > ?} // end namespace llvm > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Thu Oct 15 10:26:46 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 15 Oct 2009 10:26:46 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910151526.n9FFQkYl011821@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.24 -> 1.25 --- Log message: videos are up! --- Diffs of the changes: (+8 -2) index.html | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.24 llvm-www/devmtg/2009-10/index.html:1.25 --- llvm-www/devmtg/2009-10/index.html:1.24 Thu Oct 15 02:04:54 2009 +++ llvm-www/devmtg/2009-10/index.html Thu Oct 15 10:25:06 2009 @@ -41,7 +41,13 @@ major LLVM subsystems and talks on applications of LLVM for various specific projects.

        -

        Videos will take 2-4 weeks from the meeting to appear. Please be patient.

        +

        This pages lists all of the slides and videos for all of the talks of the +day. The talks were held in two rooms - in one room we only were able to +record a screencast, in the other room we have full video. Please note that +the 'mobile' versions of the videos are actually larger (in file size) and +lower quality than the 'computer' versions, because a weaker codec had to be +used.

        + @@ -277,7 +283,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 07:04:54 $ +
        Last modified: $Date: 2009/10/15 15:25:06 $ From grosbach at apple.com Thu Oct 15 11:31:28 2009 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 15 Oct 2009 09:31:28 -0700 Subject: [llvm-commits] [llvm] r84172 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp In-Reply-To: <200910150510.n9F5AaL1008503@zion.cs.uiuc.edu> References: <200910150510.n9F5AaL1008503@zion.cs.uiuc.edu> Message-ID: <9CA07D19-3B2C-4C03-81A5-B9D7CF0A6403@apple.com> On Oct 14, 2009, at 10:10 PM, Bob Wilson wrote: > Author: bwilson > Date: Thu Oct 15 00:10:36 2009 > New Revision: 84172 > > URL: http://llvm.org/viewvc/llvm-project?rev=84172&view=rev > Log: > Fix another problem with ARM constant pools. Radar 7303551. > When ARMConstantIslandPass cannot find any good locations (i.e., > "water") to > place constants, it falls back to inserting unconditional branches > to make a > place to put them. My recent change exposed a problem in this > area. We may > sometimes append to the same block more than one unconditional > branch. The > symptoms of this are that the generated assembly has a branch to an > undefined > label and running llc with -debug will cause a seg fault. > > This happens more easily since my change to prevent CPEs from moving > from > lower to higher addresses as the algorithm iterates, but it could have > happened before. The end of the block may be in range for various > constant > pool references, but the insertion point for new CPEs is not right > at the end > of the block -- it is at the end of the CPEs that have already been > placed > at the end of the block. The insertion point could be out of > range. When > that happens, the fallback code will always append another > unconditional > branch if the end of the block is in range. > > The fix is to only append an unconditional branch if the block does > not > already end with one. I also removed a check to see if the constant > pool load > instruction is at the end of the block, since that is redundant with > checking if the end of the block is in-range. > Doesn't this mean that the new constant pool entry still be out of range? Or, if it's added at the top of the list rather than the end, that it could potentially move other items in the pool to be out of range? Not sure I completely follow. > There is more to be done here, but I think this fixes the immediate > problem. > > Modified: > llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp > > Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=84172&r1=84171&r2=84172&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Oct 15 > 00:10:36 2009 > @@ -1006,14 +1006,12 @@ > BBSizes[UserMBB->getNumber()]; > assert(OffsetOfNextBlock== BBOffsets[UserMBB->getNumber()+1]); > > - // If the use is at the end of the block, or the end of the block > - // is within range, make new water there. (The addition below is > - // for the unconditional branch we will be adding: 4 bytes on > ARM + Thumb2, > - // 2 on Thumb1. Possible Thumb1 alignment padding is allowed for > + // If the block does not end in an unconditional branch already, > and if the > + // end of the block is within range, make new water there. (The > addition > + // below is for the unconditional branch we will be adding: 4 > bytes on ARM + > + // Thumb2, 2 on Thumb1. Possible Thumb1 alignment padding is > allowed for > // inside OffsetIsInRange. > - // If the block ends in an unconditional branch already, it is > water, > - // and is known to be out of range, so we'll always be adding a > branch.) > - if (&UserMBB->back() == UserMI || > + if (BBHasFallthrough(UserMBB) && > OffsetIsInRange(UserOffset, OffsetOfNextBlock + (isThumb1 ? 2: > 4), > U.MaxDisp, U.NegOk, U.IsSoImm)) { > DEBUG(errs() << "Split at end of block\n"); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From bob.wilson at apple.com Thu Oct 15 11:37:15 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 15 Oct 2009 09:37:15 -0700 Subject: [llvm-commits] [llvm] r84172 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp In-Reply-To: <9CA07D19-3B2C-4C03-81A5-B9D7CF0A6403@apple.com> References: <200910150510.n9F5AaL1008503@zion.cs.uiuc.edu> <9CA07D19-3B2C-4C03-81A5-B9D7CF0A6403@apple.com> Message-ID: <4CDC14A1-6179-4ADC-B739-B68482A0EB71@apple.com> On Oct 15, 2009, at 9:31 AM, Jim Grosbach wrote: > > On Oct 14, 2009, at 10:10 PM, Bob Wilson wrote: > >> Author: bwilson >> Date: Thu Oct 15 00:10:36 2009 >> New Revision: 84172 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84172&view=rev >> Log: >> Fix another problem with ARM constant pools. Radar 7303551. >> When ARMConstantIslandPass cannot find any good locations (i.e., >> "water") to >> place constants, it falls back to inserting unconditional branches >> to make a >> place to put them. My recent change exposed a problem in this >> area. We may >> sometimes append to the same block more than one unconditional >> branch. The >> symptoms of this are that the generated assembly has a branch to an >> undefined >> label and running llc with -debug will cause a seg fault. >> >> This happens more easily since my change to prevent CPEs from >> moving from >> lower to higher addresses as the algorithm iterates, but it could >> have >> happened before. The end of the block may be in range for various >> constant >> pool references, but the insertion point for new CPEs is not right >> at the end >> of the block -- it is at the end of the CPEs that have already been >> placed >> at the end of the block. The insertion point could be out of >> range. When >> that happens, the fallback code will always append another >> unconditional >> branch if the end of the block is in range. >> >> The fix is to only append an unconditional branch if the block does >> not >> already end with one. I also removed a check to see if the >> constant pool load >> instruction is at the end of the block, since that is redundant with >> checking if the end of the block is in-range. >> > > Doesn't this mean that the new constant pool entry still be out of > range? Or, if it's added at the top of the list rather than the end, > that it could potentially move other items in the pool to be out of > range? Not sure I completely follow. If it can't add an unconditional branch, the next thing it tries is to split the block. That will always succeed. The key is to never go back and reconsider placing a constant in a location that has already been considered*. Doing so can prevent the pass from terminating. If you want to discuss the details, it would be easier to do it in person. * Footnote: ....except that I'm working on another patch that will make that condition slightly more complicated. Details to follow. > >> There is more to be done here, but I think this fixes the immediate >> problem. >> >> Modified: >> llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >> >> Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=84172&r1=84171&r2=84172&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Oct 15 >> 00:10:36 2009 >> @@ -1006,14 +1006,12 @@ >> BBSizes[UserMBB->getNumber()]; >> assert(OffsetOfNextBlock== BBOffsets[UserMBB->getNumber()+1]); >> >> - // If the use is at the end of the block, or the end of the block >> - // is within range, make new water there. (The addition below is >> - // for the unconditional branch we will be adding: 4 bytes on >> ARM + Thumb2, >> - // 2 on Thumb1. Possible Thumb1 alignment padding is allowed for >> + // If the block does not end in an unconditional branch already, >> and if the >> + // end of the block is within range, make new water there. (The >> addition >> + // below is for the unconditional branch we will be adding: 4 >> bytes on ARM + >> + // Thumb2, 2 on Thumb1. Possible Thumb1 alignment padding is >> allowed for >> // inside OffsetIsInRange. >> - // If the block ends in an unconditional branch already, it is >> water, >> - // and is known to be out of range, so we'll always be adding a >> branch.) >> - if (&UserMBB->back() == UserMI || >> + if (BBHasFallthrough(UserMBB) && >> OffsetIsInRange(UserOffset, OffsetOfNextBlock + (isThumb1 ? 2: >> 4), >> U.MaxDisp, U.NegOk, U.IsSoImm)) { >> DEBUG(errs() << "Split at end of block\n"); >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From grosbach at apple.com Thu Oct 15 11:41:10 2009 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 15 Oct 2009 09:41:10 -0700 Subject: [llvm-commits] [llvm] r84172 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp In-Reply-To: <4CDC14A1-6179-4ADC-B739-B68482A0EB71@apple.com> References: <200910150510.n9F5AaL1008503@zion.cs.uiuc.edu> <9CA07D19-3B2C-4C03-81A5-B9D7CF0A6403@apple.com> <4CDC14A1-6179-4ADC-B739-B68482A0EB71@apple.com> Message-ID: <82F73FA8-FCCD-44BF-9101-5B851B449613@apple.com> On Oct 15, 2009, at 9:37 AM, Bob Wilson wrote: > > On Oct 15, 2009, at 9:31 AM, Jim Grosbach wrote: > >> >> On Oct 14, 2009, at 10:10 PM, Bob Wilson wrote: >> >>> Author: bwilson >>> Date: Thu Oct 15 00:10:36 2009 >>> New Revision: 84172 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=84172&view=rev >>> Log: >>> Fix another problem with ARM constant pools. Radar 7303551. >>> When ARMConstantIslandPass cannot find any good locations (i.e., >>> "water") to >>> place constants, it falls back to inserting unconditional branches >>> to make a >>> place to put them. My recent change exposed a problem in this >>> area. We may >>> sometimes append to the same block more than one unconditional >>> branch. The >>> symptoms of this are that the generated assembly has a branch to >>> an undefined >>> label and running llc with -debug will cause a seg fault. >>> >>> This happens more easily since my change to prevent CPEs from >>> moving from >>> lower to higher addresses as the algorithm iterates, but it could >>> have >>> happened before. The end of the block may be in range for various >>> constant >>> pool references, but the insertion point for new CPEs is not right >>> at the end >>> of the block -- it is at the end of the CPEs that have already >>> been placed >>> at the end of the block. The insertion point could be out of >>> range. When >>> that happens, the fallback code will always append another >>> unconditional >>> branch if the end of the block is in range. >>> >>> The fix is to only append an unconditional branch if the block >>> does not >>> already end with one. I also removed a check to see if the >>> constant pool load >>> instruction is at the end of the block, since that is redundant with >>> checking if the end of the block is in-range. >>> >> >> Doesn't this mean that the new constant pool entry still be out of >> range? Or, if it's added at the top of the list rather than the >> end, that it could potentially move other items in the pool to be >> out of range? Not sure I completely follow. > > If it can't add an unconditional branch, the next thing it tries is > to split the block. That will always succeed. Aha! I misunderstood what you were getting at. This makes much more sense. Thanks! > > The key is to never go back and reconsider placing a constant in a > location that has already been considered*. Doing so can prevent > the pass from terminating. If you want to discuss the details, it > would be easier to do it in person. > > * Footnote: ....except that I'm working on another patch that will > make that condition slightly more complicated. Details to follow. > >> >>> There is more to be done here, but I think this fixes the >>> immediate problem. >>> >>> Modified: >>> llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >>> >>> Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=84172&r1=84171&r2=84172&view=diff >>> >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) >>> +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Oct 15 >>> 00:10:36 2009 >>> @@ -1006,14 +1006,12 @@ >>> BBSizes[UserMBB->getNumber()]; >>> assert(OffsetOfNextBlock== BBOffsets[UserMBB->getNumber()+1]); >>> >>> - // If the use is at the end of the block, or the end of the block >>> - // is within range, make new water there. (The addition below is >>> - // for the unconditional branch we will be adding: 4 bytes on >>> ARM + Thumb2, >>> - // 2 on Thumb1. Possible Thumb1 alignment padding is allowed for >>> + // If the block does not end in an unconditional branch >>> already, and if the >>> + // end of the block is within range, make new water there. >>> (The addition >>> + // below is for the unconditional branch we will be adding: 4 >>> bytes on ARM + >>> + // Thumb2, 2 on Thumb1. Possible Thumb1 alignment padding is >>> allowed for >>> // inside OffsetIsInRange. >>> - // If the block ends in an unconditional branch already, it is >>> water, >>> - // and is known to be out of range, so we'll always be adding a >>> branch.) >>> - if (&UserMBB->back() == UserMI || >>> + if (BBHasFallthrough(UserMBB) && >>> OffsetIsInRange(UserOffset, OffsetOfNextBlock + (isThumb1 ? 2: >>> 4), >>> U.MaxDisp, U.NegOk, U.IsSoImm)) { >>> DEBUG(errs() << "Split at end of block\n"); >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From benny.kra at googlemail.com Thu Oct 15 11:49:20 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 15 Oct 2009 16:49:20 -0000 Subject: [llvm-commits] [llvm] r84186 - /llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Message-ID: <200910151649.n9FGnK9K014817@zion.cs.uiuc.edu> Author: d0k Date: Thu Oct 15 11:49:16 2009 New Revision: 84186 URL: http://llvm.org/viewvc/llvm-project?rev=84186&view=rev Log: Disable another unittest that doesn't work on arm and ppc. Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=84186&r1=84185&r2=84186&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Thu Oct 15 11:49:16 2009 @@ -221,7 +221,6 @@ F1Ptr(); } -#endif // Regression test for PR5162. This used to trigger an AssertingVH inside the // JIT's Function to stub mapping. @@ -263,6 +262,7 @@ EXPECT_EQ(Func2->getNumUses(), 0u); Func2->eraseFromParent(); } +#endif // This code is copied from JITEventListenerTest, but it only runs once for all // the tests in this directory. Everything seems fine, but that's strange From gohman at apple.com Thu Oct 15 12:52:20 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 15 Oct 2009 10:52:20 -0700 Subject: [llvm-commits] [llvm] r84158 - in /llvm/trunk: lib/CodeGen/CodePlacementOpt.cpp test/CodeGen/X86/avoid-loop-align-2.ll test/CodeGen/X86/avoid-loop-align.ll In-Reply-To: References: <200910150036.n9F0aNZF031889@zion.cs.uiuc.edu> Message-ID: <247471C8-EDB7-468C-A3DD-1B91C011C43F@apple.com> On Oct 14, 2009, at 10:33 PM, Evan Cheng wrote: > > On Oct 14, 2009, at 5:36 PM, Dan Gohman wrote: > >> Author: djg >> Date: Wed Oct 14 19:36:22 2009 >> New Revision: 84158 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84158&view=rev >> Log: >> Make CodePlacementOpt align loops, rather than loop headers. The >> header is just the entry block to the loop, and it needn't be at >> the top of the loop in the code layout. > > Thanks. This is aligning the destination of the back edge, right? It aligns the destination of branches that branch to the top of the loop, from a layout perspective. > > Have you tested the performance and code size impact of this patch? Not exhaustively, but 253.perlbmk, which I happened to have been running for unrelated reasons, saw an 8% speedup, though that's dependent on it having gotten unlucky before. Dan From stoklund at 2pi.dk Thu Oct 15 13:48:54 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 15 Oct 2009 18:48:54 -0000 Subject: [llvm-commits] [llvm] r84190 - /llvm/trunk/Makefile.rules Message-ID: <200910151848.n9FImuSI019499@zion.cs.uiuc.edu> Author: stoklund Date: Thu Oct 15 13:48:47 2009 New Revision: 84190 URL: http://llvm.org/viewvc/llvm-project?rev=84190&view=rev Log: Tablegen target intrinsics from the target main .td file. Fix pasto. Modified: llvm/trunk/Makefile.rules Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=84190&r1=84189&r2=84190&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Thu Oct 15 13:48:47 2009 @@ -1540,8 +1540,8 @@ $(Verb) $(TableGen) -gen-callingconv -o $(call SYSPATH, $@) $< $(TARGET:%=$(ObjDir)/%GenIntrinsics.inc.tmp): \ -$(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir - $(Echo) "Building $( Author: nicholas Date: Thu Oct 15 13:48:58 2009 New Revision: 84191 URL: http://llvm.org/viewvc/llvm-project?rev=84191&view=rev Log: Add missing break statements! Thanks to Duncan Sands for pointing this out! Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84191&r1=84190&r2=84191&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Thu Oct 15 13:48:58 2009 @@ -358,11 +358,13 @@ if (alias(II->getOperand(2), PtrSize, P, Size) == NoAlias) return NoModRef; } + break; case Intrinsic::invariant_end: { unsigned PtrSize = cast(II->getOperand(2))->getZExtValue(); if (alias(II->getOperand(3), PtrSize, P, Size) == NoAlias) return NoModRef; } + break; } } } From stoklund at 2pi.dk Thu Oct 15 13:49:29 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 15 Oct 2009 18:49:29 -0000 Subject: [llvm-commits] [llvm] r84192 - in /llvm/trunk: include/llvm/Target/TargetIntrinsicInfo.h lib/Target/TargetIntrinsicInfo.cpp Message-ID: <200910151849.n9FInUBS019542@zion.cs.uiuc.edu> Author: stoklund Date: Thu Oct 15 13:49:26 2009 New Revision: 84192 URL: http://llvm.org/viewvc/llvm-project?rev=84192&view=rev Log: Clean up TargetIntrinsicInfo API. Add pure virtual methods. Modified: llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h llvm/trunk/lib/Target/TargetIntrinsicInfo.cpp Modified: llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h?rev=84192&r1=84191&r2=84192&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetIntrinsicInfo.h Thu Oct 15 13:49:26 2009 @@ -25,35 +25,21 @@ /// TargetIntrinsicInfo - Interface to description of machine instruction set /// class TargetIntrinsicInfo { - - const char **Intrinsics; // Raw array to allow static init'n - unsigned NumIntrinsics; // Number of entries in the desc array - - TargetIntrinsicInfo(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT - void operator=(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT + TargetIntrinsicInfo(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT + void operator=(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT public: - TargetIntrinsicInfo(const char **desc, unsigned num); + TargetIntrinsicInfo(); virtual ~TargetIntrinsicInfo(); - unsigned getNumIntrinsics() const { return NumIntrinsics; } - - virtual Function *getDeclaration(Module *M, const char *BuiltinName) const { - return 0; - } - - // Returns the Function declaration for intrinsic BuiltinName. If the - // intrinsic can be overloaded, uses Tys to return the correct function. - virtual Function *getDeclaration(Module *M, const char *BuiltinName, - const Type **Tys, unsigned numTys) const { - return 0; - } + /// Return the name of a target intrinsic, e.g. "llvm.bfin.ssync". + virtual const char *getName(unsigned IntrID) const =0; - // Returns true if the Builtin can be overloaded. - virtual bool isOverloaded(Module *M, const char *BuiltinName) const { - return false; - } + /// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown + /// names. + virtual unsigned lookupName(const char *Name, unsigned Len) const =0; - virtual unsigned getIntrinsicID(Function *F) const { return 0; } + /// Return the target intrinsic ID of a function, or 0. + virtual unsigned getIntrinsicID(Function *F) const; }; } // End llvm namespace Modified: llvm/trunk/lib/Target/TargetIntrinsicInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetIntrinsicInfo.cpp?rev=84192&r1=84191&r2=84192&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetIntrinsicInfo.cpp (original) +++ llvm/trunk/lib/Target/TargetIntrinsicInfo.cpp Thu Oct 15 13:49:26 2009 @@ -12,11 +12,19 @@ //===----------------------------------------------------------------------===// #include "llvm/Target/TargetIntrinsicInfo.h" +#include "llvm/Function.h" +#include "llvm/ADT/StringMap.h" using namespace llvm; -TargetIntrinsicInfo::TargetIntrinsicInfo(const char **desc, unsigned count) - : Intrinsics(desc), NumIntrinsics(count) { +TargetIntrinsicInfo::TargetIntrinsicInfo() { } TargetIntrinsicInfo::~TargetIntrinsicInfo() { } + +unsigned TargetIntrinsicInfo::getIntrinsicID(Function *F) const { + const ValueName *ValName = F->getValueName(); + if (!ValName) + return 0; + return lookupName(ValName->getKeyData(), ValName->getKeyLength()); +} From stoklund at 2pi.dk Thu Oct 15 13:50:04 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 15 Oct 2009 18:50:04 -0000 Subject: [llvm-commits] [llvm] r84193 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAG.cpp utils/TableGen/CodeGenDAGPatterns.h utils/TableGen/DAGISelEmitter.cpp Message-ID: <200910151850.n9FIo5Hw019579@zion.cs.uiuc.edu> Author: stoklund Date: Thu Oct 15 13:50:03 2009 New Revision: 84193 URL: http://llvm.org/viewvc/llvm-project?rev=84193&view=rev Log: Report errors correctly for unselected target intrinsics. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=84193&r1=84192&r2=84193&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Oct 15 13:50:03 2009 @@ -30,6 +30,7 @@ #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetInstrInfo.h" +#include "llvm/Target/TargetIntrinsicInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" @@ -5404,14 +5405,16 @@ case ISD::EH_RETURN: return "EH_RETURN"; case ISD::ConstantPool: return "ConstantPool"; case ISD::ExternalSymbol: return "ExternalSymbol"; - case ISD::INTRINSIC_WO_CHAIN: { - unsigned IID = cast(getOperand(0))->getZExtValue(); - return Intrinsic::getName((Intrinsic::ID)IID); - } + case ISD::INTRINSIC_WO_CHAIN: case ISD::INTRINSIC_VOID: case ISD::INTRINSIC_W_CHAIN: { - unsigned IID = cast(getOperand(1))->getZExtValue(); - return Intrinsic::getName((Intrinsic::ID)IID); + unsigned OpNo = getOpcode() == ISD::INTRINSIC_WO_CHAIN ? 0 : 1; + unsigned IID = cast(getOperand(OpNo))->getZExtValue(); + if (IID < Intrinsic::num_intrinsics) + return Intrinsic::getName((Intrinsic::ID)IID); + else if (const TargetIntrinsicInfo *TII = G->getTarget().getIntrinsicInfo()) + return TII->getName(IID); + llvm_unreachable("Invalid intrinsic ID"); } case ISD::BUILD_VECTOR: return "BUILD_VECTOR"; Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=84193&r1=84192&r2=84193&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Thu Oct 15 13:50:03 2009 @@ -584,6 +584,8 @@ return intrinsic_wo_chain_sdnode; } + bool hasTargetIntrinsics() { return !TgtIntrinsics.empty(); } + private: void ParseNodeInfo(); void ParseNodeTransforms(); Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=84193&r1=84192&r2=84193&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Thu Oct 15 13:50:03 2009 @@ -2067,8 +2067,16 @@ << " errs() << \"Cannot yet select: \";\n" << " unsigned iid = cast(N.getOperand(" << "N.getOperand(0).getValueType() == MVT::Other))->getZExtValue();\n" - << " llvm_report_error(\"Cannot yet select: intrinsic %\" +\n" - << "Intrinsic::getName((Intrinsic::ID)iid));\n" + << " if (iid < Intrinsic::num_intrinsics)\n" + << " llvm_report_error(\"Cannot yet select: intrinsic %\" + " + << "Intrinsic::getName((Intrinsic::ID)iid));\n"; + if (CGP.hasTargetIntrinsics()) { + OS << " else if (const TargetIntrinsicInfo *tii = TM.getIntrinsicInfo())\n" + << " llvm_report_error(Twine(\"Cannot yet select: target intrinsic " + << "%\") + tii->getName(iid));\n"; + } + OS << " else\n" + << " llvm_report_error(\"Cannot yet select: invalid intrinsic\");\n" << "}\n\n"; } From stoklund at 2pi.dk Thu Oct 15 13:50:53 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 15 Oct 2009 18:50:53 -0000 Subject: [llvm-commits] [llvm] r84194 - in /llvm/trunk: include/llvm/Intrinsics.td include/llvm/IntrinsicsBlackfin.td lib/Target/Blackfin/Blackfin.td lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp lib/Target/Blackfin/BlackfinIntrinsicInfo.h lib/Target/Blackfin/BlackfinIntrinsics.td lib/Target/Blackfin/BlackfinTargetMachine.h lib/Target/Blackfin/CMakeLists.txt lib/Target/Blackfin/Makefile test/CodeGen/Blackfin/sync-intr.ll Message-ID: <200910151850.n9FIosDX019618@zion.cs.uiuc.edu> Author: stoklund Date: Thu Oct 15 13:50:52 2009 New Revision: 84194 URL: http://llvm.org/viewvc/llvm-project?rev=84194&view=rev Log: Move Blackfin intrinsics into the Target/Blackfin directory. Added: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.h llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsics.td - copied, changed from r84193, llvm/trunk/include/llvm/IntrinsicsBlackfin.td Removed: llvm/trunk/include/llvm/IntrinsicsBlackfin.td Modified: llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/lib/Target/Blackfin/Blackfin.td llvm/trunk/lib/Target/Blackfin/BlackfinTargetMachine.h llvm/trunk/lib/Target/Blackfin/CMakeLists.txt llvm/trunk/lib/Target/Blackfin/Makefile llvm/trunk/test/CodeGen/Blackfin/sync-intr.ll Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=84194&r1=84193&r2=84194&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Thu Oct 15 13:50:52 2009 @@ -474,4 +474,3 @@ include "llvm/IntrinsicsCellSPU.td" include "llvm/IntrinsicsAlpha.td" include "llvm/IntrinsicsXCore.td" -include "llvm/IntrinsicsBlackfin.td" Removed: llvm/trunk/include/llvm/IntrinsicsBlackfin.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsBlackfin.td?rev=84193&view=auto ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsBlackfin.td (original) +++ llvm/trunk/include/llvm/IntrinsicsBlackfin.td (removed) @@ -1,34 +0,0 @@ -//===- IntrinsicsBlackfin.td - Defines Blackfin intrinsics -*- tablegen -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines all of the blackfin-specific intrinsics. -// -//===----------------------------------------------------------------------===// - -//===----------------------------------------------------------------------===// -// Core synchronisation etc. -// -// These intrinsics have sideeffects. Each represent a single instruction, but -// workarounds are sometimes required depending on the cpu. - -let TargetPrefix = "bfin" in { - - // Execute csync instruction with workarounds - def int_bfin_csync : GCCBuiltin<"__builtin_bfin_csync">, - Intrinsic<[llvm_void_ty]>; - - // Execute ssync instruction with workarounds - def int_bfin_ssync : GCCBuiltin<"__builtin_bfin_ssync">, - Intrinsic<[llvm_void_ty]>; - - // Execute idle instruction with workarounds - def int_bfin_idle : GCCBuiltin<"__builtin_bfin_idle">, - Intrinsic<[llvm_void_ty]>; - -} Modified: llvm/trunk/lib/Target/Blackfin/Blackfin.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/Blackfin.td?rev=84194&r1=84193&r2=84194&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/Blackfin.td (original) +++ llvm/trunk/lib/Target/Blackfin/Blackfin.td Thu Oct 15 13:50:52 2009 @@ -74,6 +74,7 @@ include "BlackfinRegisterInfo.td" include "BlackfinCallingConv.td" +include "BlackfinIntrinsics.td" include "BlackfinInstrInfo.td" def BlackfinInstrInfo : InstrInfo {} Added: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp?rev=84194&view=auto ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp (added) +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Thu Oct 15 13:50:52 2009 @@ -0,0 +1,53 @@ +//===- BlackfinIntrinsicInfo.cpp - Intrinsic Information --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the Blackfin implementation of TargetIntrinsicInfo. +// +//===----------------------------------------------------------------------===// + +#include "BlackfinIntrinsicInfo.h" +#include "llvm/Intrinsics.h" +#include "llvm/Support/raw_ostream.h" +#include + +using namespace llvm; + +namespace bfinIntrinsic { + + enum ID { + last_non_bfin_intrinsic = Intrinsic::num_intrinsics-1, +#define GET_INTRINSIC_ENUM_VALUES +#include "BlackfinGenIntrinsics.inc" +#undef GET_INTRINSIC_ENUM_VALUES + , num_bfin_intrinsics + }; + +} + +const char *BlackfinIntrinsicInfo::getName(unsigned IntrID) const { + static const char *const names[] = { +#define GET_INTRINSIC_NAME_TABLE +#include "BlackfinGenIntrinsics.inc" +#undef GET_INTRINSIC_NAME_TABLE + }; + + if (IntrID < Intrinsic::num_intrinsics) + return 0; + assert(IntrID < bfinIntrinsic::num_bfin_intrinsics && "Invalid intrinsic ID"); + + return names[IntrID - Intrinsic::num_intrinsics]; +} + +unsigned +BlackfinIntrinsicInfo::lookupName(const char *Name, unsigned Len) const { +#define GET_FUNCTION_RECOGNIZER +#include "BlackfinGenIntrinsics.inc" +#undef GET_FUNCTION_RECOGNIZER + return 0; +} Added: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.h?rev=84194&view=auto ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.h (added) +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.h Thu Oct 15 13:50:52 2009 @@ -0,0 +1,28 @@ +//===- BlackfinIntrinsicInfo.h - Blackfin Intrinsic Information -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the Blackfin implementation of TargetIntrinsicInfo. +// +//===----------------------------------------------------------------------===// +#ifndef BLACKFININTRINSICS_H +#define BLACKFININTRINSICS_H + +#include "llvm/Target/TargetIntrinsicInfo.h" + +namespace llvm { + + class BlackfinIntrinsicInfo : public TargetIntrinsicInfo { + public: + const char *getName(unsigned IntrID) const; + unsigned lookupName(const char *Name, unsigned Len) const; + }; + +} + +#endif Copied: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsics.td (from r84193, llvm/trunk/include/llvm/IntrinsicsBlackfin.td) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsics.td?p2=llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsics.td&p1=llvm/trunk/include/llvm/IntrinsicsBlackfin.td&r1=84193&r2=84194&rev=84194&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsBlackfin.td (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsics.td Thu Oct 15 13:50:52 2009 @@ -1,4 +1,4 @@ -//===- IntrinsicsBlackfin.td - Defines Blackfin intrinsics -*- tablegen -*-===// +//===- BlackfinIntrinsics.td - Defines Blackfin intrinsics -*- tablegen -*-===// // // The LLVM Compiler Infrastructure // @@ -11,24 +11,24 @@ // //===----------------------------------------------------------------------===// +let TargetPrefix = "bfin", isTarget = 1 in { + //===----------------------------------------------------------------------===// // Core synchronisation etc. // // These intrinsics have sideeffects. Each represent a single instruction, but // workarounds are sometimes required depending on the cpu. -let TargetPrefix = "bfin" in { - - // Execute csync instruction with workarounds - def int_bfin_csync : GCCBuiltin<"__builtin_bfin_csync">, - Intrinsic<[llvm_void_ty]>; - - // Execute ssync instruction with workarounds - def int_bfin_ssync : GCCBuiltin<"__builtin_bfin_ssync">, - Intrinsic<[llvm_void_ty]>; - - // Execute idle instruction with workarounds - def int_bfin_idle : GCCBuiltin<"__builtin_bfin_idle">, - Intrinsic<[llvm_void_ty]>; +// Execute csync instruction with workarounds +def int_bfin_csync : GCCBuiltin<"__builtin_bfin_csync">, + Intrinsic<[llvm_void_ty]>; + +// Execute ssync instruction with workarounds +def int_bfin_ssync : GCCBuiltin<"__builtin_bfin_ssync">, + Intrinsic<[llvm_void_ty]>; + +// Execute idle instruction with workarounds +def int_bfin_idle : GCCBuiltin<"__builtin_bfin_idle">, + Intrinsic<[llvm_void_ty]>; } Modified: llvm/trunk/lib/Target/Blackfin/BlackfinTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinTargetMachine.h?rev=84194&r1=84193&r2=84194&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinTargetMachine.h (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinTargetMachine.h Thu Oct 15 13:50:52 2009 @@ -20,6 +20,7 @@ #include "BlackfinInstrInfo.h" #include "BlackfinSubtarget.h" #include "BlackfinISelLowering.h" +#include "BlackfinIntrinsicInfo.h" namespace llvm { @@ -29,6 +30,7 @@ BlackfinTargetLowering TLInfo; BlackfinInstrInfo InstrInfo; TargetFrameInfo FrameInfo; + BlackfinIntrinsicInfo IntrinsicInfo; public: BlackfinTargetMachine(const Target &T, const std::string &TT, const std::string &FS); @@ -47,6 +49,9 @@ virtual const TargetData *getTargetData() const { return &DataLayout; } virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel); + const TargetIntrinsicInfo *getIntrinsicInfo() const { + return &IntrinsicInfo; + } }; } // end namespace llvm Modified: llvm/trunk/lib/Target/Blackfin/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/CMakeLists.txt?rev=84194&r1=84193&r2=84194&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/Blackfin/CMakeLists.txt Thu Oct 15 13:50:52 2009 @@ -9,9 +9,11 @@ tablegen(BlackfinGenDAGISel.inc -gen-dag-isel) tablegen(BlackfinGenSubtarget.inc -gen-subtarget) tablegen(BlackfinGenCallingConv.inc -gen-callingconv) +tablegen(BlackfinGenIntrinsics.inc -gen-tgt-intrinsic) add_llvm_target(BlackfinCodeGen BlackfinInstrInfo.cpp + BlackfinIntrinsicInfo.cpp BlackfinISelDAGToDAG.cpp BlackfinISelLowering.cpp BlackfinMCAsmInfo.cpp Modified: llvm/trunk/lib/Target/Blackfin/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/Makefile?rev=84194&r1=84193&r2=84194&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/Makefile (original) +++ llvm/trunk/lib/Target/Blackfin/Makefile Thu Oct 15 13:50:52 2009 @@ -15,7 +15,7 @@ BlackfinGenRegisterInfo.inc BlackfinGenInstrNames.inc \ BlackfinGenInstrInfo.inc BlackfinGenAsmWriter.inc \ BlackfinGenDAGISel.inc BlackfinGenSubtarget.inc \ - BlackfinGenCallingConv.inc + BlackfinGenCallingConv.inc BlackfinGenIntrinsics.inc DIRS = AsmPrinter TargetInfo Modified: llvm/trunk/test/CodeGen/Blackfin/sync-intr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Blackfin/sync-intr.ll?rev=84194&r1=84193&r2=84194&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Blackfin/sync-intr.ll (original) +++ llvm/trunk/test/CodeGen/Blackfin/sync-intr.ll Thu Oct 15 13:50:52 2009 @@ -2,8 +2,11 @@ define void @f() nounwind { entry: + ; CHECK-NOT: llvm.bfin ; CHECK: csync; call void @llvm.bfin.csync() + + ; CHECK-NOT: llvm.bfin ; CHECK: ssync; call void @llvm.bfin.ssync() ret void From sanjiv.gupta at microchip.com Thu Oct 15 14:26:29 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Thu, 15 Oct 2009 19:26:29 -0000 Subject: [llvm-commits] [llvm] r84195 - in /llvm/trunk: lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h lib/Target/PIC16/PIC16.h lib/Target/PIC16/PIC16DebugInfo.cpp lib/Target/PIC16/PIC16ISelLowering.cpp lib/Target/PIC16/PIC16InstrInfo.cpp lib/Target/PIC16/PIC16MCAsmInfo.cpp lib/Target/PIC16/PIC16MemSelOpt.cpp lib/Target/PIC16/PIC16TargetObjectFile.cpp lib/Target/PIC16/PIC16TargetObjectFile.h test/CodeGen/PIC16/globals.ll Message-ID: <200910151926.n9FJQVDj020895@zion.cs.uiuc.edu> Author: sgupta Date: Thu Oct 15 14:26:25 2009 New Revision: 84195 URL: http://llvm.org/viewvc/llvm-project?rev=84195&view=rev Log: Re-apply 84180 with the fixed test case. Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h llvm/trunk/lib/Target/PIC16/PIC16.h llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h llvm/trunk/test/CodeGen/PIC16/globals.ll Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Thu Oct 15 14:26:25 2009 @@ -12,8 +12,9 @@ // //===----------------------------------------------------------------------===// +#include "PIC16ABINames.h" #include "PIC16AsmPrinter.h" -#include "MCSectionPIC16.h" +#include "PIC16Section.h" #include "PIC16MCAsmInfo.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" @@ -39,7 +40,7 @@ : AsmPrinter(O, TM, T, V), DbgInfo(O, T) { PTLI = static_cast(TM.getTargetLowering()); PMAI = static_cast(T); - PTOF = (PIC16TargetObjectFile*)&PTLI->getObjFileLowering(); + PTOF = (PIC16TargetObjectFile *)&PTLI->getObjFileLowering(); } bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) { @@ -73,11 +74,12 @@ DbgInfo.BeginFunction(MF); // Emit the autos section of function. - EmitAutos(CurrentFnName); + // EmitAutos(CurrentFnName); // Now emit the instructions of function in its code section. - const MCSection *fCodeSection = - getObjFileLowering().getSectionForFunction(CurrentFnName); + const MCSection *fCodeSection + = getObjFileLowering().SectionForCode(CurrentFnName); + // Start the Code Section. O << "\n"; OutStreamer.SwitchSection(fCodeSection); @@ -229,12 +231,26 @@ // Set the section names for all globals. for (Module::global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) - if (!I->isDeclaration() && !I->hasAvailableExternallyLinkage()) { + I != E; ++I) { + + // Record External Var Decls. + if (I->isDeclaration()) { + ExternalVarDecls.push_back(I); + continue; + } + + // Record Exteranl Var Defs. + if (I->hasExternalLinkage() || I->hasCommonLinkage()) { + ExternalVarDefs.push_back(I); + } + + // Sectionify actual data. + if (!I->hasAvailableExternallyLinkage()) { const MCSection *S = getObjFileLowering().SectionForGlobal(I, Mang, TM); - I->setSection(((const MCSectionPIC16*)S)->getName()); + I->setSection(((const PIC16Section *)S)->getName()); } + } DbgInfo.BeginModule(M); EmitFunctionDecls(M); @@ -242,7 +258,9 @@ EmitDefinedVars(M); EmitIData(M); EmitUData(M); + EmitAllAutos(M); EmitRomData(M); + EmitUserSections(M); return Result; } @@ -287,7 +305,7 @@ // Emit variables imported from other Modules. void PIC16AsmPrinter::EmitUndefinedVars(Module &M) { - std::vector Items = PTOF->ExternalVarDecls->Items; + std::vector Items = ExternalVarDecls; if (!Items.size()) return; O << "\n" << MAI->getCommentString() << "Imported Variables - BEGIN" << "\n"; @@ -299,7 +317,7 @@ // Emit variables defined in this module and are available to other modules. void PIC16AsmPrinter::EmitDefinedVars(Module &M) { - std::vector Items = PTOF->ExternalVarDefs->Items; + std::vector Items = ExternalVarDefs; if (!Items.size()) return; O << "\n" << MAI->getCommentString() << "Exported Variables - BEGIN" << "\n"; @@ -312,24 +330,14 @@ // Emit initialized data placed in ROM. void PIC16AsmPrinter::EmitRomData(Module &M) { // Print ROM Data section. - const std::vector &ROSections = PTOF->ROSections; - for (unsigned i = 0; i < ROSections.size(); i++) { - const std::vector &Items = ROSections[i]->Items; - if (!Items.size()) continue; - O << "\n"; - OutStreamer.SwitchSection(PTOF->ROSections[i]->S_); - for (unsigned j = 0; j < Items.size(); j++) { - O << Mang->getMangledName(Items[j]); - Constant *C = Items[j]->getInitializer(); - int AddrSpace = Items[j]->getType()->getAddressSpace(); - EmitGlobalConstant(C, AddrSpace); - } - } + const PIC16Section *ROSection = PTOF->ROMDATASection(); + if (ROSection == NULL) return; + EmitInitializedDataSection(ROSection); } bool PIC16AsmPrinter::doFinalization(Module &M) { printLibcallDecls(); - EmitRemainingAutos(); + // EmitRemainingAutos(); DbgInfo.EndModule(M); O << "\n\t" << "END\n"; return AsmPrinter::doFinalization(M); @@ -343,7 +351,7 @@ O << "\n"; const MCSection *fPDataSection = - getObjFileLowering().getSectionForFunctionFrame(CurrentFnName); + getObjFileLowering().SectionForFrame(CurrentFnName); OutStreamer.SwitchSection(fPDataSection); // Emit function frame label @@ -379,103 +387,79 @@ O << PAN::getTempdataLabel(CurrentFnName) << " RES " << TempSize << '\n'; } -void PIC16AsmPrinter::EmitIData(Module &M) { - // Print all IDATA sections. - const std::vector &IDATASections = PTOF->IDATASections; - for (unsigned i = 0; i < IDATASections.size(); i++) { - O << "\n"; - if (IDATASections[i]->S_->getName().find("llvm.") != std::string::npos) - continue; - OutStreamer.SwitchSection(IDATASections[i]->S_); - std::vector Items = IDATASections[i]->Items; +void PIC16AsmPrinter::EmitInitializedDataSection(const PIC16Section *S) { + /// Emit Section header. + OutStreamer.SwitchSection(S); + + std::vector Items = S->Items; for (unsigned j = 0; j < Items.size(); j++) { std::string Name = Mang->getMangledName(Items[j]); Constant *C = Items[j]->getInitializer(); int AddrSpace = Items[j]->getType()->getAddressSpace(); O << Name; EmitGlobalConstant(C, AddrSpace); - } - } + } } -void PIC16AsmPrinter::EmitUData(Module &M) { - const TargetData *TD = TM.getTargetData(); +void PIC16AsmPrinter::EmitIData(Module &M) { - // Print all BSS sections. - const std::vector &BSSSections = PTOF->BSSSections; - for (unsigned i = 0; i < BSSSections.size(); i++) { + // Print all IDATA sections. + const std::vector &IDATASections = PTOF->IDATASections(); + for (unsigned i = 0; i < IDATASections.size(); i++) { O << "\n"; - OutStreamer.SwitchSection(BSSSections[i]->S_); - std::vector Items = BSSSections[i]->Items; + if (IDATASections[i]->getName().find("llvm.") != std::string::npos) + continue; + + EmitInitializedDataSection(IDATASections[i]); + } +} + +void PIC16AsmPrinter::EmitUninitializedDataSection(const PIC16Section *S) { + const TargetData *TD = TM.getTargetData(); + OutStreamer.SwitchSection(S); + std::vector Items = S->Items; for (unsigned j = 0; j < Items.size(); j++) { std::string Name = Mang->getMangledName(Items[j]); Constant *C = Items[j]->getInitializer(); const Type *Ty = C->getType(); unsigned Size = TD->getTypeAllocSize(Ty); - O << Name << " RES " << Size << "\n"; } - } } -void PIC16AsmPrinter::EmitAutos(std::string FunctName) { - // Section names for all globals are already set. - const TargetData *TD = TM.getTargetData(); - - // Now print Autos section for this function. - std::string SectionName = PAN::getAutosSectionName(FunctName); - const std::vector &AutosSections = PTOF->AutosSections; - for (unsigned i = 0; i < AutosSections.size(); i++) { +void PIC16AsmPrinter::EmitUData(Module &M) { + // Print all UDATA sections. + const std::vector &UDATASections = PTOF->UDATASections(); + for (unsigned i = 0; i < UDATASections.size(); i++) { O << "\n"; - if (AutosSections[i]->S_->getName() == SectionName) { - // Set the printing status to true - AutosSections[i]->setPrintedStatus(true); - OutStreamer.SwitchSection(AutosSections[i]->S_); - const std::vector &Items = AutosSections[i]->Items; - for (unsigned j = 0; j < Items.size(); j++) { - std::string VarName = Mang->getMangledName(Items[j]); - Constant *C = Items[j]->getInitializer(); - const Type *Ty = C->getType(); - unsigned Size = TD->getTypeAllocSize(Ty); - // Emit memory reserve directive. - O << VarName << " RES " << Size << "\n"; - } - break; - } + EmitUninitializedDataSection(UDATASections[i]); } } -// Print autos that were not printed during the code printing of functions. -// As the functions might themselves would have got deleted by the optimizer. -void PIC16AsmPrinter::EmitRemainingAutos() { - const TargetData *TD = TM.getTargetData(); - - // Now print Autos section for this function. - std::vector AutosSections = PTOF->AutosSections; - for (unsigned i = 0; i < AutosSections.size(); i++) { - - // if the section is already printed then don't print again - if (AutosSections[i]->isPrinted()) - continue; - - // Set status as printed - AutosSections[i]->setPrintedStatus(true); - +void PIC16AsmPrinter::EmitUserSections(Module &M) { + const std::vector &USERSections = PTOF->USERSections(); + for (unsigned i = 0; i < USERSections.size(); i++) { O << "\n"; - OutStreamer.SwitchSection(AutosSections[i]->S_); - const std::vector &Items = AutosSections[i]->Items; - for (unsigned j = 0; j < Items.size(); j++) { - std::string VarName = Mang->getMangledName(Items[j]); - Constant *C = Items[j]->getInitializer(); - const Type *Ty = C->getType(); - unsigned Size = TD->getTypeAllocSize(Ty); - // Emit memory reserve directive. - O << VarName << " RES " << Size << "\n"; + const PIC16Section *S = USERSections[i]; + if (S->isUDATA_Type()) { + EmitUninitializedDataSection(S); + } else if (S->isIDATA_Type() || S->isROMDATA_Type()) { + EmitInitializedDataSection(S); + } else { + llvm_unreachable ("unknow user section type"); } } } +void PIC16AsmPrinter::EmitAllAutos(Module &M) { + // Print all AUTO sections. + const std::vector &AUTOSections = PTOF->AUTOSections(); + for (unsigned i = 0; i < AUTOSections.size(); i++) { + O << "\n"; + EmitUninitializedDataSection(AUTOSections[i]); + } +} extern "C" void LLVMInitializePIC16AsmPrinter() { RegisterAsmPrinter X(ThePIC16Target); Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h Thu Oct 15 14:26:25 2009 @@ -53,11 +53,13 @@ void EmitDefinedVars (Module &M); void EmitIData (Module &M); void EmitUData (Module &M); - void EmitAutos (std::string FunctName); - void EmitRemainingAutos (); + void EmitAllAutos (Module &M); void EmitRomData (Module &M); + void EmitUserSections (Module &M); void EmitFunctionFrame(MachineFunction &MF); void printLibcallDecls(); + void EmitUninitializedDataSection(const PIC16Section *S); + void EmitInitializedDataSection(const PIC16Section *S); protected: bool doInitialization(Module &M); bool doFinalization(Module &M); @@ -74,6 +76,8 @@ PIC16DbgInfo DbgInfo; const PIC16MCAsmInfo *PMAI; std::list LibcallDecls; // List of extern decls. + std::vector ExternalVarDecls; + std::vector ExternalVarDefs; }; } // end of namespace Modified: llvm/trunk/lib/Target/PIC16/PIC16.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16.h?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16.h Thu Oct 15 14:26:25 2009 @@ -42,266 +42,15 @@ UGE }; } - // A Central class to manage all ABI naming conventions. - // PAN - [P]ic16 [A]BI [N]ames - class PAN { - public: - // Map the name of the symbol to its section name. - // Current ABI: - // ----------------------------------------------------- - // ALL Names are prefixed with the symobl '@'. - // ------------------------------------------------------ - // Global variables do not have any '.' in their names. - // These are maily function names and global variable names. - // Example - @foo, @i - // ------------------------------------------------------- - // Functions and auto variables. - // Names are mangled as .. - // Where is '@' and is any one of - // the following - // .auto. - an automatic var of a function. - // .temp. - temproray data of a function. - // .ret. - return value label for a function. - // .frame. - Frame label for a function where retval, args - // and temps are stored. - // .args. - Label used to pass arguments to a direct call. - // Example - Function name: @foo - // Its frame: @foo.frame. - // Its retval: @foo.ret. - // Its local vars: @foo.auto.a - // Its temp data: @foo.temp. - // Its arg passing: @foo.args. - //---------------------------------------------- - // Libcall - compiler generated libcall names must start with .lib. - // This id will be used to emit extern decls for libcalls. - // Example - libcall name: @.lib.sra.i8 - // To pass args: @.lib.sra.i8.args. - // To return val: @.lib.sra.i8.ret. - //---------------------------------------------- - // SECTION Names - // uninitialized globals - @udata..# - // initialized globals - @idata..# - // Function frame - @.frame_section. - // Function autos - @.autos_section. - // Declarations - Enclosed in comments. No section for them. - //---------------------------------------------------------- - - // Tags used to mangle different names. - enum TAGS { - PREFIX_SYMBOL, - GLOBAL, - STATIC_LOCAL, - AUTOS_LABEL, - FRAME_LABEL, - RET_LABEL, - ARGS_LABEL, - TEMPS_LABEL, - - LIBCALL, - - FRAME_SECTION, - AUTOS_SECTION, - CODE_SECTION - }; - - // Textual names of the tags. - inline static const char *getTagName(TAGS tag) { - switch (tag) { - default: return ""; - case PREFIX_SYMBOL: return "@"; - case AUTOS_LABEL: return ".auto."; - case FRAME_LABEL: return ".frame."; - case TEMPS_LABEL: return ".temp."; - case ARGS_LABEL: return ".args."; - case RET_LABEL: return ".ret."; - case LIBCALL: return ".lib."; - case FRAME_SECTION: return ".frame_section."; - case AUTOS_SECTION: return ".autos_section."; - case CODE_SECTION: return ".code_section."; - } - } - - // Get tag type for the Symbol. - inline static TAGS getSymbolTag(const std::string &Sym) { - if (Sym.find(getTagName(TEMPS_LABEL)) != std::string::npos) - return TEMPS_LABEL; - - if (Sym.find(getTagName(FRAME_LABEL)) != std::string::npos) - return FRAME_LABEL; - - if (Sym.find(getTagName(RET_LABEL)) != std::string::npos) - return RET_LABEL; - - if (Sym.find(getTagName(ARGS_LABEL)) != std::string::npos) - return ARGS_LABEL; - - if (Sym.find(getTagName(AUTOS_LABEL)) != std::string::npos) - return AUTOS_LABEL; - - if (Sym.find(getTagName(LIBCALL)) != std::string::npos) - return LIBCALL; - - // It does not have any Tag. So its a true global or static local. - if (Sym.find(".") == std::string::npos) - return GLOBAL; - - // If a . is there, then it may be static local. - // We should mangle these as well in clang. - if (Sym.find(".") != std::string::npos) - return STATIC_LOCAL; - - assert (0 && "Could not determine Symbol's tag"); - return PREFIX_SYMBOL; // Silence warning when assertions are turned off. - } - - // addPrefix - add prefix symbol to a name if there isn't one already. - inline static std::string addPrefix (const std::string &Name) { - std::string prefix = getTagName (PREFIX_SYMBOL); - - // If this name already has a prefix, nothing to do. - if (Name.compare(0, prefix.size(), prefix) == 0) - return Name; - - return prefix + Name; - } - - // Get mangled func name from a mangled sym name. - // In all cases func name is the first component before a '.'. - static inline std::string getFuncNameForSym(const std::string &Sym1) { - assert (getSymbolTag(Sym1) != GLOBAL && "not belongs to a function"); - - std::string Sym = addPrefix(Sym1); - - // Position of the . after func name. That's where func name ends. - size_t func_name_end = Sym.find ('.'); - - return Sym.substr (0, func_name_end); - } - - // Get Frame start label for a func. - static std::string getFrameLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(FRAME_LABEL); - return Func1 + tag; - } - - static std::string getRetvalLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(RET_LABEL); - return Func1 + tag; - } - - static std::string getArgsLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(ARGS_LABEL); - return Func1 + tag; - } - - static std::string getTempdataLabel(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(TEMPS_LABEL); - return Func1 + tag; - } - - static std::string getFrameSectionName(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(FRAME_SECTION); - return Func1 + tag + "# UDATA_OVR"; - } - static std::string getAutosSectionName(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(AUTOS_SECTION); - return Func1 + tag + "# UDATA_OVR"; - } - - static std::string getCodeSectionName(const std::string &Func) { - std::string Func1 = addPrefix(Func); - std::string tag = getTagName(CODE_SECTION); - return Func1 + tag + "# CODE"; - } - - // udata, romdata and idata section names are generated by a given number. - // @udata..# - static std::string getUdataSectionName(unsigned num, - std::string prefix = "") { - std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << prefix << "udata." << num - << ".# UDATA"; - return o.str(); - } - - static std::string getRomdataSectionName(unsigned num, - std::string prefix = "") { - std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << prefix << "romdata." << num - << ".# ROMDATA"; - return o.str(); - } - - static std::string getIdataSectionName(unsigned num, - std::string prefix = "") { - std::ostringstream o; - o << getTagName(PREFIX_SYMBOL) << prefix << "idata." << num - << ".# IDATA"; - return o.str(); - } - - inline static bool isLocalName (const std::string &Name) { - if (getSymbolTag(Name) == AUTOS_LABEL) - return true; - - return false; - } - - inline static bool isMemIntrinsic (const std::string &Name) { - if (Name.compare("@memcpy") == 0 || Name.compare("@memset") == 0 || - Name.compare("@memmove") == 0) { - return true; - } - - return false; - } - - inline static bool isLocalToFunc (std::string &Func, std::string &Var) { - if (! isLocalName(Var)) return false; - - std::string Func1 = addPrefix(Func); - // Extract func name of the varilable. - const std::string &fname = getFuncNameForSym(Var); - - if (fname.compare(Func1) == 0) - return true; - - return false; - } - - - // Get the section for the given external symbol names. - // This tries to find the type (Tag) of the symbol from its mangled name - // and return appropriate section name for it. - static inline std::string getSectionNameForSym(const std::string &Sym1) { - std::string Sym = addPrefix(Sym1); - - std::string SectionName; - - std::string Fname = getFuncNameForSym (Sym); - TAGS id = getSymbolTag (Sym); - - switch (id) { - default : assert (0 && "Could not determine external symbol type"); - case FRAME_LABEL: - case RET_LABEL: - case TEMPS_LABEL: - case ARGS_LABEL: { - return getFrameSectionName(Fname); - } - case AUTOS_LABEL: { - return getAutosSectionName(Fname); - } - } - } - }; // class PAN. + enum PIC16SectionType { + CODE, + UDATA, + IDATA, + ROMDATA, + UDATA_OVR, + UDATA_SHR + }; // External symbol names require memory to live till the program end. Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Thu Oct 15 14:26:25 2009 @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "PIC16.h" +#include "PIC16ABINames.h" #include "PIC16DebugInfo.h" #include "llvm/GlobalVariable.h" #include "llvm/CodeGen/MachineFunction.h" Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Thu Oct 15 14:26:25 2009 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "pic16-lower" +#include "PIC16ABINames.h" #include "PIC16ISelLowering.h" #include "PIC16TargetObjectFile.h" #include "PIC16TargetMachine.h" Modified: llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp Thu Oct 15 14:26:25 2009 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "PIC16.h" +#include "PIC16ABINames.h" #include "PIC16InstrInfo.h" #include "PIC16TargetMachine.h" #include "PIC16GenInstrInfo.inc" Modified: llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16MCAsmInfo.cpp Thu Oct 15 14:26:25 2009 @@ -16,6 +16,7 @@ // FIXME: Layering violation to get enums and static function, should be moved // to separate headers. #include "PIC16.h" +#include "PIC16ABINames.h" #include "PIC16ISelLowering.h" using namespace llvm; Modified: llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16MemSelOpt.cpp Thu Oct 15 14:26:25 2009 @@ -21,6 +21,7 @@ #define DEBUG_TYPE "pic16-codegen" #include "PIC16.h" +#include "PIC16ABINames.h" #include "PIC16InstrInfo.h" #include "PIC16MCAsmInfo.h" #include "PIC16TargetMachine.h" Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp Thu Oct 15 14:26:25 2009 @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// #include "PIC16TargetObjectFile.h" -#include "MCSectionPIC16.h" #include "PIC16ISelLowering.h" #include "PIC16TargetMachine.h" +#include "PIC16Section.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/MC/MCSection.h" @@ -19,75 +19,111 @@ using namespace llvm; -MCSectionPIC16 *MCSectionPIC16::Create(const StringRef &Name, SectionKind K, - int Address, int Color, MCContext &Ctx) { - return new (Ctx) MCSectionPIC16(Name, K, Address, Color); +PIC16TargetObjectFile::PIC16TargetObjectFile() { } +/// Find a pic16 section. If not found, create one. +PIC16Section *PIC16TargetObjectFile:: +getPIC16Section(const std::string &Name, PIC16SectionType Ty, + const std::string &Address, int Color) const { -void MCSectionPIC16::PrintSwitchToSection(const MCAsmInfo &MAI, - raw_ostream &OS) const { - OS << getName() << '\n'; + /// Return if we have an already existing one. + PIC16Section *&Entry = SectionsByName[Name]; + if (Entry) + return Entry; + + + Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); + return Entry; } +/// Find a standard pic16 data section. If not found, create one and keep +/// track of it by adding it to appropriate std section list. +PIC16Section *PIC16TargetObjectFile:: +getPIC16DataSection(const std::string &Name, PIC16SectionType Ty, + const std::string &Address, int Color) const { + + /// Return if we have an already existing one. + PIC16Section *&Entry = SectionsByName[Name]; + if (Entry) + return Entry; + + /// Else create a new one and add it to appropriate section list. + Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); + switch (Ty) { + default: llvm_unreachable ("unknow standard section type."); + case UDATA: UDATASections_.push_back(Entry); break; + case IDATA: IDATASections_.push_back(Entry); break; + case ROMDATA: ROMDATASection_ = Entry; break; + } -PIC16TargetObjectFile::PIC16TargetObjectFile() - : ExternalVarDecls(0), ExternalVarDefs(0) { + return Entry; } + + +/// Find a standard pic16 autos section. If not found, create one and keep +/// track of it by adding it to appropriate std section list. +PIC16Section *PIC16TargetObjectFile:: +getPIC16AutoSection(const std::string &Name, PIC16SectionType Ty, + const std::string &Address, int Color) const { -const MCSectionPIC16 *PIC16TargetObjectFile:: -getPIC16Section(const char *Name, SectionKind Kind, - int Address, int Color) const { - MCSectionPIC16 *&Entry = SectionsByName[Name]; + /// Return if we have an already existing one. + PIC16Section *&Entry = SectionsByName[Name]; if (Entry) return Entry; - return Entry = MCSectionPIC16::Create(Name, Kind, Address, Color, - getContext()); + + /// Else create a new one and add it to appropriate section list. + Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); + + assert (Ty == UDATA_OVR && "incorrect section type for autos"); + AUTOSections_.push_back(Entry); + + return Entry; } + +/// Find a pic16 user section. If not found, create one and keep +/// track of it by adding it to appropriate std section list. +PIC16Section *PIC16TargetObjectFile:: +getPIC16UserSection(const std::string &Name, PIC16SectionType Ty, + const std::string &Address, int Color) const { + + /// Return if we have an already existing one. + PIC16Section *&Entry = SectionsByName[Name]; + if (Entry) + return Entry; + /// Else create a new one and add it to appropriate section list. + Entry = PIC16Section::Create(Name, Ty, Address, Color, getContext()); + + USERSections_.push_back(Entry); + + return Entry; +} + +/// Do some standard llvm stuff. PIC16 really does not need any of this. void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){ TargetLoweringObjectFile::Initialize(Ctx, tm); TM = &tm; - BSSSection = getPIC16Section("udata.# UDATA", MCSectionPIC16::UDATA_Kind()); - ReadOnlySection = getPIC16Section("romdata.# ROMDATA", - MCSectionPIC16::ROMDATA_Kind()); - DataSection = getPIC16Section("idata.# IDATA", MCSectionPIC16::IDATA_Kind()); + // BSSSection = getPIC16DataSection("udata.#", UDATA); + // ReadOnlySection = getPIC16DataSection("romdata.#", ROMDATA); + // DataSection = getPIC16DataSection("idata.#", IDATA); // Need because otherwise a .text symbol is emitted by DwarfWriter // in BeginModule, and gpasm cribbs for that .text symbol. - TextSection = getPIC16Section("", SectionKind::getText()); - - ROSections.push_back(new PIC16Section((MCSectionPIC16*)ReadOnlySection)); - - // FIXME: I don't know what the classification of these sections really is. - // These aren't really objects belonging to any section. Just emit them - // in AsmPrinter and remove this code from here. - ExternalVarDecls = new PIC16Section(getPIC16Section("ExternalVarDecls", - SectionKind::getMetadata())); - ExternalVarDefs = new PIC16Section(getPIC16Section("ExternalVarDefs", - SectionKind::getMetadata())); -} - -const MCSection *PIC16TargetObjectFile:: -getSectionForFunction(const std::string &FnName) const { - std::string T = PAN::getCodeSectionName(FnName); - return getPIC16Section(T.c_str(), SectionKind::getText()); -} - - -const MCSection *PIC16TargetObjectFile:: -getSectionForFunctionFrame(const std::string &FnName) const { - std::string T = PAN::getFrameSectionName(FnName); - return getPIC16Section(T.c_str(), SectionKind::getDataRel()); + // FIXME: below + // TextSection = getPIC16DataSection("", UDATA); + ROMDATASection_ = NULL; } +/// allocateUDATA - Allocate a un-initialized global to an existing or new UDATA +/// section and return that section. const MCSection * -PIC16TargetObjectFile::getBSSSectionForGlobal(const GlobalVariable *GV) const { +PIC16TargetObjectFile::allocateUDATA(const GlobalVariable *GV) const { assert(GV->hasInitializer() && "This global doesn't need space"); Constant *C = GV->getInitializer(); assert(C->isNullValue() && "Unitialized globals has non-zero initializer"); @@ -97,41 +133,37 @@ const Type *Ty = C->getType(); unsigned ValSize = TD->getTypeAllocSize(Ty); - // Go through all BSS Sections and assign this variable + // Go through all UDATA Sections and assign this variable // to the first available section having enough space. - PIC16Section *FoundBSS = NULL; - for (unsigned i = 0; i < BSSSections.size(); i++) { - if (DataBankSize - BSSSections[i]->Size >= ValSize) { - FoundBSS = BSSSections[i]; + PIC16Section *Found = NULL; + for (unsigned i = 0; i < UDATASections_.size(); i++) { + if (DataBankSize - UDATASections_[i]->getSize() >= ValSize) { + Found = UDATASections_[i]; break; } } - // No BSS section spacious enough was found. Crate a new one. - if (!FoundBSS) { - std::string name = PAN::getUdataSectionName(BSSSections.size()); - const MCSectionPIC16 *NewSection - = getPIC16Section(name.c_str(), MCSectionPIC16::UDATA_Kind()); - - FoundBSS = new PIC16Section(NewSection); - - // Add this newly created BSS section to the list of BSSSections. - BSSSections.push_back(FoundBSS); + // No UDATA section spacious enough was found. Crate a new one. + if (!Found) { + std::string name = PAN::getUdataSectionName(UDATASections_.size()); + Found = getPIC16DataSection(name.c_str(), UDATA); } - // Insert the GV into this BSS. - FoundBSS->Items.push_back(GV); - FoundBSS->Size += ValSize; - return FoundBSS->S_; + // Insert the GV into this UDATA section. + Found->Items.push_back(GV); + Found->setSize(Found->getSize() + ValSize); + return Found; } +/// allocateIDATA - allocate an initialized global into an existing +/// or new section and return that section. const MCSection * -PIC16TargetObjectFile::getIDATASectionForGlobal(const GlobalVariable *GV) const{ +PIC16TargetObjectFile::allocateIDATA(const GlobalVariable *GV) const{ assert(GV->hasInitializer() && "This global doesn't need space"); Constant *C = GV->getInitializer(); assert(!C->isNullValue() && "initialized globals has zero initializer"); assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE && - "can split initialized RAM data only"); + "can allocate initialized RAM data only"); // Find how much space this global needs. const TargetData *TD = TM->getTargetData(); @@ -140,64 +172,47 @@ // Go through all IDATA Sections and assign this variable // to the first available section having enough space. - PIC16Section *FoundIDATA = NULL; - for (unsigned i = 0; i < IDATASections.size(); i++) { - if (DataBankSize - IDATASections[i]->Size >= ValSize) { - FoundIDATA = IDATASections[i]; + PIC16Section *Found = NULL; + for (unsigned i = 0; i < IDATASections_.size(); i++) { + if (DataBankSize - IDATASections_[i]->getSize() >= ValSize) { + Found = IDATASections_[i]; break; } } // No IDATA section spacious enough was found. Crate a new one. - if (!FoundIDATA) { - std::string name = PAN::getIdataSectionName(IDATASections.size()); - const MCSectionPIC16 *NewSection = - getPIC16Section(name.c_str(), MCSectionPIC16::IDATA_Kind()); - - FoundIDATA = new PIC16Section(NewSection); - - // Add this newly created IDATA section to the list of IDATASections. - IDATASections.push_back(FoundIDATA); + if (!Found) { + std::string name = PAN::getIdataSectionName(IDATASections_.size()); + Found = getPIC16DataSection(name.c_str(), IDATA); } // Insert the GV into this IDATA. - FoundIDATA->Items.push_back(GV); - FoundIDATA->Size += ValSize; - return FoundIDATA->S_; + Found->Items.push_back(GV); + Found->setSize(Found->getSize() + ValSize); + return Found; } -// Get the section for an automatic variable of a function. -// For PIC16 they are globals only with mangled names. +// Allocate a program memory variable into ROMDATA section. const MCSection * -PIC16TargetObjectFile::getSectionForAuto(const GlobalVariable *GV) const { - - const std::string name = PAN::getSectionNameForSym(GV->getName()); - - // Go through all Auto Sections and assign this variable - // to the appropriate section. - PIC16Section *FoundAutoSec = NULL; - for (unsigned i = 0; i < AutosSections.size(); i++) { - if (AutosSections[i]->S_->getName() == name) { - FoundAutoSec = AutosSections[i]; - break; - } - } +PIC16TargetObjectFile::allocateROMDATA(const GlobalVariable *GV) const { - // No Auto section was found. Crate a new one. - if (!FoundAutoSec) { - const MCSectionPIC16 *NewSection = - getPIC16Section(name.c_str(), MCSectionPIC16::UDATA_OVR_Kind()); + std::string name = PAN::getRomdataSectionName(); + PIC16Section *S = getPIC16DataSection(name.c_str(), ROMDATA); - FoundAutoSec = new PIC16Section(NewSection); + S->Items.push_back(GV); + return S; +} - // Add this newly created autos section to the list of AutosSections. - AutosSections.push_back(FoundAutoSec); - } +// Get the section for an automatic variable of a function. +// For PIC16 they are globals only with mangled names. +const MCSection * +PIC16TargetObjectFile::allocateAUTO(const GlobalVariable *GV) const { - // Insert the auto into this section. - FoundAutoSec->Items.push_back(GV); + const std::string name = PAN::getSectionNameForSym(GV->getName()); + PIC16Section *S = getPIC16AutoSection(name.c_str()); - return FoundAutoSec->S_; + S->Items.push_back(GV); + return S; } @@ -214,56 +229,50 @@ if (!GV) return TargetLoweringObjectFile::SelectSectionForGlobal(GV1, Kind, Mang,TM); - // Record External Var Decls. - if (GV->isDeclaration()) { - ExternalVarDecls->Items.push_back(GV); - return ExternalVarDecls->S_; - } - assert(GV->hasInitializer() && "A def without initializer?"); // First, if this is an automatic variable for a function, get the section // name for it and return. std::string name = GV->getName(); if (PAN::isLocalName(name)) - return getSectionForAuto(GV); - - // Record Exteranl Var Defs. - if (GV->hasExternalLinkage() || GV->hasCommonLinkage()) - ExternalVarDefs->Items.push_back(GV); + return allocateAUTO(GV); // See if this is an uninitialized global. const Constant *C = GV->getInitializer(); if (C->isNullValue()) - return getBSSSectionForGlobal(GV); + return allocateUDATA(GV); // If this is initialized data in RAM. Put it in the correct IDATA section. if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) - return getIDATASectionForGlobal(GV); + return allocateIDATA(GV); // This is initialized data in rom, put it in the readonly section. if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) - return getROSectionForGlobal(GV); + return allocateROMDATA(GV); // Else let the default implementation take care of it. return TargetLoweringObjectFile::SelectSectionForGlobal(GV, Kind, Mang,TM); } PIC16TargetObjectFile::~PIC16TargetObjectFile() { - for (unsigned i = 0; i < BSSSections.size(); i++) - delete BSSSections[i]; - for (unsigned i = 0; i < IDATASections.size(); i++) - delete IDATASections[i]; - for (unsigned i = 0; i < AutosSections.size(); i++) - delete AutosSections[i]; - for (unsigned i = 0; i < ROSections.size(); i++) - delete ROSections[i]; - delete ExternalVarDecls; - delete ExternalVarDefs; +#if 0 + for (unsigned i = 0; i < UDATASections_.size(); i++) + delete UDATASections_[i]; + for (unsigned i = 0; i < IDATASections_.size(); i++) + delete IDATASections_[i]; + + delete ROMDATASection_; + + for (unsigned i = 0; i < AUTOSections_.size(); i++) + delete AUTOSections_[i]; + + for (unsigned i = 0; i < USERSections_.size(); i++) + delete USERSections_[i]; +#endif } -/// getSpecialCasedSectionGlobals - Allow the target to completely override +/// getExplicitSectionGlobal - Allow the target to completely override /// section assignment of a global. const MCSection *PIC16TargetObjectFile:: getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, @@ -274,167 +283,83 @@ std::string SectName = GVar->getSection(); // If address for a variable is specified, get the address and create // section. + // FIXME: move this attribute checking in PAN. std::string AddrStr = "Address="; if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) { std::string SectAddr = SectName.substr(AddrStr.length()); - return CreateSectionForGlobal(GVar, Mang, SectAddr); + return allocateAtGivenAddress(GVar, SectAddr); } // Create the section specified with section attribute. - return CreateSectionForGlobal(GVar, Mang); + return allocateInGivenSection(GVar); } - return getPIC16Section(GV->getSection().c_str(), Kind); + return getPIC16DataSection(GV->getSection().c_str(), UDATA); +} + +// Interface used by AsmPrinter to get a code section for a function. +const PIC16Section * +PIC16TargetObjectFile::SectionForCode(const std::string &FnName) const { + const std::string &sec_name = PAN::getCodeSectionName(FnName); + return getPIC16Section(sec_name, CODE); } -// Create a new section for global variable. If Addr is given then create -// section at that address else create by name. +// Interface used by AsmPrinter to get a frame section for a function. +const PIC16Section * +PIC16TargetObjectFile::SectionForFrame(const std::string &FnName) const { + const std::string &sec_name = PAN::getFrameSectionName(FnName); + return getPIC16Section(sec_name, UDATA_OVR); +} + +// Allocate a global var in existing or new section of given name. const MCSection * -PIC16TargetObjectFile::CreateSectionForGlobal(const GlobalVariable *GV, - Mangler *Mang, - const std::string &Addr) const { +PIC16TargetObjectFile::allocateInGivenSection(const GlobalVariable *GV) const { + // Determine the type of section that we need to create. + PIC16SectionType SecTy; + // See if this is an uninitialized global. const Constant *C = GV->getInitializer(); if (C->isNullValue()) - return CreateBSSSectionForGlobal(GV, Addr); - + SecTy = UDATA; // If this is initialized data in RAM. Put it in the correct IDATA section. - if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) - return CreateIDATASectionForGlobal(GV, Addr); - + else if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) + SecTy = IDATA; // This is initialized data in rom, put it in the readonly section. - if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) - return CreateROSectionForGlobal(GV, Addr); - - // Else let the default implementation take care of it. - return TargetLoweringObjectFile::SectionForGlobal(GV, Mang, *TM); -} - -// Create uninitialized section for a variable. -const MCSection * -PIC16TargetObjectFile::CreateBSSSectionForGlobal(const GlobalVariable *GV, - std::string Addr) const { - assert(GV->hasInitializer() && "This global doesn't need space"); - assert(GV->getInitializer()->isNullValue() && - "Unitialized global has non-zero initializer"); - std::string Name; - // If address is given then create a section at that address else create a - // section by section name specified in GV. - PIC16Section *FoundBSS = NULL; - if (Addr.empty()) { - Name = GV->getSection() + " UDATA"; - for (unsigned i = 0; i < BSSSections.size(); i++) { - if (BSSSections[i]->S_->getName() == Name) { - FoundBSS = BSSSections[i]; - break; - } - } - } else { - std::string Prefix = GV->getNameStr() + "." + Addr + "."; - Name = PAN::getUdataSectionName(BSSSections.size(), Prefix) + " " + Addr; - } - - PIC16Section *NewBSS = FoundBSS; - if (NewBSS == NULL) { - const MCSectionPIC16 *NewSection = - getPIC16Section(Name.c_str(), MCSectionPIC16::UDATA_Kind()); - NewBSS = new PIC16Section(NewSection); - BSSSections.push_back(NewBSS); - } - - // Insert the GV into this BSS. - NewBSS->Items.push_back(GV); + else if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) + SecTy = ROMDATA; + else + llvm_unreachable ("Could not determine section type for global"); - // We do not want to put any GV without explicit section into this section - // so set its size to DatabankSize. - NewBSS->Size = DataBankSize; - return NewBSS->S_; -} - -// Get rom section for a variable. Currently there can be only one rom section -// unless a variable explicitly requests a section. -const MCSection * -PIC16TargetObjectFile::getROSectionForGlobal(const GlobalVariable *GV) const { - ROSections[0]->Items.push_back(GV); - return ROSections[0]->S_; + PIC16Section *S = getPIC16UserSection(GV->getSection().c_str(), SecTy); + S->Items.push_back(GV); + return S; } -// Create initialized data section for a variable. +// Allocate a global var in a new absolute sections at given address. const MCSection * -PIC16TargetObjectFile::CreateIDATASectionForGlobal(const GlobalVariable *GV, - std::string Addr) const { - assert(GV->hasInitializer() && "This global doesn't need space"); - assert(!GV->getInitializer()->isNullValue() && - "initialized global has zero initializer"); - assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE && - "can be used for initialized RAM data only"); - - std::string Name; - // If address is given then create a section at that address else create a - // section by section name specified in GV. - PIC16Section *FoundIDATASec = NULL; - if (Addr.empty()) { - Name = GV->getSection() + " IDATA"; - for (unsigned i = 0; i < IDATASections.size(); i++) { - if (IDATASections[i]->S_->getName() == Name) { - FoundIDATASec = IDATASections[i]; - break; - } - } - } else { - std::string Prefix = GV->getNameStr() + "." + Addr + "."; - Name = PAN::getIdataSectionName(IDATASections.size(), Prefix) + " " + Addr; - } +PIC16TargetObjectFile::allocateAtGivenAddress(const GlobalVariable *GV, + const std::string &Addr) const { + // Determine the type of section that we need to create. + PIC16SectionType SecTy; - PIC16Section *NewIDATASec = FoundIDATASec; - if (NewIDATASec == NULL) { - const MCSectionPIC16 *NewSection = - getPIC16Section(Name.c_str(), MCSectionPIC16::IDATA_Kind()); - NewIDATASec = new PIC16Section(NewSection); - IDATASections.push_back(NewIDATASec); - } - // Insert the GV into this IDATA Section. - NewIDATASec->Items.push_back(GV); - // We do not want to put any GV without explicit section into this section - // so set its size to DatabankSize. - NewIDATASec->Size = DataBankSize; - return NewIDATASec->S_; + // See if this is an uninitialized global. + const Constant *C = GV->getInitializer(); + if (C->isNullValue()) + SecTy = UDATA; + // If this is initialized data in RAM. Put it in the correct IDATA section. + else if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE) + SecTy = IDATA; + // This is initialized data in rom, put it in the readonly section. + else if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE) + SecTy = ROMDATA; + else + llvm_unreachable ("Could not determine section type for global"); + + std::string Prefix = GV->getNameStr() + "." + Addr + "."; + std::string SName = PAN::getUserSectionName(Prefix); + PIC16Section *S = getPIC16UserSection(SName.c_str(), SecTy, Addr.c_str()); + S->Items.push_back(GV); + return S; } -// Create a section in rom for a variable. -const MCSection * -PIC16TargetObjectFile::CreateROSectionForGlobal(const GlobalVariable *GV, - std::string Addr) const { - assert(GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE && - "can be used for ROM data only"); - - std::string Name; - // If address is given then create a section at that address else create a - // section by section name specified in GV. - PIC16Section *FoundROSec = NULL; - if (Addr.empty()) { - Name = GV->getSection() + " ROMDATA"; - for (unsigned i = 1; i < ROSections.size(); i++) { - if (ROSections[i]->S_->getName() == Name) { - FoundROSec = ROSections[i]; - break; - } - } - } else { - std::string Prefix = GV->getNameStr() + "." + Addr + "."; - Name = PAN::getRomdataSectionName(ROSections.size(), Prefix) + " " + Addr; - } - - PIC16Section *NewRomSec = FoundROSec; - if (NewRomSec == NULL) { - const MCSectionPIC16 *NewSection = - getPIC16Section(Name.c_str(), MCSectionPIC16::ROMDATA_Kind()); - NewRomSec = new PIC16Section(NewSection); - ROSections.push_back(NewRomSec); - } - - // Insert the GV into this ROM Section. - NewRomSec->Items.push_back(GV); - return NewRomSec->S_; -} Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Thu Oct 15 14:26:25 2009 @@ -10,6 +10,8 @@ #ifndef LLVM_TARGET_PIC16_TARGETOBJECTFILE_H #define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H +#include "PIC16.h" +#include "PIC16ABINames.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/ADT/StringMap.h" #include @@ -19,7 +21,7 @@ class GlobalVariable; class Module; class PIC16TargetMachine; - class MCSectionPIC16; + class PIC16Section; enum { DataBankSize = 80 }; @@ -29,91 +31,124 @@ /// again and printing only those that match the current section. /// Keeping values inside the sections make printing a section much easier. /// - /// FIXME: MOVE ALL THIS STUFF TO MCSectionPIC16. + /// FIXME: MOVE ALL THIS STUFF TO PIC16Section. /// - struct PIC16Section { - const MCSectionPIC16 *S_; // Connection to actual Section. - unsigned Size; // Total size of the objects contained. - bool SectionPrinted; - std::vector Items; - - PIC16Section(const MCSectionPIC16 *s) { - S_ = s; - Size = 0; - SectionPrinted = false; - } - bool isPrinted() const { return SectionPrinted; } - void setPrintedStatus(bool status) { SectionPrinted = status; } - }; - + + /// PIC16TargetObjectFile - PIC16 Object file. Contains data and code + /// sections. + // PIC16 Object File has two types of sections. + // 1. Standard Sections + // 1.1 un-initialized global data + // 1.2 initialized global data + // 1.3 program memory data + // 1.4 local variables of functions. + // 2. User defined sections + // 2.1 Objects placed in a specific section. (By _Section() macro) + // 2.2 Objects placed at a specific address. (By _Address() macro) class PIC16TargetObjectFile : public TargetLoweringObjectFile { /// SectionsByName - Bindings of names to allocated sections. - mutable StringMap SectionsByName; + mutable StringMap SectionsByName; const TargetMachine *TM; - const MCSectionPIC16 *getPIC16Section(const char *Name, - SectionKind K, - int Address = -1, - int Color = -1) const; - public: - mutable std::vector BSSSections; - mutable std::vector IDATASections; - mutable std::vector AutosSections; - mutable std::vector ROSections; - mutable PIC16Section *ExternalVarDecls; - mutable PIC16Section *ExternalVarDefs; - + /// Lists of sections. + /// Standard Data Sections. + mutable std::vector UDATASections_; + mutable std::vector IDATASections_; + mutable PIC16Section * ROMDATASection_; + + /// Standard Auto Sections. + mutable std::vector AUTOSections_; + + /// User specified sections. + mutable std::vector USERSections_; + + + /// Find or Create a PIC16 Section, without adding it to any + /// section list. + PIC16Section *getPIC16Section(const std::string &Name, + PIC16SectionType Ty, + const std::string &Address = "", + int Color = -1) const; + + /// Convenience functions. These wrappers also take care of adding + /// the newly created section to the appropriate sections list. + + /// Find or Create PIC16 Standard Data Section. + PIC16Section *getPIC16DataSection(const std::string &Name, + PIC16SectionType Ty, + const std::string &Address = "", + int Color = -1) const; + + /// Find or Create PIC16 Standard Auto Section. + PIC16Section *getPIC16AutoSection(const std::string &Name, + PIC16SectionType Ty = UDATA_OVR, + const std::string &Address = "", + int Color = -1) const; + + /// Find or Create PIC16 Standard Auto Section. + PIC16Section *getPIC16UserSection(const std::string &Name, + PIC16SectionType Ty, + const std::string &Address = "", + int Color = -1) const; + + /// Allocate Un-initialized data to a standard UDATA section. + const MCSection *allocateUDATA(const GlobalVariable *GV) const; + + /// Allocate Initialized data to a standard IDATA section. + const MCSection *allocateIDATA(const GlobalVariable *GV) const; + + /// Allocate ROM data to the standard ROMDATA section. + const MCSection *allocateROMDATA(const GlobalVariable *GV) const; + + /// Allocate an AUTO variable to an AUTO section. + const MCSection *allocateAUTO(const GlobalVariable *GV) const; + + /// Allocate DATA in user specified section. + const MCSection *allocateInGivenSection(const GlobalVariable *GV) const; + + /// Allocate DATA at user specified address. + const MCSection *allocateAtGivenAddress(const GlobalVariable *GV, + const std::string &Addr) const; + + public: PIC16TargetObjectFile(); ~PIC16TargetObjectFile(); - void Initialize(MCContext &Ctx, const TargetMachine &TM); - + /// Override section allocations for user specified sections. virtual const MCSection * getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; + /// Select sections for Data and Auto variables(globals). virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine&) const; - const MCSection *getSectionForFunction(const std::string &FnName) const; - const MCSection *getSectionForFunctionFrame(const std::string &FnName)const; - - - private: - std::string getSectionNameForSym(const std::string &Sym) const; + /// Return a code section for a function. + const PIC16Section *SectionForCode (const std::string &FnName) const; - const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const; - const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const; - const MCSection *getSectionForAuto(const GlobalVariable *GV) const; - const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV, - std::string Addr = "") const; - const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV, - std::string Addr = "") const; - const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const; - const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV, - std::string Addr = "") const; - const MCSection *CreateSectionForGlobal(const GlobalVariable *GV, - Mangler *Mang, - const std::string &Addr = "") const; - public: - void SetSectionForGVs(Module &M); - const std::vector &getBSSSections() const { - return BSSSections; + /// Return a frame section for a function. + const PIC16Section *SectionForFrame (const std::string &FnName) const; + + /// Accessors for various section lists. + const std::vector &UDATASections() const { + return UDATASections_; } - const std::vector &getIDATASections() const { - return IDATASections; + const std::vector &IDATASections() const { + return IDATASections_; } - const std::vector &getAutosSections() const { - return AutosSections; + const PIC16Section *ROMDATASection() const { + return ROMDATASection_; } - const std::vector &getROSections() const { - return ROSections; + const std::vector &AUTOSections() const { + return AUTOSections_; + } + const std::vector &USERSections() const { + return USERSections_; } - }; } // end namespace llvm Modified: llvm/trunk/test/CodeGen/PIC16/globals.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PIC16/globals.ll?rev=84195&r1=84194&r2=84195&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PIC16/globals.ll (original) +++ llvm/trunk/test/CodeGen/PIC16/globals.ll Thu Oct 15 14:26:25 2009 @@ -1,15 +1,15 @@ ; RUN: llc < %s -march=pic16 | FileCheck %s @G1 = global i32 4712, section "Address=412" -; CHECK: @G1.412.idata.0.# IDATA 412 +; CHECK: @G1.412..user_section.# IDATA 412 ; CHECK: @G1 dl 4712 @G2 = global i32 0, section "Address=412" -; CHECK: @G2.412.udata.0.# UDATA 412 +; CHECK: @G2.412..user_section.# UDATA 412 ; CHECK: @G2 RES 4 @G3 = addrspace(1) constant i32 4712, section "Address=412" -; CHECK: @G3.412.romdata.1.# ROMDATA 412 +; CHECK: @G3.412..user_section.# ROMDATA 412 ; CHECK: @G3 rom_dl 4712 From benny.kra at googlemail.com Thu Oct 15 14:46:40 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 15 Oct 2009 19:46:40 -0000 Subject: [llvm-commits] [llvm] r84196 - in /llvm/trunk/lib/Target/PIC16: PIC16ABINames.h PIC16Section.cpp PIC16Section.h Message-ID: <200910151946.n9FJkfTV021679@zion.cs.uiuc.edu> Author: d0k Date: Thu Oct 15 14:46:34 2009 New Revision: 84196 URL: http://llvm.org/viewvc/llvm-project?rev=84196&view=rev Log: Add files Sanjiv forgot. Added: llvm/trunk/lib/Target/PIC16/PIC16ABINames.h - copied unchanged from r84180, llvm/trunk/lib/Target/PIC16/PIC16ABINames.h llvm/trunk/lib/Target/PIC16/PIC16Section.cpp - copied unchanged from r84180, llvm/trunk/lib/Target/PIC16/PIC16Section.cpp llvm/trunk/lib/Target/PIC16/PIC16Section.h - copied unchanged from r84180, llvm/trunk/lib/Target/PIC16/PIC16Section.h From tonic at nondot.org Thu Oct 15 14:47:56 2009 From: tonic at nondot.org (Tanya Lattner) Date: Thu, 15 Oct 2009 14:47:56 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/Phoenix_AcceleratingRuby.pdf index.html Message-ID: <200910151947.n9FJluM6021735@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: Phoenix_AcceleratingRuby.pdf added (r1.1) index.html updated: 1.25 -> 1.26 --- Log message: Add slides for ruby talk by Evan Phoenix. --- Diffs of the changes: (+2 -2) Phoenix_AcceleratingRuby.pdf | 0 index.html | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-www/devmtg/2009-10/Phoenix_AcceleratingRuby.pdf Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.25 llvm-www/devmtg/2009-10/index.html:1.26 --- llvm-www/devmtg/2009-10/index.html:1.25 Thu Oct 15 10:25:06 2009 +++ llvm-www/devmtg/2009-10/index.html Thu Oct 15 14:45:12 2009 @@ -256,7 +256,7 @@ - [Waiting for Slides]

        + [Slides] [Video(Computer) [Video(Mobile) @@ -283,7 +283,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 15:25:06 $ +
        Last modified: $Date: 2009/10/15 19:45:12 $ From vhernandez at apple.com Thu Oct 15 15:14:53 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 15 Oct 2009 20:14:53 -0000 Subject: [llvm-commits] [llvm] r84199 - in /llvm/trunk: include/llvm/Analysis/MallocHelper.h lib/Analysis/MallocHelper.cpp lib/Analysis/PointerTracking.cpp lib/Transforms/IPO/GlobalOpt.cpp Message-ID: <200910152014.n9FKErMI022629@zion.cs.uiuc.edu> Author: hernande Date: Thu Oct 15 15:14:52 2009 New Revision: 84199 URL: http://llvm.org/viewvc/llvm-project?rev=84199&view=rev Log: Fix bug where array malloc with unexpected computation of the size argument resulted in MallocHelper identifying the malloc as a non-array malloc. This broke GlobalOpt's optimization of stores of mallocs to global variables. The fix is to classify malloc's into 3 categories: 1. non-array mallocs 2. array mallocs whose array size can be determined 3. mallocs that cannot be determined to be of type 1 or 2 and cannot be optimized getMallocArraySize() returns NULL for category 3, and all users of this function must avoid their malloc optimization if this function returns NULL. Eventually, currently unexpected codegen for computing the malloc's size argument will be supported in isArrayMalloc() and getMallocArraySize(), extending malloc optimizations to those examples. Modified: llvm/trunk/include/llvm/Analysis/MallocHelper.h llvm/trunk/lib/Analysis/MallocHelper.cpp llvm/trunk/lib/Analysis/PointerTracking.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/include/llvm/Analysis/MallocHelper.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MallocHelper.h?rev=84199&r1=84198&r2=84199&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/MallocHelper.h (original) +++ llvm/trunk/include/llvm/Analysis/MallocHelper.h Thu Oct 15 15:14:52 2009 @@ -46,9 +46,9 @@ /// matches the malloc call IR generated by CallInst::CreateMalloc(). This /// means that it is a malloc call with one bitcast use AND the malloc call's /// size argument is: -/// 1. a constant not equal to the malloc's allocated type +/// 1. a constant not equal to the size of the malloced type /// or -/// 2. the result of a multiplication by the malloc's allocated type +/// 2. the result of a multiplication by the size of the malloced type /// Otherwise it returns NULL. /// The unique bitcast is needed to determine the type/size of the array /// allocation. @@ -66,18 +66,17 @@ /// unique bitcast use, then return NULL. const Type* getMallocAllocatedType(const CallInst* CI); -/// getMallocArraySize - Returns the array size of a malloc call. The array -/// size is computated in 1 of 3 ways: -/// 1. If the element type if of size 1, then array size is the argument to +/// getMallocArraySize - Returns the array size of a malloc call. For array +/// mallocs, the size is computated in 1 of 3 ways: +/// 1. If the element type is of size 1, then array size is the argument to /// malloc. /// 2. Else if the malloc's argument is a constant, the array size is that /// argument divided by the element type's size. /// 3. Else the malloc argument must be a multiplication and the array size is /// the first operand of the multiplication. -/// This function returns constant 1 if: -/// 1. The malloc call's allocated type cannot be determined. -/// 2. IR wasn't created by a call to CallInst::CreateMalloc() with a non-NULL -/// ArraySize. +/// For non-array mallocs, the computed size is constant 1. +/// This function returns NULL for all mallocs whose array size cannot be +/// determined. Value* getMallocArraySize(CallInst* CI, LLVMContext &Context, const TargetData* TD); Modified: llvm/trunk/lib/Analysis/MallocHelper.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MallocHelper.cpp?rev=84199&r1=84198&r2=84199&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MallocHelper.cpp (original) +++ llvm/trunk/lib/Analysis/MallocHelper.cpp Thu Oct 15 15:14:52 2009 @@ -130,9 +130,9 @@ /// matches the malloc call IR generated by CallInst::CreateMalloc(). This /// means that it is a malloc call with one bitcast use AND the malloc call's /// size argument is: -/// 1. a constant not equal to the malloc's allocated type +/// 1. a constant not equal to the size of the malloced type /// or -/// 2. the result of a multiplication by the malloc's allocated type +/// 2. the result of a multiplication by the size of the malloced type /// Otherwise it returns NULL. /// The unique bitcast is needed to determine the type/size of the array /// allocation. @@ -183,25 +183,60 @@ return PT ? PT->getElementType() : NULL; } +/// isSafeToGetMallocArraySize - Returns true if the array size of a malloc can +/// be determined. It can be determined in these 3 cases of malloc codegen: +/// 1. non-array malloc: The malloc's size argument is a constant and equals the /// size of the type being malloced. +/// 2. array malloc: This is a malloc call with one bitcast use AND the malloc +/// call's size argument is a constant multiple of the size of the malloced +/// type. +/// 3. array malloc: This is a malloc call with one bitcast use AND the malloc +/// call's size argument is the result of a multiplication by the size of the +/// malloced type. +/// Otherwise returns false. +static bool isSafeToGetMallocArraySize(const CallInst *CI, + LLVMContext &Context, + const TargetData* TD) { + if (!CI) + return false; + + // Type must be known to determine array size. + const Type* T = getMallocAllocatedType(CI); + if (!T) return false; + + Value* MallocArg = CI->getOperand(1); + Constant *ElementSize = ConstantExpr::getSizeOf(T); + ElementSize = ConstantExpr::getTruncOrBitCast(ElementSize, + MallocArg->getType()); + + // First, check if it is a non-array malloc. + if (isa(MallocArg) && (MallocArg == ElementSize)) + return true; + + // Second, check if it can be determined that this is an array malloc. + return isArrayMallocHelper(CI, Context, TD); +} + /// isConstantOne - Return true only if val is constant int 1. static bool isConstantOne(Value *val) { return isa(val) && cast(val)->isOne(); } -/// getMallocArraySize - Returns the array size of a malloc call. The array -/// size is computated in 1 of 3 ways: -/// 1. If the element type if of size 1, then array size is the argument to +/// getMallocArraySize - Returns the array size of a malloc call. For array +/// mallocs, the size is computated in 1 of 3 ways: +/// 1. If the element type is of size 1, then array size is the argument to /// malloc. /// 2. Else if the malloc's argument is a constant, the array size is that /// argument divided by the element type's size. /// 3. Else the malloc argument must be a multiplication and the array size is /// the first operand of the multiplication. -/// This function returns constant 1 if: -/// 1. The malloc call's allocated type cannot be determined. -/// 2. IR wasn't created by a call to CallInst::CreateMalloc() with a non-NULL -/// ArraySize. +/// For non-array mallocs, the computed size is constant 1. +/// This function returns NULL for all mallocs whose array size cannot be +/// determined. Value* llvm::getMallocArraySize(CallInst* CI, LLVMContext &Context, const TargetData* TD) { + if (isSafeToGetMallocArraySize(CI, Context, TD)) + return NULL; + // Match CreateMalloc's use of constant 1 array-size for non-array mallocs. if (!isArrayMalloc(CI, Context, TD)) return ConstantInt::get(CI->getOperand(1)->getType(), 1); Modified: llvm/trunk/lib/Analysis/PointerTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PointerTracking.cpp?rev=84199&r1=84198&r2=84199&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/PointerTracking.cpp (original) +++ llvm/trunk/lib/Analysis/PointerTracking.cpp Thu Oct 15 15:14:52 2009 @@ -102,8 +102,9 @@ if (CallInst *CI = extractMallocCall(V)) { Value *arraySize = getMallocArraySize(CI, P->getContext(), TD); - Ty = getMallocAllocatedType(CI); - if (!Ty || !arraySize) return SE->getCouldNotCompute(); + const Type* AllocTy = getMallocAllocatedType(CI); + if (!AllocTy || !arraySize) return SE->getCouldNotCompute(); + Ty = AllocTy; // arraySize elements of type Ty. return SE->getSCEV(arraySize); } Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=84199&r1=84198&r2=84199&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Oct 15 15:14:52 2009 @@ -950,12 +950,14 @@ BitCastInst *BCI, LLVMContext &Context, TargetData* TD) { + DEBUG(errs() << "PROMOTING MALLOC GLOBAL: " << *GV + << " CALL = " << *CI << " BCI = " << *BCI << '\n'); + const Type *IntPtrTy = TD->getIntPtrType(Context); - DEBUG(errs() << "PROMOTING MALLOC GLOBAL: " << *GV << " MALLOC = " << *CI); - - ConstantInt *NElements = cast(getMallocArraySize(CI, - Context, TD)); + Value* ArraySize = getMallocArraySize(CI, Context, TD); + assert(ArraySize && "not a malloc whose array size can be determined"); + ConstantInt *NElements = cast(ArraySize); if (NElements->getZExtValue() != 1) { // If we have an array allocation, transform it to a single element // allocation to make the code below simpler. @@ -976,9 +978,6 @@ // Create the new global variable. The contents of the malloc'd memory is // undefined, so initialize with an undef value. - // FIXME: This new global should have the alignment returned by malloc. Code - // could depend on malloc returning large alignment (on the mac, 16 bytes) but - // this would only guarantee some lower alignment. const Type *MAT = getMallocAllocatedType(CI); Constant *Init = UndefValue::get(MAT); GlobalVariable *NewGV = new GlobalVariable(*GV->getParent(), @@ -1892,16 +1891,17 @@ // transform the program to use global memory instead of malloc'd memory. // This eliminates dynamic allocation, avoids an indirection accessing the // data, and exposes the resultant global to further GlobalOpt. - if (ConstantInt *NElements = - dyn_cast(getMallocArraySize(CI, Context, TD))) { - // Restrict this transformation to only working on small allocations - // (2048 bytes currently), as we don't want to introduce a 16M global or - // something. - if (TD && - NElements->getZExtValue() * TD->getTypeAllocSize(AllocTy) < 2048) { - GVI = OptimizeGlobalAddressOfMalloc(GV, CI, BCI, Context, TD); - return true; - } + Value *NElems = getMallocArraySize(CI, Context, TD); + if (NElems) { + if (ConstantInt *NElements = dyn_cast(NElems)) + // Restrict this transformation to only working on small allocations + // (2048 bytes currently), as we don't want to introduce a 16M global or + // something. + if (TD && + NElements->getZExtValue() * TD->getTypeAllocSize(AllocTy) < 2048) { + GVI = OptimizeGlobalAddressOfMalloc(GV, CI, BCI, Context, TD); + return true; + } } // If the allocation is an array of structures, consider transforming this From evan.cheng at apple.com Thu Oct 15 15:23:25 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 15 Oct 2009 20:23:25 -0000 Subject: [llvm-commits] [llvm] r84200 - in /llvm/trunk/lib/Target/X86: X86Subtarget.cpp X86Subtarget.h Message-ID: <200910152023.n9FKNQS8023030@zion.cs.uiuc.edu> Author: evancheng Date: Thu Oct 15 15:23:21 2009 New Revision: 84200 URL: http://llvm.org/viewvc/llvm-project?rev=84200&view=rev Log: Remove X86Subtarget::IsLinux. It's no longer being used. Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=84200&r1=84199&r2=84200&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Thu Oct 15 15:23:21 2009 @@ -382,7 +382,6 @@ , HasFMA4(false) , IsBTMemSlow(false) , DarwinVers(0) - , IsLinux(false) , stackAlignment(8) // FIXME: this is a known good value for Yonah. How about others? , MaxInlineSizeThreshold(128) @@ -434,7 +433,6 @@ } else if (TT.find("linux") != std::string::npos) { // Linux doesn't imply ELF, but we don't currently support anything else. TargetType = isELF; - IsLinux = true; } else if (TT.find("cygwin") != std::string::npos) { TargetType = isCygwin; } else if (TT.find("mingw") != std::string::npos) { Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=84200&r1=84199&r2=84200&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Thu Oct 15 15:23:21 2009 @@ -82,9 +82,6 @@ /// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc. unsigned char DarwinVers; // Is any darwin-x86 platform. - /// isLinux - true if this is a "linux" platform. - bool IsLinux; - /// stackAlignment - The minimum alignment known to hold of the stack frame on /// entry to the function and which must be maintained by every function. unsigned stackAlignment; @@ -195,11 +192,7 @@ /// getDarwinVers - Return the darwin version number, 8 = Tiger, 9 = Leopard, /// 10 = Snow Leopard, etc. unsigned getDarwinVers() const { return DarwinVers; } - - /// isLinux - Return true if the target is "Linux". - bool isLinux() const { return IsLinux; } - - + /// ClassifyGlobalReference - Classify a global variable reference for the /// current subtarget according to how we should reference it in a non-pcrel /// context. From enderby at apple.com Thu Oct 15 15:48:49 2009 From: enderby at apple.com (Kevin Enderby) Date: Thu, 15 Oct 2009 20:48:49 -0000 Subject: [llvm-commits] [llvm] r84201 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <200910152048.n9FKmnCg023900@zion.cs.uiuc.edu> Author: enderby Date: Thu Oct 15 15:48:48 2009 New Revision: 84201 URL: http://llvm.org/viewvc/llvm-project?rev=84201&view=rev Log: More bits of the ARM target assembler for llvm-mc, code added to parse labels as expressions, code for parsing a few arm specific directives (still needs the MCStreamer calls for these). Some clean up of the operand parsing code and adding some comments. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=84201&r1=84200&r2=84201&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Thu Oct 15 15:48:48 2009 @@ -56,6 +56,14 @@ bool ParseDirectiveWord(unsigned Size, SMLoc L); + bool ParseDirectiveThumb(SMLoc L); + + bool ParseDirectiveThumbFunc(SMLoc L); + + bool ParseDirectiveCode(SMLoc L); + + bool ParseDirectiveSyntax(SMLoc L); + // TODO - For now hacked versions of the next two are in here in this file to // allow some parser testing until the table gen versions are implemented. @@ -230,8 +238,8 @@ return false; } -// Try to parse a register list. The first token must be a '{' when called -// for now. +// Parse a register list, return false if successful else return true or an +// error. The first token must be a '{' when called. bool ARMAsmParser::ParseRegisterList(ARMOperand &Op) { assert(getLexer().getTok().is(AsmToken::LCurly) && "Token is not an Left Curly Brace"); @@ -277,7 +285,8 @@ return false; } -// Try to parse an arm memory expression. It must start with a '[' token. +// Parse an arm memory expression, return false if successful else return true +// or an error. The first token must be a '[' when called. // TODO Only preindexing and postindexing addressing are started, unindexed // with option, etc are still to do. bool ARMAsmParser::ParseMemory(ARMOperand &Op) { @@ -465,7 +474,7 @@ return false; } -// A hack to allow some testing +// A hack to allow some testing, to be replaced by a real table gen version. int ARMAsmParser::MatchRegisterName(const StringRef &Name) { if (Name == "r0" || Name == "R0") return 0; @@ -504,7 +513,7 @@ return -1; } -// A hack to allow some testing +// A hack to allow some testing, to be replaced by a real table gen version. bool ARMAsmParser::MatchInstruction(SmallVectorImpl &Operands, MCInst &Inst) { struct ARMOperand Op0 = Operands[0]; @@ -516,40 +525,49 @@ Mnemonic == "ldmfd" || Mnemonic == "ldr" || Mnemonic == "mov" || - Mnemonic == "sub") + Mnemonic == "sub" || + Mnemonic == "bl" || + Mnemonic == "push" || + Mnemonic == "blx" || + Mnemonic == "pop") return false; return true; } -// TODO - this is a work in progress +// Parse a arm instruction operand. For now this parses the operand regardless +// of the mnemonic. bool ARMAsmParser::ParseOperand(ARMOperand &Op) { switch (getLexer().getKind()) { case AsmToken::Identifier: if (!ParseRegister(Op)) return false; - // TODO parse other operands that start with an identifier like labels - return Error(getLexer().getTok().getLoc(), "labels not yet supported"); + // This was not a register so parse other operands that start with an + // identifier (like labels) as expressions and create them as immediates. + const MCExpr *IdVal; + if (getParser().ParseExpression(IdVal)) + return true; + Op = ARMOperand::CreateImm(IdVal); + return false; case AsmToken::LBrac: - if (!ParseMemory(Op)) - return false; + return ParseMemory(Op); case AsmToken::LCurly: - if (!ParseRegisterList(Op)) - return false; + return ParseRegisterList(Op); case AsmToken::Hash: // #42 -> immediate. // TODO: ":lower16:" and ":upper16:" modifiers after # before immediate getLexer().Lex(); - const MCExpr *Val; - if (getParser().ParseExpression(Val)) + const MCExpr *ImmVal; + if (getParser().ParseExpression(ImmVal)) return true; - Op = ARMOperand::CreateImm(Val); + Op = ARMOperand::CreateImm(ImmVal); return false; default: return Error(getLexer().getTok().getLoc(), "unexpected token in operand"); } } +// Parse an arm instruction mnemonic followed by its operands. bool ARMAsmParser::ParseInstruction(const StringRef &Name, MCInst &Inst) { SmallVector Operands; @@ -579,10 +597,19 @@ return true; } +/// ParseDirective parses the arm specific directives bool ARMAsmParser::ParseDirective(AsmToken DirectiveID) { StringRef IDVal = DirectiveID.getIdentifier(); if (IDVal == ".word") return ParseDirectiveWord(4, DirectiveID.getLoc()); + else if (IDVal == ".thumb") + return ParseDirectiveThumb(DirectiveID.getLoc()); + else if (IDVal == ".thumb_func") + return ParseDirectiveThumbFunc(DirectiveID.getLoc()); + else if (IDVal == ".code") + return ParseDirectiveCode(DirectiveID.getLoc()); + else if (IDVal == ".syntax") + return ParseDirectiveSyntax(DirectiveID.getLoc()); return true; } @@ -611,6 +638,93 @@ return false; } +/// ParseDirectiveThumb +/// ::= .thumb +bool ARMAsmParser::ParseDirectiveThumb(SMLoc L) { + if (getLexer().isNot(AsmToken::EndOfStatement)) + return Error(L, "unexpected token in directive"); + getLexer().Lex(); + + // TODO: set thumb mode + // TODO: tell the MC streamer the mode + // getParser().getStreamer().Emit???(); + return false; +} + +/// ParseDirectiveThumbFunc +/// ::= .thumbfunc symbol_name +bool ARMAsmParser::ParseDirectiveThumbFunc(SMLoc L) { + const AsmToken &Tok = getLexer().getTok(); + if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String)) + return Error(L, "unexpected token in .syntax directive"); + StringRef SymbolName = getLexer().getTok().getIdentifier(); + getLexer().Lex(); // Consume the identifier token. + + if (getLexer().isNot(AsmToken::EndOfStatement)) + return Error(L, "unexpected token in directive"); + getLexer().Lex(); + + // TODO: mark symbol as a thumb symbol + // getParser().getStreamer().Emit???(); + return false; +} + +/// ParseDirectiveSyntax +/// ::= .syntax unified | divided +bool ARMAsmParser::ParseDirectiveSyntax(SMLoc L) { + const AsmToken &Tok = getLexer().getTok(); + if (Tok.isNot(AsmToken::Identifier)) + return Error(L, "unexpected token in .syntax directive"); + const StringRef &Mode = Tok.getString(); + bool unified_syntax; + if (Mode == "unified" || Mode == "UNIFIED") { + getLexer().Lex(); + unified_syntax = true; + } + else if (Mode == "divided" || Mode == "DIVIDED") { + getLexer().Lex(); + unified_syntax = false; + } + else + return Error(L, "unrecognized syntax mode in .syntax directive"); + + if (getLexer().isNot(AsmToken::EndOfStatement)) + return Error(getLexer().getTok().getLoc(), "unexpected token in directive"); + getLexer().Lex(); + + // TODO tell the MC streamer the mode + // getParser().getStreamer().Emit???(); + return false; +} + +/// ParseDirectiveCode +/// ::= .code 16 | 32 +bool ARMAsmParser::ParseDirectiveCode(SMLoc L) { + const AsmToken &Tok = getLexer().getTok(); + if (Tok.isNot(AsmToken::Integer)) + return Error(L, "unexpected token in .code directive"); + int64_t Val = getLexer().getTok().getIntVal(); + bool thumb_mode; + if (Val == 16) { + getLexer().Lex(); + thumb_mode = true; + } + else if (Val == 32) { + getLexer().Lex(); + thumb_mode = false; + } + else + return Error(L, "invalid operand to .code directive"); + + if (getLexer().isNot(AsmToken::EndOfStatement)) + return Error(getLexer().getTok().getLoc(), "unexpected token in directive"); + getLexer().Lex(); + + // TODO tell the MC streamer the mode + // getParser().getStreamer().Emit???(); + return false; +} + // Force static initialization. extern "C" void LLVMInitializeARMAsmParser() { RegisterAsmParser X(TheARMTarget); From bob.wilson at apple.com Thu Oct 15 15:49:47 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 15 Oct 2009 20:49:47 -0000 Subject: [llvm-commits] [llvm] r84202 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200910152049.n9FKnlnl023998@zion.cs.uiuc.edu> Author: bwilson Date: Thu Oct 15 15:49:47 2009 New Revision: 84202 URL: http://llvm.org/viewvc/llvm-project?rev=84202&view=rev Log: Fix a potential performance problem in placing ARM constant pools. In the case where there are no good places to put constants and we fall back upon inserting unconditional branches to make new blocks, allow all constant pool references in range of those blocks to put constants there, even if that means resetting the "high water marks" for those references. This will still terminate because you can't keep splitting blocks forever, and in the bad cases where we have to split blocks, it is important to avoid splitting more than necessary. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=84202&r1=84201&r2=84202&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Oct 15 15:49:47 2009 @@ -28,9 +28,11 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Statistic.h" +#include using namespace llvm; STATISTIC(NumCPEs, "Number of constpool entries"); @@ -70,6 +72,10 @@ /// to a return, unreachable, or unconditional branch). std::vector WaterList; + /// NewWaterList - The subset of WaterList that was created since the + /// previous iteration by inserting unconditional branches. + SmallSet NewWaterList; + typedef std::vector::iterator water_iterator; /// CPUser - One user of a constant pool, keeping the machine instruction @@ -175,9 +181,7 @@ void AdjustBBOffsetsAfter(MachineBasicBlock *BB, int delta); bool DecrementOldEntry(unsigned CPI, MachineInstr* CPEMI); int LookForExistingCPEntry(CPUser& U, unsigned UserOffset); - bool LookForWater(CPUser&U, unsigned UserOffset, - MachineBasicBlock *&NewMBB); - MachineBasicBlock *AcceptWater(water_iterator IP); + bool LookForWater(CPUser&U, unsigned UserOffset, water_iterator &WaterIter); void CreateNewWater(unsigned CPUserIndex, unsigned UserOffset, MachineBasicBlock *&NewMBB); bool HandleConstantPoolUser(MachineFunction &MF, unsigned CPUserIndex); @@ -297,6 +301,10 @@ if (CPChange && ++NoCPIters > 30) llvm_unreachable("Constant Island pass failed to converge!"); DEBUG(dumpBBs()); + + // Clear NewWaterList now. If we split a block for branches, it should + // appear as "new water" for the next iteration of constant pool placement. + NewWaterList.clear(); bool BRChange = false; for (unsigned i = 0, e = ImmBranches.size(); i != e; ++i) @@ -629,7 +637,7 @@ /// Split the basic block containing MI into two blocks, which are joined by -/// an unconditional branch. Update datastructures and renumber blocks to +/// an unconditional branch. Update data structures and renumber blocks to /// account for this change and returns the newly created block. MachineBasicBlock *ARMConstantIslands::SplitBlockBeforeInstr(MachineInstr *MI) { MachineBasicBlock *OrigBB = MI->getParent(); @@ -691,6 +699,7 @@ WaterList.insert(next(IP), NewBB); else WaterList.insert(IP, OrigBB); + NewWaterList.insert(OrigBB); // Figure out how large the first NewMBB is. (It cannot // contain a constpool_entry or tablejump.) @@ -941,30 +950,16 @@ return ((1<<23)-1)*4; } -/// AcceptWater - Small amount of common code factored out of the following. -/// -MachineBasicBlock *ARMConstantIslands::AcceptWater(water_iterator IP) { - DEBUG(errs() << "found water in range\n"); - MachineBasicBlock *WaterBB = *IP; - // Remove the original WaterList entry; we want subsequent - // insertions in this vicinity to go after the one we're - // about to insert. This considerably reduces the number - // of times we have to move the same CPE more than once. - WaterList.erase(IP); - // CPE goes before following block (NewMBB). - return next(MachineFunction::iterator(WaterBB)); -} - -/// LookForWater - look for an existing entry in the WaterList in which +/// LookForWater - Look for an existing entry in the WaterList in which /// we can place the CPE referenced from U so it's within range of U's MI. -/// Returns true if found, false if not. If it returns true, NewMBB +/// Returns true if found, false if not. If it returns true, WaterIter /// is set to the WaterList entry. For Thumb, prefer water that will not /// introduce padding to water that will. To ensure that this pass /// terminates, the CPE location for a particular CPUser is only allowed to /// move to a lower address, so search backward from the end of the list and /// prefer the first water that is in range. bool ARMConstantIslands::LookForWater(CPUser &U, unsigned UserOffset, - MachineBasicBlock *&NewMBB) { + water_iterator &WaterIter) { if (WaterList.empty()) return false; @@ -973,9 +968,17 @@ for (water_iterator IP = prior(WaterList.end()), B = WaterList.begin();; --IP) { MachineBasicBlock* WaterBB = *IP; - // Check if water is in range and at a lower address than the current one. - if (WaterBB->getNumber() < U.HighWaterMark->getNumber() && - WaterIsInRange(UserOffset, WaterBB, U)) { + // Check if water is in range and is either at a lower address than the + // current "high water mark" or a new water block that was created since + // the previous iteration by inserting an unconditional branch. In the + // latter case, we want to allow resetting the high water mark back to + // this new water since we haven't seen it before. Inserting branches + // should be relatively uncommon and when it does happen, we want to be + // sure to take advantage of it for all the CPEs near that block, so that + // we don't insert more branches than necessary. + if (WaterIsInRange(UserOffset, WaterBB, U) && + (WaterBB->getNumber() < U.HighWaterMark->getNumber() || + NewWaterList.count(WaterBB))) { unsigned WBBId = WaterBB->getNumber(); if (isThumb && (BBOffsets[WBBId] + BBSizes[WBBId])%4 != 0) { @@ -986,7 +989,7 @@ IPThatWouldPad = IP; } } else { - NewMBB = AcceptWater(IP); + WaterIter = IP; return true; } } @@ -994,7 +997,7 @@ break; } if (FoundWaterThatWouldPad) { - NewMBB = AcceptWater(IPThatWouldPad); + WaterIter = IPThatWouldPad; return true; } return false; @@ -1107,7 +1110,6 @@ MachineInstr *CPEMI = U.CPEMI; unsigned CPI = CPEMI->getOperand(1).getIndex(); unsigned Size = CPEMI->getOperand(2).getImm(); - MachineBasicBlock *NewMBB; // Compute this only once, it's expensive. The 4 or 8 is the value the // hardware keeps in the PC. unsigned UserOffset = GetOffsetOf(UserMI) + (isThumb ? 4 : 8); @@ -1123,14 +1125,50 @@ unsigned ID = AFI->createConstPoolEntryUId(); // Look for water where we can place this CPE. - if (!LookForWater(U, UserOffset, NewMBB)) { + MachineBasicBlock *NewIsland = MF.CreateMachineBasicBlock(); + MachineBasicBlock *NewMBB; + water_iterator IP; + if (LookForWater(U, UserOffset, IP)) { + DEBUG(errs() << "found water in range\n"); + MachineBasicBlock *WaterBB = *IP; + + // If the original WaterList entry was "new water" on this iteration, + // propagate that to the new island. This is just keeping NewWaterList + // updated to match the WaterList, which will be updated below. + if (NewWaterList.count(WaterBB)) { + NewWaterList.erase(WaterBB); + NewWaterList.insert(NewIsland); + } + // The new CPE goes before the following block (NewMBB). + NewMBB = next(MachineFunction::iterator(WaterBB)); + + } else { // No water found. DEBUG(errs() << "No water found\n"); CreateNewWater(CPUserIndex, UserOffset, NewMBB); - } + + // SplitBlockBeforeInstr adds to WaterList, which is important when it is + // called while handling branches so that the water will be seen on the + // next iteration for constant pools, but in this context, we don't want + // it. Check for this so it will be removed from the WaterList. + // Also remove any entry from NewWaterList. + MachineBasicBlock *WaterBB = prior(MachineFunction::iterator(NewMBB)); + IP = std::find(WaterList.begin(), WaterList.end(), WaterBB); + if (IP != WaterList.end()) + NewWaterList.erase(WaterBB); + + // We are adding new water. Update NewWaterList. + NewWaterList.insert(NewIsland); + } + + // Remove the original WaterList entry; we want subsequent insertions in + // this vicinity to go after the one we're about to insert. This + // considerably reduces the number of times we have to move the same CPE + // more than once and is also important to ensure the algorithm terminates. + if (IP != WaterList.end()) + WaterList.erase(IP); // Okay, we know we can put an island before NewMBB now, do it! - MachineBasicBlock *NewIsland = MF.CreateMachineBasicBlock(); MF.insert(NewMBB, NewIsland); // Update internal data structures to account for the newly inserted MBB. From jyasskin at gmail.com Thu Oct 15 16:15:50 2009 From: jyasskin at gmail.com (jyasskin at gmail.com) Date: Thu, 15 Oct 2009 21:15:50 +0000 Subject: [llvm-commits] [PATCH] Allow Module deletion after function compiled. Message-ID: <0016e640d40ea96dff0475ffc8c8@google.com> Reviewers: , Message: Patch at http://codereview.appspot.com/download/issue133043_1.diff Description: Fix http://llvm.org/PR4822: allow module deletion after function compiled. When functions are compiled, they accumulate references in the JITResolver's stub maps. This patch removes those references when the functions are destroyed. It's illegal to destroy a Function when any thread may still try to call its machine code. TODO: Write a ValueMap<> class instead of all these CallbackVH subclasses and explicit constructor calls. This depends on http://codereview.appspot.com/130080 Please review this at http://codereview.appspot.com/133043 Affected files: M lib/ExecutionEngine/JIT/JITEmitter.cpp M unittests/ExecutionEngine/JIT/JITTest.cpp M unittests/ExecutionEngine/JIT/Makefile From johnny.chen at apple.com Thu Oct 15 16:32:10 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 15 Oct 2009 14:32:10 -0700 Subject: [llvm-commits] Typo in Neon Long 3-argument intrinsics Message-ID: <1E2F6D23-4081-4E18-9E35-7C8DC791F13C@apple.com> Hi, Typo for element size of 8 bits: multiclass N3VLInt3_QHS's op21_20 should be 0b00, not 0b01. -------------- next part -------------- A non-text attachment was scrubbed... Name: ARMInstrNEON.td.patch3 Type: application/octet-stream Size: 638 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091015/2af9c898/attachment.obj From enderby at apple.com Thu Oct 15 16:42:46 2009 From: enderby at apple.com (Kevin Enderby) Date: Thu, 15 Oct 2009 21:42:46 -0000 Subject: [llvm-commits] [llvm] r84205 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <200910152142.n9FLglDV025942@zion.cs.uiuc.edu> Author: enderby Date: Thu Oct 15 16:42:45 2009 New Revision: 84205 URL: http://llvm.org/viewvc/llvm-project?rev=84205&view=rev Log: Fix ARM memory operand parsing of post indexing with just a base register, that is just "[Rn]" and no tailing comma with an offset, etc. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=84205&r1=84204&r2=84205&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Thu Oct 15 16:42:45 2009 @@ -383,50 +383,55 @@ Writeback = true; getLexer().Lex(); // Eat right bracket token. - const AsmToken &CommaTok = getLexer().getTok(); - if (CommaTok.isNot(AsmToken::Comma)) - return Error(CommaTok.getLoc(), "',' expected"); - getLexer().Lex(); // Eat comma token. - - const AsmToken &NextTok = getLexer().getTok(); - if (NextTok.is(AsmToken::Plus)) - getLexer().Lex(); // Eat plus token. - else if (NextTok.is(AsmToken::Minus)) { - Negative = true; - getLexer().Lex(); // Eat minus token - } - - // See if there is a register following the "[Rn]," we have so far. - const AsmToken &OffsetRegTok = getLexer().getTok(); - int OffsetRegNum = MatchRegisterName(OffsetRegTok.getString()); + int OffsetRegNum = 0; bool OffsetRegShifted = false; enum ShiftType ShiftType; const MCExpr *ShiftAmount; const MCExpr *Offset; - if (OffsetRegNum != -1) { - OffsetIsReg = true; - getLexer().Lex(); // Eat identifier token for the offset register. - // Look for a comma then a shift - const AsmToken &Tok = getLexer().getTok(); - if (Tok.is(AsmToken::Comma)) { - getLexer().Lex(); // Eat comma token. - - const AsmToken &Tok = getLexer().getTok(); - if (ParseShift(&ShiftType, ShiftAmount)) - return Error(Tok.getLoc(), "shift expected"); - OffsetRegShifted = true; + + const AsmToken &NextTok = getLexer().getTok(); + if (NextTok.isNot(AsmToken::EndOfStatement)) { + if (NextTok.isNot(AsmToken::Comma)) + return Error(NextTok.getLoc(), "',' expected"); + getLexer().Lex(); // Eat comma token. + + const AsmToken &PlusMinusTok = getLexer().getTok(); + if (PlusMinusTok.is(AsmToken::Plus)) + getLexer().Lex(); // Eat plus token. + else if (PlusMinusTok.is(AsmToken::Minus)) { + Negative = true; + getLexer().Lex(); // Eat minus token } - } - else { // "[Rn]," we have so far was not followed by "Rm" - // Look for #offset following the "[Rn]," - const AsmToken &HashTok = getLexer().getTok(); - if (HashTok.isNot(AsmToken::Hash)) - return Error(HashTok.getLoc(), "'#' expected"); - getLexer().Lex(); // Eat hash token. - if (getParser().ParseExpression(Offset)) - return true; + // See if there is a register following the "[Rn]," we have so far. + const AsmToken &OffsetRegTok = getLexer().getTok(); + OffsetRegNum = MatchRegisterName(OffsetRegTok.getString()); + if (OffsetRegNum != -1) { + OffsetIsReg = true; + getLexer().Lex(); // Eat identifier token for the offset register. + // Look for a comma then a shift + const AsmToken &Tok = getLexer().getTok(); + if (Tok.is(AsmToken::Comma)) { + getLexer().Lex(); // Eat comma token. + + const AsmToken &Tok = getLexer().getTok(); + if (ParseShift(&ShiftType, ShiftAmount)) + return Error(Tok.getLoc(), "shift expected"); + OffsetRegShifted = true; + } + } + else { // "[Rn]," we have so far was not followed by "Rm" + // Look for #offset following the "[Rn]," + const AsmToken &HashTok = getLexer().getTok(); + if (HashTok.isNot(AsmToken::Hash)) + return Error(HashTok.getLoc(), "'#' expected"); + getLexer().Lex(); // Eat hash token. + + if (getParser().ParseExpression(Offset)) + return true; + } } + Op = ARMOperand::CreateMem(BaseRegNum, OffsetIsReg, Offset, OffsetRegNum, OffsetRegShifted, ShiftType, ShiftAmount, Preindexed, Postindexed, Negative, Writeback); From sabre at nondot.org Thu Oct 15 16:45:59 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 15 Oct 2009 16:45:59 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910152145.n9FLjxNV026088@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.26 -> 1.27 --- Log message: grammar --- Diffs of the changes: (+2 -2) index.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.26 llvm-www/devmtg/2009-10/index.html:1.27 --- llvm-www/devmtg/2009-10/index.html:1.26 Thu Oct 15 14:45:12 2009 +++ llvm-www/devmtg/2009-10/index.html Thu Oct 15 16:44:17 2009 @@ -41,7 +41,7 @@ major LLVM subsystems and talks on applications of LLVM for various specific projects.

        -

        This pages lists all of the slides and videos for all of the talks of the +

        This page lists all of the slides and videos for all of the talks of the day. The talks were held in two rooms - in one room we only were able to record a screencast, in the other room we have full video. Please note that the 'mobile' versions of the videos are actually larger (in file size) and @@ -283,7 +283,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
        Last modified: $Date: 2009/10/15 19:45:12 $ +
        Last modified: $Date: 2009/10/15 21:44:17 $ From bob.wilson at apple.com Thu Oct 15 16:57:49 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 15 Oct 2009 21:57:49 -0000 Subject: [llvm-commits] [llvm] r84206 - /llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Message-ID: <200910152157.n9FLvngc026480@zion.cs.uiuc.edu> Author: bwilson Date: Thu Oct 15 16:57:47 2009 New Revision: 84206 URL: http://llvm.org/viewvc/llvm-project?rev=84206&view=rev Log: Fix encoding bits for N3VLInt3_QHS multiclass with 8-bit elements. Patch by Johnny Chen. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=84206&r1=84205&r2=84206&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Thu Oct 15 16:57:47 2009 @@ -1381,7 +1381,7 @@ multiclass N3VLInt3_QHS op11_8, bit op4, string OpcodeStr, Intrinsic IntOp> : N3VLInt3_HS { - def v8i16 : N3VLInt3; } From bob.wilson at apple.com Thu Oct 15 16:55:41 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 15 Oct 2009 14:55:41 -0700 Subject: [llvm-commits] Typo in Neon Long 3-argument intrinsics In-Reply-To: <1E2F6D23-4081-4E18-9E35-7C8DC791F13C@apple.com> References: <1E2F6D23-4081-4E18-9E35-7C8DC791F13C@apple.com> Message-ID: <9EE76EA7-9B9A-4BF6-970E-1969BF7B42B4@apple.com> Applied. Thanks! On Oct 15, 2009, at 2:32 PM, Johnny Chen wrote: > Hi, > > Typo for element size of 8 bits: > > multiclass N3VLInt3_QHS's op21_20 should be 0b00, not 0b01. > > > < > ARMInstrNEON.td.patch3>_______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From deeppatel1987 at gmail.com Thu Oct 15 17:25:32 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Thu, 15 Oct 2009 22:25:32 -0000 Subject: [llvm-commits] [llvm] r84212 - in /llvm/trunk: lib/Target/ARM/Thumb2ITBlockPass.cpp test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll Message-ID: <200910152225.n9FMPWt7027457@zion.cs.uiuc.edu> Author: sandeep Date: Thu Oct 15 17:25:32 2009 New Revision: 84212 URL: http://llvm.org/viewvc/llvm-project?rev=84212&view=rev Log: Branches must be the last instruction in a Thumb2 IT block. Approved by Evan Cheng. Added: llvm/trunk/test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll Modified: llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp Modified: llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp?rev=84212&r1=84211&r2=84212&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2ITBlockPass.cpp Thu Oct 15 17:25:32 2009 @@ -107,8 +107,12 @@ // Finalize IT mask. ARMCC::CondCodes OCC = ARMCC::getOppositeCondition(CC); unsigned Mask = 0, Pos = 3; - while (MBBI != E && Pos) { + // Branches, including tricky ones like LDM_RET, need to end an IT + // block so check the instruction we just put in the block. + while (MBBI != E && Pos && + (!MI->getDesc().isBranch() && !MI->getDesc().isReturn())) { MachineInstr *NMI = &*MBBI; + MI = NMI; DebugLoc ndl = NMI->getDebugLoc(); unsigned NPredReg = 0; ARMCC::CondCodes NCC = getPredicate(NMI, NPredReg); Added: llvm/trunk/test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll?rev=84212&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll Thu Oct 15 17:25:32 2009 @@ -0,0 +1,44 @@ +; RUN: llc < %s -mtriple=thumbv7-eabi -mcpu=cortex-a8 -float-abi=hard | FileCheck %s + +; A fix for PR5204 will require this check to be changed. + +%"struct.__gnu_cxx::__normal_iterator, std::allocator > >" = type { i8* } +%"struct.__gnu_cxx::new_allocator" = type <{ i8 }> +%"struct.std::basic_string,std::allocator >" = type { %"struct.__gnu_cxx::__normal_iterator, std::allocator > >" } +%"struct.std::basic_string,std::allocator >::_Rep" = type { %"struct.std::basic_string,std::allocator >::_Rep_base" } +%"struct.std::basic_string,std::allocator >::_Rep_base" = type { i32, i32, i32 } + + +define weak arm_aapcs_vfpcc i32 @_ZNKSs7compareERKSs(%"struct.std::basic_string,std::allocator >"* %this, %"struct.std::basic_string,std::allocator >"* %__str) { +; CHECK: _ZNKSs7compareERKSs: +; CHECK: it ne +; CHECK-NEXT: ldmfdne.w +; CHECK-NEXT: itt eq +; CHECK-NEXT: subeq.w +; CHECK-NEXT: ldmfdeq.w +entry: + %0 = tail call arm_aapcs_vfpcc i32 @_ZNKSs4sizeEv(%"struct.std::basic_string,std::allocator >"* %this) ; [#uses=3] + %1 = tail call arm_aapcs_vfpcc i32 @_ZNKSs4sizeEv(%"struct.std::basic_string,std::allocator >"* %__str) ; [#uses=3] + %2 = icmp ult i32 %1, %0 ; [#uses=1] + %3 = select i1 %2, i32 %1, i32 %0 ; [#uses=1] + %4 = tail call arm_aapcs_vfpcc i8* @_ZNKSs7_M_dataEv(%"struct.std::basic_string,std::allocator >"* %this) ; [#uses=1] + %5 = tail call arm_aapcs_vfpcc i8* @_ZNKSs4dataEv(%"struct.std::basic_string,std::allocator >"* %__str) ; [#uses=1] + %6 = tail call arm_aapcs_vfpcc i32 @memcmp(i8* %4, i8* %5, i32 %3) nounwind readonly ; [#uses=2] + %7 = icmp eq i32 %6, 0 ; [#uses=1] + br i1 %7, label %bb, label %bb1 + +bb: ; preds = %entry + %8 = sub i32 %0, %1 ; [#uses=1] + ret i32 %8 + +bb1: ; preds = %entry + ret i32 %6 +} + +declare arm_aapcs_vfpcc i32 @memcmp(i8* nocapture, i8* nocapture, i32) nounwind readonly + +declare arm_aapcs_vfpcc i32 @_ZNKSs4sizeEv(%"struct.std::basic_string,std::allocator >"* %this) + +declare arm_aapcs_vfpcc i8* @_ZNKSs7_M_dataEv(%"struct.std::basic_string,std::allocator >"* %this) + +declare arm_aapcs_vfpcc i8* @_ZNKSs4dataEv(%"struct.std::basic_string,std::allocator >"* %this) From asl at math.spbu.ru Thu Oct 15 17:36:22 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Thu, 15 Oct 2009 22:36:22 -0000 Subject: [llvm-commits] [llvm] r84214 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Message-ID: <200910152236.n9FMaNFn027877@zion.cs.uiuc.edu> Author: asl Date: Thu Oct 15 17:36:18 2009 New Revision: 84214 URL: http://llvm.org/viewvc/llvm-project?rev=84214&view=rev Log: Dllexport stuff cleanup: 1. Emit external function type information for all COFF targets since it's a feature of object format 2. Emit linker directives only for cygming (since this is ld-specific stuff) Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=84214&r1=84213&r2=84214&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Thu Oct 15 17:36:18 2009 @@ -225,7 +225,7 @@ std::string Name = Mang->getMangledName(GV, Suffix, Suffix[0] != '\0'); if (Subtarget->isTargetCygMing()) { - X86COFFMachineModuleInfo &COFFMMI = + X86COFFMachineModuleInfo &COFFMMI = MMI->getObjFileInfo(); COFFMMI.DecorateCygMingName(Name, GV, *TM.getTargetData()); } @@ -871,48 +871,54 @@ // linker can safely perform dead code stripping. Since LLVM never // generates code that does this, it is always safe to set. O << "\t.subsections_via_symbols\n"; - } - - if (Subtarget->isTargetCOFF()) { - // Necessary for dllexport support - std::vector DLLExportedFns, DLLExportedGlobals; + } - X86COFFMachineModuleInfo &COFFMMI = + if (Subtarget->isTargetCOFF()) { + X86COFFMachineModuleInfo &COFFMMI = MMI->getObjFileInfo(); - TargetLoweringObjectFileCOFF &TLOFCOFF = - static_cast(getObjFileLowering()); - for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I) - if (I->hasDLLExportLinkage()) - DLLExportedFns.push_back(Mang->getMangledName(I)); - - for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) - if (I->hasDLLExportLinkage()) - DLLExportedGlobals.push_back(Mang->getMangledName(I)); - - if (Subtarget->isTargetCygMing()) { - // Emit type information for external functions - for (X86COFFMachineModuleInfo::stub_iterator I = COFFMMI.stub_begin(), + // Emit type information for external functions + for (X86COFFMachineModuleInfo::stub_iterator I = COFFMMI.stub_begin(), E = COFFMMI.stub_end(); I != E; ++I) { - O << "\t.def\t " << I->getKeyData() + O << "\t.def\t " << I->getKeyData() << ";\t.scl\t" << COFF::C_EXT << ";\t.type\t" << (COFF::DT_FCN << COFF::N_BTSHFT) << ";\t.endef\n"; - } } - - // Output linker support code for dllexported globals on windows. - if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) { - OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve", - true, + + if (Subtarget->isTargetCygMing()) { + // Necessary for dllexport support + std::vector DLLExportedFns, DLLExportedGlobals; + + TargetLoweringObjectFileCOFF &TLOFCOFF = + static_cast(getObjFileLowering()); + + for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I) + if (I->hasDLLExportLinkage()) { + std::string Name = Mang->getMangledName(I); + COFFMMI.DecorateCygMingName(Name, I, *TM.getTargetData()); + DLLExportedFns.push_back(Name); + } + + for (Module::const_global_iterator I = M.global_begin(), + E = M.global_end(); I != E; ++I) + if (I->hasDLLExportLinkage()) { + std::string Name = Mang->getMangledName(I); + COFFMMI.DecorateCygMingName(Name, I, *TM.getTargetData()); + DLLExportedGlobals.push_back(Mang->getMangledName(I)); + } + + // Output linker support code for dllexported globals on windows. + if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) { + OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve", + true, SectionKind::getMetadata())); - - for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i) - O << "\t.ascii \" -export:" << DLLExportedGlobals[i] << ",data\"\n"; - - for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i) - O << "\t.ascii \" -export:" << DLLExportedFns[i] << "\"\n"; + for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i) + O << "\t.ascii \" -export:" << DLLExportedGlobals[i] << ",data\"\n"; + + for (unsigned i = 0, e = DLLExportedFns.size(); i != e; ++i) + O << "\t.ascii \" -export:" << DLLExportedFns[i] << "\"\n"; + } } } } From bob.wilson at apple.com Thu Oct 15 18:12:06 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 15 Oct 2009 23:12:06 -0000 Subject: [llvm-commits] [llvm] r84218 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <200910152312.n9FNC64V029092@zion.cs.uiuc.edu> Author: bwilson Date: Thu Oct 15 18:12:05 2009 New Revision: 84218 URL: http://llvm.org/viewvc/llvm-project?rev=84218&view=rev Log: Revert svn r80498 and replace it with a different solution. The only problem I can see with the original code was that I forgot that this runs after type legalization and hence the result type will always be i32. (Custom legalization of EXTRACT_VECTOR_ELT is only enabled for vector types with 8- and 16-bit elements.) Regarding the FIXME comment: any information about sign and zero-extension should be captured by separate extension operations. The DAG combiner should handle those to produce either VGETLANEu or VGETLANEs, and that seems to be working now. If there are cases that we're missing, let me know. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=84218&r1=84217&r2=84218&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Oct 15 18:12:05 2009 @@ -2695,18 +2695,10 @@ DebugLoc dl = Op.getDebugLoc(); SDValue Vec = Op.getOperand(0); SDValue Lane = Op.getOperand(1); - - // FIXME: This is invalid for 8 and 16-bit elements - the information about - // sign / zero extension is lost! - Op = DAG.getNode(ARMISD::VGETLANEu, dl, MVT::i32, Vec, Lane); - Op = DAG.getNode(ISD::AssertZext, dl, MVT::i32, Op, DAG.getValueType(VT)); - - if (VT.bitsLT(MVT::i32)) - Op = DAG.getNode(ISD::TRUNCATE, dl, VT, Op); - else if (VT.bitsGT(MVT::i32)) - Op = DAG.getNode(ISD::ANY_EXTEND, dl, VT, Op); - - return Op; + assert(VT == MVT::i32 && + Vec.getValueType().getVectorElementType().getSizeInBits() < 32 && + "unexpected type for custom-lowering vector extract"); + return DAG.getNode(ARMISD::VGETLANEu, dl, MVT::i32, Vec, Lane); } static SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) { From evan.cheng at apple.com Thu Oct 15 19:33:09 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 16 Oct 2009 00:33:09 -0000 Subject: [llvm-commits] [llvm] r84226 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200910160033.n9G0X9BM031841@zion.cs.uiuc.edu> Author: evancheng Date: Thu Oct 15 19:33:09 2009 New Revision: 84226 URL: http://llvm.org/viewvc/llvm-project?rev=84226&view=rev Log: When checking aliases between phi sources and V2, we know the sources are not themselves phi nodes. However, V2 may be. Call aliasCheck with V2 first to potentially eliminate a std::swap call. Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84226&r1=84225&r2=84226&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Thu Oct 15 19:33:09 2009 @@ -222,7 +222,7 @@ private: // VisitedPHIs - Track PHI nodes visited by a aliasCheck() call. - SmallSet VisitedPHIs; + SmallPtrSet VisitedPHIs; // aliasGEP - Provide a bunch of ad-hoc rules to disambiguate a GEP instruction // against another. @@ -533,7 +533,7 @@ if (!VisitedPHIs.insert(PN)) return MayAlias; - SmallSet UniqueSrc; + SmallPtrSet UniqueSrc; SmallVector V1Srcs; for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { Value *PV1 = PN->getIncomingValue(i); @@ -557,7 +557,7 @@ // NoAlias / MustAlias. Otherwise, returns MayAlias. for (unsigned i = 1, e = V1Srcs.size(); i != e; ++i) { Value *V = V1Srcs[i]; - AliasResult ThisAlias = aliasCheck(V, PNSize, V2, V2Size); + AliasResult ThisAlias = aliasCheck(V2, V2Size, V, PNSize); if (ThisAlias != Alias || ThisAlias == MayAlias) return MayAlias; } From johnny.chen at apple.com Thu Oct 15 19:55:09 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 15 Oct 2009 17:55:09 -0700 Subject: [llvm-commits] Fix typo of ARM Neon's VABAs and VABAu (Vector Absolute Difference and Accumulate) Message-ID: <2A76CF12-BC4D-4631-9B40-F794613C9E22@apple.com> Hi, Refs: A7-13 & A8-526 Probably the chip designer wants to distinguish VABA and VABD of three registers of the same length not with Instr{11-8}, but with only Instr{4}. But then, for three registers of different lengths, VABAL and VABDL has different Instr{11-8}, but with Instr{4}=0. Ref: A7-15. -------------- next part -------------- A non-text attachment was scrubbed... Name: ARMInstrNEON.td.patch4 Type: application/octet-stream Size: 839 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091015/fa8f0aa8/attachment.obj From daniel at zuster.org Thu Oct 15 20:33:11 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 16 Oct 2009 01:33:11 -0000 Subject: [llvm-commits] [llvm] r84228 - in /llvm/trunk: include/llvm/MC/MCContext.h lib/MC/MCContext.cpp lib/MC/MCExpr.cpp Message-ID: <200910160133.n9G1XCqn001315@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Oct 15 20:33:11 2009 New Revision: 84228 URL: http://llvm.org/viewvc/llvm-project?rev=84228&view=rev Log: MC: Switch MCContext value table to storing MCExprs. Modified: llvm/trunk/include/llvm/MC/MCContext.h llvm/trunk/lib/MC/MCContext.cpp llvm/trunk/lib/MC/MCExpr.cpp Modified: llvm/trunk/include/llvm/MC/MCContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=84228&r1=84227&r2=84228&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCContext.h (original) +++ llvm/trunk/include/llvm/MC/MCContext.h Thu Oct 15 20:33:11 2009 @@ -15,7 +15,7 @@ #include "llvm/Support/Allocator.h" namespace llvm { - class MCValue; + class MCExpr; class MCSection; class MCSymbol; class StringRef; @@ -36,7 +36,7 @@ /// SymbolValues - Bindings of symbols to values. // // FIXME: Is there a good reason to not just put this in the MCSymbol? - DenseMap SymbolValues; + DenseMap SymbolValues; /// Allocator - Allocator object used for creating machine code objects. /// @@ -63,7 +63,7 @@ /// @param IsTemporary - Whether this symbol is an assembler temporary, /// which should not survive into the symbol table for the translation unit. MCSymbol *GetOrCreateSymbol(const StringRef &Name); - + /// CreateTemporarySymbol - Create a new temporary symbol with the specified /// @param Name. /// @@ -79,22 +79,30 @@ /// @name Symbol Value Table /// @{ - /// ClearSymbolValue - Erase a value binding for @arg Symbol, if one exists. - void ClearSymbolValue(const MCSymbol *Symbol); + /// ClearSymbolValue - Erase the variable binding for @arg Symbol, if one + /// exists. + void ClearSymbolValue(const MCSymbol *Symbol) { + SymbolValues.erase(Symbol); + } - /// SetSymbolValue - Set the value binding for @arg Symbol to @arg Value. - void SetSymbolValue(const MCSymbol *Symbol, const MCValue &Value); + /// SetSymbolValue - Set the variable binding for @arg Symbol to @arg Value. + void SetSymbolValue(const MCSymbol *Symbol, const MCExpr *Value) { + assert(Value && "Invalid variable assignment!"); + SymbolValues.insert(std::make_pair(Symbol, Value)); + } - /// GetSymbolValue - Return the current value for @arg Symbol, or null if - /// none exists. - const MCValue *GetSymbolValue(const MCSymbol *Symbol) const; + /// GetSymbolValue - Return the current variable value for @arg Symbol, or + /// null if @arg Symbol is not a variable. + const MCExpr *GetSymbolValue(const MCSymbol *Symbol) const { + return SymbolValues.lookup(Symbol); + } /// @} void *Allocate(unsigned Size, unsigned Align = 8) { return Allocator.Allocate(Size, Align); } - void Deallocate(void *Ptr) { + void Deallocate(void *Ptr) { } }; Modified: llvm/trunk/lib/MC/MCContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=84228&r1=84227&r2=84228&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCContext.cpp (original) +++ llvm/trunk/lib/MC/MCContext.cpp Thu Oct 15 20:33:11 2009 @@ -52,20 +52,3 @@ MCSymbol *MCContext::LookupSymbol(const StringRef &Name) const { return Symbols.lookup(Name); } - -void MCContext::ClearSymbolValue(const MCSymbol *Sym) { - SymbolValues.erase(Sym); -} - -void MCContext::SetSymbolValue(const MCSymbol *Sym, const MCValue &Value) { - SymbolValues[Sym] = Value; -} - -const MCValue *MCContext::GetSymbolValue(const MCSymbol *Sym) const { - DenseMap::iterator it = SymbolValues.find(Sym); - - if (it == SymbolValues.end()) - return 0; - - return &it->second; -} Modified: llvm/trunk/lib/MC/MCExpr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=84228&r1=84227&r2=84228&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCExpr.cpp (original) +++ llvm/trunk/lib/MC/MCExpr.cpp Thu Oct 15 20:33:11 2009 @@ -181,10 +181,9 @@ case SymbolRef: { const MCSymbol &Sym = cast(this)->getSymbol(); - if (const MCValue *Value = Ctx.GetSymbolValue(&Sym)) - Res = *Value; - else - Res = MCValue::get(&Sym, 0, 0); + if (const MCExpr *Value = Ctx.GetSymbolValue(&Sym)) + return Value->EvaluateAsRelocatable(Ctx, Res); + Res = MCValue::get(&Sym, 0, 0); return true; } From daniel at zuster.org Thu Oct 15 20:33:57 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 16 Oct 2009 01:33:57 -0000 Subject: [llvm-commits] [llvm] r84229 - in /llvm/trunk: include/llvm/MC/MCContext.h include/llvm/MC/MCSymbol.h lib/MC/MCExpr.cpp Message-ID: <200910160133.n9G1XvAW001348@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Oct 15 20:33:57 2009 New Revision: 84229 URL: http://llvm.org/viewvc/llvm-project?rev=84229&view=rev Log: MC: Move assembler variable values from MCContext to MCSymbol. Modified: llvm/trunk/include/llvm/MC/MCContext.h llvm/trunk/include/llvm/MC/MCSymbol.h llvm/trunk/lib/MC/MCExpr.cpp Modified: llvm/trunk/include/llvm/MC/MCContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=84229&r1=84228&r2=84229&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCContext.h (original) +++ llvm/trunk/include/llvm/MC/MCContext.h Thu Oct 15 20:33:57 2009 @@ -33,11 +33,6 @@ /// Symbols - Bindings of names to symbols. StringMap Symbols; - /// SymbolValues - Bindings of symbols to values. - // - // FIXME: Is there a good reason to not just put this in the MCSymbol? - DenseMap SymbolValues; - /// Allocator - Allocator object used for creating machine code objects. /// /// We use a bump pointer allocator to avoid the need to track all allocated @@ -76,28 +71,6 @@ MCSymbol *LookupSymbol(const StringRef &Name) const; /// @} - /// @name Symbol Value Table - /// @{ - - /// ClearSymbolValue - Erase the variable binding for @arg Symbol, if one - /// exists. - void ClearSymbolValue(const MCSymbol *Symbol) { - SymbolValues.erase(Symbol); - } - - /// SetSymbolValue - Set the variable binding for @arg Symbol to @arg Value. - void SetSymbolValue(const MCSymbol *Symbol, const MCExpr *Value) { - assert(Value && "Invalid variable assignment!"); - SymbolValues.insert(std::make_pair(Symbol, Value)); - } - - /// GetSymbolValue - Return the current variable value for @arg Symbol, or - /// null if @arg Symbol is not a variable. - const MCExpr *GetSymbolValue(const MCSymbol *Symbol) const { - return SymbolValues.lookup(Symbol); - } - - /// @} void *Allocate(unsigned Size, unsigned Align = 8) { return Allocator.Allocate(Size, Align); Modified: llvm/trunk/include/llvm/MC/MCSymbol.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=84229&r1=84228&r2=84229&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCSymbol.h (original) +++ llvm/trunk/include/llvm/MC/MCSymbol.h Thu Oct 15 20:33:57 2009 @@ -20,6 +20,7 @@ namespace llvm { class MCAsmInfo; + class MCExpr; class MCSection; class MCContext; class raw_ostream; @@ -45,6 +46,9 @@ /// absolute symbols. const MCSection *Section; + /// Value - If non-null, the value for a variable symbol. + const MCExpr *Value; + /// IsTemporary - True if this is an assembler temporary label, which /// typically does not survive in the .o file's symbol table. Usually /// "Lfoo" or ".foo". @@ -52,9 +56,9 @@ private: // MCContext creates and uniques these. friend class MCContext; - MCSymbol(const StringRef &_Name, bool _IsTemporary) - : Name(_Name), Section(0), IsTemporary(_IsTemporary) {} - + MCSymbol(const StringRef &_Name, bool _IsTemporary) + : Name(_Name), Section(0), Value(0), IsTemporary(_IsTemporary) {} + MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT void operator=(const MCSymbol&); // DO NOT IMPLEMENT public: @@ -69,6 +73,10 @@ return IsTemporary; } + /// @} + /// @name Associated Sections + /// @{ + /// isDefined - Check if this symbol is defined (i.e., it has an address). /// /// Defined symbols are either absolute or in some section. @@ -105,6 +113,23 @@ void setAbsolute() { Section = AbsolutePseudoSection; } /// @} + /// @name Variable Symbols + /// @{ + + /// isVariable - Check if this is a variable symbol. + bool isVariable() const { + return Value != 0; + } + + /// getValue() - Get the value for variable symbols, or null if the symbol + /// is not a variable. + const MCExpr *getValue() const { return Value; } + + void setValue(const MCExpr *Value) { + this->Value = Value; + } + + /// @} /// print - Print the value to the stream \arg OS. void print(raw_ostream &OS, const MCAsmInfo *MAI) const; Modified: llvm/trunk/lib/MC/MCExpr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=84229&r1=84228&r2=84229&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCExpr.cpp (original) +++ llvm/trunk/lib/MC/MCExpr.cpp Thu Oct 15 20:33:57 2009 @@ -181,8 +181,11 @@ case SymbolRef: { const MCSymbol &Sym = cast(this)->getSymbol(); - if (const MCExpr *Value = Ctx.GetSymbolValue(&Sym)) - return Value->EvaluateAsRelocatable(Ctx, Res); + + // Evaluate recursively if this is a variable. + if (Sym.isVariable()) + return Sym.getValue()->EvaluateAsRelocatable(Ctx, Res); + Res = MCValue::get(&Sym, 0, 0); return true; } From daniel at zuster.org Thu Oct 15 20:34:54 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 16 Oct 2009 01:34:54 -0000 Subject: [llvm-commits] [llvm] r84230 - in /llvm/trunk: lib/MC/MCAsmStreamer.cpp test/MC/AsmParser/labels.s test/MC/AsmParser/variables.s tools/llvm-mc/AsmParser.cpp Message-ID: <200910160134.n9G1Ysl9001398@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Oct 15 20:34:54 2009 New Revision: 84230 URL: http://llvm.org/viewvc/llvm-project?rev=84230&view=rev Log: MC: When parsing a variable reference, substitute absolute variables immediately since they are allowed to be redefined. Added: llvm/trunk/test/MC/AsmParser/variables.s Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/test/MC/AsmParser/labels.s llvm/trunk/tools/llvm-mc/AsmParser.cpp Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=84230&r1=84229&r2=84230&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Thu Oct 15 20:34:54 2009 @@ -123,9 +123,12 @@ OS << " = "; Value->print(OS, &MAI); OS << '\n'; + + // FIXME: Lift context changes into super class. + Symbol->setValue(Value); } -void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol, +void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol, SymbolAttr Attribute) { switch (Attribute) { case Global: OS << ".globl"; break; Modified: llvm/trunk/test/MC/AsmParser/labels.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/labels.s?rev=84230&r1=84229&r2=84230&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/labels.s (original) +++ llvm/trunk/test/MC/AsmParser/labels.s Thu Oct 15 20:34:54 2009 @@ -12,21 +12,21 @@ .long 0 .text -foo: +foo: // CHECK: addl $24, a$b(%eax) - addl $24, "a$b"(%eax) + addl $24, "a$b"(%eax) // CHECK: addl $24, a$b+10(%eax) addl $24, ("a$b" + 10)(%eax) - + // CHECK: b$c = 10 "b$c" = 10 -// CHECK: addl $b$c, %eax +// CHECK: addl $10, %eax addl "b$c", %eax - + // CHECK: "a 0" = 11 .set "a 0", 11 - -// CHECK: .long "a 0" + +// CHECK: .long 11 .long "a 0" // XXCHCK: .section "a 1,a 2" @@ -48,12 +48,12 @@ .lcomm "a 7", 1 // FIXME: We don't bother to support .lsym. - + // CHECX: .lsym "a 8",1 // .lsym "a 8", 1 // CHECK: "a 9" = a-b .set "a 9", a - b - + // CHECK: .long "a 9" .long "a 9" Added: llvm/trunk/test/MC/AsmParser/variables.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/variables.s?rev=84230&view=auto ============================================================================== --- llvm/trunk/test/MC/AsmParser/variables.s (added) +++ llvm/trunk/test/MC/AsmParser/variables.s Thu Oct 15 20:34:54 2009 @@ -0,0 +1,15 @@ +// RUN: llvm-mc %s + + .data + t0_v0 = 1 + t0_v1 = t0_v0 + .if t0_v1 != 1 + .abort "invalid value" + .endif + + t1_v0 = 1 + t1_v1 = t0_v0 + t1_v0 = 2 + .if t0_v1 != 1 + .abort "invalid value" + .endif Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=84230&r1=84229&r2=84230&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Thu Oct 15 20:34:54 2009 @@ -21,6 +21,7 @@ #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/MC/MCValue.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetAsmParser.h" @@ -220,12 +221,22 @@ Res = MCUnaryExpr::CreateLNot(Res, getContext()); return false; case AsmToken::String: - case AsmToken::Identifier: - // This is a label, this should be parsed as part of an expression, to - // handle things like LFOO+4. - Res = MCSymbolRefExpr::Create(Lexer.getTok().getIdentifier(), getContext()); + case AsmToken::Identifier: { + // This is a symbol reference. + MCSymbol *Sym = CreateSymbol(Lexer.getTok().getIdentifier()); Lexer.Lex(); // Eat identifier. + + // If this is an absolute variable reference, substitute it now to preserve + // semantics in the face of reassignment. + if (Sym->getValue() && isa(Sym->getValue())) { + Res = Sym->getValue(); + return false; + } + + // Otherwise create a symbol ref. + Res = MCSymbolRefExpr::Create(Sym, getContext()); return false; + } case AsmToken::Integer: Res = MCConstantExpr::Create(Lexer.getTok().getIntVal(), getContext()); Lexer.Lex(); // Eat token. From daniel at zuster.org Thu Oct 15 20:57:39 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 16 Oct 2009 01:57:39 -0000 Subject: [llvm-commits] [llvm] r84232 - in /llvm/trunk: lib/MC/MCAsmStreamer.cpp test/MC/AsmParser/variables-invalid.s tools/llvm-mc/AsmParser.cpp Message-ID: <200910160157.n9G1vd5C002244@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Oct 15 20:57:39 2009 New Revision: 84232 URL: http://llvm.org/viewvc/llvm-project?rev=84232&view=rev Log: MC: Tweak variable assignment diagnostics, and make reassignment of non-absolute variables and symbols invalid. Added: llvm/trunk/test/MC/AsmParser/variables-invalid.s Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/tools/llvm-mc/AsmParser.cpp Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=84232&r1=84231&r2=84232&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Thu Oct 15 20:57:39 2009 @@ -125,6 +125,7 @@ OS << '\n'; // FIXME: Lift context changes into super class. + // FIXME: Set associated section. Symbol->setValue(Value); } Added: llvm/trunk/test/MC/AsmParser/variables-invalid.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/variables-invalid.s?rev=84232&view=auto ============================================================================== --- llvm/trunk/test/MC/AsmParser/variables-invalid.s (added) +++ llvm/trunk/test/MC/AsmParser/variables-invalid.s Thu Oct 15 20:57:39 2009 @@ -0,0 +1,17 @@ +// RUN: not llvm-mc %s 2> %t +// RUN: FileCheck --input-file %t %s + + .data +// CHECK: invalid assignment to 't0_v0' + t0_v0 = t0_v0 + 1 + + t1_v1 = 1 + t1_v1 = 2 + +t2_s0: +// CHECK: redefinition of 't2_s0' + t2_s0 = 2 + + t3_s0 = t2_s0 + 1 +// CHECK: invalid reassignment of non-absolute variable 't3_s0' + t3_s0 = 1 Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=84232&r1=84231&r2=84232&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Thu Oct 15 20:57:39 2009 @@ -741,14 +741,25 @@ // Eat the end of statement marker. Lexer.Lex(); - // Diagnose assignment to a label. - // - // FIXME: Diagnostics. Note the location of the definition as a label. + // Validate that the LHS is allowed to be a variable (either it has not been + // used as a symbol, or it is an absolute symbol). + MCSymbol *Sym = getContext().LookupSymbol(Name); + if (Sym) { + // Diagnose assignment to a label. + // + // FIXME: Diagnostics. Note the location of the definition as a label. + // FIXME: Diagnose assignment to protected identifier (e.g., register name). + if (!Sym->isUndefined() && !Sym->isAbsolute()) + return Error(EqualLoc, "redefinition of '" + Name + "'"); + else if (!Sym->isVariable()) + return Error(EqualLoc, "invalid assignment to '" + Name + "'"); + else if (!isa(Sym->getValue())) + return Error(EqualLoc, "invalid reassignment of non-absolute variable '" + + Name + "'"); + } else + Sym = CreateSymbol(Name); + // FIXME: Handle '.'. - // FIXME: Diagnose assignment to protected identifier (e.g., register name). - MCSymbol *Sym = CreateSymbol(Name); - if (!Sym->isUndefined() && !Sym->isAbsolute()) - return Error(EqualLoc, "symbol has already been defined"); // Do the assignment. Out.EmitAssignment(Sym, Value); From daniel at zuster.org Thu Oct 15 20:57:53 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 16 Oct 2009 01:57:53 -0000 Subject: [llvm-commits] [llvm] r84233 - in /llvm/trunk: include/llvm/MC/MCExpr.h lib/MC/MCExpr.cpp lib/MC/MCMachOStreamer.cpp tools/llvm-mc/AsmParser.cpp Message-ID: <200910160157.n9G1vrog002264@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Oct 15 20:57:52 2009 New Revision: 84233 URL: http://llvm.org/viewvc/llvm-project?rev=84233&view=rev Log: MC: Remove unneeded context argument to MCExpr::Evaluate*. Modified: llvm/trunk/include/llvm/MC/MCExpr.h llvm/trunk/lib/MC/MCExpr.cpp llvm/trunk/lib/MC/MCMachOStreamer.cpp llvm/trunk/tools/llvm-mc/AsmParser.cpp Modified: llvm/trunk/include/llvm/MC/MCExpr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=84233&r1=84232&r2=84233&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCExpr.h (original) +++ llvm/trunk/include/llvm/MC/MCExpr.h Thu Oct 15 20:57:52 2009 @@ -62,14 +62,14 @@ /// /// @param Res - The absolute value, if evaluation succeeds. /// @result - True on success. - bool EvaluateAsAbsolute(MCContext &Ctx, int64_t &Res) const; + bool EvaluateAsAbsolute(int64_t &Res) const; /// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable /// value, i.e. an expression of the fixed form (a - b + constant). /// /// @param Res - The relocatable value, if evaluation succeeds. /// @result - True on success. - bool EvaluateAsRelocatable(MCContext &Ctx, MCValue &Res) const; + bool EvaluateAsRelocatable(MCValue &Res) const; /// @} Modified: llvm/trunk/lib/MC/MCExpr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=84233&r1=84232&r2=84233&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCExpr.cpp (original) +++ llvm/trunk/lib/MC/MCExpr.cpp Thu Oct 15 20:57:52 2009 @@ -141,10 +141,10 @@ /* *** */ -bool MCExpr::EvaluateAsAbsolute(MCContext &Ctx, int64_t &Res) const { +bool MCExpr::EvaluateAsAbsolute(int64_t &Res) const { MCValue Value; - if (!EvaluateAsRelocatable(Ctx, Value) || !Value.isAbsolute()) + if (!EvaluateAsRelocatable(Value) || !Value.isAbsolute()) return false; Res = Value.getConstant(); @@ -173,7 +173,7 @@ return true; } -bool MCExpr::EvaluateAsRelocatable(MCContext &Ctx, MCValue &Res) const { +bool MCExpr::EvaluateAsRelocatable(MCValue &Res) const { switch (getKind()) { case Constant: Res = MCValue::get(cast(this)->getValue()); @@ -184,7 +184,7 @@ // Evaluate recursively if this is a variable. if (Sym.isVariable()) - return Sym.getValue()->EvaluateAsRelocatable(Ctx, Res); + return Sym.getValue()->EvaluateAsRelocatable(Res); Res = MCValue::get(&Sym, 0, 0); return true; @@ -194,7 +194,7 @@ const MCUnaryExpr *AUE = cast(this); MCValue Value; - if (!AUE->getSubExpr()->EvaluateAsRelocatable(Ctx, Value)) + if (!AUE->getSubExpr()->EvaluateAsRelocatable(Value)) return false; switch (AUE->getOpcode()) { @@ -227,8 +227,8 @@ const MCBinaryExpr *ABE = cast(this); MCValue LHSValue, RHSValue; - if (!ABE->getLHS()->EvaluateAsRelocatable(Ctx, LHSValue) || - !ABE->getRHS()->EvaluateAsRelocatable(Ctx, RHSValue)) + if (!ABE->getLHS()->EvaluateAsRelocatable(LHSValue) || + !ABE->getRHS()->EvaluateAsRelocatable(RHSValue)) return false; // We only support a few operations on non-constant expressions, handle Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=84233&r1=84232&r2=84233&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Thu Oct 15 20:57:52 2009 @@ -346,8 +346,7 @@ unsigned char Value) { MCValue RelocOffset; - if (!AddValueSymbols(Offset)->EvaluateAsRelocatable(getContext(), - RelocOffset)) + if (!AddValueSymbols(Offset)->EvaluateAsRelocatable(RelocOffset)) return llvm_report_error("expected relocatable expression"); new MCOrgFragment(RelocOffset, Value, CurSectionData); Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=84233&r1=84232&r2=84233&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original) +++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Thu Oct 15 20:57:52 2009 @@ -292,7 +292,7 @@ if (ParseExpression(Expr)) return true; - if (!Expr->EvaluateAsAbsolute(Ctx, Res)) + if (!Expr->EvaluateAsAbsolute(Res)) return Error(StartLoc, "expected absolute expression"); return false; From daniel at zuster.org Thu Oct 15 20:58:04 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 16 Oct 2009 01:58:04 -0000 Subject: [llvm-commits] [llvm] r84234 - in /llvm/trunk: include/llvm/MC/MCAssembler.h lib/MC/MCAssembler.cpp lib/MC/MCMachOStreamer.cpp Message-ID: <200910160158.n9G1w4Em002286@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Oct 15 20:58:03 2009 New Revision: 84234 URL: http://llvm.org/viewvc/llvm-project?rev=84234&view=rev Log: MC: Switch assembler API to using MCExpr instead of MCValue. Modified: llvm/trunk/include/llvm/MC/MCAssembler.h llvm/trunk/lib/MC/MCAssembler.cpp llvm/trunk/lib/MC/MCMachOStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCAssembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=84234&r1=84233&r2=84234&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAssembler.h (original) +++ llvm/trunk/include/llvm/MC/MCAssembler.h Thu Oct 15 20:58:03 2009 @@ -13,7 +13,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist_node.h" -#include "llvm/MC/MCValue.h" #include "llvm/Support/Casting.h" #include "llvm/Support/DataTypes.h" #include // FIXME: Shouldn't be needed. @@ -22,8 +21,10 @@ class raw_ostream; class MCAssembler; class MCContext; +class MCExpr; class MCSection; class MCSectionData; +class MCSymbol; class MCFragment : public ilist_node { MCFragment(const MCFragment&); // DO NOT IMPLEMENT @@ -174,7 +175,7 @@ class MCFillFragment : public MCFragment { /// Value - Value to use for filling bytes. - MCValue Value; + const MCExpr *Value; /// ValueSize - The size (in bytes) of \arg Value to use when filling. unsigned ValueSize; @@ -183,10 +184,10 @@ uint64_t Count; public: - MCFillFragment(MCValue _Value, unsigned _ValueSize, uint64_t _Count, + MCFillFragment(const MCExpr &_Value, unsigned _ValueSize, uint64_t _Count, MCSectionData *SD = 0) : MCFragment(FT_Fill, SD), - Value(_Value), ValueSize(_ValueSize), Count(_Count) {} + Value(&_Value), ValueSize(_ValueSize), Count(_Count) {} /// @name Accessors /// @{ @@ -195,7 +196,7 @@ return ValueSize * Count; } - MCValue getValue() const { return Value; } + const MCExpr &getValue() const { return *Value; } unsigned getValueSize() const { return ValueSize; } @@ -211,15 +212,15 @@ class MCOrgFragment : public MCFragment { /// Offset - The offset this fragment should start at. - MCValue Offset; + const MCExpr *Offset; /// Value - Value to use for filling bytes. int8_t Value; public: - MCOrgFragment(MCValue _Offset, int8_t _Value, MCSectionData *SD = 0) + MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0) : MCFragment(FT_Org, SD), - Offset(_Offset), Value(_Value) {} + Offset(&_Offset), Value(_Value) {} /// @name Accessors /// @{ @@ -229,7 +230,7 @@ return ~UINT64_C(0); } - MCValue getOffset() const { return Offset; } + const MCExpr &getOffset() const { return *Offset; } uint8_t getValue() const { return Value; } @@ -294,10 +295,7 @@ uint64_t Offset; /// Value - The expression to eventually write into the fragment. - // - // FIXME: We could probably get away with requiring the client to pass in an - // owned reference whose lifetime extends past that of the fixup. - MCValue Value; + const MCExpr *Value; /// Size - The fixup size. unsigned Size; @@ -308,9 +306,9 @@ uint64_t FixedValue; public: - Fixup(MCFragment &_Fragment, uint64_t _Offset, const MCValue &_Value, + Fixup(MCFragment &_Fragment, uint64_t _Offset, const MCExpr &_Value, unsigned _Size) - : Fragment(&_Fragment), Offset(_Offset), Value(_Value), Size(_Size), + : Fragment(&_Fragment), Offset(_Offset), Value(&_Value), Size(_Size), FixedValue(0) {} }; Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=84234&r1=84233&r2=84234&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Thu Oct 15 20:58:03 2009 @@ -9,7 +9,10 @@ #define DEBUG_TYPE "assembler" #include "llvm/MC/MCAssembler.h" +#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCSectionMachO.h" +#include "llvm/MC/MCSymbol.h" +#include "llvm/MC/MCValue.h" #include "llvm/Target/TargetMachOWriterInfo.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallString.h" @@ -397,6 +400,7 @@ }; void ComputeScatteredRelocationInfo(MCAssembler &Asm, MCSectionData::Fixup &Fixup, + const MCValue &Target, DenseMap &SymbolMap, std::vector &Relocs) { uint32_t Address = Fixup.Fragment->getOffset() + Fixup.Offset; @@ -404,13 +408,12 @@ unsigned Type = RIT_Vanilla; // See . - - const MCSymbol *A = Fixup.Value.getSymA(); + const MCSymbol *A = Target.getSymA(); MCSymbolData *SD = SymbolMap.lookup(A); uint32_t Value = SD->getFragment()->getAddress() + SD->getOffset(); uint32_t Value2 = 0; - if (const MCSymbol *B = Fixup.Value.getSymB()) { + if (const MCSymbol *B = Target.getSymB()) { Type = RIT_LocalDifference; MCSymbolData *SD = SymbolMap.lookup(B); @@ -421,7 +424,7 @@ assert((1U << Log2Size) == Fixup.Size && "Invalid fixup size!"); // The value which goes in the fixup is current value of the expression. - Fixup.FixedValue = Value - Value2 + Fixup.Value.getConstant(); + Fixup.FixedValue = Value - Value2 + Target.getConstant(); MachRelocationEntry MRE; MRE.Word0 = ((Address << 0) | @@ -450,13 +453,17 @@ MCSectionData::Fixup &Fixup, DenseMap &SymbolMap, std::vector &Relocs) { - // If this is a local symbol plus an offset or a difference, then we need a + MCValue Target; + if (!Fixup.Value->EvaluateAsRelocatable(Target)) + llvm_report_error("expected relocatable expression"); + + // If this is a difference or a local symbol plus an offset, then we need a // scattered relocation entry. - if (Fixup.Value.getSymB()) // a - b - return ComputeScatteredRelocationInfo(Asm, Fixup, SymbolMap, Relocs); - if (Fixup.Value.getSymA() && Fixup.Value.getConstant()) - if (!Fixup.Value.getSymA()->isUndefined()) - return ComputeScatteredRelocationInfo(Asm, Fixup, SymbolMap, Relocs); + if (Target.getSymB() || + (Target.getSymA() && !Target.getSymA()->isUndefined() && + Target.getConstant())) + return ComputeScatteredRelocationInfo(Asm, Fixup, Target, + SymbolMap, Relocs); // See . uint32_t Address = Fixup.Fragment->getOffset() + Fixup.Offset; @@ -466,13 +473,13 @@ unsigned IsExtern = 0; unsigned Type = 0; - if (Fixup.Value.isAbsolute()) { // constant + if (Target.isAbsolute()) { // constant // SymbolNum of 0 indicates the absolute section. Type = RIT_Vanilla; Value = 0; llvm_unreachable("FIXME: Not yet implemented!"); } else { - const MCSymbol *Symbol = Fixup.Value.getSymA(); + const MCSymbol *Symbol = Target.getSymA(); MCSymbolData *SD = SymbolMap.lookup(Symbol); if (Symbol->isUndefined()) { @@ -495,7 +502,7 @@ } // The value which goes in the fixup is current value of the expression. - Fixup.FixedValue = Value + Fixup.Value.getConstant(); + Fixup.FixedValue = Value + Target.getConstant(); unsigned Log2Size = Log2_32(Fixup.Size); assert((1U << Log2Size) == Fixup.Size && "Invalid fixup size!"); @@ -978,8 +985,12 @@ F.setFileSize(F.getMaxFileSize()); + MCValue Target; + if (!FF.getValue().EvaluateAsRelocatable(Target)) + llvm_report_error("expected relocatable expression"); + // If the fill value is constant, thats it. - if (FF.getValue().isAbsolute()) + if (Target.isAbsolute()) break; // Otherwise, add fixups for the values. @@ -994,9 +1005,13 @@ case MCFragment::FT_Org: { MCOrgFragment &OF = cast(F); - if (!OF.getOffset().isAbsolute()) + MCValue Target; + if (!OF.getOffset().EvaluateAsRelocatable(Target)) + llvm_report_error("expected relocatable expression"); + + if (!Target.isAbsolute()) llvm_unreachable("FIXME: Not yet implemented!"); - uint64_t OrgOffset = OF.getOffset().getConstant(); + uint64_t OrgOffset = Target.getConstant(); uint64_t Offset = Address - SD.getAddress(); // FIXME: We need a way to communicate this error. @@ -1077,10 +1092,15 @@ MCFillFragment &FF = cast(F); int64_t Value = 0; - if (FF.getValue().isAbsolute()) - Value = FF.getValue().getConstant(); + + MCValue Target; + if (!FF.getValue().EvaluateAsRelocatable(Target)) + llvm_report_error("expected relocatable expression"); + + if (Target.isAbsolute()) + Value = Target.getConstant(); for (uint64_t i = 0, e = FF.getCount(); i != e; ++i) { - if (!FF.getValue().isAbsolute()) { + if (!Target.isAbsolute()) { // Find the fixup. // // FIXME: Find a better way to write in the fixes. Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=84234&r1=84233&r2=84234&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Thu Oct 15 20:58:03 2009 @@ -321,12 +321,7 @@ } void MCMachOStreamer::EmitValue(const MCExpr *Value, unsigned Size) { - MCValue RelocValue; - - if (!AddValueSymbols(Value)->EvaluateAsRelocatable(getContext(), RelocValue)) - return llvm_report_error("expected relocatable expression"); - - new MCFillFragment(RelocValue, Size, 1, CurSectionData); + new MCFillFragment(*AddValueSymbols(Value), Size, 1, CurSectionData); } void MCMachOStreamer::EmitValueToAlignment(unsigned ByteAlignment, @@ -344,12 +339,7 @@ void MCMachOStreamer::EmitValueToOffset(const MCExpr *Offset, unsigned char Value) { - MCValue RelocOffset; - - if (!AddValueSymbols(Offset)->EvaluateAsRelocatable(RelocOffset)) - return llvm_report_error("expected relocatable expression"); - - new MCOrgFragment(RelocOffset, Value, CurSectionData); + new MCOrgFragment(*Offset, Value, CurSectionData); } void MCMachOStreamer::EmitInstruction(const MCInst &Inst) { From daniel at zuster.org Thu Oct 15 20:58:15 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 16 Oct 2009 01:58:15 -0000 Subject: [llvm-commits] [llvm] r84235 - in /llvm/trunk: include/llvm/MC/MCExpr.h lib/MC/MCAsmStreamer.cpp lib/MC/MCAssembler.cpp Message-ID: <200910160158.n9G1wGjl002316@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Oct 15 20:58:15 2009 New Revision: 84235 URL: http://llvm.org/viewvc/llvm-project?rev=84235&view=rev Log: Minor formatting tweaks. Modified: llvm/trunk/include/llvm/MC/MCExpr.h llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCAssembler.cpp Modified: llvm/trunk/include/llvm/MC/MCExpr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=84235&r1=84234&r2=84235&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCExpr.h (original) +++ llvm/trunk/include/llvm/MC/MCExpr.h Thu Oct 15 20:58:15 2009 @@ -121,9 +121,7 @@ static const MCSymbolRefExpr *Create(const MCSymbol *Symbol, MCContext &Ctx); static const MCSymbolRefExpr *Create(const StringRef &Name, MCContext &Ctx); - - - + /// @} /// @name Accessors /// @{ Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=84235&r1=84234&r2=84235&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Thu Oct 15 20:58:15 2009 @@ -132,18 +132,18 @@ void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol, SymbolAttr Attribute) { switch (Attribute) { - case Global: OS << ".globl"; break; - case Hidden: OS << ".hidden"; break; + case Global: OS << ".globl"; break; + case Hidden: OS << ".hidden"; break; case IndirectSymbol: OS << ".indirect_symbol"; break; - case Internal: OS << ".internal"; break; - case LazyReference: OS << ".lazy_reference"; break; - case NoDeadStrip: OS << ".no_dead_strip"; break; - case PrivateExtern: OS << ".private_extern"; break; - case Protected: OS << ".protected"; break; - case Reference: OS << ".reference"; break; - case Weak: OS << ".weak"; break; + case Internal: OS << ".internal"; break; + case LazyReference: OS << ".lazy_reference"; break; + case NoDeadStrip: OS << ".no_dead_strip"; break; + case PrivateExtern: OS << ".private_extern"; break; + case Protected: OS << ".protected"; break; + case Reference: OS << ".reference"; break; + case Weak: OS << ".weak"; break; case WeakDefinition: OS << ".weak_definition"; break; - case WeakReference: OS << ".weak_reference"; break; + case WeakReference: OS << ".weak_reference"; break; } OS << ' '; Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=84235&r1=84234&r2=84235&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Thu Oct 15 20:58:15 2009 @@ -51,7 +51,7 @@ Header_Magic32 = 0xFEEDFACE, Header_Magic64 = 0xFEEDFACF }; - + static const unsigned Header32Size = 28; static const unsigned Header64Size = 32; static const unsigned SegmentLoadCommand32Size = 56; @@ -130,7 +130,7 @@ bool IsLSB; public: - MachObjectWriter(raw_ostream &_OS, bool _IsLSB = true) + MachObjectWriter(raw_ostream &_OS, bool _IsLSB = true) : OS(_OS), IsLSB(_IsLSB) { } @@ -173,10 +173,10 @@ void WriteZeros(unsigned N) { const char Zeros[16] = { 0 }; - + for (unsigned i = 0, e = N / 16; i != e; ++i) OS << StringRef(Zeros, 16); - + OS << StringRef(Zeros, N % 16); } @@ -187,7 +187,7 @@ } /// @} - + void WriteHeader32(unsigned NumLoadCommands, unsigned LoadCommandsSize, bool SubsectionsViaSymbols) { uint32_t Flags = 0; @@ -387,7 +387,7 @@ Write32(MSD.StringIndex); Write8(Type); Write8(MSD.SectionIndex); - + // The Mach-O streamer uses the lowest 16-bits of the flags for the 'desc' // value. Write16(Flags); @@ -464,7 +464,7 @@ Target.getConstant())) return ComputeScatteredRelocationInfo(Asm, Fixup, Target, SymbolMap, Relocs); - + // See . uint32_t Address = Fixup.Fragment->getOffset() + Fixup.Offset; uint32_t Value = 0; @@ -481,7 +481,7 @@ } else { const MCSymbol *Symbol = Target.getSymA(); MCSymbolData *SD = SymbolMap.lookup(Symbol); - + if (Symbol->isUndefined()) { IsExtern = 1; Index = SD->getIndex(); @@ -517,7 +517,7 @@ (Type << 28)); Relocs.push_back(MRE); } - + void BindIndirectSymbols(MCAssembler &Asm, DenseMap &SymbolMap) { // This is the point where 'as' creates actual symbols for indirect symbols @@ -710,7 +710,7 @@ if (NumSymbols) ComputeSymbolTable(Asm, StringTable, LocalSymbolData, ExternalSymbolData, UndefinedSymbolData); - + // The section data starts after the header, the segment load command (and // section headers) and the symbol table. unsigned NumLoadCommands = 1; @@ -740,7 +740,7 @@ SectionDataSize = std::max(SectionDataSize, SD.getAddress() + SD.getSize()); - SectionDataFileSize = std::max(SectionDataFileSize, + SectionDataFileSize = std::max(SectionDataFileSize, SD.getAddress() + SD.getFileSize()); } @@ -755,9 +755,9 @@ Asm.getSubsectionsViaSymbols()); WriteSegmentLoadCommand32(NumSections, VMSize, SectionDataStart, SectionDataSize); - + // ... and then the section headers. - // + // // We also compute the section relocations while we do this. Note that // compute relocation info will also update the fixup to have the correct // value; this will be overwrite the appropriate data in the fragment when @@ -781,7 +781,7 @@ WriteSection32(SD, SectionStart, RelocTableEnd, NumRelocs); RelocTableEnd += NumRelocs * RelocationInfoSize; } - + // Write the symbol table load command, if used. if (NumSymbols) { unsigned FirstLocalSymbol = 0; @@ -930,7 +930,7 @@ return 0; } - + /* *** */ MCSymbolData::MCSymbolData() : Symbol(0) {} @@ -967,7 +967,7 @@ switch (F.getKind()) { case MCFragment::FT_Align: { MCAlignFragment &AF = cast(F); - + uint64_t Size = OffsetToAlignment(Address, AF.getAlignment()); if (Size > AF.getMaxBytesToEmit()) AF.setFileSize(0); @@ -1016,12 +1016,12 @@ // FIXME: We need a way to communicate this error. if (OrgOffset < Offset) - llvm_report_error("invalid .org offset '" + Twine(OrgOffset) + + llvm_report_error("invalid .org offset '" + Twine(OrgOffset) + "' (at offset '" + Twine(Offset) + "'"); - + F.setFileSize(OrgOffset - Offset); break; - } + } case MCFragment::FT_ZeroFill: { MCZeroFillFragment &ZFF = cast(F); @@ -1053,7 +1053,7 @@ MachObjectWriter &MOW) { uint64_t Start = OS.tell(); (void) Start; - + ++EmittedFragments; // FIXME: Embed in fragments instead? @@ -1066,8 +1066,8 @@ // multiple .align directives to enforce the semantics it wants), but is // severe enough that we want to report it. How to handle this? if (Count * AF.getValueSize() != AF.getFileSize()) - llvm_report_error("undefined .align directive, value size '" + - Twine(AF.getValueSize()) + + llvm_report_error("undefined .align directive, value size '" + + Twine(AF.getValueSize()) + "' is not a divisor of padding size '" + Twine(AF.getFileSize()) + "'"); @@ -1121,7 +1121,7 @@ } break; } - + case MCFragment::FT_Org: { MCOrgFragment &OF = cast(F); @@ -1151,7 +1151,7 @@ uint64_t Start = OS.tell(); (void) Start; - + for (MCSectionData::const_iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) WriteFileData(OS, *it, MOW); From daniel at zuster.org Thu Oct 15 20:58:23 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 16 Oct 2009 01:58:23 -0000 Subject: [llvm-commits] [llvm] r84236 - /llvm/trunk/lib/MC/MCMachOStreamer.cpp Message-ID: <200910160158.n9G1wNkp002331@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Oct 15 20:58:23 2009 New Revision: 84236 URL: http://llvm.org/viewvc/llvm-project?rev=84236&view=rev Log: MC: Set symbol values in MachO MCStreamer. Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=84236&r1=84235&r2=84236&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Thu Oct 15 20:58:23 2009 @@ -198,7 +198,9 @@ assert((Symbol->isUndefined() || Symbol->isAbsolute()) && "Cannot define a symbol twice!"); - llvm_unreachable("FIXME: Not yet implemented!"); + // FIXME: Lift context changes into super class. + // FIXME: Set associated section. + Symbol->setValue(Value); } void MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol, From sabre at nondot.org Thu Oct 15 21:06:31 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 16 Oct 2009 02:06:31 -0000 Subject: [llvm-commits] [llvm] r84238 - in /llvm/trunk: include/llvm/ADT/Triple.h lib/Support/Triple.cpp Message-ID: <200910160206.n9G26VAa002677@zion.cs.uiuc.edu> Author: lattner Date: Thu Oct 15 21:06:30 2009 New Revision: 84238 URL: http://llvm.org/viewvc/llvm-project?rev=84238&view=rev Log: add haiku support, patch by Paul Davey! Modified: llvm/trunk/include/llvm/ADT/Triple.h llvm/trunk/lib/Support/Triple.cpp Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=84238&r1=84237&r2=84238&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Thu Oct 15 21:06:30 2009 @@ -95,7 +95,8 @@ NetBSD, OpenBSD, Solaris, - Win32 + Win32, + Haiku }; private: Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=84238&r1=84237&r2=84238&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Thu Oct 15 21:06:30 2009 @@ -96,6 +96,7 @@ case OpenBSD: return "openbsd"; case Solaris: return "solaris"; case Win32: return "win32"; + case Haiku: return "haiku"; } return ""; @@ -276,6 +277,8 @@ OS = Solaris; else if (OSName.startswith("win32")) OS = Win32; + else if (OSName.startswith("haiku")) + OS = Haiku; else OS = UnknownOS; From sabre at nondot.org Thu Oct 15 21:13:51 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 16 Oct 2009 02:13:51 -0000 Subject: [llvm-commits] [llvm] r84239 - in /llvm/trunk: include/llvm/ADT/APFloat.h lib/Support/APFloat.cpp Message-ID: <200910160213.n9G2Dp0C003020@zion.cs.uiuc.edu> Author: lattner Date: Thu Oct 15 21:13:51 2009 New Revision: 84239 URL: http://llvm.org/viewvc/llvm-project?rev=84239&view=rev Log: Add half precision floating point support (float16) to APFloat, patch by Peter Johnson! (PR5195) Modified: llvm/trunk/include/llvm/ADT/APFloat.h llvm/trunk/lib/Support/APFloat.cpp Modified: llvm/trunk/include/llvm/ADT/APFloat.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APFloat.h?rev=84239&r1=84238&r2=84239&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/APFloat.h (original) +++ llvm/trunk/include/llvm/ADT/APFloat.h Thu Oct 15 21:13:51 2009 @@ -125,6 +125,7 @@ public: /* We support the following floating point semantics. */ + static const fltSemantics IEEEhalf; static const fltSemantics IEEEsingle; static const fltSemantics IEEEdouble; static const fltSemantics IEEEquad; @@ -321,12 +322,14 @@ opStatus roundSignificandWithExponent(const integerPart *, unsigned int, int, roundingMode); + APInt convertHalfAPFloatToAPInt() const; APInt convertFloatAPFloatToAPInt() const; APInt convertDoubleAPFloatToAPInt() const; APInt convertQuadrupleAPFloatToAPInt() const; APInt convertF80LongDoubleAPFloatToAPInt() const; APInt convertPPCDoubleDoubleAPFloatToAPInt() const; void initFromAPInt(const APInt& api, bool isIEEE = false); + void initFromHalfAPInt(const APInt& api); void initFromFloatAPInt(const APInt& api); void initFromDoubleAPInt(const APInt& api); void initFromQuadrupleAPInt(const APInt &api); Modified: llvm/trunk/lib/Support/APFloat.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=84239&r1=84238&r2=84239&view=diff ============================================================================== --- llvm/trunk/lib/Support/APFloat.cpp (original) +++ llvm/trunk/lib/Support/APFloat.cpp Thu Oct 15 21:13:51 2009 @@ -48,6 +48,7 @@ unsigned int arithmeticOK; }; + const fltSemantics APFloat::IEEEhalf = { 15, -14, 11, true }; const fltSemantics APFloat::IEEEsingle = { 127, -126, 24, true }; const fltSemantics APFloat::IEEEdouble = { 1023, -1022, 53, true }; const fltSemantics APFloat::IEEEquad = { 16383, -16382, 113, true }; @@ -2812,6 +2813,35 @@ (mysignificand & 0x7fffff))); } +APInt +APFloat::convertHalfAPFloatToAPInt() const +{ + assert(semantics == (const llvm::fltSemantics*)&IEEEhalf); + assert (partCount()==1); + + uint32_t myexponent, mysignificand; + + if (category==fcNormal) { + myexponent = exponent+15; //bias + mysignificand = (uint32_t)*significandParts(); + if (myexponent == 1 && !(mysignificand & 0x400)) + myexponent = 0; // denormal + } else if (category==fcZero) { + myexponent = 0; + mysignificand = 0; + } else if (category==fcInfinity) { + myexponent = 0xff; + mysignificand = 0; + } else { + assert(category == fcNaN && "Unknown category!"); + myexponent = 0xff; + mysignificand = (uint32_t)*significandParts(); + } + + return APInt(16, (((sign&1) << 15) | ((myexponent&0x1f) << 10) | + (mysignificand & 0x3ff))); +} + // This function creates an APInt that is just a bit map of the floating // point constant as it would appear in memory. It is not a conversion, // and treating the result as a normal integer is unlikely to be useful. @@ -2819,6 +2849,9 @@ APInt APFloat::bitcastToAPInt() const { + if (semantics == (const llvm::fltSemantics*)&IEEEhalf) + return convertHalfAPFloatToAPInt(); + if (semantics == (const llvm::fltSemantics*)&IEEEsingle) return convertFloatAPFloatToAPInt(); @@ -3051,6 +3084,39 @@ } } +void +APFloat::initFromHalfAPInt(const APInt & api) +{ + assert(api.getBitWidth()==16); + uint32_t i = (uint32_t)*api.getRawData(); + uint32_t myexponent = (i >> 15) & 0x1f; + uint32_t mysignificand = i & 0x3ff; + + initialize(&APFloat::IEEEhalf); + assert(partCount()==1); + + sign = i >> 15; + if (myexponent==0 && mysignificand==0) { + // exponent, significand meaningless + category = fcZero; + } else if (myexponent==0x1f && mysignificand==0) { + // exponent, significand meaningless + category = fcInfinity; + } else if (myexponent==0x1f && mysignificand!=0) { + // sign, exponent, significand meaningless + category = fcNaN; + *significandParts() = mysignificand; + } else { + category = fcNormal; + exponent = myexponent - 15; //bias + *significandParts() = mysignificand; + if (myexponent==0) // denormal + exponent = -14; + else + *significandParts() |= 0x400; // integer bit + } +} + /// Treat api as containing the bits of a floating point number. Currently /// we infer the floating point type from the size of the APInt. The /// isIEEE argument distinguishes between PPC128 and IEEE128 (not meaningful @@ -3058,7 +3124,9 @@ void APFloat::initFromAPInt(const APInt& api, bool isIEEE) { - if (api.getBitWidth() == 32) + if (api.getBitWidth() == 16) + return initFromHalfAPInt(api); + else if (api.getBitWidth() == 32) return initFromFloatAPInt(api); else if (api.getBitWidth()==64) return initFromDoubleAPInt(api); From clattner at apple.com Thu Oct 15 21:17:53 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 15 Oct 2009 19:17:53 -0700 Subject: [llvm-commits] [llvm] r84234 - in /llvm/trunk: include/llvm/MC/MCAssembler.h lib/MC/MCAssembler.cpp lib/MC/MCMachOStreamer.cpp In-Reply-To: <200910160158.n9G1w4Em002286@zion.cs.uiuc.edu> References: <200910160158.n9G1w4Em002286@zion.cs.uiuc.edu> Message-ID: On Oct 15, 2009, at 6:58 PM, Daniel Dunbar wrote: > Author: ddunbar > Date: Thu Oct 15 20:58:03 2009 > New Revision: 84234 > > URL: http://llvm.org/viewvc/llvm-project?rev=84234&view=rev > Log: > MC: Switch assembler API to using MCExpr instead of MCValue. Hey Daniel, Why does MCFillFragment (for example) take an return MCExpr's by reference? While I agree that these can never be null, enforcing this through the API seems like a bad idea, particularly because most clients will have them as pointers. -Chris > + MCFillFragment(const MCExpr &_Value, unsigned _ValueSize, > uint64_t _Count, > MCSectionData *SD = 0) > : MCFragment(FT_Fill, SD), > - Value(_Value), ValueSize(_ValueSize), Count(_Count) {} > + Value(&_Value), ValueSize(_ValueSize), Count(_Count) {} > > /// @name Accessors > /// @{ > @@ -195,7 +196,7 @@ > return ValueSize * Count; > } > > - MCValue getValue() const { return Value; } > + const MCExpr &getValue() const { return *Value; } > > unsigned getValueSize() const { return ValueSize; } > > @@ -211,15 +212,15 @@ > > class MCOrgFragment : public MCFragment { > /// Offset - The offset this fragment should start at. > - MCValue Offset; > + const MCExpr *Offset; > > /// Value - Value to use for filling bytes. > int8_t Value; > > public: > - MCOrgFragment(MCValue _Offset, int8_t _Value, MCSectionData *SD = > 0) > + MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData > *SD = 0) > : MCFragment(FT_Org, SD), > - Offset(_Offset), Value(_Value) {} > + Offset(&_Offset), Value(_Value) {} > > /// @name Accessors > /// @{ > @@ -229,7 +230,7 @@ > return ~UINT64_C(0); > } > > - MCValue getOffset() const { return Offset; } > + const MCExpr &getOffset() const { return *Offset; } > > uint8_t getValue() const { return Value; } > > @@ -294,10 +295,7 @@ > uint64_t Offset; > > /// Value - The expression to eventually write into the fragment. > - // > - // FIXME: We could probably get away with requiring the client > to pass in an > - // owned reference whose lifetime extends past that of the fixup. > - MCValue Value; > + const MCExpr *Value; > > /// Size - The fixup size. > unsigned Size; > @@ -308,9 +306,9 @@ > uint64_t FixedValue; > > public: > - Fixup(MCFragment &_Fragment, uint64_t _Offset, const MCValue > &_Value, > + Fixup(MCFragment &_Fragment, uint64_t _Offset, const MCExpr > &_Value, > unsigned _Size) > - : Fragment(&_Fragment), Offset(_Offset), Value(_Value), Size > (_Size), > + : Fragment(&_Fragment), Offset(_Offset), Value(&_Value), Size > (_Size), > FixedValue(0) {} > }; > > > Modified: llvm/trunk/lib/MC/MCAssembler.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=84234&r1=84233&r2=84234&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/MC/MCAssembler.cpp (original) > +++ llvm/trunk/lib/MC/MCAssembler.cpp Thu Oct 15 20:58:03 2009 > @@ -9,7 +9,10 @@ > > #define DEBUG_TYPE "assembler" > #include "llvm/MC/MCAssembler.h" > +#include "llvm/MC/MCExpr.h" > #include "llvm/MC/MCSectionMachO.h" > +#include "llvm/MC/MCSymbol.h" > +#include "llvm/MC/MCValue.h" > #include "llvm/Target/TargetMachOWriterInfo.h" > #include "llvm/ADT/DenseMap.h" > #include "llvm/ADT/SmallString.h" > @@ -397,6 +400,7 @@ > }; > void ComputeScatteredRelocationInfo(MCAssembler &Asm, > MCSectionData::Fixup &Fixup, > + const MCValue &Target, > DenseMap > &SymbolMap, > > std::vector &Relocs) { > uint32_t Address = Fixup.Fragment->getOffset() + Fixup.Offset; > @@ -404,13 +408,12 @@ > unsigned Type = RIT_Vanilla; > > // See . > - > - const MCSymbol *A = Fixup.Value.getSymA(); > + const MCSymbol *A = Target.getSymA(); > MCSymbolData *SD = SymbolMap.lookup(A); > uint32_t Value = SD->getFragment()->getAddress() + SD->getOffset > (); > uint32_t Value2 = 0; > > - if (const MCSymbol *B = Fixup.Value.getSymB()) { > + if (const MCSymbol *B = Target.getSymB()) { > Type = RIT_LocalDifference; > > MCSymbolData *SD = SymbolMap.lookup(B); > @@ -421,7 +424,7 @@ > assert((1U << Log2Size) == Fixup.Size && "Invalid fixup size!"); > > // The value which goes in the fixup is current value of the > expression. > - Fixup.FixedValue = Value - Value2 + Fixup.Value.getConstant(); > + Fixup.FixedValue = Value - Value2 + Target.getConstant(); > > MachRelocationEntry MRE; > MRE.Word0 = ((Address << 0) | > @@ -450,13 +453,17 @@ > MCSectionData::Fixup &Fixup, > DenseMap > &SymbolMap, > std::vector > &Relocs) { > - // If this is a local symbol plus an offset or a difference, > then we need a > + MCValue Target; > + if (!Fixup.Value->EvaluateAsRelocatable(Target)) > + llvm_report_error("expected relocatable expression"); > + > + // If this is a difference or a local symbol plus an offset, > then we need a > // scattered relocation entry. > - if (Fixup.Value.getSymB()) // a - b > - return ComputeScatteredRelocationInfo(Asm, Fixup, SymbolMap, > Relocs); > - if (Fixup.Value.getSymA() && Fixup.Value.getConstant()) > - if (!Fixup.Value.getSymA()->isUndefined()) > - return ComputeScatteredRelocationInfo(Asm, Fixup, > SymbolMap, Relocs); > + if (Target.getSymB() || > + (Target.getSymA() && !Target.getSymA()->isUndefined() && > + Target.getConstant())) > + return ComputeScatteredRelocationInfo(Asm, Fixup, Target, > + SymbolMap, Relocs); > > // See . > uint32_t Address = Fixup.Fragment->getOffset() + Fixup.Offset; > @@ -466,13 +473,13 @@ > unsigned IsExtern = 0; > unsigned Type = 0; > > - if (Fixup.Value.isAbsolute()) { // constant > + if (Target.isAbsolute()) { // constant > // SymbolNum of 0 indicates the absolute section. > Type = RIT_Vanilla; > Value = 0; > llvm_unreachable("FIXME: Not yet implemented!"); > } else { > - const MCSymbol *Symbol = Fixup.Value.getSymA(); > + const MCSymbol *Symbol = Target.getSymA(); > MCSymbolData *SD = SymbolMap.lookup(Symbol); > > if (Symbol->isUndefined()) { > @@ -495,7 +502,7 @@ > } > > // The value which goes in the fixup is current value of the > expression. > - Fixup.FixedValue = Value + Fixup.Value.getConstant(); > + Fixup.FixedValue = Value + Target.getConstant(); > > unsigned Log2Size = Log2_32(Fixup.Size); > assert((1U << Log2Size) == Fixup.Size && "Invalid fixup size!"); > @@ -978,8 +985,12 @@ > > F.setFileSize(F.getMaxFileSize()); > > + MCValue Target; > + if (!FF.getValue().EvaluateAsRelocatable(Target)) > + llvm_report_error("expected relocatable expression"); > + > // If the fill value is constant, thats it. > - if (FF.getValue().isAbsolute()) > + if (Target.isAbsolute()) > break; > > // Otherwise, add fixups for the values. > @@ -994,9 +1005,13 @@ > case MCFragment::FT_Org: { > MCOrgFragment &OF = cast(F); > > - if (!OF.getOffset().isAbsolute()) > + MCValue Target; > + if (!OF.getOffset().EvaluateAsRelocatable(Target)) > + llvm_report_error("expected relocatable expression"); > + > + if (!Target.isAbsolute()) > llvm_unreachable("FIXME: Not yet implemented!"); > - uint64_t OrgOffset = OF.getOffset().getConstant(); > + uint64_t OrgOffset = Target.getConstant(); > uint64_t Offset = Address - SD.getAddress(); > > // FIXME: We need a way to communicate this error. > @@ -1077,10 +1092,15 @@ > MCFillFragment &FF = cast(F); > > int64_t Value = 0; > - if (FF.getValue().isAbsolute()) > - Value = FF.getValue().getConstant(); > + > + MCValue Target; > + if (!FF.getValue().EvaluateAsRelocatable(Target)) > + llvm_report_error("expected relocatable expression"); > + > + if (Target.isAbsolute()) > + Value = Target.getConstant(); > for (uint64_t i = 0, e = FF.getCount(); i != e; ++i) { > - if (!FF.getValue().isAbsolute()) { > + if (!Target.isAbsolute()) { > // Find the fixup. > // > // FIXME: Find a better way to write in the fixes. > > Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=84234&r1=84233&r2=84234&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) > +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Thu Oct 15 20:58:03 2009 > @@ -321,12 +321,7 @@ > } > > void MCMachOStreamer::EmitValue(const MCExpr *Value, unsigned Size) { > - MCValue RelocValue; > - > - if (!AddValueSymbols(Value)->EvaluateAsRelocatable(getContext(), > RelocValue)) > - return llvm_report_error("expected relocatable expression"); > - > - new MCFillFragment(RelocValue, Size, 1, CurSectionData); > + new MCFillFragment(*AddValueSymbols(Value), Size, 1, > CurSectionData); > } > > void MCMachOStreamer::EmitValueToAlignment(unsigned ByteAlignment, > @@ -344,12 +339,7 @@ > > void MCMachOStreamer::EmitValueToOffset(const MCExpr *Offset, > unsigned char Value) { > - MCValue RelocOffset; > - > - if (!AddValueSymbols(Offset)->EvaluateAsRelocatable(RelocOffset)) > - return llvm_report_error("expected relocatable expression"); > - > - new MCOrgFragment(RelocOffset, Value, CurSectionData); > + new MCOrgFragment(*Offset, Value, CurSectionData); > } > > void MCMachOStreamer::EmitInstruction(const MCInst &Inst) { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From nicholas at mxc.ca Thu Oct 15 22:29:07 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 15 Oct 2009 20:29:07 -0700 Subject: [llvm-commits] [llvm] r84159 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp In-Reply-To: <4AD6DD98.5010904@free.fr> References: <200910150036.n9F0aaWY031906@zion.cs.uiuc.edu> <4AD6DD98.5010904@free.fr> Message-ID: <4AD7E883.9060900@mxc.ca> Duncan Sands wrote: > Hi Nick, > >> Take advantage of TargetData when available; we know that the atomic >> intrinsics >> only dereference the element they point to directly with no pointer >> arithmetic. > > if there's no target data available, I guess there's no point in using > ~0U for the size because the generic code already handles this case > since the intrinsics are marked IntrWriteArgMem? That's correct. When target data isn't available, this code path is off. Nick From nicholas at mxc.ca Thu Oct 15 22:29:50 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 15 Oct 2009 20:29:50 -0700 Subject: [llvm-commits] [llvm] r84174 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp In-Reply-To: <4AD6E0C0.6040108@free.fr> References: <200910150612.n9F6CEfp010584@zion.cs.uiuc.edu> <4AD6E0C0.6040108@free.fr> Message-ID: <4AD7E8AE.2040807@mxc.ca> Duncan Sands wrote: > Hi Nick, > >> + case Intrinsic::lifetime_start: >> + case Intrinsic::lifetime_end: >> + case Intrinsic::invariant_start: { >> + unsigned PtrSize = >> cast(II->getOperand(1))->getZExtValue(); >> + if (alias(II->getOperand(2), PtrSize, P, Size) == NoAlias) >> + return NoModRef; >> + } > > did you mean to fall through here? Nope! Good catch! Nick > >> + case Intrinsic::invariant_end: { >> + unsigned PtrSize = >> cast(II->getOperand(2))->getZExtValue(); >> + if (alias(II->getOperand(3), PtrSize, P, Size) == NoAlias) >> + return NoModRef; >> + } > > Ciao, > > Duncan. > From bob.wilson at apple.com Thu Oct 15 22:58:48 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 16 Oct 2009 03:58:48 -0000 Subject: [llvm-commits] [llvm] r84243 - /llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Message-ID: <200910160358.n9G3wnWu006712@zion.cs.uiuc.edu> Author: bwilson Date: Thu Oct 15 22:58:44 2009 New Revision: 84243 URL: http://llvm.org/viewvc/llvm-project?rev=84243&view=rev Log: Fix more NEON instruction encodings. Patch by Johnny Chen. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=84243&r1=84242&r2=84243&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Thu Oct 15 22:58:44 2009 @@ -1903,8 +1903,8 @@ defm VABDLu : N3VLInt_QHS<1,1,0b0111,0, IIC_VBINi4Q, "vabdl.u", int_arm_neon_vabdlu, 0>; // VABA : Vector Absolute Difference and Accumulate -defm VABAs : N3VInt3_QHS<0,1,0b0101,0, "vaba.s", int_arm_neon_vabas>; -defm VABAu : N3VInt3_QHS<1,1,0b0101,0, "vaba.u", int_arm_neon_vabau>; +defm VABAs : N3VInt3_QHS<0,0,0b0111,1, "vaba.s", int_arm_neon_vabas>; +defm VABAu : N3VInt3_QHS<1,0,0b0111,1, "vaba.u", int_arm_neon_vabau>; // VABAL : Vector Absolute Difference and Accumulate Long (Q += | D - D |) defm VABALs : N3VLInt3_QHS<0,1,0b0101,0, "vabal.s", int_arm_neon_vabals>; From bob.wilson at apple.com Thu Oct 15 22:59:51 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 15 Oct 2009 20:59:51 -0700 Subject: [llvm-commits] Fix typo of ARM Neon's VABAs and VABAu (Vector Absolute Difference and Accumulate) In-Reply-To: <2A76CF12-BC4D-4631-9B40-F794613C9E22@apple.com> References: <2A76CF12-BC4D-4631-9B40-F794613C9E22@apple.com> Message-ID: Applied. I hope there's not too many more of these -- it's kind of embarassing how many of them I got wrong! On Oct 15, 2009, at 5:55 PM, Johnny Chen wrote: > Hi, > > Refs: A7-13 & A8-526 > Probably the chip designer wants to distinguish VABA and VABD of three registers of the same length > not with Instr{11-8}, but with only Instr{4}. > > But then, for three registers of different lengths, VABAL and VABDL has different Instr{11-8}, but with Instr{4}=0. > Ref: A7-15. > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sanjiv.gupta at microchip.com Fri Oct 16 00:11:08 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Fri, 16 Oct 2009 10:41:08 +0530 Subject: [llvm-commits] [llvm] r84196 - in /llvm/trunk/lib/Target/PIC16: PIC16ABINames.h PIC16Section.cpp PIC16Section.h In-Reply-To: <200910151946.n9FJkfTV021679@zion.cs.uiuc.edu> References: <200910151946.n9FJkfTV021679@zion.cs.uiuc.edu> Message-ID: <4AD8006C.1070006@microchip.com> Thanks Benjamin. Benjamin Kramer wrote: > Author: d0k > Date: Thu Oct 15 14:46:34 2009 > New Revision: 84196 > > URL: http://llvm.org/viewvc/llvm-project?rev=84196&view=rev > Log: > Add files Sanjiv forgot. > > Added: > llvm/trunk/lib/Target/PIC16/PIC16ABINames.h > - copied unchanged from r84180, llvm/trunk/lib/Target/PIC16/PIC16ABINames.h > llvm/trunk/lib/Target/PIC16/PIC16Section.cpp > - copied unchanged from r84180, llvm/trunk/lib/Target/PIC16/PIC16Section.cpp > llvm/trunk/lib/Target/PIC16/PIC16Section.h > - copied unchanged from r84180, llvm/trunk/lib/Target/PIC16/PIC16Section.h > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- THIS E-MAIL TRANSMISSION, AND ANY DOCUMENTS, FILES OR PREVIOUS E-MAILS ATTACHED TO IT, IS CONFIDENTIAL INFORMATION INTENDED ONLY FOR THE USE OF THE NAMED RECIPIENT(S). ANY DISSEMINATION, DISTRIBUTION OR DUPLICATION OF THIS TRANSMISSION IS STRICTLY PROHIBITED. If you believe you have received this e-mail in error, please notify the Sender and delete the e-mail from your system. DISCLAIMER OF LIABILITY: This transmittal and any accompanying information is for suggestion only and is provided "AS IS". It shall not be deemed to modify Microchip's standard warranty for its products. It is your responsibility to ensure that this information meets your requirements. MICROCHIP DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED STATUTORY OR OTHERWISE, INCLUDING BUT NOT LIMITED TO MERCHANTABILITY, FITNESS FOR PURPOSE, NON-INFRINGEMENT, QUALITY, OR CONDITION. MICROCHIP PROVIDES THIS INFORMATION CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS. To the fullest extent allowed by law, Microchip's liability shall not exceed the amount of fee, if any, that you have paid directly to Microchip for development of this information and associated services. From evan.cheng at apple.com Fri Oct 16 00:18:41 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 16 Oct 2009 05:18:41 -0000 Subject: [llvm-commits] [llvm] r84244 - /llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp Message-ID: <200910160518.n9G5IfFr009280@zion.cs.uiuc.edu> Author: evancheng Date: Fri Oct 16 00:18:39 2009 New Revision: 84244 URL: http://llvm.org/viewvc/llvm-project?rev=84244&view=rev Log: 80 column violation. Modified: llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp Modified: llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp?rev=84244&r1=84243&r2=84244&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp (original) +++ llvm/trunk/lib/CodeGen/ExactHazardRecognizer.cpp Fri Oct 16 00:18:39 2009 @@ -22,7 +22,8 @@ using namespace llvm; -ExactHazardRecognizer::ExactHazardRecognizer(const InstrItineraryData &LItinData) : +ExactHazardRecognizer:: +ExactHazardRecognizer(const InstrItineraryData &LItinData) : ScheduleHazardRecognizer(), ItinData(LItinData) { // Determine the maximum depth of any itinerary. This determines the From evan.cheng at apple.com Fri Oct 16 00:33:59 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 16 Oct 2009 05:33:59 -0000 Subject: [llvm-commits] [llvm] r84246 - /llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Message-ID: <200910160533.n9G5XxtU009724@zion.cs.uiuc.edu> Author: evancheng Date: Fri Oct 16 00:33:58 2009 New Revision: 84246 URL: http://llvm.org/viewvc/llvm-project?rev=84246&view=rev Log: Add comment. Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=84246&r1=84245&r2=84246&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Fri Oct 16 00:33:58 2009 @@ -101,6 +101,8 @@ // Set CPU specific features. if (CPUString == "cortex-a8") { PostRAScheduler = true; + // On Cortext-a8, it's faster to perform some single-precision FP + // operations with NEON instructions. if (UseNEONFP.getPosition() == 0) UseNEONForSinglePrecisionFP = true; } From xuzhongxing at gmail.com Fri Oct 16 00:42:28 2009 From: xuzhongxing at gmail.com (Zhongxing Xu) Date: Fri, 16 Oct 2009 05:42:28 -0000 Subject: [llvm-commits] [llvm] r84247 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200910160542.n9G5gSDj010002@zion.cs.uiuc.edu> Author: zhongxingxu Date: Fri Oct 16 00:42:28 2009 New Revision: 84247 URL: http://llvm.org/viewvc/llvm-project?rev=84247&view=rev Log: Indent code. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=84247&r1=84246&r2=84247&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Oct 16 00:42:28 2009 @@ -226,7 +226,7 @@ assert(Emitted && "Unable to issue a live-in copy instruction!\n"); (void) Emitted; -CopyRegMap.insert(std::make_pair(prior(Pos), VirtReg)); + CopyRegMap.insert(std::make_pair(prior(Pos), VirtReg)); if (Coalesced) { if (&*InsertPos == UseMI) ++InsertPos; MBB->erase(UseMI); From evan.cheng at apple.com Fri Oct 16 01:10:37 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 16 Oct 2009 06:10:37 -0000 Subject: [llvm-commits] [llvm] r84248 - /llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Message-ID: <200910160610.n9G6AcK1011236@zion.cs.uiuc.edu> Author: evancheng Date: Fri Oct 16 01:10:34 2009 New Revision: 84248 URL: http://llvm.org/viewvc/llvm-project?rev=84248&view=rev Log: If post-alloc scheduler is not enabled, it should return false, not true. Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=84248&r1=84247&r2=84248&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Fri Oct 16 01:10:34 2009 @@ -234,12 +234,12 @@ // Check for explicit enable/disable of post-ra scheduling. if (EnablePostRAScheduler.getPosition() > 0) { if (!EnablePostRAScheduler) - return true; + return false; } else { - // Check that post-RA scheduling is enabled for this function + // Check that post-RA scheduling is enabled for this target. const TargetSubtarget &ST = Fn.getTarget().getSubtarget(); if (!ST.enablePostRAScheduler()) - return true; + return false; } DEBUG(errs() << "PostRAScheduler\n"); From evan.cheng at apple.com Fri Oct 16 01:11:08 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 16 Oct 2009 06:11:08 -0000 Subject: [llvm-commits] [llvm] r84249 - in /llvm/trunk: lib/Target/ARM/ARMSubtarget.cpp test/CodeGen/ARM/ldrd.ll Message-ID: <200910160611.n9G6B9so011263@zion.cs.uiuc.edu> Author: evancheng Date: Fri Oct 16 01:11:08 2009 New Revision: 84249 URL: http://llvm.org/viewvc/llvm-project?rev=84249&view=rev Log: Enable post-alloc scheduling for all ARM variants except for Thumb1. Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp llvm/trunk/test/CodeGen/ARM/ldrd.ll Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=84249&r1=84248&r2=84249&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Fri Oct 16 01:11:08 2009 @@ -27,11 +27,11 @@ cl::init(false), cl::Hidden); ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS, - bool isThumb) + bool isT) : ARMArchVersion(V4T) , ARMFPUType(None) , UseNEONForSinglePrecisionFP(UseNEONFP) - , IsThumb(isThumb) + , IsThumb(isT) , ThumbMode(Thumb1) , PostRAScheduler(false) , IsR9Reserved(ReserveR9) @@ -98,9 +98,11 @@ if (isTargetDarwin()) IsR9Reserved = ReserveR9 | (ARMArchVersion < V6); + if (!isThumb() || hasThumb2()) + PostRAScheduler = true; + // Set CPU specific features. if (CPUString == "cortex-a8") { - PostRAScheduler = true; // On Cortext-a8, it's faster to perform some single-precision FP // operations with NEON instructions. if (UseNEONFP.getPosition() == 0) Modified: llvm/trunk/test/CodeGen/ARM/ldrd.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/ldrd.ll?rev=84249&r1=84248&r2=84249&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/ldrd.ll (original) +++ llvm/trunk/test/CodeGen/ARM/ldrd.ll Fri Oct 16 01:11:08 2009 @@ -7,13 +7,13 @@ define i64 @t(i64 %a) nounwind readonly { entry: -;V6: ldrd r2, [r2] +;V6: ldrd r2, [r2] -;V5: ldr r3, [r2] -;V5-NEXT: ldr r2, [r2, #+4] +;V5: ldr r3, [r2] +;V5: ldr r2, [r2, #+4] -;EABI: ldr r3, [r2] -;EABI-NEXT: ldr r2, [r2, #+4] +;EABI: ldr r3, [r2] +;EABI: ldr r2, [r2, #+4] %0 = load i64** @b, align 4 %1 = load i64* %0, align 4 From evan.cheng at apple.com Fri Oct 16 01:18:10 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 16 Oct 2009 06:18:10 -0000 Subject: [llvm-commits] [llvm] r84250 - /llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Message-ID: <200910160618.n9G6IBXf011504@zion.cs.uiuc.edu> Author: evancheng Date: Fri Oct 16 01:18:09 2009 New Revision: 84250 URL: http://llvm.org/viewvc/llvm-project?rev=84250&view=rev Log: I am no spelling bee. Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=84250&r1=84249&r2=84250&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Fri Oct 16 01:18:09 2009 @@ -103,7 +103,7 @@ // Set CPU specific features. if (CPUString == "cortex-a8") { - // On Cortext-a8, it's faster to perform some single-precision FP + // On Cortex-a8, it's faster to perform some single-precision FP // operations with NEON instructions. if (UseNEONFP.getPosition() == 0) UseNEONForSinglePrecisionFP = true; From baldrick at free.fr Fri Oct 16 02:03:24 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 16 Oct 2009 09:03:24 +0200 Subject: [llvm-commits] [llvm] r84199 - in /llvm/trunk: include/llvm/Analysis/MallocHelper.h lib/Analysis/MallocHelper.cpp lib/Analysis/PointerTracking.cpp lib/Transforms/IPO/GlobalOpt.cpp In-Reply-To: <200910152014.n9FKErMI022629@zion.cs.uiuc.edu> References: <200910152014.n9FKErMI022629@zion.cs.uiuc.edu> Message-ID: <4AD81ABC.8090905@free.fr> Hi Victor, there doesn't seem to be a testcase. > The fix is to classify malloc's into 3 categories: > 1. non-array mallocs > 2. array mallocs whose array size can be determined > 3. mallocs that cannot be determined to be of type 1 or 2 and cannot be optimized Do you plan to do anything in the case when a variable amount is being allocated, and it can be proved that the amount is a multiple of the size of the allocated type? > -/// getMallocArraySize - Returns the array size of a malloc call. The array > -/// size is computated in 1 of 3 ways: > -/// 1. If the element type if of size 1, then array size is the argument to > +/// getMallocArraySize - Returns the array size of a malloc call. For array > +/// mallocs, the size is computated in 1 of 3 ways: computated -> computed > +/// 1. If the element type is of size 1, then array size is the argument to > /// malloc. > /// 2. Else if the malloc's argument is a constant, the array size is that > /// argument divided by the element type's size. What if the constant is not a multiple of the size of the malloc'd type? > /// 3. Else the malloc argument must be a multiplication and the array size is > /// the first operand of the multiplication. So you are not caring about the multiplication overflowing and giving something funny? > -/// This function returns constant 1 if: > -/// 1. The malloc call's allocated type cannot be determined. > -/// 2. IR wasn't created by a call to CallInst::CreateMalloc() with a non-NULL > -/// ArraySize. > +/// For non-array mallocs, the computed size is constant 1. > +/// This function returns NULL for all mallocs whose array size cannot be > +/// determined. Just a general comment about writing comments: I don't think the comment should be explaining the algorithm getMallocArraySize uses, it should be explaining the semantics of getMallocArraySize. Can't you just say that if the amount malloc'd is a multiple of the size of the malloced type then it returns that multiple, otherwise it returns NULL? > +/// isSafeToGetMallocArraySize - Returns true if the array size of a malloc can > +/// be determined. It can be determined in these 3 cases of malloc codegen: > +/// 1. non-array malloc: The malloc's size argument is a constant and equals the /// size of the type being malloced. The above line should be two lines. > +/// 2. array malloc: This is a malloc call with one bitcast use AND the malloc > +/// call's size argument is a constant multiple of the size of the malloced > +/// type. Rather than talking about one bitcast use, why don't you say: we were able to determine the type being malloced. > +/// 3. array malloc: This is a malloc call with one bitcast use AND the malloc > +/// call's size argument is the result of a multiplication by the size of the > +/// malloced type. > +/// Otherwise returns false. As I mentioned above, I don't think you should describe the algorithm a function uses in the comment describing it. Why not only say: Returns true if the array size of a malloc can be determined. Also, why have this logic in its own function? It is only used in getMallocArraySize, and there is the danger that the two functions get out of sync. Ciao, Duncan. From baldrick at free.fr Fri Oct 16 02:12:35 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 16 Oct 2009 09:12:35 +0200 Subject: [llvm-commits] [llvm] r84199 - in /llvm/trunk: include/llvm/Analysis/MallocHelper.h lib/Analysis/MallocHelper.cpp lib/Analysis/PointerTracking.cpp lib/Transforms/IPO/GlobalOpt.cpp In-Reply-To: <200910152014.n9FKErMI022629@zion.cs.uiuc.edu> References: <200910152014.n9FKErMI022629@zion.cs.uiuc.edu> Message-ID: <4AD81CE3.2020304@free.fr> Hi Victor, > Value* llvm::getMallocArraySize(CallInst* CI, LLVMContext &Context, > const TargetData* TD) { > + if (isSafeToGetMallocArraySize(CI, Context, TD)) > + return NULL; looks like the check is inverted here: shouldn't you be returning NULL is it isn't safe, not if it is safe? Ciao, Duncan. From sanjiv.gupta at microchip.com Fri Oct 16 03:58:36 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Fri, 16 Oct 2009 08:58:36 -0000 Subject: [llvm-commits] [llvm] r84251 - in /llvm/trunk/lib/Target/PIC16: AsmPrinter/PIC16AsmPrinter.cpp AsmPrinter/PIC16AsmPrinter.h PIC16ABINames.h PIC16TargetObjectFile.cpp Message-ID: <200910160858.n9G8wbv6030092@zion.cs.uiuc.edu> Author: sgupta Date: Fri Oct 16 03:58:34 2009 New Revision: 84251 URL: http://llvm.org/viewvc/llvm-project?rev=84251&view=rev Log: Cleaned up some code. No functionality change. Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h llvm/trunk/lib/Target/PIC16/PIC16ABINames.h llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=84251&r1=84250&r2=84251&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Fri Oct 16 03:58:34 2009 @@ -73,9 +73,6 @@ DbgInfo.BeginFunction(MF); - // Emit the autos section of function. - // EmitAutos(CurrentFnName); - // Now emit the instructions of function in its code section. const MCSection *fCodeSection = getObjFileLowering().SectionForCode(CurrentFnName); @@ -329,15 +326,11 @@ // Emit initialized data placed in ROM. void PIC16AsmPrinter::EmitRomData(Module &M) { - // Print ROM Data section. - const PIC16Section *ROSection = PTOF->ROMDATASection(); - if (ROSection == NULL) return; - EmitInitializedDataSection(ROSection); + EmitSingleSection(PTOF->ROMDATASection()); } bool PIC16AsmPrinter::doFinalization(Module &M) { printLibcallDecls(); - // EmitRemainingAutos(); DbgInfo.EndModule(M); O << "\n\t" << "END\n"; return AsmPrinter::doFinalization(M); @@ -402,20 +395,13 @@ } } +// Print all IDATA sections. void PIC16AsmPrinter::EmitIData(Module &M) { - - // Print all IDATA sections. - const std::vector &IDATASections = PTOF->IDATASections(); - for (unsigned i = 0; i < IDATASections.size(); i++) { - O << "\n"; - if (IDATASections[i]->getName().find("llvm.") != std::string::npos) - continue; - - EmitInitializedDataSection(IDATASections[i]); - } + EmitSectionList (M, PTOF->IDATASections()); } -void PIC16AsmPrinter::EmitUninitializedDataSection(const PIC16Section *S) { +void PIC16AsmPrinter:: +EmitUninitializedDataSection(const PIC16Section *S) { const TargetData *TD = TM.getTargetData(); OutStreamer.SwitchSection(S); std::vector Items = S->Items; @@ -428,41 +414,52 @@ } } +// Print all UDATA sections. void PIC16AsmPrinter::EmitUData(Module &M) { - // Print all UDATA sections. - const std::vector &UDATASections = PTOF->UDATASections(); - for (unsigned i = 0; i < UDATASections.size(); i++) { - O << "\n"; - EmitUninitializedDataSection(UDATASections[i]); - } + EmitSectionList (M, PTOF->UDATASections()); } +// Print all USER sections. void PIC16AsmPrinter::EmitUserSections(Module &M) { - const std::vector &USERSections = PTOF->USERSections(); - for (unsigned i = 0; i < USERSections.size(); i++) { - O << "\n"; - const PIC16Section *S = USERSections[i]; - if (S->isUDATA_Type()) { - EmitUninitializedDataSection(S); - } else if (S->isIDATA_Type() || S->isROMDATA_Type()) { - EmitInitializedDataSection(S); - } else { - llvm_unreachable ("unknow user section type"); - } - } + EmitSectionList (M, PTOF->USERSections()); } +// Print all AUTO sections. void PIC16AsmPrinter::EmitAllAutos(Module &M) { - // Print all AUTO sections. - const std::vector &AUTOSections = PTOF->AUTOSections(); - for (unsigned i = 0; i < AUTOSections.size(); i++) { - O << "\n"; - EmitUninitializedDataSection(AUTOSections[i]); - } + EmitSectionList (M, PTOF->AUTOSections()); } extern "C" void LLVMInitializePIC16AsmPrinter() { RegisterAsmPrinter X(ThePIC16Target); } +// Emit one data section using correct section emitter based on section type. +void PIC16AsmPrinter::EmitSingleSection(const PIC16Section *S) { + if (S == NULL) return; + + switch (S->getType()) { + default: llvm_unreachable ("unknow user section type"); + case UDATA: + case UDATA_SHR: + case UDATA_OVR: + EmitUninitializedDataSection(S); + break; + case IDATA: + case ROMDATA: + EmitInitializedDataSection(S); + break; + } +} + +// Emit a list of sections. +void PIC16AsmPrinter:: +EmitSectionList(Module &M, const std::vector &SList) { + for (unsigned i = 0; i < SList.size(); i++) { + // Exclude llvm specific metadata sections. + if (SList[i]->getName().find("llvm.") != std::string::npos) + continue; + O << "\n"; + EmitSingleSection(SList[i]); + } +} Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h?rev=84251&r1=84250&r2=84251&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h Fri Oct 16 03:58:34 2009 @@ -60,6 +60,9 @@ void printLibcallDecls(); void EmitUninitializedDataSection(const PIC16Section *S); void EmitInitializedDataSection(const PIC16Section *S); + void EmitSingleSection(const PIC16Section *S); + void EmitSectionList(Module &M, + const std::vector< PIC16Section *> &SList); protected: bool doInitialization(Module &M); bool doFinalization(Module &M); Modified: llvm/trunk/lib/Target/PIC16/PIC16ABINames.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ABINames.h?rev=84251&r1=84250&r2=84251&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ABINames.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ABINames.h Fri Oct 16 03:58:34 2009 @@ -40,6 +40,7 @@ // Global variables do not have any '.' in their names. // These are maily function names and global variable names. // Example - @foo, @i + // Static local variables - @. // ------------------------------------------------------- // Functions and auto variables. // Names are mangled as .. @@ -67,8 +68,12 @@ // SECTION Names // uninitialized globals - @udata..# // initialized globals - @idata..# + // Program memory data - @romdata.# + // Variables with user defined section name - + // Variables with user defined address - @.user_section.

        .# // Function frame - @.frame_section. // Function autos - @.autos_section. + // Overlay sections - @.## // Declarations - Enclosed in comments. No section for them. //---------------------------------------------------------- Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp?rev=84251&r1=84250&r2=84251&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp Fri Oct 16 03:58:34 2009 @@ -22,6 +22,9 @@ PIC16TargetObjectFile::PIC16TargetObjectFile() { } +PIC16TargetObjectFile::~PIC16TargetObjectFile() { +} + /// Find a pic16 section. If not found, create one. PIC16Section *PIC16TargetObjectFile:: getPIC16Section(const std::string &Name, PIC16SectionType Ty, @@ -104,19 +107,11 @@ return Entry; } -/// Do some standard llvm stuff. PIC16 really does not need any of this. +/// Do some standard initialization. void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){ TargetLoweringObjectFile::Initialize(Ctx, tm); TM = &tm; - // BSSSection = getPIC16DataSection("udata.#", UDATA); - // ReadOnlySection = getPIC16DataSection("romdata.#", ROMDATA); - // DataSection = getPIC16DataSection("idata.#", IDATA); - - // Need because otherwise a .text symbol is emitted by DwarfWriter - // in BeginModule, and gpasm cribbs for that .text symbol. - // FIXME: below - // TextSection = getPIC16DataSection("", UDATA); ROMDATASection_ = NULL; } @@ -254,22 +249,7 @@ return TargetLoweringObjectFile::SelectSectionForGlobal(GV, Kind, Mang,TM); } -PIC16TargetObjectFile::~PIC16TargetObjectFile() { -#if 0 - for (unsigned i = 0; i < UDATASections_.size(); i++) - delete UDATASections_[i]; - for (unsigned i = 0; i < IDATASections_.size(); i++) - delete IDATASections_[i]; - - delete ROMDATASection_; - for (unsigned i = 0; i < AUTOSections_.size(); i++) - delete AUTOSections_[i]; - - for (unsigned i = 0; i < USERSections_.size(); i++) - delete USERSections_[i]; -#endif -} /// getExplicitSectionGlobal - Allow the target to completely override From benny.kra at googlemail.com Fri Oct 16 05:29:10 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Fri, 16 Oct 2009 10:29:10 -0000 Subject: [llvm-commits] [llvm] r84252 - /llvm/trunk/lib/Target/PIC16/CMakeLists.txt Message-ID: <200910161029.n9GATBld001580@zion.cs.uiuc.edu> Author: d0k Date: Fri Oct 16 05:29:08 2009 New Revision: 84252 URL: http://llvm.org/viewvc/llvm-project?rev=84252&view=rev Log: Update CMake file. Modified: llvm/trunk/lib/Target/PIC16/CMakeLists.txt Modified: llvm/trunk/lib/Target/PIC16/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/CMakeLists.txt?rev=84252&r1=84251&r2=84252&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/PIC16/CMakeLists.txt Fri Oct 16 05:29:08 2009 @@ -18,6 +18,7 @@ PIC16MemSelOpt.cpp PIC16MCAsmInfo.cpp PIC16RegisterInfo.cpp + PIC16Section.cpp PIC16Subtarget.cpp PIC16TargetMachine.cpp PIC16TargetObjectFile.cpp From baldrick at free.fr Fri Oct 16 07:18:31 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 16 Oct 2009 12:18:31 -0000 Subject: [llvm-commits] [llvm] r84253 - /llvm/trunk/test/Transforms/GVN/calls-readonly.ll Message-ID: <200910161218.n9GCIYJi005720@zion.cs.uiuc.edu> Author: baldrick Date: Fri Oct 16 07:18:23 2009 New Revision: 84253 URL: http://llvm.org/viewvc/llvm-project?rev=84253&view=rev Log: Check that GVN performs this transform even if the calls themselves are not marked readonly, but only the called functions. Modified: llvm/trunk/test/Transforms/GVN/calls-readonly.ll Modified: llvm/trunk/test/Transforms/GVN/calls-readonly.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/calls-readonly.ll?rev=84253&r1=84252&r2=84253&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/calls-readonly.ll (original) +++ llvm/trunk/test/Transforms/GVN/calls-readonly.ll Fri Oct 16 07:18:23 2009 @@ -6,22 +6,22 @@ define i8* @test(i8* %P, i8* %Q, i32 %x, i32 %y) nounwind readonly { entry: - %0 = tail call i32 @strlen(i8* %P) nounwind readonly ; [#uses=2] - %1 = icmp eq i32 %0, 0 ; [#uses=1] - br i1 %1, label %bb, label %bb1 + %0 = tail call i32 @strlen(i8* %P) ; [#uses=2] + %1 = icmp eq i32 %0, 0 ; [#uses=1] + br i1 %1, label %bb, label %bb1 -bb: ; preds = %entry - %2 = sdiv i32 %x, %y ; [#uses=1] - br label %bb1 +bb: ; preds = %entry + %2 = sdiv i32 %x, %y ; [#uses=1] + br label %bb1 -bb1: ; preds = %bb, %entry - %x_addr.0 = phi i32 [ %2, %bb ], [ %x, %entry ] ; [#uses=1] - %3 = tail call i8* @strchr(i8* %Q, i32 97) nounwind readonly ; [#uses=1] - %4 = tail call i32 @strlen(i8* %P) nounwind readonly ; [#uses=1] - %5 = add i32 %x_addr.0, %0 ; [#uses=1] - %.sum = sub i32 %5, %4 ; [#uses=1] - %6 = getelementptr i8* %3, i32 %.sum ; [#uses=1] - ret i8* %6 +bb1: ; preds = %bb, %entry + %x_addr.0 = phi i32 [ %2, %bb ], [ %x, %entry ] ; [#uses=1] + %3 = tail call i8* @strchr(i8* %Q, i32 97) ; [#uses=1] + %4 = tail call i32 @strlen(i8* %P) ; [#uses=1] + %5 = add i32 %x_addr.0, %0 ; [#uses=1] + %.sum = sub i32 %5, %4 ; [#uses=1] + %6 = getelementptr i8* %3, i32 %.sum ; [#uses=1] + ret i8* %6 } declare i32 @strlen(i8*) nounwind readonly From baldrick at free.fr Fri Oct 16 10:20:14 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 16 Oct 2009 15:20:14 -0000 Subject: [llvm-commits] [llvm] r84256 - in /llvm/trunk: include/llvm/Transforms/Utils/SSAUpdater.h lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <200910161520.n9GFKFP5011951@zion.cs.uiuc.edu> Author: baldrick Date: Fri Oct 16 10:20:13 2009 New Revision: 84256 URL: http://llvm.org/viewvc/llvm-project?rev=84256&view=rev Log: Strip trailing white space. Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h?rev=84256&r1=84255&r2=84256&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h Fri Oct 16 10:20:13 2009 @@ -21,7 +21,7 @@ class PHINode; template class SmallVectorImpl; - + /// SSAUpdater - This class updates SSA form for a set of values defined in /// multiple blocks. This is used when code duplication or another unstructured /// transformation wants to rewrite a set of uses of one value with uses of a @@ -33,17 +33,17 @@ /// eliminate them, and want the WeakVH to track this. //typedef DenseMap > AvailableValsTy; void *AV; - + /// PrototypeValue is an arbitrary representative value, which we derive names /// and a type for PHI nodes. Value *PrototypeValue; - + /// IncomingPredInfo - We use this as scratch space when doing our recursive /// walk. This should only be used in GetValueInBlockInternal, normally it /// should be empty. //std::vector > > IncomingPredInfo; void *IPI; - + /// InsertedPHIs - If this is non-null, the SSAUpdater adds all PHI nodes that /// it creates to the vector. SmallVectorImpl *InsertedPHIs; @@ -52,11 +52,11 @@ /// in with all PHI Nodes created by rewriting. SSAUpdater(SmallVectorImpl *InsertedPHIs = 0); ~SSAUpdater(); - + /// Initialize - Reset this object to get ready for a new set of SSA /// updates. ProtoValue is the value used to name PHI nodes. void Initialize(Value *ProtoValue); - + /// AddAvailableValue - Indicate that a rewritten value is available at the /// end of the specified block with the specified value. void AddAvailableValue(BasicBlock *BB, Value *V); @@ -64,11 +64,11 @@ /// HasValueForBlock - Return true if the SSAUpdater already has a value for /// the specified block. bool HasValueForBlock(BasicBlock *BB) const; - + /// GetValueAtEndOfBlock - Construct SSA form, materializing a value that is /// live at the end of the specified block. Value *GetValueAtEndOfBlock(BasicBlock *BB); - + /// GetValueInMiddleOfBlock - Construct SSA form, materializing a value that /// is live in the middle of the specified block. /// @@ -89,14 +89,14 @@ /// merge the appropriate values, and this value isn't live out of the block. /// Value *GetValueInMiddleOfBlock(BasicBlock *BB); - + /// RewriteUse - Rewrite a use of the symbolic value. This handles PHI nodes, /// which use their value in the corresponding predecessor. Note that this /// will not work if the use is supposed to be rewritten to a value defined in /// the same block as the use, but above it. Any 'AddAvailableValue's added /// for the use's block will be considered to be below it. void RewriteUse(Use &U); - + private: Value *GetValueAtEndOfBlockInternal(BasicBlock *BB); void operator=(const SSAUpdater&); // DO NOT IMPLEMENT Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=84256&r1=84255&r2=84256&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Fri Oct 16 10:20:13 2009 @@ -48,7 +48,7 @@ AV = new AvailableValsTy(); else getAvailableVals(AV).clear(); - + if (IPI == 0) IPI = new IncomingPredInfoTy(); else @@ -104,12 +104,12 @@ // GetValueAtEndOfBlock to do our work. if (!getAvailableVals(AV).count(BB)) return GetValueAtEndOfBlock(BB); - + // Otherwise, we have the hard case. Get the live-in values for each // predecessor. SmallVector, 8> PredValues; Value *SingularValue = 0; - + // We can get our predecessor info by walking the pred_iterator list, but it // is relatively slow. If we already have PHI nodes in this block, walk one // of them to get the predecessor list instead. @@ -118,7 +118,7 @@ BasicBlock *PredBB = SomePhi->getIncomingBlock(i); Value *PredVal = GetValueAtEndOfBlock(PredBB); PredValues.push_back(std::make_pair(PredBB, PredVal)); - + // Compute SingularValue. if (i == 0) SingularValue = PredVal; @@ -131,7 +131,7 @@ BasicBlock *PredBB = *PI; Value *PredVal = GetValueAtEndOfBlock(PredBB); PredValues.push_back(std::make_pair(PredBB, PredVal)); - + // Compute SingularValue. if (isFirstPred) { SingularValue = PredVal; @@ -140,25 +140,25 @@ SingularValue = 0; } } - + // If there are no predecessors, just return undef. if (PredValues.empty()) return UndefValue::get(PrototypeValue->getType()); - + // Otherwise, if all the merged values are the same, just use it. if (SingularValue != 0) return SingularValue; - + // Otherwise, we do need a PHI: insert one now. PHINode *InsertedPHI = PHINode::Create(PrototypeValue->getType(), PrototypeValue->getName(), &BB->front()); InsertedPHI->reserveOperandSpace(PredValues.size()); - + // Fill in all the predecessors of the PHI. for (unsigned i = 0, e = PredValues.size(); i != e; ++i) InsertedPHI->addIncoming(PredValues[i].second, PredValues[i].first); - + // See if the PHI node can be merged to a single value. This can happen in // loop cases when we get a PHI of itself and one other value. if (Value *ConstVal = InsertedPHI->hasConstantValue()) { @@ -168,7 +168,7 @@ // If the client wants to know about all new instructions, tell it. if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI); - + DEBUG(errs() << " Inserted PHI: " << *InsertedPHI << "\n"); return InsertedPHI; } @@ -180,7 +180,7 @@ BasicBlock *UseBB = User->getParent(); if (PHINode *UserPN = dyn_cast(User)) UseBB = UserPN->getIncomingBlock(U); - + U.set(GetValueInMiddleOfBlock(UseBB)); } @@ -192,11 +192,11 @@ /// Value *SSAUpdater::GetValueAtEndOfBlockInternal(BasicBlock *BB) { AvailableValsTy &AvailableVals = getAvailableVals(AV); - + // Query AvailableVals by doing an insertion of null. std::pair InsertRes = AvailableVals.insert(std::make_pair(BB, WeakVH())); - + // Handle the case when the insertion fails because we have already seen BB. if (!InsertRes.second) { // If the insertion failed, there are two cases. The first case is that the @@ -204,7 +204,7 @@ // return the value. if (InsertRes.first->second != 0) return InsertRes.first->second; - + // Otherwise, if the value we find is null, then this is the value is not // known but it is being computed elsewhere in our recursion. This means // that we have a cycle. Handle this by inserting a PHI node and returning @@ -214,7 +214,7 @@ PHINode::Create(PrototypeValue->getType(), PrototypeValue->getName(), &BB->front()); } - + // Okay, the value isn't in the map and we just inserted a null in the entry // to indicate that we're processing the block. Since we have no idea what // value is in this block, we have to recurse through our predecessors. @@ -225,13 +225,13 @@ // of the recursion, just use IncomingPredInfo as an explicit stack. IncomingPredInfoTy &IncomingPredInfo = getIncomingPredInfo(IPI); unsigned FirstPredInfoEntry = IncomingPredInfo.size(); - + // As we're walking the predecessors, keep track of whether they are all // producing the same value. If so, this value will capture it, if not, it // will get reset to null. We distinguish the no-predecessor case explicitly // below. TrackingVH SingularValue; - + // We can get our predecessor info by walking the pred_iterator list, but it // is relatively slow. If we already have PHI nodes in this block, walk one // of them to get the predecessor list instead. @@ -240,7 +240,7 @@ BasicBlock *PredBB = SomePhi->getIncomingBlock(i); Value *PredVal = GetValueAtEndOfBlockInternal(PredBB); IncomingPredInfo.push_back(std::make_pair(PredBB, PredVal)); - + // Compute SingularValue. if (i == 0) SingularValue = PredVal; @@ -253,7 +253,7 @@ BasicBlock *PredBB = *PI; Value *PredVal = GetValueAtEndOfBlockInternal(PredBB); IncomingPredInfo.push_back(std::make_pair(PredBB, PredVal)); - + // Compute SingularValue. if (isFirstPred) { SingularValue = PredVal; @@ -262,19 +262,19 @@ SingularValue = 0; } } - + // If there are no predecessors, then we must have found an unreachable block // just return 'undef'. Since there are no predecessors, InsertRes must not // be invalidated. if (IncomingPredInfo.size() == FirstPredInfoEntry) return InsertRes.first->second = UndefValue::get(PrototypeValue->getType()); - + /// Look up BB's entry in AvailableVals. 'InsertRes' may be invalidated. If /// this block is involved in a loop, a no-entry PHI node will have been /// inserted as InsertedVal. Otherwise, we'll still have the null we inserted /// above. TrackingVH &InsertedVal = AvailableVals[BB]; - + // If all the predecessor values are the same then we don't need to insert a // PHI. This is the simple and common case. if (SingularValue) { @@ -291,31 +291,31 @@ } else { InsertedVal = SingularValue; } - + // Drop the entries we added in IncomingPredInfo to restore the stack. IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry, IncomingPredInfo.end()); return InsertedVal; } - + // Otherwise, we do need a PHI: insert one now if we don't already have one. if (InsertedVal == 0) InsertedVal = PHINode::Create(PrototypeValue->getType(), PrototypeValue->getName(), &BB->front()); - + PHINode *InsertedPHI = cast(InsertedVal); InsertedPHI->reserveOperandSpace(IncomingPredInfo.size()-FirstPredInfoEntry); - + // Fill in all the predecessors of the PHI. for (IncomingPredInfoTy::iterator I = IncomingPredInfo.begin()+FirstPredInfoEntry, E = IncomingPredInfo.end(); I != E; ++I) InsertedPHI->addIncoming(I->second, I->first); - + // Drop the entries we added in IncomingPredInfo to restore the stack. IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry, IncomingPredInfo.end()); - + // See if the PHI node can be merged to a single value. This can happen in // loop cases when we get a PHI of itself and one other value. if (Value *ConstVal = InsertedPHI->hasConstantValue()) { @@ -324,12 +324,10 @@ InsertedVal = ConstVal; } else { DEBUG(errs() << " Inserted PHI: " << *InsertedPHI << "\n"); - + // If the client wants to know about all new instructions, tell it. if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI); } - + return InsertedVal; } - - From johnny.chen at apple.com Fri Oct 16 11:09:07 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 16 Oct 2009 09:09:07 -0700 Subject: [llvm-commits] Fix typo of ARM Neon's VABAs and VABAu (Vector Absolute Difference and Accumulate) In-Reply-To: References: <2A76CF12-BC4D-4631-9B40-F794613C9E22@apple.com> Message-ID: <13638639-8E3E-42A9-A14A-1D56C66B0729@apple.com> It's a tedious job to bringup the .td in the first place. :-) On Oct 15, 2009, at 8:59 PM, Bob Wilson wrote: > Applied. I hope there's not too many more of these -- it's kind of embarassing how many of them I got wrong! > > On Oct 15, 2009, at 5:55 PM, Johnny Chen wrote: > >> Hi, >> >> Refs: A7-13 & A8-526 >> Probably the chip designer wants to distinguish VABA and VABD of three registers of the same length >> not with Instr{11-8}, but with only Instr{4}. >> >> But then, for three registers of different lengths, VABAL and VABDL has different Instr{11-8}, but with Instr{4}=0. >> Ref: A7-15. >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From vhernandez at apple.com Fri Oct 16 11:12:24 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 16 Oct 2009 09:12:24 -0700 Subject: [llvm-commits] [llvm] r84199 - in /llvm/trunk: include/llvm/Analysis/MallocHelper.h lib/Analysis/MallocHelper.cpp lib/Analysis/PointerTracking.cpp lib/Transforms/IPO/GlobalOpt.cpp In-Reply-To: <4AD81CE3.2020304@free.fr> References: <200910152014.n9FKErMI022629@zion.cs.uiuc.edu> <4AD81CE3.2020304@free.fr> Message-ID: <06E4B778-ECD2-45FB-8D5F-1CC751B8537C@apple.com> Duncan, You are correct. Will fix that immediately. And add the test case to make sure I didn't mess it up again. Victor On Oct 16, 2009, at 12:12 AM, Duncan Sands wrote: > Hi Victor, > >> Value* llvm::getMallocArraySize(CallInst* CI, LLVMContext &Context, >> const TargetData* TD) { >> + if (isSafeToGetMallocArraySize(CI, Context, TD)) >> + return NULL; > > looks like the check is inverted here: shouldn't you be returning > NULL is it isn't safe, not if it is safe? > > Ciao, > > Duncan. From daniel at zuster.org Fri Oct 16 11:30:03 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 16 Oct 2009 16:30:03 -0000 Subject: [llvm-commits] [llvm] r84257 - in /llvm/trunk/test/MC/AsmParser: variables-invalid.s variables.s Message-ID: <200910161630.n9GGU3I0014412@zion.cs.uiuc.edu> Author: ddunbar Date: Fri Oct 16 11:30:02 2009 New Revision: 84257 URL: http://llvm.org/viewvc/llvm-project?rev=84257&view=rev Log: Force triple in tests. Modified: llvm/trunk/test/MC/AsmParser/variables-invalid.s llvm/trunk/test/MC/AsmParser/variables.s Modified: llvm/trunk/test/MC/AsmParser/variables-invalid.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/variables-invalid.s?rev=84257&r1=84256&r2=84257&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/variables-invalid.s (original) +++ llvm/trunk/test/MC/AsmParser/variables-invalid.s Fri Oct 16 11:30:02 2009 @@ -1,4 +1,4 @@ -// RUN: not llvm-mc %s 2> %t +// RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t // RUN: FileCheck --input-file %t %s .data Modified: llvm/trunk/test/MC/AsmParser/variables.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/variables.s?rev=84257&r1=84256&r2=84257&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/variables.s (original) +++ llvm/trunk/test/MC/AsmParser/variables.s Fri Oct 16 11:30:02 2009 @@ -1,4 +1,4 @@ -// RUN: llvm-mc %s +// RUN: llvm-mc -triple i386-unknown-unknown %s .data t0_v0 = 1 From sabre at nondot.org Fri Oct 16 11:30:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 16 Oct 2009 16:30:58 -0000 Subject: [llvm-commits] [llvm] r84258 - /llvm/trunk/docs/ReleaseNotes.html Message-ID: <200910161630.n9GGUwMk014456@zion.cs.uiuc.edu> Author: lattner Date: Fri Oct 16 11:30:58 2009 New Revision: 84258 URL: http://llvm.org/viewvc/llvm-project?rev=84258&view=rev Log: Update from Cristina, llvm-gcc doesn't build on the SPARC version of solaris at the moment. Modified: llvm/trunk/docs/ReleaseNotes.html Modified: llvm/trunk/docs/ReleaseNotes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=84258&r1=84257&r2=84258&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes.html (original) +++ llvm/trunk/docs/ReleaseNotes.html Fri Oct 16 11:30:58 2009 @@ -1025,7 +1025,7 @@
      53. Intel and AMD machines running on Win32 using MinGW libraries (native).
      54. Intel and AMD machines running on Win32 with the Cygwin libraries (limited support is available for native builds with Visual C++).
      55. -
      56. Sun UltraSPARC workstations running Solaris 10.
      57. +
      58. Sun x86 and AMD64 machines running Solaris 10, OpenSolaris 0906.
      59. Alpha-based machines running Debian GNU/Linux.
      60. From vhernandez at apple.com Fri Oct 16 13:07:20 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 16 Oct 2009 18:07:20 -0000 Subject: [llvm-commits] [llvm] r84260 - /llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll Message-ID: <200910161807.n9GI7L1F018059@zion.cs.uiuc.edu> Author: hernande Date: Fri Oct 16 13:07:17 2009 New Revision: 84260 URL: http://llvm.org/viewvc/llvm-project?rev=84260&view=rev Log: Invert isSafeToGetMallocArraySize check because we return NULL when we don't know the size. Thanks to Duncan Sands for noticing this bug. Added: llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll Added: llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll?rev=84260&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll (added) +++ llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll Fri Oct 16 13:07:17 2009 @@ -0,0 +1,30 @@ +; Test ensures that non-optimizable array mallocs are not optimized; specifically +; GlobalOpt was treating a non-optimizable array malloc as a non-array malloc +; and optimizing the global object that the malloc was stored to as a single +; element global. The global object @TOP in this test should not be optimized. +; RUN: opt < %s -globalopt -S | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-apple-darwin10.0" + + at TOP = internal global i64* null ; [#uses=2] +; CHECK: @TOP = internal global i64* null + at channelColumns = internal global i64 0 ; [#uses=2] + +; Derived from @DescribeChannel() in yacr2 +define void @test() nounwind ssp { + store i64 2335, i64* @channelColumns, align 8 + %1 = load i64* @channelColumns, align 8 ; [#uses=1] + %2 = shl i64 %1, 3 ; [#uses=1] + %3 = add i64 %2, 8 ; [#uses=1] + %4 = call noalias i8* @malloc(i64 %3) nounwind ; [#uses=1] +; CHECK: call noalias i8* @malloc + %5 = bitcast i8* %4 to i64* ; [#uses=1] + store i64* %5, i64** @TOP, align 8 + %6 = load i64** @TOP, align 8 ; [#uses=1] + %7 = getelementptr inbounds i64* %6, i64 13 ; [#uses=1] + store i64 0, i64* %7, align 8 + ret void +} + +declare noalias i8* @malloc(i64) nounwind From vhernandez at apple.com Fri Oct 16 13:08:18 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 16 Oct 2009 18:08:18 -0000 Subject: [llvm-commits] [llvm] r84261 - /llvm/trunk/lib/Analysis/MallocHelper.cpp Message-ID: <200910161808.n9GI8IH5018092@zion.cs.uiuc.edu> Author: hernande Date: Fri Oct 16 13:08:17 2009 New Revision: 84261 URL: http://llvm.org/viewvc/llvm-project?rev=84261&view=rev Log: Invert isSafeToGetMallocArraySize check because we return NULL when we don't know the size. Thanks to Duncan Sands for noticing this bug. Modified: llvm/trunk/lib/Analysis/MallocHelper.cpp Modified: llvm/trunk/lib/Analysis/MallocHelper.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MallocHelper.cpp?rev=84261&r1=84260&r2=84261&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MallocHelper.cpp (original) +++ llvm/trunk/lib/Analysis/MallocHelper.cpp Fri Oct 16 13:08:17 2009 @@ -234,7 +234,7 @@ /// determined. Value* llvm::getMallocArraySize(CallInst* CI, LLVMContext &Context, const TargetData* TD) { - if (isSafeToGetMallocArraySize(CI, Context, TD)) + if (!isSafeToGetMallocArraySize(CI, Context, TD)) return NULL; // Match CreateMalloc's use of constant 1 array-size for non-array mallocs. From vhernandez at apple.com Fri Oct 16 13:09:21 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 16 Oct 2009 11:09:21 -0700 Subject: [llvm-commits] [llvm] r84260 - /llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll In-Reply-To: <200910161807.n9GI7L1F018059@zion.cs.uiuc.edu> References: <200910161807.n9GI7L1F018059@zion.cs.uiuc.edu> Message-ID: <5B2311A8-0FDB-4D3E-926D-75CF8DA3DBD7@apple.com> Apologies, this is the commit message for rev 84261. This is the testcase that tests for the bug fixed by rev 84261. Victor On Oct 16, 2009, at 11:07 AM, Victor Hernandez wrote: > Author: hernande > Date: Fri Oct 16 13:07:17 2009 > New Revision: 84260 > > URL: http://llvm.org/viewvc/llvm-project?rev=84260&view=rev > Log: > Invert isSafeToGetMallocArraySize check because we return NULL when > we don't know the size. > > Thanks to Duncan Sands for noticing this bug. > > > Added: > llvm/trunk/test/Transforms/GlobalOpt/2009-11-16- > MallocSingleStoreToGlobalVar.ll > > Added: llvm/trunk/test/Transforms/GlobalOpt/2009-11-16- > MallocSingleStoreToGlobalVar.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll?rev=84260&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/Transforms/GlobalOpt/2009-11-16- > MallocSingleStoreToGlobalVar.ll (added) > +++ llvm/trunk/test/Transforms/GlobalOpt/2009-11-16- > MallocSingleStoreToGlobalVar.ll Fri Oct 16 13:07:17 2009 > @@ -0,0 +1,30 @@ > +; Test ensures that non-optimizable array mallocs are not > optimized; specifically > +; GlobalOpt was treating a non-optimizable array malloc as a non- > array malloc > +; and optimizing the global object that the malloc was stored to as > a single > +; element global. The global object @TOP in this test should not > be optimized. > +; RUN: opt < %s -globalopt -S | FileCheck %s > + > +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32- > i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64- > s0:64:64-f80:128:128" > +target triple = "x86_64-apple-darwin10.0" > + > + at TOP = internal global i64* null ; > [#uses=2] > +; CHECK: @TOP = internal global i64* null > + at channelColumns = internal global i64 0 ; > [#uses=2] > + > +; Derived from @DescribeChannel() in yacr2 > +define void @test() nounwind ssp { > + store i64 2335, i64* @channelColumns, align 8 > + %1 = load i64* @channelColumns, align 8 ; [#uses=1] > + %2 = shl i64 %1, 3 ; [#uses=1] > + %3 = add i64 %2, 8 ; [#uses=1] > + %4 = call noalias i8* @malloc(i64 %3) nounwind ; [#uses=1] > +; CHECK: call noalias i8* @malloc > + %5 = bitcast i8* %4 to i64* ; [#uses=1] > + store i64* %5, i64** @TOP, align 8 > + %6 = load i64** @TOP, align 8 ; [#uses=1] > + %7 = getelementptr inbounds i64* %6, i64 13 ; [#uses=1] > + store i64 0, i64* %7, align 8 > + ret void > +} > + > +declare noalias i8* @malloc(i64) nounwind > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From johnny.chen at apple.com Fri Oct 16 13:17:26 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 16 Oct 2009 11:17:26 -0700 Subject: [llvm-commits] Patch for encodings of VEXT (Vector Extract) Message-ID: Hi, Refs: A8-598. Leave Inst{11-8}, which represents the starting byte index of the extracted result in the concatenation of the operands and is left unspecified. -------------- next part -------------- A non-text attachment was scrubbed... Name: ARMInstrNEON.patch5 Type: application/octet-stream Size: 2673 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091016/b71ba602/attachment.obj From dpatel at apple.com Fri Oct 16 13:18:04 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 16 Oct 2009 18:18:04 -0000 Subject: [llvm-commits] [llvm] r84262 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/DebugInfo/2009-11-16-Scope.ll Message-ID: <200910161818.n9GII4oO018390@zion.cs.uiuc.edu> Author: dpatel Date: Fri Oct 16 13:18:03 2009 New Revision: 84262 URL: http://llvm.org/viewvc/llvm-project?rev=84262&view=rev Log: If there is not any llvm instruction associated with each lexical scope encoded in debug info then create such scope on demand for variable info. Added: llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=84262&r1=84261&r2=84262&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Oct 16 13:18:03 2009 @@ -1811,10 +1811,18 @@ DIVariable DV (Var); if (DV.isNull()) continue; unsigned VSlot = VI->second; + DbgScope *Scope = NULL; DenseMap::iterator DSI = DbgScopeMap.find(DV.getContext().getNode()); - assert (DSI != DbgScopeMap.end() && "Unable to find variable scope!"); - DbgScope *Scope = DSI->second; + if (DSI != DbgScopeMap.end()) + Scope = DSI->second; + else + // There is not any instruction assocated with this scope, so get + // a new scope. + Scope = getDbgScope(DV.getContext().getNode(), + NULL /* Not an instruction */, + NULL /* Not inlined */); + assert (Scope && "Unable to find variable scope!"); Scope->AddVariable(new DbgVariable(DV, VSlot, false)); } } Added: llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll?rev=84262&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll (added) +++ llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll Fri Oct 16 13:18:03 2009 @@ -0,0 +1,33 @@ +; RUN: llc %s -O0 -o /dev/null +; PR 5197 +; There is not any llvm instruction assocated with !5. The code generator +; should be able to handle this. + +define void @bar() nounwind ssp { +entry: + %count_ = alloca i32, align 4 ; [#uses=2] + br label %do.body, !dbg !0 + +do.body: ; preds = %entry + %0 = bitcast i32* %count_ to { }* ; <{ }*> [#uses=1] + call void @llvm.dbg.declare({ }* %0, metadata !4) + %conv = ptrtoint i32* %count_ to i32, !dbg !0 ; [#uses=1] + %call = call i32 @foo(i32 %conv) ssp, !dbg !0 ; [#uses=0] + br label %do.end, !dbg !0 + +do.end: ; preds = %do.body + ret void, !dbg !7 +} + +declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone + +declare i32 @foo(i32) ssp + +!0 = metadata !{i32 5, i32 2, metadata !1, null} +!1 = metadata !{i32 458763, metadata !2}; [DW_TAG_lexical_block ] +!2 = metadata !{i32 458798, i32 0, metadata !3, metadata !"bar", metadata !"bar", metadata !"bar", metadata !3, i32 4, null, i1 false, i1 true}; [DW_TAG_subprogram ] +!3 = metadata !{i32 458769, i32 0, i32 12, metadata !"genmodes.i", metadata !"/Users/yash/Downloads", metadata !"clang 1.1", i1 true, i1 false, metadata !"", i32 0}; [DW_TAG_compile_unit ] +!4 = metadata !{i32 459008, metadata !5, metadata !"count_", metadata !3, i32 5, metadata !6}; [ DW_TAG_auto_variable ] +!5 = metadata !{i32 458763, metadata !1}; [DW_TAG_lexical_block ] +!6 = metadata !{i32 458788, metadata !3, metadata !"int", metadata !3, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5}; [DW_TAG_base_type ] +!7 = metadata !{i32 6, i32 1, metadata !2, null} From dpatel at apple.com Fri Oct 16 13:45:50 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 16 Oct 2009 18:45:50 -0000 Subject: [llvm-commits] [llvm] r84264 - in /llvm/trunk: lib/AsmParser/LLParser.cpp test/DebugInfo/2009-11-16-Phi.ll Message-ID: <200910161845.n9GIjoVA019536@zion.cs.uiuc.edu> Author: dpatel Date: Fri Oct 16 13:45:49 2009 New Revision: 84264 URL: http://llvm.org/viewvc/llvm-project?rev=84264&view=rev Log: Parse PHI instruction with attached metadata. Added: llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll Modified: llvm/trunk/lib/AsmParser/LLParser.cpp Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=84264&r1=84263&r2=84264&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Oct 16 13:45:49 2009 @@ -3315,6 +3315,9 @@ if (!EatIfPresent(lltok::comma)) break; + if (Lex.getKind() == lltok::NamedOrCustomMD) + break; + if (ParseToken(lltok::lsquare, "expected '[' in phi value list") || ParseValue(Ty, Op0, PFS) || ParseToken(lltok::comma, "expected ',' after insertelement value") || @@ -3323,6 +3326,9 @@ return true; } + if (Lex.getKind() == lltok::NamedOrCustomMD) + if (ParseOptionalCustomMetadata()) return true; + if (!Ty->isFirstClassType()) return Error(TypeLoc, "phi node must have first class type"); Added: llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll?rev=84264&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll (added) +++ llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll Fri Oct 16 13:45:49 2009 @@ -0,0 +1,13 @@ +; RUN: llvm-as %s -disable-output + +define i32 @foo() { +E: + br label %B2 +B1: + br label %B2 +B2: + %0 = phi i32 [ 0, %E ], [ 1, %B1 ], !dbg !0 + ret i32 %0 +} + +!0 = metadata !{i32 42} \ No newline at end of file From gohman at apple.com Fri Oct 16 15:59:36 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 16 Oct 2009 20:59:36 -0000 Subject: [llvm-commits] [llvm] r84271 - in /llvm/trunk: lib/Transforms/Scalar/CodeGenPrepare.cpp test/CodeGen/X86/codegen-prepare-extload.ll test/CodeGen/X86/stack-color-with-reg.ll Message-ID: <200910162059.n9GKxalW024201@zion.cs.uiuc.edu> Author: djg Date: Fri Oct 16 15:59:35 2009 New Revision: 84271 URL: http://llvm.org/viewvc/llvm-project?rev=84271&view=rev Log: Move zext and sext casts fed by loads into the same block as the load, to help SelectionDAG fold them into the loads, unless conditions are unfavorable. Added: llvm/trunk/test/CodeGen/X86/codegen-prepare-extload.ll Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=84271&r1=84270&r2=84271&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Fri Oct 16 15:59:35 2009 @@ -73,6 +73,7 @@ DenseMap &SunkAddrs); bool OptimizeInlineAsmInst(Instruction *I, CallSite CS, DenseMap &SunkAddrs); + bool MoveExtToFormExtLoad(Instruction *I); bool OptimizeExtUses(Instruction *I); void findLoopBackEdges(const Function &F); }; @@ -731,6 +732,43 @@ return MadeChange; } +/// MoveExtToFormExtLoad - Move a zext or sext fed by a load into the same +/// basic block as the load, unless conditions are unfavorable. This allows +/// SelectionDAG to fold the extend into the load. +/// +bool CodeGenPrepare::MoveExtToFormExtLoad(Instruction *I) { + // Look for a load being extended. + LoadInst *LI = dyn_cast(I->getOperand(0)); + if (!LI) return false; + + // If they're already in the same block, there's nothing to do. + if (LI->getParent() == I->getParent()) + return false; + + // If the load has other users and the truncate is not free, this probably + // isn't worthwhile. + if (!LI->hasOneUse() && + TLI && !TLI->isTruncateFree(I->getType(), LI->getType())) + return false; + + // Check whether the target supports casts folded into loads. + unsigned LType; + if (isa(I)) + LType = ISD::ZEXTLOAD; + else { + assert(isa(I) && "Unexpected ext type!"); + LType = ISD::SEXTLOAD; + } + if (TLI && !TLI->isLoadExtLegal(LType, TLI->getValueType(LI->getType()))) + return false; + + // Move the extend into the same block as the load, so that SelectionDAG + // can fold it. + I->removeFromParent(); + I->insertAfter(LI); + return true; +} + bool CodeGenPrepare::OptimizeExtUses(Instruction *I) { BasicBlock *DefBB = I->getParent(); @@ -846,8 +884,10 @@ MadeChange |= Change; } - if (!Change && (isa(I) || isa(I))) + if (!Change && (isa(I) || isa(I))) { + MadeChange |= MoveExtToFormExtLoad(I); MadeChange |= OptimizeExtUses(I); + } } else if (CmpInst *CI = dyn_cast(I)) { MadeChange |= OptimizeCmpExpression(CI); } else if (LoadInst *LI = dyn_cast(I)) { Added: llvm/trunk/test/CodeGen/X86/codegen-prepare-extload.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/codegen-prepare-extload.ll?rev=84271&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/codegen-prepare-extload.ll (added) +++ llvm/trunk/test/CodeGen/X86/codegen-prepare-extload.ll Fri Oct 16 15:59:35 2009 @@ -0,0 +1,20 @@ +; RUN: llc < %s -march=x86-64 | FileCheck %s +; rdar://7304838 + +; CodeGenPrepare should move the zext into the block with the load +; so that SelectionDAG can select it with the load. + +; CHECK: movzbl (%rdi), %eax + +define void @foo(i8* %p, i32* %q) { +entry: + %t = load i8* %p + %a = icmp slt i8 %t, 20 + br i1 %a, label %true, label %false +true: + %s = zext i8 %t to i32 + store i32 %s, i32* %q + ret void +false: + ret void +} Modified: llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll?rev=84271&r1=84270&r2=84271&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll (original) +++ llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Fri Oct 16 15:59:35 2009 @@ -1,6 +1,6 @@ ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -relocation-model=pic -disable-fp-elim -color-ss-with-regs -stats -info-output-file - > %t -; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 5 -; RUN: grep asm-printer %t | grep 179 +; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 6 +; RUN: grep asm-printer %t | grep 177 type { [62 x %struct.Bitvec*] } ; type %0 type { i8* } ; type %1 From evan.cheng at apple.com Fri Oct 16 16:02:20 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 16 Oct 2009 21:02:20 -0000 Subject: [llvm-commits] [llvm] r84272 - in /llvm/trunk: include/llvm/Target/TargetMachine.h tools/llc/llc.cpp tools/lli/lli.cpp Message-ID: <200910162102.n9GL2KSa024364@zion.cs.uiuc.edu> Author: evancheng Date: Fri Oct 16 16:02:20 2009 New Revision: 84272 URL: http://llvm.org/viewvc/llvm-project?rev=84272&view=rev Log: Add a CodeGenOpt::Less level to match -O1. It'll be used by clients which do not want post-regalloc scheduling. Modified: llvm/trunk/include/llvm/Target/TargetMachine.h llvm/trunk/tools/llc/llc.cpp llvm/trunk/tools/lli/lli.cpp Modified: llvm/trunk/include/llvm/Target/TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=84272&r1=84271&r2=84272&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) +++ llvm/trunk/include/llvm/Target/TargetMachine.h Fri Oct 16 16:02:20 2009 @@ -74,9 +74,10 @@ // Code generation optimization level. namespace CodeGenOpt { enum Level { - Default, - None, - Aggressive + None, // -O0 + Less, // -O1 + Default, // -O2, -Os + Aggressive // -O3 }; } Modified: llvm/trunk/tools/llc/llc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=84272&r1=84271&r2=84272&view=diff ============================================================================== --- llvm/trunk/tools/llc/llc.cpp (original) +++ llvm/trunk/tools/llc/llc.cpp Fri Oct 16 16:02:20 2009 @@ -298,7 +298,7 @@ return 1; case ' ': break; case '0': OLvl = CodeGenOpt::None; break; - case '1': + case '1': OLvl = CodeGenOpt::Less; break; case '2': OLvl = CodeGenOpt::Default; break; case '3': OLvl = CodeGenOpt::Aggressive; break; } Modified: llvm/trunk/tools/lli/lli.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=84272&r1=84271&r2=84272&view=diff ============================================================================== --- llvm/trunk/tools/lli/lli.cpp (original) +++ llvm/trunk/tools/lli/lli.cpp Fri Oct 16 16:02:20 2009 @@ -148,7 +148,7 @@ return 1; case ' ': break; case '0': OLvl = CodeGenOpt::None; break; - case '1': + case '1': OLvl = CodeGenOpt::Less; break; case '2': OLvl = CodeGenOpt::Default; break; case '3': OLvl = CodeGenOpt::Aggressive; break; } From evan.cheng at apple.com Fri Oct 16 16:06:16 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 16 Oct 2009 21:06:16 -0000 Subject: [llvm-commits] [llvm] r84273 - in /llvm/trunk: include/llvm/CodeGen/Passes.h include/llvm/Target/TargetSubtarget.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/PostRASchedulerList.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/X86/X86Subtarget.h Message-ID: <200910162106.n9GL6G9n024486@zion.cs.uiuc.edu> Author: evancheng Date: Fri Oct 16 16:06:15 2009 New Revision: 84273 URL: http://llvm.org/viewvc/llvm-project?rev=84273&view=rev Log: Change createPostRAScheduler so it can be turned off at llc -O1. Modified: llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/include/llvm/Target/TargetSubtarget.h llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h llvm/trunk/lib/Target/X86/X86Subtarget.h Modified: llvm/trunk/include/llvm/CodeGen/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=84273&r1=84272&r2=84273&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) +++ llvm/trunk/include/llvm/CodeGen/Passes.h Fri Oct 16 16:06:15 2009 @@ -15,13 +15,13 @@ #ifndef LLVM_CODEGEN_PASSES_H #define LLVM_CODEGEN_PASSES_H +#include "llvm/Target/TargetMachine.h" #include namespace llvm { class FunctionPass; class PassInfo; - class TargetMachine; class TargetLowering; class RegisterCoalescer; class raw_ostream; @@ -119,8 +119,9 @@ /// FunctionPass *createLowerSubregsPass(); - /// createPostRAScheduler - under development. - FunctionPass *createPostRAScheduler(); + /// createPostRAScheduler - This pass performs post register allocation + /// scheduling. + FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel); /// BranchFolding Pass - This pass performs machine code CFG based /// optimizations to delete branches to branches, eliminate branches to Modified: llvm/trunk/include/llvm/Target/TargetSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSubtarget.h?rev=84273&r1=84272&r2=84273&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetSubtarget.h (original) +++ llvm/trunk/include/llvm/Target/TargetSubtarget.h Fri Oct 16 16:06:15 2009 @@ -14,6 +14,8 @@ #ifndef LLVM_TARGET_TARGETSUBTARGET_H #define LLVM_TARGET_TARGETSUBTARGET_H +#include "llvm/Target/TargetMachine.h" + namespace llvm { class SDep; @@ -39,9 +41,12 @@ /// should be attempted. virtual unsigned getSpecialAddressLatency() const { return 0; } - // enablePostRAScheduler - Return true to enable - // post-register-allocation scheduling. - virtual bool enablePostRAScheduler() const { return false; } + // enablePostRAScheduler - If the target can benefit from post-regalloc + // scheduling and the specified optimization level meets the requirement + // return true to enable post-register-allocation scheduling. + virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel) const { + return false; + } // adjustSchedDependency - Perform target specific adjustments to // the latency of a schedule dependency. Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=84273&r1=84272&r2=84273&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Oct 16 16:06:15 2009 @@ -323,7 +323,7 @@ // Second pass scheduler. if (OptLevel != CodeGenOpt::None) { - PM.add(createPostRAScheduler()); + PM.add(createPostRAScheduler(OptLevel)); printAndVerify(PM); } Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=84273&r1=84272&r2=84273&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Fri Oct 16 16:06:15 2009 @@ -78,10 +78,12 @@ namespace { class VISIBILITY_HIDDEN PostRAScheduler : public MachineFunctionPass { AliasAnalysis *AA; + CodeGenOpt::Level OptLevel; public: static char ID; - PostRAScheduler() : MachineFunctionPass(&ID) {} + PostRAScheduler(CodeGenOpt::Level ol) : + MachineFunctionPass(&ID), OptLevel(ol) {} void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); @@ -238,7 +240,7 @@ } else { // Check that post-RA scheduling is enabled for this target. const TargetSubtarget &ST = Fn.getTarget().getSubtarget(); - if (!ST.enablePostRAScheduler()) + if (!ST.enablePostRAScheduler(OptLevel)) return false; } @@ -1195,6 +1197,6 @@ // Public Constructor Functions //===----------------------------------------------------------------------===// -FunctionPass *llvm::createPostRAScheduler() { - return new PostRAScheduler(); +FunctionPass *llvm::createPostRAScheduler(CodeGenOpt::Level OptLevel) { + return new PostRAScheduler(OptLevel); } Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=84273&r1=84272&r2=84273&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Fri Oct 16 16:06:15 2009 @@ -126,9 +126,11 @@ const std::string & getCPUString() const { return CPUString; } - /// enablePostRAScheduler - From TargetSubtarget, return true to - /// enable post-RA scheduler. - bool enablePostRAScheduler() const { return PostRAScheduler; } + /// enablePostRAScheduler - True at 'More' optimization except + /// for Thumb1. + bool enablePostRAScheduler(CodeGenOpt::Level OptLevel) const { + return PostRAScheduler && OptLevel >= CodeGenOpt::Default; + } /// getInstrItins - Return the instruction itineraies based on subtarget /// selection. Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=84273&r1=84272&r2=84273&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Fri Oct 16 16:06:15 2009 @@ -215,6 +215,13 @@ /// indicating the number of scheduling cycles of backscheduling that /// should be attempted. unsigned getSpecialAddressLatency() const; + + /// enablePostRAScheduler - X86 target is enabling post-alloc scheduling + /// at 'More' optimization level. + bool enablePostRAScheduler(CodeGenOpt::Level OptLevel) const { + // FIXME: This causes llvm to miscompile itself on i386. :-( + return false/*OptLevel >= CodeGenOpt::Default*/; + } }; } // End llvm namespace From evan.cheng at apple.com Fri Oct 16 16:07:30 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 16 Oct 2009 21:07:30 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r84274 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200910162107.n9GL7Ukv024537@zion.cs.uiuc.edu> Author: evancheng Date: Fri Oct 16 16:07:29 2009 New Revision: 84274 URL: http://llvm.org/viewvc/llvm-project?rev=84274&view=rev Log: Match llvm CodeGenOpt change. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=84274&r1=84273&r2=84274&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Fri Oct 16 16:07:29 2009 @@ -655,13 +655,14 @@ FunctionPassManager *PM = PerFunctionPasses; HasPerFunctionPasses = true; - CodeGenOpt::Level OptLevel = CodeGenOpt::Default; - - switch (optimize) { - default: break; - case 0: OptLevel = CodeGenOpt::None; break; - case 3: OptLevel = CodeGenOpt::Aggressive; break; - } + CodeGenOpt::Level OptLevel = CodeGenOpt::Default; // -O2, -Os, and -Oz + if (optimize == 0) + OptLevel = CodeGenOpt::None; + else if (optimize == 1) + OptLevel = CodeGenOpt::Less; + else if (optimize == 3) + // -O3 and above. + OptLevel = CodeGenOpt::Aggressive; // Normal mode, emit a .s file by running the code generator. // Note, this also adds codegenerator level optimization passes. From dpatel at apple.com Fri Oct 16 16:27:44 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 16 Oct 2009 21:27:44 -0000 Subject: [llvm-commits] [llvm] r84276 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200910162127.n9GLRiAs025141@zion.cs.uiuc.edu> Author: dpatel Date: Fri Oct 16 16:27:43 2009 New Revision: 84276 URL: http://llvm.org/viewvc/llvm-project?rev=84276&view=rev Log: Do not emit name entry for a pointer type. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=84276&r1=84275&r2=84276&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Oct 16 16:27:43 2009 @@ -923,7 +923,7 @@ AddType(DW_Unit, &Buffer, FromTy); // Add name if not anonymous or intermediate type. - if (Name) + if (Name && Tag != dwarf::DW_TAG_pointer_type) AddString(&Buffer, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name); // Add size if non-zero (derived types might be zero-sized.) From wangmp at apple.com Fri Oct 16 17:06:15 2009 From: wangmp at apple.com (Mon P Wang) Date: Fri, 16 Oct 2009 22:06:15 -0000 Subject: [llvm-commits] [llvm] r84279 - in /llvm/trunk/lib/CodeGen/SelectionDAG: LegalizeTypes.h LegalizeVectorTypes.cpp Message-ID: <200910162206.n9GM6JQh026732@zion.cs.uiuc.edu> Author: wangmp Date: Fri Oct 16 17:05:48 2009 New Revision: 84279 URL: http://llvm.org/viewvc/llvm-project?rev=84279&view=rev Log: Allow widening of extract subvector Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=84279&r1=84278&r2=84279&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Fri Oct 16 17:05:48 2009 @@ -617,6 +617,7 @@ SDValue WidenVecOp_BIT_CONVERT(SDNode *N); SDValue WidenVecOp_CONCAT_VECTORS(SDNode *N); SDValue WidenVecOp_EXTRACT_VECTOR_ELT(SDNode *N); + SDValue WidenVecOp_EXTRACT_SUBVECTOR(SDNode *N); SDValue WidenVecOp_STORE(SDNode* N); SDValue WidenVecOp_Convert(SDNode *N); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=84279&r1=84278&r2=84279&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Fri Oct 16 17:05:48 2009 @@ -1789,6 +1789,7 @@ case ISD::BIT_CONVERT: Res = WidenVecOp_BIT_CONVERT(N); break; case ISD::CONCAT_VECTORS: Res = WidenVecOp_CONCAT_VECTORS(N); break; + case ISD::EXTRACT_SUBVECTOR: Res = WidenVecOp_EXTRACT_SUBVECTOR(N); break; case ISD::EXTRACT_VECTOR_ELT: Res = WidenVecOp_EXTRACT_VECTOR_ELT(N); break; case ISD::STORE: Res = WidenVecOp_STORE(N); break; @@ -1893,6 +1894,12 @@ return DAG.getNode(ISD::BUILD_VECTOR, dl, VT, &Ops[0], NumElts); } +SDValue DAGTypeLegalizer::WidenVecOp_EXTRACT_SUBVECTOR(SDNode *N) { + SDValue InOp = GetWidenedVector(N->getOperand(0)); + return DAG.getNode(ISD::EXTRACT_SUBVECTOR, N->getDebugLoc(), + N->getValueType(0), InOp, N->getOperand(1)); +} + SDValue DAGTypeLegalizer::WidenVecOp_EXTRACT_VECTOR_ELT(SDNode *N) { SDValue InOp = GetWidenedVector(N->getOperand(0)); return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, N->getDebugLoc(), From wangmp at apple.com Fri Oct 16 17:07:20 2009 From: wangmp at apple.com (Mon P Wang) Date: Fri, 16 Oct 2009 22:07:20 -0000 Subject: [llvm-commits] [llvm] r84280 - /llvm/trunk/test/CodeGen/X86/widen_extract-1.ll Message-ID: <200910162207.n9GM7LJM026779@zion.cs.uiuc.edu> Author: wangmp Date: Fri Oct 16 17:07:19 2009 New Revision: 84280 URL: http://llvm.org/viewvc/llvm-project?rev=84280&view=rev Log: Add test case for r84279 Added: llvm/trunk/test/CodeGen/X86/widen_extract-1.ll Added: llvm/trunk/test/CodeGen/X86/widen_extract-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_extract-1.ll?rev=84280&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_extract-1.ll (added) +++ llvm/trunk/test/CodeGen/X86/widen_extract-1.ll Fri Oct 16 17:07:19 2009 @@ -0,0 +1,12 @@ +; RUN: llc < %s -march=x86-64 -mattr=+sse42 -disable-mmx | FileCheck %s +; widen extract subvector + +define void @convert(<2 x double>* %dst.addr, <3 x double> %src) { +entry: +; CHECK: convert: +; CHECK: unpcklpd {{%xmm[0-7]}}, {{%xmm[0-7]}} +; CHECK-NEXT: movapd + %val = shufflevector <3 x double> %src, <3 x double> undef, <2 x i32> < i32 0, i32 1> + store <2 x double> %val, <2 x double>* %dst.addr + ret void +} From wangmp at apple.com Fri Oct 16 17:09:11 2009 From: wangmp at apple.com (Mon P Wang) Date: Fri, 16 Oct 2009 22:09:11 -0000 Subject: [llvm-commits] [llvm] r84282 - in /llvm/trunk/test/CodeGen/X86: widen_arith-1.ll widen_arith-2.ll widen_arith-3.ll widen_arith-4.ll widen_arith-5.ll widen_arith-6.ll widen_cast-1.ll widen_cast-2.ll widen_cast-3.ll widen_cast-4.ll widen_cast-5.ll widen_cast-6.ll widen_conv-1.ll widen_conv-2.ll widen_conv-3.ll widen_conv-4.ll widen_select-1.ll widen_shuffle-1.ll widen_shuffle-2.ll Message-ID: <200910162209.n9GM9FQ3026874@zion.cs.uiuc.edu> Author: wangmp Date: Fri Oct 16 17:09:05 2009 New Revision: 84282 URL: http://llvm.org/viewvc/llvm-project?rev=84282&view=rev Log: Update tests to use FileCheck Modified: llvm/trunk/test/CodeGen/X86/widen_arith-1.ll llvm/trunk/test/CodeGen/X86/widen_arith-2.ll llvm/trunk/test/CodeGen/X86/widen_arith-3.ll llvm/trunk/test/CodeGen/X86/widen_arith-4.ll llvm/trunk/test/CodeGen/X86/widen_arith-5.ll llvm/trunk/test/CodeGen/X86/widen_arith-6.ll llvm/trunk/test/CodeGen/X86/widen_cast-1.ll llvm/trunk/test/CodeGen/X86/widen_cast-2.ll llvm/trunk/test/CodeGen/X86/widen_cast-3.ll llvm/trunk/test/CodeGen/X86/widen_cast-4.ll llvm/trunk/test/CodeGen/X86/widen_cast-5.ll llvm/trunk/test/CodeGen/X86/widen_cast-6.ll llvm/trunk/test/CodeGen/X86/widen_conv-1.ll llvm/trunk/test/CodeGen/X86/widen_conv-2.ll llvm/trunk/test/CodeGen/X86/widen_conv-3.ll llvm/trunk/test/CodeGen/X86/widen_conv-4.ll llvm/trunk/test/CodeGen/X86/widen_select-1.ll llvm/trunk/test/CodeGen/X86/widen_shuffle-1.ll llvm/trunk/test/CodeGen/X86/widen_shuffle-2.ll Modified: llvm/trunk/test/CodeGen/X86/widen_arith-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_arith-1.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_arith-1.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_arith-1.ll Fri Oct 16 17:09:05 2009 @@ -1,14 +1,12 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep paddb %t | count 1 -; RUN: grep pextrb %t | count 1 -; RUN: not grep pextrw %t +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s ; Widen a v3i8 to v16i8 to use a vector add -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" - define void @update(<3 x i8>* %dst, <3 x i8>* %src, i32 %n) nounwind { entry: +; CHECK-NOT: pextrw +; CHECK: paddb +; CHECK: pextrb %dst.addr = alloca <3 x i8>* ; <<3 x i8>**> [#uses=2] %src.addr = alloca <3 x i8>* ; <<3 x i8>**> [#uses=2] %n.addr = alloca i32 ; [#uses=2] Modified: llvm/trunk/test/CodeGen/X86/widen_arith-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_arith-2.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_arith-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_arith-2.ll Fri Oct 16 17:09:05 2009 @@ -1,9 +1,8 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep paddb %t | count 1 -; RUN: grep pand %t | count 1 +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: paddb +; CHECK: pand ; widen v8i8 to v16i8 (checks even power of 2 widening with add & and) -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" define void @update(i64* %dst_i, i64* %src_i, i32 %n) nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/widen_arith-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_arith-3.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_arith-3.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_arith-3.ll Fri Oct 16 17:09:05 2009 @@ -1,12 +1,10 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep paddw %t | count 1 -; RUN: grep movd %t | count 2 -; RUN: grep pextrw %t | count 1 +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: paddw +; CHECK: movd +; CHECK: pextrw ; Widen a v3i16 to v8i16 to do a vector add -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i686-apple-darwin10.0.0d2" @.str = internal constant [4 x i8] c"%d \00" ; <[4 x i8]*> [#uses=1] @.str1 = internal constant [2 x i8] c"\0A\00" ; <[2 x i8]*> [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/widen_arith-4.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_arith-4.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_arith-4.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_arith-4.ll Fri Oct 16 17:09:05 2009 @@ -1,11 +1,9 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep psubw %t | count 1 -; RUN: grep pmullw %t | count 1 +; RUN: llc < %s -march=x86-64 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: psubw +; CHECK-NEXT: pmullw ; Widen a v5i16 to v8i16 to do a vector sub and multiple -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" - define void @update(<5 x i16>* %dst, <5 x i16>* %src, i32 %n) nounwind { entry: %dst.addr = alloca <5 x i16>* ; <<5 x i16>**> [#uses=2] Modified: llvm/trunk/test/CodeGen/X86/widen_arith-5.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_arith-5.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_arith-5.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_arith-5.ll Fri Oct 16 17:09:05 2009 @@ -1,10 +1,9 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep pmulld %t | count 1 -; RUN: grep psubd %t | count 1 -; RUN: grep movaps %t | count 1 +; RUN: llc < %s -march=x86-64 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: movaps +; CHECK: pmulld +; CHECK: psubd ; widen a v3i32 to v4i32 to do a vector multiple and a subtraction -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" define void @update(<3 x i32>* %dst, <3 x i32>* %src, i32 %n) nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/widen_arith-6.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_arith-6.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_arith-6.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_arith-6.ll Fri Oct 16 17:09:05 2009 @@ -1,9 +1,8 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep mulps %t | count 1 -; RUN: grep addps %t | count 1 +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: mulps +; CHECK: addps ; widen a v3f32 to vfi32 to do a vector multiple and an add -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" define void @update(<3 x float>* %dst, <3 x float>* %src, i32 %n) nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/widen_cast-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_cast-1.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_cast-1.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_cast-1.ll Fri Oct 16 17:09:05 2009 @@ -1,7 +1,7 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep paddw %t | count 1 -; RUN: grep movd %t | count 1 -; RUN: grep pextrd %t | count 1 +; RUN: llc -march=x86 -mattr=+sse42 < %s -disable-mmx | FileCheck %s +; CHECK: paddw +; CHECK: pextrd +; CHECK: movd ; bitcast a v4i16 to v2i32 Modified: llvm/trunk/test/CodeGen/X86/widen_cast-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_cast-2.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_cast-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_cast-2.ll Fri Oct 16 17:09:05 2009 @@ -1,6 +1,11 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep pextrd %t | count 5 -; RUN: grep movd %t | count 3 +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: pextrd +; CHECK: pextrd +; CHECK: movd +; CHECK: pextrd +; CHECK: pextrd +; CHECK: pextrd +; CHECK: movd ; bitcast v14i16 to v7i32 Modified: llvm/trunk/test/CodeGen/X86/widen_cast-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_cast-3.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_cast-3.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_cast-3.ll Fri Oct 16 17:09:05 2009 @@ -1,6 +1,7 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep paddd %t | count 1 -; RUN: grep pextrd %t | count 2 +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: paddd +; CHECK: pextrd +; CHECK: pextrd ; bitcast v12i8 to v3i32 Modified: llvm/trunk/test/CodeGen/X86/widen_cast-4.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_cast-4.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_cast-4.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_cast-4.ll Fri Oct 16 17:09:05 2009 @@ -1,5 +1,12 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep sarb %t | count 8 +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: sarb +; CHECK: sarb +; CHECK: sarb +; CHECK: sarb +; CHECK: sarb +; CHECK: sarb +; CHECK: sarb +; CHECK: sarb ; v8i8 that is widen to v16i8 then split ; FIXME: This is widen to v16i8 and split to 16 and we then rebuild the vector. Modified: llvm/trunk/test/CodeGen/X86/widen_cast-5.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_cast-5.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_cast-5.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_cast-5.ll Fri Oct 16 17:09:05 2009 @@ -1,4 +1,6 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: movl +; CHECK: movd ; bitcast a i64 to v2i32 Modified: llvm/trunk/test/CodeGen/X86/widen_cast-6.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_cast-6.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_cast-6.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_cast-6.ll Fri Oct 16 17:09:05 2009 @@ -1,5 +1,5 @@ -; RUN: llc < %s -march=x86 -mattr=+sse41 -disable-mmx -o %t -; RUN: grep movd %t | count 1 +; RUN: llc < %s -march=x86 -mattr=+sse41 -disable-mmx | FileCheck %s +; CHECK: movd ; Test bit convert that requires widening in the operand. Modified: llvm/trunk/test/CodeGen/X86/widen_conv-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_conv-1.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_conv-1.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_conv-1.ll Fri Oct 16 17:09:05 2009 @@ -1,6 +1,6 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; RUN: grep pshufd %t | count 1 -; RUN: grep paddd %t | count 1 +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: pshufd +; CHECK: paddd ; truncate v2i64 to v2i32 Modified: llvm/trunk/test/CodeGen/X86/widen_conv-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_conv-2.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_conv-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_conv-2.ll Fri Oct 16 17:09:05 2009 @@ -1,4 +1,6 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: movswl +; CHECK: movswl ; sign extension v2i32 to v2i16 Modified: llvm/trunk/test/CodeGen/X86/widen_conv-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_conv-3.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_conv-3.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_conv-3.ll Fri Oct 16 17:09:05 2009 @@ -1,5 +1,6 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t -; grep cvtsi2ss %t | count 1 +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: cvtsi2ss + ; sign to float v2i16 to v2f32 define void @convert(<2 x float>* %dst.addr, <2 x i16> %src) nounwind { Modified: llvm/trunk/test/CodeGen/X86/widen_conv-4.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_conv-4.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_conv-4.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_conv-4.ll Fri Oct 16 17:09:05 2009 @@ -1,4 +1,5 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: cvtsi2ss ; unsigned to float v7i16 to v7f32 Modified: llvm/trunk/test/CodeGen/X86/widen_select-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_select-1.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_select-1.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_select-1.ll Fri Oct 16 17:09:05 2009 @@ -1,4 +1,5 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: jne ; widening select v6i32 and then a sub Modified: llvm/trunk/test/CodeGen/X86/widen_shuffle-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_shuffle-1.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_shuffle-1.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_shuffle-1.ll Fri Oct 16 17:09:05 2009 @@ -1,4 +1,6 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: insertps +; CHECK: extractps ; widening shuffle v3float and then a add Modified: llvm/trunk/test/CodeGen/X86/widen_shuffle-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_shuffle-2.ll?rev=84282&r1=84281&r2=84282&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_shuffle-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_shuffle-2.ll Fri Oct 16 17:09:05 2009 @@ -1,4 +1,6 @@ -; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx -o %t +; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx | FileCheck %s +; CHECK: insertps +; CHECK: extractps ; widening shuffle v3float and then a add From vhernandez at apple.com Fri Oct 16 18:12:27 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 16 Oct 2009 23:12:27 -0000 Subject: [llvm-commits] [llvm] r84288 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll Message-ID: <200910162312.n9GNCSu1029143@zion.cs.uiuc.edu> Author: hernande Date: Fri Oct 16 18:12:25 2009 New Revision: 84288 URL: http://llvm.org/viewvc/llvm-project?rev=84288&view=rev Log: HeapAllocSRoA also needs to check if malloc array size can be computed. Added: llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=84288&r1=84287&r2=84288&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Fri Oct 16 18:12:25 2009 @@ -1586,6 +1586,8 @@ << " BITCAST = " << *BCI << '\n'); const Type* MAT = getMallocAllocatedType(CI); const StructType *STy = cast(MAT); + Value* ArraySize = getMallocArraySize(CI, Context, TD); + assert(ArraySize && "not a malloc whose array size can be determined"); // There is guaranteed to be at least one use of the malloc (storing // it into GV). If there are other uses, change them to be uses of @@ -1610,8 +1612,8 @@ GV->isThreadLocal()); FieldGlobals.push_back(NGV); - Value *NMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(Context), FieldTy, - getMallocArraySize(CI, Context, TD), + Value *NMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(Context), + FieldTy, ArraySize, BCI->getName() + ".f" + Twine(FieldNo)); FieldMallocs.push_back(NMI); new StoreInst(NMI, NGV, BCI); @@ -1892,6 +1894,7 @@ // This eliminates dynamic allocation, avoids an indirection accessing the // data, and exposes the resultant global to further GlobalOpt. Value *NElems = getMallocArraySize(CI, Context, TD); + // We cannot optimize the malloc if we cannot determine malloc array size. if (NElems) { if (ConstantInt *NElements = dyn_cast(NElems)) // Restrict this transformation to only working on small allocations @@ -1902,42 +1905,43 @@ GVI = OptimizeGlobalAddressOfMalloc(GV, CI, BCI, Context, TD); return true; } - } - // If the allocation is an array of structures, consider transforming this - // into multiple malloc'd arrays, one for each field. This is basically - // SRoA for malloc'd memory. - - // If this is an allocation of a fixed size array of structs, analyze as a - // variable size array. malloc [100 x struct],1 -> malloc struct, 100 - if (!isArrayMalloc(CI, Context, TD)) - if (const ArrayType *AT = dyn_cast(AllocTy)) - AllocTy = AT->getElementType(); - - if (const StructType *AllocSTy = dyn_cast(AllocTy)) { - // This the structure has an unreasonable number of fields, leave it - // alone. - if (AllocSTy->getNumElements() <= 16 && AllocSTy->getNumElements() != 0 && - AllGlobalLoadUsesSimpleEnoughForHeapSRA(GV, BCI)) { - - // If this is a fixed size array, transform the Malloc to be an alloc of - // structs. malloc [100 x struct],1 -> malloc struct, 100 - if (const ArrayType *AT = dyn_cast(getMallocAllocatedType(CI))) { - Value* NumElements = ConstantInt::get(Type::getInt32Ty(Context), - AT->getNumElements()); - Value* NewMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(Context), - AllocSTy, NumElements, - BCI->getName()); - Value *Cast = new BitCastInst(NewMI, getMallocType(CI), "tmp", CI); - BCI->replaceAllUsesWith(Cast); - BCI->eraseFromParent(); - CI->eraseFromParent(); - BCI = cast(NewMI); - CI = extractMallocCallFromBitCast(NewMI); - } + // If the allocation is an array of structures, consider transforming this + // into multiple malloc'd arrays, one for each field. This is basically + // SRoA for malloc'd memory. + + // If this is an allocation of a fixed size array of structs, analyze as a + // variable size array. malloc [100 x struct],1 -> malloc struct, 100 + if (!isArrayMalloc(CI, Context, TD)) + if (const ArrayType *AT = dyn_cast(AllocTy)) + AllocTy = AT->getElementType(); + + if (const StructType *AllocSTy = dyn_cast(AllocTy)) { + // This the structure has an unreasonable number of fields, leave it + // alone. + if (AllocSTy->getNumElements() <= 16 && AllocSTy->getNumElements() != 0 && + AllGlobalLoadUsesSimpleEnoughForHeapSRA(GV, BCI)) { + + // If this is a fixed size array, transform the Malloc to be an alloc of + // structs. malloc [100 x struct],1 -> malloc struct, 100 + if (const ArrayType *AT = + dyn_cast(getMallocAllocatedType(CI))) { + Value* NumElements = ConstantInt::get(Type::getInt32Ty(Context), + AT->getNumElements()); + Value* NewMI = CallInst::CreateMalloc(CI, TD->getIntPtrType(Context), + AllocSTy, NumElements, + BCI->getName()); + Value *Cast = new BitCastInst(NewMI, getMallocType(CI), "tmp", CI); + BCI->replaceAllUsesWith(Cast); + BCI->eraseFromParent(); + CI->eraseFromParent(); + BCI = cast(NewMI); + CI = extractMallocCallFromBitCast(NewMI); + } - GVI = PerformHeapAllocSRoA(GV, CI, BCI, Context, TD); - return true; + GVI = PerformHeapAllocSRoA(GV, CI, BCI, Context, TD); + return true; + } } } Added: llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll?rev=84288&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll (added) +++ llvm/trunk/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll Fri Oct 16 18:12:25 2009 @@ -0,0 +1,26 @@ +; RUN: opt < %s -globalopt -S | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-apple-darwin10.0" + +%struct.hashheader = type { i16, i16, i16, i16, i16, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32, [5 x i8], [13 x i8], i8, i8, i8, [228 x i16], [228 x i8], [228 x i8], [228 x i8], [228 x i8], [228 x i8], [228 x i8], [128 x i8], [100 x [11 x i8]], [100 x i32], [100 x i32], i16 } +%struct.strchartype = type { i8*, i8*, i8* } + + at hashheader = internal global %struct.hashheader zeroinitializer, align 32 ; <%struct.hashheader*> [#uses=1] + at chartypes = internal global %struct.strchartype* null ; <%struct.strchartype**> [#uses=1] +; CHECK-NOT: @hashheader +; CHECK-NOT: @chartypes + +; based on linit in office-ispell +define void @test() nounwind ssp { + %1 = load i32* getelementptr inbounds (%struct.hashheader* @hashheader, i64 0, i32 13), align 8 ; [#uses=1] + %2 = sext i32 %1 to i64 ; [#uses=1] + %3 = mul i64 %2, ptrtoint (%struct.strchartype* getelementptr (%struct.strchartype* null, i64 1) to i64) ; [#uses=1] + %4 = tail call i8* @malloc(i64 %3) ; [#uses=1] +; CHECK: call i8* @malloc(i64 + %5 = bitcast i8* %4 to %struct.strchartype* ; <%struct.strchartype*> [#uses=1] + store %struct.strchartype* %5, %struct.strchartype** @chartypes, align 8 + ret void +} + +declare noalias i8* @malloc(i64) From vhernandez at apple.com Fri Oct 16 19:00:24 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Sat, 17 Oct 2009 00:00:24 -0000 Subject: [llvm-commits] [llvm] r84292 - in /llvm/trunk: examples/BrainF/ include/llvm/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Transforms/IPO/ lib/Transforms/Scalar/ lib/VMCore/ test/Transforms/GlobalOpt/ test/Transforms/IndMemRem/ test/Transforms/InstCombine/ Message-ID: <200910170000.n9H00RWN030901@zion.cs.uiuc.edu> Author: hernande Date: Fri Oct 16 19:00:19 2009 New Revision: 84292 URL: http://llvm.org/viewvc/llvm-project?rev=84292&view=rev Log: Autoupgrade malloc insts to malloc calls. Update testcases that rely on malloc insts being present. Also prematurely remove MallocInst handling from IndMemRemoval and RaiseAllocations to help pass tests in this incremental step. Modified: llvm/trunk/examples/BrainF/BrainF.cpp llvm/trunk/include/llvm/Instructions.h llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLParser.h llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll llvm/trunk/test/Transforms/IndMemRem/2009-01-24-Noalias.ll llvm/trunk/test/Transforms/InstCombine/cast-malloc.ll llvm/trunk/test/Transforms/InstCombine/cast.ll llvm/trunk/test/Transforms/InstCombine/getelementptr.ll llvm/trunk/test/Transforms/InstCombine/malloc-free-delete.ll llvm/trunk/test/Transforms/InstCombine/malloc2.ll llvm/trunk/test/Transforms/InstCombine/malloc3.ll Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Fri Oct 16 19:00:19 2009 @@ -25,6 +25,7 @@ #include "BrainF.h" #include "llvm/Constants.h" +#include "llvm/Instructions.h" #include "llvm/Intrinsics.h" #include "llvm/ADT/STLExtras.h" #include @@ -78,7 +79,11 @@ //%arr = malloc i8, i32 %d ConstantInt *val_mem = ConstantInt::get(C, APInt(32, memtotal)); - ptr_arr = builder->CreateMalloc(IntegerType::getInt8Ty(C), val_mem, "arr"); + BasicBlock* BB = builder->GetInsertBlock(); + const Type* IntPtrTy = IntegerType::getInt32Ty(C); + ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, IntegerType::getInt8Ty(C), + val_mem, NULL, "arr"); + BB->getInstList().push_back(cast(ptr_arr)); //call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1) { Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Fri Oct 16 19:00:19 2009 @@ -1047,7 +1047,7 @@ const Twine &Name = ""); static Value *CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, Value *ArraySize = 0, - const Twine &Name = ""); + Function* MallocF = 0, const Twine &Name = ""); ~CallInst(); @@ -1152,6 +1152,11 @@ const Value *getCalledValue() const { return Op<0>(); } Value *getCalledValue() { return Op<0>(); } + /// setCalledFunction - Set the function called + void setCalledFunction(Value* Fn) { + Op<0>() = Fn; + } + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const CallInst *) { return true; } static inline bool classof(const Instruction *I) { Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Fri Oct 16 19:00:19 2009 @@ -602,6 +602,9 @@ // Scan CurPtr ahead, seeing if there is just whitespace before the newline. if (JustWhitespaceNewLine(CurPtr)) return lltok::kw_zeroext; + } else if (Len == 6 && !memcmp(StartChar, "malloc", 6)) { + // Autoupgrade malloc instruction + return lltok::kw_malloc; } // Keywords for instructions. @@ -641,7 +644,6 @@ INSTKEYWORD(unwind, Unwind); INSTKEYWORD(unreachable, Unreachable); - INSTKEYWORD(malloc, Malloc); INSTKEYWORD(alloca, Alloca); INSTKEYWORD(free, Free); INSTKEYWORD(load, Load); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Oct 16 19:00:19 2009 @@ -69,6 +69,27 @@ /// ValidateEndOfModule - Do final validity and sanity checks at the end of the /// module. bool LLParser::ValidateEndOfModule() { + // Update auto-upgraded malloc calls from "autoupgrade_malloc" to "malloc". + if (MallocF) { + MallocF->setName("malloc"); + // If setName() does not set the name to "malloc", then there is already a + // declaration of "malloc". In that case, iterate over all calls to MallocF + // and get them to call the declared "malloc" instead. + if (MallocF->getName() != "malloc") { + Function* realMallocF = M->getFunction("malloc"); + for (User::use_iterator UI = MallocF->use_begin(), UE= MallocF->use_end(); + UI != UE; ) { + User* user = *UI; + UI++; + if (CallInst *Call = dyn_cast(user)) + Call->setCalledFunction(realMallocF); + } + if (!realMallocF->doesNotAlias(0)) realMallocF->setDoesNotAlias(0); + MallocF->eraseFromParent(); + MallocF = NULL; + } + } + if (!ForwardRefTypes.empty()) return Error(ForwardRefTypes.begin()->second.second, "use of undefined type named '" + @@ -2783,8 +2804,8 @@ case lltok::kw_call: return ParseCall(Inst, PFS, false); case lltok::kw_tail: return ParseCall(Inst, PFS, true); // Memory. - case lltok::kw_alloca: - case lltok::kw_malloc: return ParseAlloc(Inst, PFS, KeywordVal); + case lltok::kw_alloca: return ParseAlloc(Inst, PFS); + case lltok::kw_malloc: return ParseAlloc(Inst, PFS, BB, false); case lltok::kw_free: return ParseFree(Inst, PFS); case lltok::kw_load: return ParseLoad(Inst, PFS, false); case lltok::kw_store: return ParseStore(Inst, PFS, false); @@ -3445,7 +3466,7 @@ /// ::= 'malloc' Type (',' TypeAndValue)? (',' OptionalInfo)? /// ::= 'alloca' Type (',' TypeAndValue)? (',' OptionalInfo)? bool LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS, - unsigned Opc) { + BasicBlock* BB, bool isAlloca) { PATypeHolder Ty(Type::getVoidTy(Context)); Value *Size = 0; LocTy SizeLoc; @@ -3466,10 +3487,21 @@ if (Size && Size->getType() != Type::getInt32Ty(Context)) return Error(SizeLoc, "element count must be i32"); - if (Opc == Instruction::Malloc) - Inst = new MallocInst(Ty, Size, Alignment); - else + if (isAlloca) Inst = new AllocaInst(Ty, Size, Alignment); + else { + // Autoupgrade old malloc instruction to malloc call. + const Type* IntPtrTy = Type::getInt32Ty(Context); + const Type* Int8PtrTy = PointerType::getUnqual(Type::getInt8Ty(Context)); + if (!MallocF) + // Prototype malloc as "void *autoupgrade_malloc(int32)". + MallocF = cast(M->getOrInsertFunction("autoupgrade_malloc", + Int8PtrTy, IntPtrTy, NULL)); + // "autoupgrade_malloc" updated to "malloc" in ValidateEndOfModule(). + + Inst = cast(CallInst::CreateMalloc(BB, IntPtrTy, Ty, + Size, MallocF)); + } return false; } Modified: llvm/trunk/lib/AsmParser/LLParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.h (original) +++ llvm/trunk/lib/AsmParser/LLParser.h Fri Oct 16 19:00:19 2009 @@ -75,9 +75,11 @@ std::map > ForwardRefVals; std::map > ForwardRefValIDs; std::vector NumberedVals; + Function* MallocF; public: LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m) : - Context(m->getContext()), Lex(F, SM, Err, m->getContext()), M(m) {} + Context(m->getContext()), Lex(F, SM, Err, m->getContext()), + M(m), MallocF(NULL) {} bool Run(); LLVMContext& getContext() { return Context; } @@ -276,7 +278,8 @@ bool ParseShuffleVector(Instruction *&I, PerFunctionState &PFS); bool ParsePHI(Instruction *&I, PerFunctionState &PFS); bool ParseCall(Instruction *&I, PerFunctionState &PFS, bool isTail); - bool ParseAlloc(Instruction *&I, PerFunctionState &PFS, unsigned Opc); + bool ParseAlloc(Instruction *&I, PerFunctionState &PFS, + BasicBlock *BB = 0, bool isAlloca = true); bool ParseFree(Instruction *&I, PerFunctionState &PFS); bool ParseLoad(Instruction *&I, PerFunctionState &PFS, bool isVolatile); bool ParseStore(Instruction *&I, PerFunctionState &PFS, bool isVolatile); Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Oct 16 19:00:19 2009 @@ -2044,14 +2044,21 @@ } case bitc::FUNC_CODE_INST_MALLOC: { // MALLOC: [instty, op, align] + // Autoupgrade malloc instruction to malloc call. if (Record.size() < 3) return Error("Invalid MALLOC record"); const PointerType *Ty = dyn_cast_or_null(getTypeByID(Record[0])); Value *Size = getFnValueByID(Record[1], Type::getInt32Ty(Context)); - unsigned Align = Record[2]; if (!Ty || !Size) return Error("Invalid MALLOC record"); - I = new MallocInst(Ty->getElementType(), Size, (1 << Align) >> 1); + if (!CurBB) return Error("Invalid malloc instruction with no BB"); + const Type* Int32Ty = IntegerType::getInt32Ty(CurBB->getContext()); + if (Size->getType() != Int32Ty) + Size = CastInst::CreateIntegerCast(Size, Int32Ty, false /*ZExt*/, + "", CurBB); + Value* Malloc = CallInst::CreateMalloc(CurBB, Int32Ty, + Ty->getElementType(), Size, NULL); + I = cast(Malloc); InstructionList.push_back(I); break; } Modified: llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp Fri Oct 16 19:00:19 2009 @@ -24,6 +24,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Compiler.h" +#include "llvm/Target/TargetData.h" using namespace llvm; STATISTIC(NumBounceSites, "Number of sites modified"); @@ -66,20 +67,28 @@ } if (Function* F = M.getFunction("malloc")) { if (F->isDeclaration() && F->arg_size() == 1 && !F->use_empty()) { - Function* FN = Function::Create(F->getFunctionType(), - GlobalValue::LinkOnceAnyLinkage, - "malloc_llvm_bounce", &M); - FN->setDoesNotAlias(0); - BasicBlock* bb = BasicBlock::Create(M.getContext(), "entry",FN); - Instruction* c = CastInst::CreateIntegerCast( - FN->arg_begin(), Type::getInt32Ty(M.getContext()), false, "c", bb); - Instruction* a = new MallocInst(Type::getInt8Ty(M.getContext()), - c, "m", bb); - ReturnInst::Create(M.getContext(), a, bb); - ++NumBounce; - NumBounceSites += F->getNumUses(); - F->replaceAllUsesWith(FN); - changed = true; + TargetData* TD = getAnalysisIfAvailable(); + if (TD) { + Function* FN = Function::Create(F->getFunctionType(), + GlobalValue::LinkOnceAnyLinkage, + "malloc_llvm_bounce", &M); + F->replaceAllUsesWith(FN); + FN->setDoesNotAlias(0); + BasicBlock* bb = BasicBlock::Create(M.getContext(), "entry", FN); + const Type* IntPtrTy = TD->getIntPtrType(M.getContext()); + Value* c = FN->arg_begin(); + if (FN->arg_begin()->getType() != IntPtrTy) + c = CastInst::CreateIntegerCast(FN->arg_begin(), IntPtrTy, false, + "c", bb); + Value* a = CallInst::CreateMalloc(bb, IntPtrTy, + Type::getInt8Ty(M.getContext()), + c, NULL, "m"); + bb->getInstList().push_back(cast(a)); + ReturnInst::Create(M.getContext(), a, bb); + ++NumBounce; + NumBounceSites += F->getNumUses(); + changed = true; + } } } return changed; Modified: llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp Fri Oct 16 19:00:19 2009 @@ -1,4 +1,4 @@ -//===- RaiseAllocations.cpp - Convert @malloc & @free calls to insts ------===// +//===- RaiseAllocations.cpp - Convert @free calls to insts ------===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This file defines the RaiseAllocations pass which convert malloc and free -// calls to malloc and free instructions. +// This file defines the RaiseAllocations pass which convert free calls to free +// instructions. // //===----------------------------------------------------------------------===// @@ -29,19 +29,19 @@ STATISTIC(NumRaised, "Number of allocations raised"); namespace { - // RaiseAllocations - Turn @malloc and @free calls into the appropriate + // RaiseAllocations - Turn @free calls into the appropriate // instruction. // class VISIBILITY_HIDDEN RaiseAllocations : public ModulePass { - Function *MallocFunc; // Functions in the module we are processing - Function *FreeFunc; // Initialized by doPassInitializationVirt + Function *FreeFunc; // Functions in the module we are processing + // Initialized by doPassInitializationVirt public: static char ID; // Pass identification, replacement for typeid RaiseAllocations() - : ModulePass(&ID), MallocFunc(0), FreeFunc(0) {} + : ModulePass(&ID), FreeFunc(0) {} // doPassInitialization - For the raise allocations pass, this finds a - // declaration for malloc and free if they exist. + // declaration for free if it exists. // void doInitialization(Module &M); @@ -61,50 +61,16 @@ } -// If the module has a symbol table, they might be referring to the malloc and -// free functions. If this is the case, grab the method pointers that the -// module is using. +// If the module has a symbol table, they might be referring to the free +// function. If this is the case, grab the method pointers that the module is +// using. // -// Lookup @malloc and @free in the symbol table, for later use. If they don't +// Lookup @free in the symbol table, for later use. If they don't // exist, or are not external, we do not worry about converting calls to that // function into the appropriate instruction. // void RaiseAllocations::doInitialization(Module &M) { - // Get Malloc and free prototypes if they exist! - MallocFunc = M.getFunction("malloc"); - if (MallocFunc) { - const FunctionType* TyWeHave = MallocFunc->getFunctionType(); - - // Get the expected prototype for malloc - const FunctionType *Malloc1Type = - FunctionType::get(Type::getInt8PtrTy(M.getContext()), - std::vector(1, - Type::getInt64Ty(M.getContext())), false); - - // Chck to see if we got the expected malloc - if (TyWeHave != Malloc1Type) { - // Check to see if the prototype is wrong, giving us i8*(i32) * malloc - // This handles the common declaration of: 'void *malloc(unsigned);' - const FunctionType *Malloc2Type = - FunctionType::get(PointerType::getUnqual( - Type::getInt8Ty(M.getContext())), - std::vector(1, - Type::getInt32Ty(M.getContext())), false); - if (TyWeHave != Malloc2Type) { - // Check to see if the prototype is missing, giving us - // i8*(...) * malloc - // This handles the common declaration of: 'void *malloc();' - const FunctionType *Malloc3Type = - FunctionType::get(PointerType::getUnqual( - Type::getInt8Ty(M.getContext())), - true); - if (TyWeHave != Malloc3Type) - // Give up - MallocFunc = 0; - } - } - } - + // Get free prototype if it exists! FreeFunc = M.getFunction("free"); if (FreeFunc) { const FunctionType* TyWeHave = FreeFunc->getFunctionType(); @@ -138,72 +104,18 @@ } // Don't mess with locally defined versions of these functions... - if (MallocFunc && !MallocFunc->isDeclaration()) MallocFunc = 0; if (FreeFunc && !FreeFunc->isDeclaration()) FreeFunc = 0; } // run - Transform calls into instructions... // bool RaiseAllocations::runOnModule(Module &M) { - // Find the malloc/free prototypes... + // Find the free prototype... doInitialization(M); bool Changed = false; - // First, process all of the malloc calls... - if (MallocFunc) { - std::vector Users(MallocFunc->use_begin(), MallocFunc->use_end()); - std::vector EqPointers; // Values equal to MallocFunc - while (!Users.empty()) { - User *U = Users.back(); - Users.pop_back(); - - if (Instruction *I = dyn_cast(U)) { - CallSite CS = CallSite::get(I); - if (CS.getInstruction() && !CS.arg_empty() && - (CS.getCalledFunction() == MallocFunc || - std::find(EqPointers.begin(), EqPointers.end(), - CS.getCalledValue()) != EqPointers.end())) { - - Value *Source = *CS.arg_begin(); - - // If no prototype was provided for malloc, we may need to cast the - // source size. - if (Source->getType() != Type::getInt32Ty(M.getContext())) - Source = - CastInst::CreateIntegerCast(Source, - Type::getInt32Ty(M.getContext()), - false/*ZExt*/, - "MallocAmtCast", I); - - MallocInst *MI = new MallocInst(Type::getInt8Ty(M.getContext()), - Source, "", I); - MI->takeName(I); - I->replaceAllUsesWith(MI); - - // If the old instruction was an invoke, add an unconditional branch - // before the invoke, which will become the new terminator. - if (InvokeInst *II = dyn_cast(I)) - BranchInst::Create(II->getNormalDest(), I); - - // Delete the old call site - I->eraseFromParent(); - Changed = true; - ++NumRaised; - } - } else if (GlobalValue *GV = dyn_cast(U)) { - Users.insert(Users.end(), GV->use_begin(), GV->use_end()); - EqPointers.push_back(GV); - } else if (ConstantExpr *CE = dyn_cast(U)) { - if (CE->isCast()) { - Users.insert(Users.end(), CE->use_begin(), CE->use_end()); - EqPointers.push_back(CE); - } - } - } - } - - // Next, process all free calls... + // Process all free calls... if (FreeFunc) { std::vector Users(FreeFunc->use_begin(), FreeFunc->use_end()); std::vector EqPointers; // Values equal to FreeFunc Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Fri Oct 16 19:00:19 2009 @@ -29,6 +29,7 @@ #include "llvm/IntrinsicInst.h" #include "llvm/LLVMContext.h" #include "llvm/Pass.h" +#include "llvm/Analysis/MallocHelper.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CFG.h" #include "llvm/Support/Debug.h" @@ -121,7 +122,7 @@ if (I->getOpcode() == Instruction::PHI || I->getOpcode() == Instruction::Alloca || I->getOpcode() == Instruction::Load || - I->getOpcode() == Instruction::Malloc || + I->getOpcode() == Instruction::Malloc || isMalloc(I) || I->getOpcode() == Instruction::Invoke || (I->getOpcode() == Instruction::Call && !isa(I)) || Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Fri Oct 16 19:00:19 2009 @@ -1699,12 +1699,16 @@ LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name) { - return wrap(unwrap(B)->CreateMalloc(unwrap(Ty), 0, Name)); + const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); + return wrap(CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), IntPtrT, + unwrap(Ty), 0, 0, Twine(Name))); } LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name) { - return wrap(unwrap(B)->CreateMalloc(unwrap(Ty), unwrap(Val), Name)); + const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); + return wrap(CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), IntPtrT, + unwrap(Ty), unwrap(Val), 0, Twine(Name))); } LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Fri Oct 16 19:00:19 2009 @@ -462,7 +462,8 @@ static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize, const Twine &NameStr) { + Value *ArraySize, Function* MallocF, + const Twine &NameStr) { assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) && "createMalloc needs either InsertBefore or InsertAtEnd"); @@ -499,27 +500,34 @@ BasicBlock* BB = InsertBefore ? InsertBefore->getParent() : InsertAtEnd; Module* M = BB->getParent()->getParent(); const Type *BPTy = Type::getInt8PtrTy(BB->getContext()); - // prototype malloc as "void *malloc(size_t)" - Constant *MallocF = M->getOrInsertFunction("malloc", BPTy, IntPtrTy, NULL); - if (!cast(MallocF)->doesNotAlias(0)) - cast(MallocF)->setDoesNotAlias(0); + if (!MallocF) + // prototype malloc as "void *malloc(size_t)" + MallocF = cast(M->getOrInsertFunction("malloc", BPTy, + IntPtrTy, NULL)); + if (!MallocF->doesNotAlias(0)) MallocF->setDoesNotAlias(0); const PointerType *AllocPtrType = PointerType::getUnqual(AllocTy); CallInst *MCall = NULL; - Value *MCast = NULL; + Value *Result = NULL; if (InsertBefore) { MCall = CallInst::Create(MallocF, AllocSize, "malloccall", InsertBefore); - // Create a cast instruction to convert to the right type... - MCast = new BitCastInst(MCall, AllocPtrType, NameStr, InsertBefore); + Result = MCall; + if (Result->getType() != AllocPtrType) + // Create a cast instruction to convert to the right type... + Result = new BitCastInst(MCall, AllocPtrType, NameStr, InsertBefore); } else { - MCall = CallInst::Create(MallocF, AllocSize, "malloccall", InsertAtEnd); - // Create a cast instruction to convert to the right type... - MCast = new BitCastInst(MCall, AllocPtrType, NameStr); + MCall = CallInst::Create(MallocF, AllocSize, "malloccall"); + Result = MCall; + if (Result->getType() != AllocPtrType) { + InsertAtEnd->getInstList().push_back(MCall); + // Create a cast instruction to convert to the right type... + Result = new BitCastInst(MCall, AllocPtrType, NameStr); + } } MCall->setTailCall(); assert(MCall->getType() != Type::getVoidTy(BB->getContext()) && "Malloc has void return type"); - return MCast; + return Result; } /// CreateMalloc - Generate the IR for a call to malloc: @@ -531,7 +539,8 @@ Value *CallInst::CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, const Type *AllocTy, Value *ArraySize, const Twine &Name) { - return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, ArraySize, Name); + return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, + ArraySize, NULL, Name); } /// CreateMalloc - Generate the IR for a call to malloc: @@ -544,8 +553,9 @@ /// responsibility of the caller. Value *CallInst::CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, Value *ArraySize, - const Twine &Name) { - return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, ArraySize, Name); + Function* MallocF, const Twine &Name) { + return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, + ArraySize, MallocF, Name); } //===----------------------------------------------------------------------===// Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-2.ll Fri Oct 16 19:00:19 2009 @@ -1,4 +1,6 @@ -; RUN: opt < %s -globalopt -S | not grep malloc +; RUN: opt < %s -globalopt -globaldce -S | not grep malloc +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i686-apple-darwin8" @G = internal global i32* null ; [#uses=3] Modified: llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/malloc-promote-3.ll Fri Oct 16 19:00:19 2009 @@ -1,4 +1,6 @@ -; RUN: opt < %s -globalopt -S | not grep malloc +; RUN: opt < %s -globalopt -globaldce -S | not grep malloc +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i686-apple-darwin8" @G = internal global i32* null ; [#uses=4] Modified: llvm/trunk/test/Transforms/IndMemRem/2009-01-24-Noalias.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndMemRem/2009-01-24-Noalias.ll?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndMemRem/2009-01-24-Noalias.ll (original) +++ llvm/trunk/test/Transforms/IndMemRem/2009-01-24-Noalias.ll Fri Oct 16 19:00:19 2009 @@ -1,4 +1,6 @@ ; RUN: opt < %s -indmemrem -S | grep bounce | grep noalias +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i686-apple-darwin8" declare i8* @malloc(i32) Modified: llvm/trunk/test/Transforms/InstCombine/cast-malloc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast-malloc.ll?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast-malloc.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast-malloc.ll Fri Oct 16 19:00:19 2009 @@ -1,6 +1,6 @@ ; test that casted mallocs get converted to malloc of the right type ; RUN: opt < %s -instcombine -S | \ -; RUN: not grep bitcast +; RUN: grep bitcast | count 1 ; The target datalayout is important for this test case. We have to tell ; instcombine that the ABI alignment for a long is 4-bytes, not 8, otherwise Modified: llvm/trunk/test/Transforms/InstCombine/cast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast.ll?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/cast.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/cast.ll Fri Oct 16 19:00:19 2009 @@ -102,8 +102,8 @@ %p = malloc [4 x i8] ; <[4 x i8]*> [#uses=1] %c = bitcast [4 x i8]* %p to i32* ; [#uses=1] ret i32* %c -; CHECK: %p = malloc i32 -; CHECK: ret i32* %p +; CHECK: %malloccall = tail call i8* @malloc(i32 ptrtoint ([4 x i8]* getelementptr ([4 x i8]* null, i32 1) to i32)) +; CHECK: ret i32* %c } define i8* @test13(i64 %A) { @@ -274,9 +274,9 @@ %tmp8.upgrd.1 = bitcast [16 x i8]* %tmp8 to double* ; [#uses=1] store double* %tmp8.upgrd.1, double** %tmp ret void -; CHECK: %tmp81 = malloc [2 x double] -; CHECK: %tmp81.sub = getelementptr inbounds [2 x double]* %tmp81, i64 0, i64 0 -; CHECK: store double* %tmp81.sub, double** %tmp +; CHECK: %malloccall = tail call i8* @malloc(i32 ptrtoint ([16 x i8]* getelementptr ([16 x i8]* null, i32 1) to i32)) +; CHECK: %tmp8.upgrd.1 = bitcast i8* %malloccall to double* +; CHECK: store double* %tmp8.upgrd.1, double** %tmp ; CHECK: ret void } Modified: llvm/trunk/test/Transforms/InstCombine/getelementptr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/getelementptr.ll?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/getelementptr.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/getelementptr.ll Fri Oct 16 19:00:19 2009 @@ -58,7 +58,7 @@ %B = getelementptr i32* %A, i64 2 ret i32* %B ; CHECK: @test6 -; CHECK: getelementptr [4 x i32]* %M, i64 0, i64 2 +; CHECK: getelementptr i8* %malloccall, i64 8 } define i32* @test7(i32* %I, i64 %C, i64 %D) { Modified: llvm/trunk/test/Transforms/InstCombine/malloc-free-delete.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/malloc-free-delete.ll?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/malloc-free-delete.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/malloc-free-delete.ll Fri Oct 16 19:00:19 2009 @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | grep {ret i32 0} -; RUN: opt < %s -instcombine -S | not grep malloc +; RUN: opt < %s -instcombine -globaldce -S | not grep malloc ; PR1201 define i32 @main(i32 %argc, i8** %argv) { %c_19 = alloca i8* ; [#uses=2] Modified: llvm/trunk/test/Transforms/InstCombine/malloc2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/malloc2.ll?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/malloc2.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/malloc2.ll Fri Oct 16 19:00:19 2009 @@ -1,5 +1,4 @@ ; RUN: opt < %s -instcombine -S | grep {ret i32 0} -; RUN: opt < %s -instcombine -S | not grep malloc ; PR1313 define i32 @test1(i32 %argc, i8* %argv, i8* %envp) { Modified: llvm/trunk/test/Transforms/InstCombine/malloc3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/malloc3.ll?rev=84292&r1=84291&r2=84292&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/malloc3.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/malloc3.ll Fri Oct 16 19:00:19 2009 @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep {malloc.*struct.foo} | count 2 +; RUN: opt < %s -instcombine -S | not grep load ; PR1728 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" From gohman at apple.com Fri Oct 16 19:28:26 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 17 Oct 2009 00:28:26 -0000 Subject: [llvm-commits] [llvm] r84294 - /llvm/trunk/include/llvm/CodeGen/MachineFunction.h Message-ID: <200910170028.n9H0SQ59031740@zion.cs.uiuc.edu> Author: djg Date: Fri Oct 16 19:28:24 2009 New Revision: 84294 URL: http://llvm.org/viewvc/llvm-project?rev=84294&view=rev Log: Add a splice member function which accepts a range instead of a single iterator. Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=84294&r1=84293&r2=84294&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Fri Oct 16 19:28:24 2009 @@ -267,6 +267,9 @@ void splice(iterator InsertPt, iterator MBBI) { BasicBlocks.splice(InsertPt, BasicBlocks, MBBI); } + void splice(iterator InsertPt, iterator MBBI, iterator MBBE) { + BasicBlocks.splice(InsertPt, BasicBlocks, MBBI, MBBE); + } void remove(iterator MBBI) { BasicBlocks.remove(MBBI); From gohman at apple.com Fri Oct 16 19:32:55 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 17 Oct 2009 00:32:55 -0000 Subject: [llvm-commits] [llvm] r84295 - in /llvm/trunk: lib/CodeGen/CodePlacementOpt.cpp test/CodeGen/X86/2009-04-20-LinearScanOpt.ll test/CodeGen/X86/loop_blocks.ll Message-ID: <200910170032.n9H0Ww8n031876@zion.cs.uiuc.edu> Author: djg Date: Fri Oct 16 19:32:43 2009 New Revision: 84295 URL: http://llvm.org/viewvc/llvm-project?rev=84295&view=rev Log: Enhance CodePlacementOpt's unconditional intra-loop branch elimination logic to be more general and understand more varieties of loops. Teach CodePlacementOpt to reorganize the basic blocks of a loop so that they are contiguous. This also includes a fair amount of logic for preserving fall-through edges while doing so. This fixes a BranchFolding-ism where blocks which can't be made to use a fall-through edge and don't conveniently fit anywhere nearby get tossed out to the end of the function. Added: llvm/trunk/test/CodeGen/X86/loop_blocks.ll Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp llvm/trunk/test/CodeGen/X86/2009-04-20-LinearScanOpt.ll Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=84295&r1=84294&r2=84295&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Fri Oct 16 19:32:43 2009 @@ -34,14 +34,6 @@ const TargetInstrInfo *TII; const TargetLowering *TLI; - /// ChangedMBBs - BBs which are modified by OptimizeIntraLoopEdges. - SmallPtrSet ChangedMBBs; - - /// UncondJmpMBBs - A list of BBs which are in loops and end with - /// unconditional branches. - SmallVector, 4> - UncondJmpMBBs; - public: static char ID; CodePlacementOpt() : MachineFunctionPass(&ID) {} @@ -58,7 +50,15 @@ } private: - bool OptimizeIntraLoopEdges(); + bool HasFallthrough(MachineBasicBlock *MBB); + bool HasAnalyzableTerminator(MachineBasicBlock *MBB); + void Splice(MachineFunction &MF, + MachineFunction::iterator InsertPt, + MachineFunction::iterator Begin, + MachineFunction::iterator End); + void UpdateTerminator(MachineBasicBlock *MBB); + bool OptimizeIntraLoopEdges(MachineFunction &MF); + bool OptimizeIntraLoopEdgesInLoop(MachineFunction &MF, MachineLoop *L); bool AlignLoops(MachineFunction &MF); bool AlignLoop(MachineFunction &MF, MachineLoop *L, unsigned Align); }; @@ -70,168 +70,364 @@ return new CodePlacementOpt(); } -/// OptimizeBackEdges - Place loop back edges to move unconditional branches -/// out of the loop. -/// -/// A: -/// ... -/// +/// HasFallthrough - Test whether the given branch has a fallthrough, either as +/// a plain fallthrough or as a fallthrough case of a conditional branch. /// -/// B: --> loop header -/// ... -/// jcc C, [exit] +bool CodePlacementOpt::HasFallthrough(MachineBasicBlock *MBB) { + MachineBasicBlock *TBB = 0, *FBB = 0; + SmallVector Cond; + if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond)) + return false; + // This conditional branch has no fallthrough. + if (FBB) + return false; + // An unconditional branch has no fallthrough. + if (Cond.empty() && TBB) + return false; + // It has a fallthrough. + return true; +} + +/// HasAnalyzableTerminator - Test whether AnalyzeBranch will succeed on MBB. +/// This is called before major changes are begun to test whether it will be +/// possible to complete the changes. /// -/// C: -/// ... -/// jmp B +/// Target-specific code is hereby encouraged to make AnalyzeBranch succeed +/// whenever possible. /// -/// ==> +bool CodePlacementOpt::HasAnalyzableTerminator(MachineBasicBlock *MBB) { + // Conservatively ignore EH landing pads. + if (MBB->isLandingPad()) return false; + + // Ignore blocks which look like they might have EH-related control flow. + // At the time of this writing, there are blocks which AnalyzeBranch + // thinks end in single uncoditional branches, yet which have two CFG + // successors. Code in this file is not prepared to reason about such things. + if (!MBB->empty() && MBB->back().getOpcode() == TargetInstrInfo::EH_LABEL) + return false; + + // Aggressively handle return blocks and similar constructs. + if (MBB->succ_empty()) return true; + + // Ask the target's AnalyzeBranch if it can handle this block. + MachineBasicBlock *TBB = 0, *FBB = 0; + SmallVector Cond; + // Make the the terminator is understood. + if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond)) + return false; + // Make sure we have the option of reversing the condition. + if (!Cond.empty() && TII->ReverseBranchCondition(Cond)) + return false; + return true; +} + +/// Splice - Move the sequence of instructions [Begin,End) to just before +/// InsertPt. Update branch instructions as needed to account for broken +/// fallthrough edges and to take advantage of newly exposed fallthrough +/// opportunities. /// -/// A: -/// ... -/// jmp B +void CodePlacementOpt::Splice(MachineFunction &MF, + MachineFunction::iterator InsertPt, + MachineFunction::iterator Begin, + MachineFunction::iterator End) { + assert(Begin != MF.begin() && End != MF.begin() && InsertPt != MF.begin() && + "Splice can't change the entry block!"); + MachineFunction::iterator OldBeginPrior = prior(Begin); + MachineFunction::iterator OldEndPrior = prior(End); + + MF.splice(InsertPt, Begin, End); + + UpdateTerminator(prior(Begin)); + UpdateTerminator(OldBeginPrior); + UpdateTerminator(OldEndPrior); +} + +/// UpdateTerminator - Update the terminator instructions in MBB to account +/// for changes to the layout. If the block previously used a fallthrough, +/// it may now need a branch, and if it previously used branching it may now +/// be able to use a fallthrough. /// -/// C: -/// ... -/// -/// -/// B: --> loop header -/// ... -/// jcc C, [exit] +void CodePlacementOpt::UpdateTerminator(MachineBasicBlock *MBB) { + // A block with no successors has no concerns with fall-through edges. + if (MBB->succ_empty()) return; + + MachineBasicBlock *TBB = 0, *FBB = 0; + SmallVector Cond; + bool B = TII->AnalyzeBranch(*MBB, TBB, FBB, Cond); + assert(!B && "UpdateTerminators requires analyzable predecessors!"); + if (Cond.empty()) { + if (TBB) { + // The block has an unconditional branch. If its successor is now + // its layout successor, delete the branch. + if (MBB->isLayoutSuccessor(TBB)) + TII->RemoveBranch(*MBB); + } else { + // The block has an unconditional fallthrough. If its successor is not + // its layout successor, insert a branch. + TBB = *MBB->succ_begin(); + if (!MBB->isLayoutSuccessor(TBB)) + TII->InsertBranch(*MBB, TBB, 0, Cond); + } + } else { + if (FBB) { + // The block has a non-fallthrough conditional branch. If one of its + // successors is its layout successor, rewrite it to a fallthrough + // conditional branch. + if (MBB->isLayoutSuccessor(TBB)) { + TII->RemoveBranch(*MBB); + TII->ReverseBranchCondition(Cond); + TII->InsertBranch(*MBB, FBB, 0, Cond); + } else if (MBB->isLayoutSuccessor(FBB)) { + TII->RemoveBranch(*MBB); + TII->InsertBranch(*MBB, TBB, 0, Cond); + } + } else { + // The block has a fallthrough conditional branch. + MachineBasicBlock *MBBA = *MBB->succ_begin(); + MachineBasicBlock *MBBB = *next(MBB->succ_begin()); + if (MBBA == TBB) std::swap(MBBB, MBBA); + if (MBB->isLayoutSuccessor(TBB)) { + TII->RemoveBranch(*MBB); + TII->ReverseBranchCondition(Cond); + TII->InsertBranch(*MBB, MBBA, 0, Cond); + } else if (!MBB->isLayoutSuccessor(MBBA)) { + TII->RemoveBranch(*MBB); + TII->InsertBranch(*MBB, TBB, MBBA, Cond); + } + } + } +} + +/// OptimizeIntraLoopEdges - Reposition loop blocks to minimize +/// intra-loop branching and to form contiguous loops. /// -bool CodePlacementOpt::OptimizeIntraLoopEdges() { +bool CodePlacementOpt::OptimizeIntraLoopEdges(MachineFunction &MF) { + bool Changed = false; + if (!TLI->shouldOptimizeCodePlacement()) - return false; + return Changed; + + for (MachineLoopInfo::iterator I = MLI->begin(), E = MLI->end(); + I != E; ++I) + Changed |= OptimizeIntraLoopEdgesInLoop(MF, *I); + return Changed; +} + +/// OptimizeIntraLoopEdgesInLoop - Reposition loop blocks to minimize +/// intra-loop branching and to form contiguous loops. +/// +/// This code takes the approach of making minor changes to the existing +/// layout to fix specific loop-oriented problems. Also, it depends on +/// AnalyzeBranch, which can't understand complex control instructions. +/// +bool CodePlacementOpt::OptimizeIntraLoopEdgesInLoop(MachineFunction &MF, + MachineLoop *L) { bool Changed = false; - for (unsigned i = 0, e = UncondJmpMBBs.size(); i != e; ++i) { - MachineBasicBlock *MBB = UncondJmpMBBs[i].first; - MachineBasicBlock *SuccMBB = UncondJmpMBBs[i].second; - MachineLoop *L = MLI->getLoopFor(MBB); - assert(L && "BB is expected to be in a loop!"); - - if (ChangedMBBs.count(MBB)) { - // BB has been modified, re-analyze. - MachineBasicBlock *TBB = 0, *FBB = 0; - SmallVector Cond; - if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond) || !Cond.empty()) + + // Do optimization for nested loops. + for (MachineLoop::iterator I = L->begin(), E = L->end(); I != E; ++I) + Changed |= OptimizeIntraLoopEdgesInLoop(MF, *I); + + // Keep a record of which blocks are in the portion of the loop contiguous + // with the loop header. + SmallPtrSet ContiguousBlocks; + ContiguousBlocks.insert(L->getHeader()); + + // Find the loop "top", ignoring any discontiguous parts. + MachineBasicBlock *TopMBB = L->getHeader(); + if (TopMBB != MF.begin()) { + MachineBasicBlock *PriorMBB = prior(MachineFunction::iterator(TopMBB)); + while (L->contains(PriorMBB)) { + ContiguousBlocks.insert(PriorMBB); + TopMBB = PriorMBB; + if (TopMBB == MF.begin()) break; + PriorMBB = prior(MachineFunction::iterator(TopMBB)); + } + } + + // Find the loop "bottom", ignoring any discontiguous parts. + MachineBasicBlock *BotMBB = L->getHeader(); + if (BotMBB != prior(MF.end())) { + MachineBasicBlock *NextMBB = next(MachineFunction::iterator(BotMBB)); + while (L->contains(NextMBB)) { + ContiguousBlocks.insert(NextMBB); + BotMBB = NextMBB; + if (BotMBB == next(MachineFunction::iterator(BotMBB))) break; + NextMBB = next(MachineFunction::iterator(BotMBB)); + } + } + + // First, move blocks which unconditionally jump to the loop top to the + // top of the loop so that they have a fall through. This can introduce a + // branch on entry to the loop, but it can eliminate a branch within the + // loop. See the @simple case in test/CodeGen/X86/loop_blocks.ll for an + // example of this. + + bool BotHasFallthrough = HasFallthrough(BotMBB); + + if (TopMBB == MF.begin() || + HasAnalyzableTerminator(prior(MachineFunction::iterator(TopMBB)))) { + new_top: + for (MachineBasicBlock::pred_iterator PI = TopMBB->pred_begin(), + PE = TopMBB->pred_end(); PI != PE; ++PI) { + MachineBasicBlock *Pred = *PI; + if (Pred == TopMBB) continue; + if (HasFallthrough(Pred)) continue; + if (!L->contains(Pred)) continue; + + // Verify that we can analyze all the loop entry edges before beginning + // any changes which will require us to be able to analyze them. + if (Pred == MF.begin()) continue; - if (MLI->getLoopFor(TBB) != L || TBB->isLandingPad()) + if (!HasAnalyzableTerminator(Pred)) + continue; + if (!HasAnalyzableTerminator(prior(MachineFunction::iterator(Pred)))) continue; - SuccMBB = TBB; - } else { - assert(MLI->getLoopFor(SuccMBB) == L && - "Successor is not in the same loop!"); - } - if (MBB->isLayoutSuccessor(SuccMBB)) { - // Successor is right after MBB, just eliminate the unconditional jmp. - // Can this happen? - TII->RemoveBranch(*MBB); - ChangedMBBs.insert(MBB); - ++NumIntraElim; + // Move the block. Changed = true; - continue; - } + ContiguousBlocks.insert(Pred); - // Now check if the predecessor is fallthrough from any BB. If there is, - // that BB should be from outside the loop since edge will become a jmp. - bool OkToMove = true; - MachineBasicBlock *FtMBB = 0, *FtTBB = 0, *FtFBB = 0; - SmallVector FtCond; - for (MachineBasicBlock::pred_iterator PI = SuccMBB->pred_begin(), - PE = SuccMBB->pred_end(); PI != PE; ++PI) { - MachineBasicBlock *PredMBB = *PI; - if (PredMBB->isLayoutSuccessor(SuccMBB)) { - if (TII->AnalyzeBranch(*PredMBB, FtTBB, FtFBB, FtCond)) { - OkToMove = false; + // Move it and all the blocks that can reach it via fallthrough edges + // exclusively, to keep existing fallthrough-edges intact. + MachineFunction::iterator Begin = Pred; + MachineFunction::iterator End = next(Begin); + while (Begin != MF.begin()) { + MachineFunction::iterator Prior = prior(Begin); + if (Prior == MF.begin()) + break; + // Stop when a non-fallthrough edge is found. + if (!HasFallthrough(Prior)) + break; + // Stop if a block which could fall-through out of the loop is found. + if (Prior->isSuccessor(End)) + break; + // If we've reached the top, stop scanning. + if (Prior == MachineFunction::iterator(TopMBB)) { + // We know top currently has a fall through (because we just checked + // it) which would be lost if we do the transformation, so it isn't + // worthwhile to do the transformation unless it would expose a new + // fallthrough edge. + if (!Prior->isSuccessor(End)) + goto next_pred; + // Otherwise we can stop scanning and procede to move the blocks. break; } - if (!FtTBB) - FtTBB = SuccMBB; - else if (!FtFBB) { - assert(FtFBB != SuccMBB && "Unexpected control flow!"); - FtFBB = SuccMBB; - } - - // A fallthrough. - FtMBB = PredMBB; - MachineLoop *PL = MLI->getLoopFor(PredMBB); - if (PL && (PL == L || PL->getLoopDepth() >= L->getLoopDepth())) - OkToMove = false; - - break; + // If we hit a switch or something complicated, don't move anything + // for this predecessor. + if (!HasAnalyzableTerminator(prior(MachineFunction::iterator(Prior)))) + break; + Begin = Prior; + ContiguousBlocks.insert(Begin); + ++NumIntraMoved; } + + // Update BotMBB, before moving Begin/End around and forgetting where + // the new bottom is. + if (BotMBB == prior(End)) + BotMBB = prior(Begin); + + // Move the blocks. + Splice(MF, TopMBB, Begin, End); + + // Update TopMBB, now that all the updates requiring the old top are + // complete. + TopMBB = Begin; + + // We have a new loop top. Iterate on it. We shouldn't have to do this + // too many times if BranchFolding has done a reasonable job. + goto new_top; + next_pred:; } + } - if (!OkToMove) - continue; + // If the loop previously didn't exit with a fall-through and it now does, + // we eliminated a branch. + if (!BotHasFallthrough && HasFallthrough(BotMBB)) { + ++NumIntraElim; + BotHasFallthrough = true; + } - // Is it profitable? If SuccMBB can fallthrough itself, that can be changed - // into a jmp. - MachineBasicBlock *TBB = 0, *FBB = 0; - SmallVector Cond; - if (TII->AnalyzeBranch(*SuccMBB, TBB, FBB, Cond)) - continue; - if (!TBB && Cond.empty()) - TBB = next(MachineFunction::iterator(SuccMBB)); - else if (!FBB && !Cond.empty()) - FBB = next(MachineFunction::iterator(SuccMBB)); - - // This calculate the cost of the transformation. Also, it finds the *only* - // intra-loop edge if there is one. - int Cost = 0; - bool HasOneIntraSucc = true; - MachineBasicBlock *IntraSucc = 0; - for (MachineBasicBlock::succ_iterator SI = SuccMBB->succ_begin(), - SE = SuccMBB->succ_end(); SI != SE; ++SI) { - MachineBasicBlock *SSMBB = *SI; - if (MLI->getLoopFor(SSMBB) == L) { - if (!IntraSucc) - IntraSucc = SSMBB; - else - HasOneIntraSucc = false; + // Next, move any loop blocks that are not in the portion of the loop + // contiguous with the header. This makes the loop contiguous, provided that + // AnalyzeBranch can handle all the relevant branching. See the @cfg_islands + // case in test/CodeGen/X86/loop_blocks.ll for an example of this. + + // Determine a position to move orphaned loop blocks to. If TopMBB is not + // entered via fallthrough and BotMBB is exited via fallthrough, prepend them + // to the top of the loop to avoid loosing that fallthrough. Otherwise append + // them to the bottom, even if it previously had a fallthrough, on the theory + // that it's worth an extra branch to keep the loop contiguous. + MachineFunction::iterator InsertPt = next(MachineFunction::iterator(BotMBB)); + bool InsertAtTop = false; + if (TopMBB != MF.begin() && + !HasFallthrough(prior(MachineFunction::iterator(TopMBB))) && + HasFallthrough(BotMBB)) { + InsertPt = TopMBB; + InsertAtTop = true; + } + + // Find non-contigous blocks and fix them. + if (InsertPt != MF.begin() && HasAnalyzableTerminator(prior(InsertPt))) + for (MachineLoop::block_iterator BI = L->block_begin(), BE = L->block_end(); + BI != BE; ++BI) { + MachineBasicBlock *BB = *BI; + + // Verify that we can analyze all the loop entry edges before beginning + // any changes which will require us to be able to analyze them. + if (!HasAnalyzableTerminator(BB)) + continue; + if (!HasAnalyzableTerminator(prior(MachineFunction::iterator(BB)))) + continue; + + // If the layout predecessor is part of the loop, this block will be + // processed along with it. This keeps them in their relative order. + if (BB != MF.begin() && + L->contains(prior(MachineFunction::iterator(BB)))) + continue; + + // Check to see if this block is already contiguous with the main + // portion of the loop. + if (!ContiguousBlocks.insert(BB)) + continue; + + // Move the block. + Changed = true; + + // Process this block and all loop blocks contiguous with it, to keep + // them in their relative order. + MachineFunction::iterator Begin = BB; + MachineFunction::iterator End = next(MachineFunction::iterator(BB)); + for (; End != MF.end(); ++End) { + if (!L->contains(End)) break; + if (!HasAnalyzableTerminator(End)) break; + ContiguousBlocks.insert(End); + ++NumIntraMoved; } - if (SuccMBB->isLayoutSuccessor(SSMBB)) - // This will become a jmp. - ++Cost; - else if (MBB->isLayoutSuccessor(SSMBB)) { - // One of the successor will become the new fallthrough. - if (SSMBB == FBB) { - FBB = 0; - --Cost; - } else if (!FBB && SSMBB == TBB && Cond.empty()) { - TBB = 0; - --Cost; - } else if (!Cond.empty() && !TII->ReverseBranchCondition(Cond)) { - assert(SSMBB == TBB); - TBB = FBB; - FBB = 0; - --Cost; + // Update BotMBB. + if (!InsertAtTop) + BotMBB = prior(End); + + // If we're inserting at the bottom of the loop, and the code we're + // moving originally had fall-through successors, bring the sucessors + // up with the loop blocks to preserve the fall-through edges. + if (!InsertAtTop) + for (; End != MF.end(); ++End) { + if (L->contains(End)) break; + if (!HasAnalyzableTerminator(End)) break; + if (!HasFallthrough(prior(End))) break; } - } - } - if (Cost) - continue; - // Now, let's move the successor to below the BB to eliminate the jmp. - SuccMBB->moveAfter(MBB); - TII->RemoveBranch(*MBB); - TII->RemoveBranch(*SuccMBB); - if (TBB) - TII->InsertBranch(*SuccMBB, TBB, FBB, Cond); - ChangedMBBs.insert(MBB); - ChangedMBBs.insert(SuccMBB); - if (FtMBB) { - TII->RemoveBranch(*FtMBB); - TII->InsertBranch(*FtMBB, FtTBB, FtFBB, FtCond); - ChangedMBBs.insert(FtMBB); + // Move the blocks. + Splice(MF, InsertPt, Begin, End); + + // Update TopMBB. + if (InsertAtTop) + TopMBB = Begin; } - Changed = true; - } - ++NumIntraMoved; return Changed; } @@ -255,6 +451,8 @@ return Changed; } +/// AlignLoop - Align loop headers to target preferred alignments. +/// bool CodePlacementOpt::AlignLoop(MachineFunction &MF, MachineLoop *L, unsigned Align) { bool Changed = false; @@ -264,13 +462,13 @@ Changed |= AlignLoop(MF, *I, Align); MachineBasicBlock *TopMBB = L->getHeader(); - if (TopMBB == MF.begin()) return Changed; - - MachineBasicBlock *PredMBB = prior(MachineFunction::iterator(TopMBB)); - while (MLI->getLoopFor(PredMBB) == L) { - TopMBB = PredMBB; - if (TopMBB == MF.begin()) return Changed; - PredMBB = prior(MachineFunction::iterator(TopMBB)); + if (TopMBB != MF.begin()) { + MachineBasicBlock *PredMBB = prior(MachineFunction::iterator(TopMBB)); + while (L->contains(PredMBB)) { + TopMBB = PredMBB; + if (TopMBB == MF.begin()) break; + PredMBB = prior(MachineFunction::iterator(TopMBB)); + } } TopMBB->setAlignment(Align); @@ -288,30 +486,9 @@ TLI = MF.getTarget().getTargetLowering(); TII = MF.getTarget().getInstrInfo(); - // Analyze the BBs first and keep track of BBs that - // end with an unconditional jmp to another block in the same loop. - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { - MachineBasicBlock *MBB = I; - if (MBB->isLandingPad()) - continue; - MachineLoop *L = MLI->getLoopFor(MBB); - if (!L) - continue; - - MachineBasicBlock *TBB = 0, *FBB = 0; - SmallVector Cond; - if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond) || !Cond.empty()) - continue; - if (MLI->getLoopFor(TBB) == L && !TBB->isLandingPad()) - UncondJmpMBBs.push_back(std::make_pair(MBB, TBB)); - } - - bool Changed = OptimizeIntraLoopEdges(); + bool Changed = OptimizeIntraLoopEdges(MF); Changed |= AlignLoops(MF); - ChangedMBBs.clear(); - UncondJmpMBBs.clear(); - return Changed; } Modified: llvm/trunk/test/CodeGen/X86/2009-04-20-LinearScanOpt.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-04-20-LinearScanOpt.ll?rev=84295&r1=84294&r2=84295&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-04-20-LinearScanOpt.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-04-20-LinearScanOpt.ll Fri Oct 16 19:32:43 2009 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation-model=pic -disable-fp-elim -stats |& grep asm-printer | grep 84 +; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation-model=pic -disable-fp-elim -stats |& grep asm-printer | grep 83 ; rdar://6802189 ; Test if linearscan is unfavoring registers for allocation to allow more reuse Added: llvm/trunk/test/CodeGen/X86/loop_blocks.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/loop_blocks.ll?rev=84295&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/loop_blocks.ll (added) +++ llvm/trunk/test/CodeGen/X86/loop_blocks.ll Fri Oct 16 19:32:43 2009 @@ -0,0 +1,207 @@ +; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -asm-verbose=false | FileCheck %s + +; These tests check for loop branching structure, and that the loop align +; directive is placed in the expected place. + +; CodeGen should insert a branch into the middle of the loop in +; order to avoid a branch within the loop. + +; CHECK: simple: +; CHECK: jmp .LBB1_1 +; CHECK-NEXT: align +; CHECK-NEXT: .LBB1_2: +; CHECK-NEXT: call loop_latch +; CHECK-NEXT: .LBB1_1: +; CHECK-NEXT: call loop_header + +define void @simple() nounwind { +entry: + br label %loop + +loop: + call void @loop_header() + %t0 = tail call i32 @get() + %t1 = icmp slt i32 %t0, 0 + br i1 %t1, label %done, label %bb + +bb: + call void @loop_latch() + br label %loop + +done: + call void @exit() + ret void +} + +; CodeGen should move block_a to the top of the loop so that it +; falls through into the loop, avoiding a branch within the loop. + +; CHECK: slightly_more_involved: +; CHECK: jmp .LBB2_1 +; CHECK-NEXT: align +; CHECK-NEXT: .LBB2_4: +; CHECK-NEXT: call bar99 +; CHECK-NEXT: .LBB2_1: +; CHECK-NEXT: call body + +define void @slightly_more_involved() nounwind { +entry: + br label %loop + +loop: + call void @body() + %t0 = call i32 @get() + %t1 = icmp slt i32 %t0, 2 + br i1 %t1, label %block_a, label %bb + +bb: + %t2 = call i32 @get() + %t3 = icmp slt i32 %t2, 99 + br i1 %t3, label %exit, label %loop + +block_a: + call void @bar99() + br label %loop + +exit: + call void @exit() + ret void +} + +; Same as slightly_more_involved, but block_a is now a CFG diamond with +; fallthrough edges which should be preserved. + +; CHECK: yet_more_involved: +; CHECK: jmp .LBB3_1 +; CHECK-NEXT: align +; CHECK-NEXT: .LBB3_7: +; CHECK-NEXT: call block_a_true_func +; CHECK-NEXT: jmp .LBB3_4 +; CHECK-NEXT: .LBB3_2: +; CHECK-NEXT: call bar99 +; CHECK-NEXT: call get +; CHECK-NEXT: cmpl $2999, %eax +; CHECK-NEXT: jle .LBB3_7 +; CHECK-NEXT: call block_a_false_func +; CHECK-NEXT: .LBB3_4: +; CHECK-NEXT: call block_a_merge_func +; CHECK-NEXT: .LBB3_1: +; CHECK-NEXT: call body + +define void @yet_more_involved() nounwind { +entry: + br label %loop + +loop: + call void @body() + %t0 = call i32 @get() + %t1 = icmp slt i32 %t0, 2 + br i1 %t1, label %block_a, label %bb + +bb: + %t2 = call i32 @get() + %t3 = icmp slt i32 %t2, 99 + br i1 %t3, label %exit, label %loop + +block_a: + call void @bar99() + %z0 = call i32 @get() + %z1 = icmp slt i32 %z0, 3000 + br i1 %z1, label %block_a_true, label %block_a_false + +block_a_true: + call void @block_a_true_func() + br label %block_a_merge + +block_a_false: + call void @block_a_false_func() + br label %block_a_merge + +block_a_merge: + call void @block_a_merge_func() + br label %loop + +exit: + call void @exit() + ret void +} + +; CodeGen should move the CFG islands that are part of the loop but don't +; conveniently fit anywhere so that they are at least contiguous with the +; loop. + +; CHECK: cfg_islands: +; CHECK: jmp .LBB4_1 +; CHECK-NEXT: align +; CHECK-NEXT: .LBB4_7: +; CHECK-NEXT: call bar100 +; CHECK-NEXT: jmp .LBB4_1 +; CHECK-NEXT: .LBB4_8: +; CHECK-NEXT: call bar101 +; CHECK-NEXT: jmp .LBB4_1 +; CHECK-NEXT: .LBB4_9: +; CHECK-NEXT: call bar102 +; CHECK-NEXT: jmp .LBB4_1 +; CHECK-NEXT: .LBB4_5: +; CHECK-NEXT: call loop_latch +; CHECK-NEXT: .LBB4_1: +; CHECK-NEXT: call loop_header + +define void @cfg_islands() nounwind { +entry: + br label %loop + +loop: + call void @loop_header() + %t0 = call i32 @get() + %t1 = icmp slt i32 %t0, 100 + br i1 %t1, label %block100, label %bb + +bb: + %t2 = call i32 @get() + %t3 = icmp slt i32 %t2, 101 + br i1 %t3, label %block101, label %bb1 + +bb1: + %t4 = call i32 @get() + %t5 = icmp slt i32 %t4, 102 + br i1 %t5, label %block102, label %bb2 + +bb2: + %t6 = call i32 @get() + %t7 = icmp slt i32 %t6, 103 + br i1 %t7, label %exit, label %bb3 + +bb3: + call void @loop_latch() + br label %loop + +exit: + call void @exit() + ret void + +block100: + call void @bar100() + br label %loop + +block101: + call void @bar101() + br label %loop + +block102: + call void @bar102() + br label %loop +} + +declare void @bar99() nounwind +declare void @bar100() nounwind +declare void @bar101() nounwind +declare void @bar102() nounwind +declare void @body() nounwind +declare void @exit() nounwind +declare void @loop_header() nounwind +declare void @loop_latch() nounwind +declare i32 @get() nounwind +declare void @block_a_true_func() nounwind +declare void @block_a_false_func() nounwind +declare void @block_a_merge_func() nounwind From vhernandez at apple.com Fri Oct 16 20:18:11 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Sat, 17 Oct 2009 01:18:11 -0000 Subject: [llvm-commits] [llvm] r84299 - in /llvm/trunk: include/llvm-c/ include/llvm/ include/llvm/Support/ include/llvm/Transforms/ lib/Analysis/ lib/Analysis/IPA/ lib/AsmParser/ lib/Bitcode/Writer/ lib/CodeGen/SelectionDAG/ lib/Target/CBackend/ lib/Target/CppBackend/ lib/Target/MSIL/ lib/Transforms/IPO/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ Message-ID: <200910170118.n9H1IDBN000804@zion.cs.uiuc.edu> Author: hernande Date: Fri Oct 16 20:18:07 2009 New Revision: 84299 URL: http://llvm.org/viewvc/llvm-project?rev=84299&view=rev Log: Remove MallocInst from LLVM Instructions. Modified: llvm/trunk/include/llvm-c/Core.h llvm/trunk/include/llvm/InstrTypes.h llvm/trunk/include/llvm/Instruction.def llvm/trunk/include/llvm/Instructions.h llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/include/llvm/Support/InstVisitor.h llvm/trunk/include/llvm/Transforms/Scalar.h llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp llvm/trunk/lib/Analysis/InlineCost.cpp llvm/trunk/lib/Analysis/InstCount.cpp llvm/trunk/lib/Analysis/ValueTracking.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp llvm/trunk/lib/Target/MSIL/MSILWriter.cpp llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp llvm/trunk/lib/VMCore/Instruction.cpp llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Fri Oct 16 20:18:07 2009 @@ -457,7 +457,6 @@ macro(UnaryInstruction) \ macro(AllocationInst) \ macro(AllocaInst) \ - macro(MallocInst) \ macro(CastInst) \ macro(BitCastInst) \ macro(FPExtInst) \ Modified: llvm/trunk/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/include/llvm/InstrTypes.h (original) +++ llvm/trunk/include/llvm/InstrTypes.h Fri Oct 16 20:18:07 2009 @@ -116,8 +116,7 @@ // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const UnaryInstruction *) { return true; } static inline bool classof(const Instruction *I) { - return I->getOpcode() == Instruction::Malloc || - I->getOpcode() == Instruction::Alloca || + return I->getOpcode() == Instruction::Alloca || I->getOpcode() == Instruction::Free || I->getOpcode() == Instruction::Load || I->getOpcode() == Instruction::VAArg || Modified: llvm/trunk/include/llvm/Instruction.def URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.def?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instruction.def (original) +++ llvm/trunk/include/llvm/Instruction.def Fri Oct 16 20:18:07 2009 @@ -128,49 +128,48 @@ // Memory operators... FIRST_MEMORY_INST(25) -HANDLE_MEMORY_INST(25, Malloc, MallocInst) // Heap management instructions -HANDLE_MEMORY_INST(26, Free , FreeInst ) -HANDLE_MEMORY_INST(27, Alloca, AllocaInst) // Stack management -HANDLE_MEMORY_INST(28, Load , LoadInst ) // Memory manipulation instrs -HANDLE_MEMORY_INST(29, Store , StoreInst ) -HANDLE_MEMORY_INST(30, GetElementPtr, GetElementPtrInst) - LAST_MEMORY_INST(30) +HANDLE_MEMORY_INST(25, Free , FreeInst ) // Heap management instructions +HANDLE_MEMORY_INST(26, Alloca, AllocaInst) // Stack management +HANDLE_MEMORY_INST(27, Load , LoadInst ) // Memory manipulation instrs +HANDLE_MEMORY_INST(28, Store , StoreInst ) +HANDLE_MEMORY_INST(29, GetElementPtr, GetElementPtrInst) + LAST_MEMORY_INST(29) // Cast operators ... // NOTE: The order matters here because CastInst::isEliminableCastPair // NOTE: (see Instructions.cpp) encodes a table based on this ordering. - FIRST_CAST_INST(31) -HANDLE_CAST_INST(31, Trunc , TruncInst ) // Truncate integers -HANDLE_CAST_INST(32, ZExt , ZExtInst ) // Zero extend integers -HANDLE_CAST_INST(33, SExt , SExtInst ) // Sign extend integers -HANDLE_CAST_INST(34, FPToUI , FPToUIInst ) // floating point -> UInt -HANDLE_CAST_INST(35, FPToSI , FPToSIInst ) // floating point -> SInt -HANDLE_CAST_INST(36, UIToFP , UIToFPInst ) // UInt -> floating point -HANDLE_CAST_INST(37, SIToFP , SIToFPInst ) // SInt -> floating point -HANDLE_CAST_INST(38, FPTrunc , FPTruncInst ) // Truncate floating point -HANDLE_CAST_INST(39, FPExt , FPExtInst ) // Extend floating point -HANDLE_CAST_INST(40, PtrToInt, PtrToIntInst) // Pointer -> Integer -HANDLE_CAST_INST(41, IntToPtr, IntToPtrInst) // Integer -> Pointer -HANDLE_CAST_INST(42, BitCast , BitCastInst ) // Type cast - LAST_CAST_INST(42) + FIRST_CAST_INST(30) +HANDLE_CAST_INST(30, Trunc , TruncInst ) // Truncate integers +HANDLE_CAST_INST(31, ZExt , ZExtInst ) // Zero extend integers +HANDLE_CAST_INST(32, SExt , SExtInst ) // Sign extend integers +HANDLE_CAST_INST(33, FPToUI , FPToUIInst ) // floating point -> UInt +HANDLE_CAST_INST(34, FPToSI , FPToSIInst ) // floating point -> SInt +HANDLE_CAST_INST(35, UIToFP , UIToFPInst ) // UInt -> floating point +HANDLE_CAST_INST(36, SIToFP , SIToFPInst ) // SInt -> floating point +HANDLE_CAST_INST(37, FPTrunc , FPTruncInst ) // Truncate floating point +HANDLE_CAST_INST(38, FPExt , FPExtInst ) // Extend floating point +HANDLE_CAST_INST(39, PtrToInt, PtrToIntInst) // Pointer -> Integer +HANDLE_CAST_INST(40, IntToPtr, IntToPtrInst) // Integer -> Pointer +HANDLE_CAST_INST(41, BitCast , BitCastInst ) // Type cast + LAST_CAST_INST(41) // Other operators... - FIRST_OTHER_INST(43) -HANDLE_OTHER_INST(43, ICmp , ICmpInst ) // Integer comparison instruction -HANDLE_OTHER_INST(44, FCmp , FCmpInst ) // Floating point comparison instr. -HANDLE_OTHER_INST(45, PHI , PHINode ) // PHI node instruction -HANDLE_OTHER_INST(46, Call , CallInst ) // Call a function -HANDLE_OTHER_INST(47, Select , SelectInst ) // select instruction -HANDLE_OTHER_INST(48, UserOp1, Instruction) // May be used internally in a pass -HANDLE_OTHER_INST(49, UserOp2, Instruction) // Internal to passes only -HANDLE_OTHER_INST(50, VAArg , VAArgInst ) // vaarg instruction -HANDLE_OTHER_INST(51, ExtractElement, ExtractElementInst)// extract from vector -HANDLE_OTHER_INST(52, InsertElement, InsertElementInst) // insert into vector -HANDLE_OTHER_INST(53, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. -HANDLE_OTHER_INST(54, ExtractValue, ExtractValueInst)// extract from aggregate -HANDLE_OTHER_INST(55, InsertValue, InsertValueInst) // insert into aggregate + FIRST_OTHER_INST(42) +HANDLE_OTHER_INST(42, ICmp , ICmpInst ) // Integer comparison instruction +HANDLE_OTHER_INST(43, FCmp , FCmpInst ) // Floating point comparison instr. +HANDLE_OTHER_INST(44, PHI , PHINode ) // PHI node instruction +HANDLE_OTHER_INST(45, Call , CallInst ) // Call a function +HANDLE_OTHER_INST(46, Select , SelectInst ) // select instruction +HANDLE_OTHER_INST(47, UserOp1, Instruction) // May be used internally in a pass +HANDLE_OTHER_INST(48, UserOp2, Instruction) // Internal to passes only +HANDLE_OTHER_INST(49, VAArg , VAArgInst ) // vaarg instruction +HANDLE_OTHER_INST(50, ExtractElement, ExtractElementInst)// extract from vector +HANDLE_OTHER_INST(51, InsertElement, InsertElementInst) // insert into vector +HANDLE_OTHER_INST(52, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. +HANDLE_OTHER_INST(53, ExtractValue, ExtractValueInst)// extract from aggregate +HANDLE_OTHER_INST(54, InsertValue, InsertValueInst) // insert into aggregate - LAST_OTHER_INST(55) + LAST_OTHER_INST(54) #undef FIRST_TERM_INST #undef HANDLE_TERM_INST Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Fri Oct 16 20:18:07 2009 @@ -37,8 +37,7 @@ // AllocationInst Class //===----------------------------------------------------------------------===// -/// AllocationInst - This class is the common base class of MallocInst and -/// AllocaInst. +/// AllocationInst - This class is the base class of AllocaInst. /// class AllocationInst : public UnaryInstruction { protected: @@ -85,56 +84,7 @@ // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const AllocationInst *) { return true; } static inline bool classof(const Instruction *I) { - return I->getOpcode() == Instruction::Alloca || - I->getOpcode() == Instruction::Malloc; - } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } -}; - - -//===----------------------------------------------------------------------===// -// MallocInst Class -//===----------------------------------------------------------------------===// - -/// MallocInst - an instruction to allocated memory on the heap -/// -class MallocInst : public AllocationInst { -public: - explicit MallocInst(const Type *Ty, Value *ArraySize = 0, - const Twine &NameStr = "", - Instruction *InsertBefore = 0) - : AllocationInst(Ty, ArraySize, Malloc, - 0, NameStr, InsertBefore) {} - MallocInst(const Type *Ty, Value *ArraySize, - const Twine &NameStr, BasicBlock *InsertAtEnd) - : AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {} - - MallocInst(const Type *Ty, const Twine &NameStr, - Instruction *InsertBefore = 0) - : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertBefore) {} - MallocInst(const Type *Ty, const Twine &NameStr, - BasicBlock *InsertAtEnd) - : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {} - - MallocInst(const Type *Ty, Value *ArraySize, - unsigned Align, const Twine &NameStr, - BasicBlock *InsertAtEnd) - : AllocationInst(Ty, ArraySize, Malloc, - Align, NameStr, InsertAtEnd) {} - MallocInst(const Type *Ty, Value *ArraySize, - unsigned Align, const Twine &NameStr = "", - Instruction *InsertBefore = 0) - : AllocationInst(Ty, ArraySize, - Malloc, Align, NameStr, InsertBefore) {} - - virtual MallocInst *clone() const; - - // Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const MallocInst *) { return true; } - static inline bool classof(const Instruction *I) { - return (I->getOpcode() == Instruction::Malloc); + return I->getOpcode() == Instruction::Alloca; } static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Fri Oct 16 20:18:07 2009 @@ -429,10 +429,6 @@ // Instruction creation methods: Memory Instructions //===--------------------------------------------------------------------===// - MallocInst *CreateMalloc(const Type *Ty, Value *ArraySize = 0, - const Twine &Name = "") { - return Insert(new MallocInst(Ty, ArraySize), Name); - } AllocaInst *CreateAlloca(const Type *Ty, Value *ArraySize = 0, const Twine &Name = "") { return Insert(new AllocaInst(Ty, ArraySize), Name); Modified: llvm/trunk/include/llvm/Support/InstVisitor.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/InstVisitor.h?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/InstVisitor.h (original) +++ llvm/trunk/include/llvm/Support/InstVisitor.h Fri Oct 16 20:18:07 2009 @@ -46,17 +46,17 @@ /// /// Declare the class. Note that we derive from InstVisitor instantiated /// /// with _our new subclasses_ type. /// /// -/// struct CountMallocVisitor : public InstVisitor { +/// struct CountAllocaVisitor : public InstVisitor { /// unsigned Count; -/// CountMallocVisitor() : Count(0) {} +/// CountAllocaVisitor() : Count(0) {} /// -/// void visitMallocInst(MallocInst &MI) { ++Count; } +/// void visitAllocaInst(AllocaInst &AI) { ++Count; } /// }; /// /// And this class would be used like this: -/// CountMallocVistor CMV; -/// CMV.visit(function); -/// NumMallocs = CMV.Count; +/// CountAllocaVisitor CAV; +/// CAV.visit(function); +/// NumAllocas = CAV.Count; /// /// The defined has 'visit' methods for Instruction, and also for BasicBlock, /// Function, and Module, which recursively process all contained instructions. @@ -165,7 +165,6 @@ RetTy visitUnreachableInst(UnreachableInst &I) { DELEGATE(TerminatorInst);} RetTy visitICmpInst(ICmpInst &I) { DELEGATE(CmpInst);} RetTy visitFCmpInst(FCmpInst &I) { DELEGATE(CmpInst);} - RetTy visitMallocInst(MallocInst &I) { DELEGATE(AllocationInst);} RetTy visitAllocaInst(AllocaInst &I) { DELEGATE(AllocationInst);} RetTy visitFreeInst(FreeInst &I) { DELEGATE(Instruction); } RetTy visitLoadInst(LoadInst &I) { DELEGATE(Instruction); } Modified: llvm/trunk/include/llvm/Transforms/Scalar.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Scalar.h (original) +++ llvm/trunk/include/llvm/Transforms/Scalar.h Fri Oct 16 20:18:07 2009 @@ -225,12 +225,11 @@ //===----------------------------------------------------------------------===// // -// LowerAllocations - Turn malloc and free instructions into @malloc and @free -// calls. +// LowerAllocations - Turn free instructions into @free calls. // // AU.addRequiredID(LowerAllocationsID); // -Pass *createLowerAllocationsPass(bool LowerMallocArgToInteger = false); +Pass *createLowerAllocationsPass(); extern const PassInfo *const LowerAllocationsID; //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp Fri Oct 16 20:18:07 2009 @@ -303,7 +303,7 @@ // Check the value being stored. Value *Ptr = SI->getOperand(0)->getUnderlyingObject(); - if (isa(Ptr) || isMalloc(Ptr)) { + if (isMalloc(Ptr)) { // Okay, easy case. } else if (CallInst *CI = dyn_cast(Ptr)) { Function *F = CI->getCalledFunction(); @@ -439,8 +439,7 @@ if (cast(*II).isVolatile()) // Treat volatile stores as reading memory somewhere. FunctionEffect |= Ref; - } else if (isa(*II) || isa(*II) || - isMalloc(&cast(*II))) { + } else if (isMalloc(&cast(*II)) || isa(*II)) { FunctionEffect |= ModRef; } Modified: llvm/trunk/lib/Analysis/InlineCost.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InlineCost.cpp (original) +++ llvm/trunk/lib/Analysis/InlineCost.cpp Fri Oct 16 20:18:07 2009 @@ -131,7 +131,7 @@ } // These, too, are calls. - if (isa(II) || isa(II)) + if (isa(II)) NumInsts += InlineConstants::CallPenalty; if (const AllocaInst *AI = dyn_cast(II)) { Modified: llvm/trunk/lib/Analysis/InstCount.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstCount.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstCount.cpp (original) +++ llvm/trunk/lib/Analysis/InstCount.cpp Fri Oct 16 20:18:07 2009 @@ -76,11 +76,11 @@ bool InstCount::runOnFunction(Function &F) { unsigned StartMemInsts = NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst + - NumInvokeInst + NumAllocaInst + NumMallocInst + NumFreeInst; + NumInvokeInst + NumAllocaInst + NumFreeInst; visit(F); unsigned EndMemInsts = NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst + - NumInvokeInst + NumAllocaInst + NumMallocInst + NumFreeInst; + NumInvokeInst + NumAllocaInst + NumFreeInst; TotalMemInst += EndMemInsts-StartMemInsts; return false; } Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Fri Oct 16 20:18:07 2009 @@ -469,26 +469,11 @@ break; } - case Instruction::Alloca: - case Instruction::Malloc: { + case Instruction::Alloca: { AllocationInst *AI = cast(V); unsigned Align = AI->getAlignment(); - if (Align == 0 && TD) { - if (isa(AI)) - Align = TD->getABITypeAlignment(AI->getType()->getElementType()); - else if (isa(AI)) { - // Malloc returns maximally aligned memory. - Align = TD->getABITypeAlignment(AI->getType()->getElementType()); - Align = - std::max(Align, - (unsigned)TD->getABITypeAlignment( - Type::getDoubleTy(V->getContext()))); - Align = - std::max(Align, - (unsigned)TD->getABITypeAlignment( - Type::getInt64Ty(V->getContext()))); - } - } + if (Align == 0 && TD) + Align = TD->getABITypeAlignment(AI->getType()->getElementType()); if (Align > 0) KnownZero = Mask & APInt::getLowBitsSet(BitWidth, Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Fri Oct 16 20:18:07 2009 @@ -3315,7 +3315,7 @@ } /// ParsePHI -/// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Value?? ']')* +/// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Value????? ']')* bool LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) { PATypeHolder Ty(Type::getVoidTy(Context)); Value *Op0, *Op1; Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Fri Oct 16 20:18:07 2009 @@ -1054,13 +1054,6 @@ Vals.push_back(VE.getValueID(I.getOperand(i))); break; - case Instruction::Malloc: - Code = bitc::FUNC_CODE_INST_MALLOC; - Vals.push_back(VE.getTypeID(I.getType())); - Vals.push_back(VE.getValueID(I.getOperand(0))); // size. - Vals.push_back(Log2_32(cast(I).getAlignment())+1); - break; - case Instruction::Free: Code = bitc::FUNC_CODE_INST_FREE; PushValueAndType(I.getOperand(0), InstID, Vals, VE); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Fri Oct 16 20:18:07 2009 @@ -5485,48 +5485,6 @@ DAG.setRoot(Chain); } - -void SelectionDAGLowering::visitMalloc(MallocInst &I) { - SDValue Src = getValue(I.getOperand(0)); - - // Scale up by the type size in the original i32 type width. Various - // mid-level optimizers may make assumptions about demanded bits etc from the - // i32-ness of the optimizer: we do not want to promote to i64 and then - // multiply on 64-bit targets. - // FIXME: Malloc inst should go away: PR715. - uint64_t ElementSize = TD->getTypeAllocSize(I.getType()->getElementType()); - if (ElementSize != 1) { - // Src is always 32-bits, make sure the constant fits. - assert(Src.getValueType() == MVT::i32); - ElementSize = (uint32_t)ElementSize; - Src = DAG.getNode(ISD::MUL, getCurDebugLoc(), Src.getValueType(), - Src, DAG.getConstant(ElementSize, Src.getValueType())); - } - - EVT IntPtr = TLI.getPointerTy(); - - Src = DAG.getZExtOrTrunc(Src, getCurDebugLoc(), IntPtr); - - TargetLowering::ArgListTy Args; - TargetLowering::ArgListEntry Entry; - Entry.Node = Src; - Entry.Ty = TLI.getTargetData()->getIntPtrType(*DAG.getContext()); - Args.push_back(Entry); - - bool isTailCall = PerformTailCallOpt && - isInTailCallPosition(&I, Attribute::None, TLI); - std::pair Result = - TLI.LowerCallTo(getRoot(), I.getType(), false, false, false, false, - 0, CallingConv::C, isTailCall, - /*isReturnValueUsed=*/true, - DAG.getExternalSymbol("malloc", IntPtr), - Args, DAG, getCurDebugLoc()); - if (Result.first.getNode()) - setValue(&I, Result.first); // Pointers always fit in registers - if (Result.second.getNode()) - DAG.setRoot(Result.second); -} - void SelectionDAGLowering::visitFree(FreeInst &I) { TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h Fri Oct 16 20:18:07 2009 @@ -60,7 +60,6 @@ class MachineInstr; class MachineModuleInfo; class MachineRegisterInfo; -class MallocInst; class PHINode; class PtrToIntInst; class ReturnInst; @@ -529,7 +528,6 @@ void visitGetElementPtr(User &I); void visitSelect(User &I); - void visitMalloc(MallocInst &I); void visitFree(FreeInst &I); void visitAlloca(AllocaInst &I); void visitLoad(LoadInst &I); Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Fri Oct 16 20:18:07 2009 @@ -302,7 +302,6 @@ void visitInlineAsm(CallInst &I); bool visitBuiltinCall(CallInst &I, Intrinsic::ID ID, bool &WroteCallee); - void visitMallocInst(MallocInst &I); void visitAllocaInst(AllocaInst &I); void visitFreeInst (FreeInst &I); void visitLoadInst (LoadInst &I); @@ -3405,10 +3404,6 @@ Out << ")"; } -void CWriter::visitMallocInst(MallocInst &I) { - llvm_unreachable("lowerallocations pass didn't work!"); -} - void CWriter::visitAllocaInst(AllocaInst &I) { Out << '('; printType(Out, I.getType()); @@ -3690,7 +3685,7 @@ if (FileType != TargetMachine::AssemblyFile) return true; PM.add(createGCLoweringPass()); - PM.add(createLowerAllocationsPass(true)); + PM.add(createLowerAllocationsPass()); PM.add(createLowerInvokePass()); PM.add(createCFGSimplificationPass()); // clean up after lower invoke. PM.add(new CBackendNameAllUsedStructsAndMergeFunctions()); Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original) +++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Fri Oct 16 20:18:07 2009 @@ -1258,20 +1258,6 @@ Out << "\");"; break; } - case Instruction::Malloc: { - const MallocInst* mallocI = cast(I); - Out << "MallocInst* " << iName << " = new MallocInst(" - << getCppName(mallocI->getAllocatedType()) << ", "; - if (mallocI->isArrayAllocation()) - Out << opNames[0] << ", " ; - Out << "\""; - printEscapedString(mallocI->getName()); - Out << "\", " << bbname << ");"; - if (mallocI->getAlignment()) - nl(Out) << iName << "->setAlignment(" - << mallocI->getAlignment() << ");"; - break; - } case Instruction::Free: { Out << "FreeInst* " << iName << " = new FreeInst(" << getCppName(I->getOperand(0)) << ", " << bbname << ");"; Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original) +++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Fri Oct 16 20:18:07 2009 @@ -1191,9 +1191,6 @@ case Instruction::Alloca: printAllocaInstruction(cast(Inst)); break; - case Instruction::Malloc: - llvm_unreachable("LowerAllocationsPass used"); - break; case Instruction::Free: llvm_unreachable("LowerAllocationsPass used"); break; @@ -1702,7 +1699,7 @@ if (FileType != TargetMachine::AssemblyFile) return true; MSILWriter* Writer = new MSILWriter(o); PM.add(createGCLoweringPass()); - PM.add(createLowerAllocationsPass(true)); + PM.add(createLowerAllocationsPass()); // FIXME: Handle switch trougth native IL instruction "switch" PM.add(createLowerSwitchPass()); PM.add(createCFGSimplificationPass()); Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Fri Oct 16 20:18:07 2009 @@ -153,7 +153,7 @@ // Writes memory. Just give up. return false; - if (isa(I)) + if (isMalloc(I)) // malloc claims not to write memory! PR3754. return false; @@ -267,7 +267,6 @@ // Check whether the pointer came from an allocation. case Instruction::Alloca: - case Instruction::Malloc: break; case Instruction::Call: if (isMalloc(RVI)) Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Fri Oct 16 20:18:07 2009 @@ -822,130 +822,6 @@ /// malloc, there is no reason to actually DO the malloc. Instead, turn the /// malloc into a global, and any loads of GV as uses of the new global. static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, - MallocInst *MI, - LLVMContext &Context) { - DEBUG(errs() << "PROMOTING MALLOC GLOBAL: " << *GV << " MALLOC = " << *MI); - ConstantInt *NElements = cast(MI->getArraySize()); - - if (NElements->getZExtValue() != 1) { - // If we have an array allocation, transform it to a single element - // allocation to make the code below simpler. - Type *NewTy = ArrayType::get(MI->getAllocatedType(), - NElements->getZExtValue()); - MallocInst *NewMI = - new MallocInst(NewTy, Constant::getNullValue(Type::getInt32Ty(Context)), - MI->getAlignment(), MI->getName(), MI); - Value* Indices[2]; - Indices[0] = Indices[1] = Constant::getNullValue(Type::getInt32Ty(Context)); - Value *NewGEP = GetElementPtrInst::Create(NewMI, Indices, Indices + 2, - NewMI->getName()+".el0", MI); - MI->replaceAllUsesWith(NewGEP); - MI->eraseFromParent(); - MI = NewMI; - } - - // Create the new global variable. The contents of the malloc'd memory is - // undefined, so initialize with an undef value. - // FIXME: This new global should have the alignment returned by malloc. Code - // could depend on malloc returning large alignment (on the mac, 16 bytes) but - // this would only guarantee some lower alignment. - Constant *Init = UndefValue::get(MI->getAllocatedType()); - GlobalVariable *NewGV = new GlobalVariable(*GV->getParent(), - MI->getAllocatedType(), false, - GlobalValue::InternalLinkage, Init, - GV->getName()+".body", - GV, - GV->isThreadLocal()); - - // Anything that used the malloc now uses the global directly. - MI->replaceAllUsesWith(NewGV); - - Constant *RepValue = NewGV; - if (NewGV->getType() != GV->getType()->getElementType()) - RepValue = ConstantExpr::getBitCast(RepValue, - GV->getType()->getElementType()); - - // If there is a comparison against null, we will insert a global bool to - // keep track of whether the global was initialized yet or not. - GlobalVariable *InitBool = - new GlobalVariable(Context, Type::getInt1Ty(Context), false, - GlobalValue::InternalLinkage, - ConstantInt::getFalse(Context), GV->getName()+".init", - GV->isThreadLocal()); - bool InitBoolUsed = false; - - // Loop over all uses of GV, processing them in turn. - std::vector Stores; - while (!GV->use_empty()) - if (LoadInst *LI = dyn_cast(GV->use_back())) { - while (!LI->use_empty()) { - Use &LoadUse = LI->use_begin().getUse(); - if (!isa(LoadUse.getUser())) - LoadUse = RepValue; - else { - ICmpInst *CI = cast(LoadUse.getUser()); - // Replace the cmp X, 0 with a use of the bool value. - Value *LV = new LoadInst(InitBool, InitBool->getName()+".val", CI); - InitBoolUsed = true; - switch (CI->getPredicate()) { - default: llvm_unreachable("Unknown ICmp Predicate!"); - case ICmpInst::ICMP_ULT: - case ICmpInst::ICMP_SLT: - LV = ConstantInt::getFalse(Context); // X < null -> always false - break; - case ICmpInst::ICMP_ULE: - case ICmpInst::ICMP_SLE: - case ICmpInst::ICMP_EQ: - LV = BinaryOperator::CreateNot(LV, "notinit", CI); - break; - case ICmpInst::ICMP_NE: - case ICmpInst::ICMP_UGE: - case ICmpInst::ICMP_SGE: - case ICmpInst::ICMP_UGT: - case ICmpInst::ICMP_SGT: - break; // no change. - } - CI->replaceAllUsesWith(LV); - CI->eraseFromParent(); - } - } - LI->eraseFromParent(); - } else { - StoreInst *SI = cast(GV->use_back()); - // The global is initialized when the store to it occurs. - new StoreInst(ConstantInt::getTrue(Context), InitBool, SI); - SI->eraseFromParent(); - } - - // If the initialization boolean was used, insert it, otherwise delete it. - if (!InitBoolUsed) { - while (!InitBool->use_empty()) // Delete initializations - cast(InitBool->use_back())->eraseFromParent(); - delete InitBool; - } else - GV->getParent()->getGlobalList().insert(GV, InitBool); - - - // Now the GV is dead, nuke it and the malloc. - GV->eraseFromParent(); - MI->eraseFromParent(); - - // To further other optimizations, loop over all users of NewGV and try to - // constant prop them. This will promote GEP instructions with constant - // indices into GEP constant-exprs, which will allow global-opt to hack on it. - ConstantPropUsersOf(NewGV, Context); - if (RepValue != NewGV) - ConstantPropUsersOf(RepValue, Context); - - return NewGV; -} - -/// OptimizeGlobalAddressOfMalloc - This function takes the specified global -/// variable, and transforms the program as if it always contained the result of -/// the specified malloc. Because it is always the result of the specified -/// malloc, there is no reason to actually DO the malloc. Instead, turn the -/// malloc into a global, and any loads of GV as uses of the new global. -static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, CallInst *CI, BitCastInst *BCI, LLVMContext &Context, @@ -1397,185 +1273,6 @@ } } -/// PerformHeapAllocSRoA - MI is an allocation of an array of structures. Break -/// it up into multiple allocations of arrays of the fields. -static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI, - LLVMContext &Context){ - DEBUG(errs() << "SROA HEAP ALLOC: " << *GV << " MALLOC = " << *MI); - const StructType *STy = cast(MI->getAllocatedType()); - - // There is guaranteed to be at least one use of the malloc (storing - // it into GV). If there are other uses, change them to be uses of - // the global to simplify later code. This also deletes the store - // into GV. - ReplaceUsesOfMallocWithGlobal(MI, GV); - - // Okay, at this point, there are no users of the malloc. Insert N - // new mallocs at the same place as MI, and N globals. - std::vector FieldGlobals; - std::vector FieldMallocs; - - for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){ - const Type *FieldTy = STy->getElementType(FieldNo); - const Type *PFieldTy = PointerType::getUnqual(FieldTy); - - GlobalVariable *NGV = - new GlobalVariable(*GV->getParent(), - PFieldTy, false, GlobalValue::InternalLinkage, - Constant::getNullValue(PFieldTy), - GV->getName() + ".f" + Twine(FieldNo), GV, - GV->isThreadLocal()); - FieldGlobals.push_back(NGV); - - MallocInst *NMI = new MallocInst(FieldTy, MI->getArraySize(), - MI->getName() + ".f" + Twine(FieldNo), MI); - FieldMallocs.push_back(NMI); - new StoreInst(NMI, NGV, MI); - } - - // The tricky aspect of this transformation is handling the case when malloc - // fails. In the original code, malloc failing would set the result pointer - // of malloc to null. In this case, some mallocs could succeed and others - // could fail. As such, we emit code that looks like this: - // F0 = malloc(field0) - // F1 = malloc(field1) - // F2 = malloc(field2) - // if (F0 == 0 || F1 == 0 || F2 == 0) { - // if (F0) { free(F0); F0 = 0; } - // if (F1) { free(F1); F1 = 0; } - // if (F2) { free(F2); F2 = 0; } - // } - Value *RunningOr = 0; - for (unsigned i = 0, e = FieldMallocs.size(); i != e; ++i) { - Value *Cond = new ICmpInst(MI, ICmpInst::ICMP_EQ, FieldMallocs[i], - Constant::getNullValue(FieldMallocs[i]->getType()), - "isnull"); - if (!RunningOr) - RunningOr = Cond; // First seteq - else - RunningOr = BinaryOperator::CreateOr(RunningOr, Cond, "tmp", MI); - } - - // Split the basic block at the old malloc. - BasicBlock *OrigBB = MI->getParent(); - BasicBlock *ContBB = OrigBB->splitBasicBlock(MI, "malloc_cont"); - - // Create the block to check the first condition. Put all these blocks at the - // end of the function as they are unlikely to be executed. - BasicBlock *NullPtrBlock = BasicBlock::Create(Context, "malloc_ret_null", - OrigBB->getParent()); - - // Remove the uncond branch from OrigBB to ContBB, turning it into a cond - // branch on RunningOr. - OrigBB->getTerminator()->eraseFromParent(); - BranchInst::Create(NullPtrBlock, ContBB, RunningOr, OrigBB); - - // Within the NullPtrBlock, we need to emit a comparison and branch for each - // pointer, because some may be null while others are not. - for (unsigned i = 0, e = FieldGlobals.size(); i != e; ++i) { - Value *GVVal = new LoadInst(FieldGlobals[i], "tmp", NullPtrBlock); - Value *Cmp = new ICmpInst(*NullPtrBlock, ICmpInst::ICMP_NE, GVVal, - Constant::getNullValue(GVVal->getType()), - "tmp"); - BasicBlock *FreeBlock = BasicBlock::Create(Context, "free_it", - OrigBB->getParent()); - BasicBlock *NextBlock = BasicBlock::Create(Context, "next", - OrigBB->getParent()); - BranchInst::Create(FreeBlock, NextBlock, Cmp, NullPtrBlock); - - // Fill in FreeBlock. - new FreeInst(GVVal, FreeBlock); - new StoreInst(Constant::getNullValue(GVVal->getType()), FieldGlobals[i], - FreeBlock); - BranchInst::Create(NextBlock, FreeBlock); - - NullPtrBlock = NextBlock; - } - - BranchInst::Create(ContBB, NullPtrBlock); - - // MI is no longer needed, remove it. - MI->eraseFromParent(); - - /// InsertedScalarizedLoads - As we process loads, if we can't immediately - /// update all uses of the load, keep track of what scalarized loads are - /// inserted for a given load. - DenseMap > InsertedScalarizedValues; - InsertedScalarizedValues[GV] = FieldGlobals; - - std::vector > PHIsToRewrite; - - // Okay, the malloc site is completely handled. All of the uses of GV are now - // loads, and all uses of those loads are simple. Rewrite them to use loads - // of the per-field globals instead. - for (Value::use_iterator UI = GV->use_begin(), E = GV->use_end(); UI != E;) { - Instruction *User = cast(*UI++); - - if (LoadInst *LI = dyn_cast(User)) { - RewriteUsesOfLoadForHeapSRoA(LI, InsertedScalarizedValues, PHIsToRewrite, - Context); - continue; - } - - // Must be a store of null. - StoreInst *SI = cast(User); - assert(isa(SI->getOperand(0)) && - "Unexpected heap-sra user!"); - - // Insert a store of null into each global. - for (unsigned i = 0, e = FieldGlobals.size(); i != e; ++i) { - const PointerType *PT = cast(FieldGlobals[i]->getType()); - Constant *Null = Constant::getNullValue(PT->getElementType()); - new StoreInst(Null, FieldGlobals[i], SI); - } - // Erase the original store. - SI->eraseFromParent(); - } - - // While we have PHIs that are interesting to rewrite, do it. - while (!PHIsToRewrite.empty()) { - PHINode *PN = PHIsToRewrite.back().first; - unsigned FieldNo = PHIsToRewrite.back().second; - PHIsToRewrite.pop_back(); - PHINode *FieldPN = cast(InsertedScalarizedValues[PN][FieldNo]); - assert(FieldPN->getNumIncomingValues() == 0 &&"Already processed this phi"); - - // Add all the incoming values. This can materialize more phis. - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - Value *InVal = PN->getIncomingValue(i); - InVal = GetHeapSROAValue(InVal, FieldNo, InsertedScalarizedValues, - PHIsToRewrite, Context); - FieldPN->addIncoming(InVal, PN->getIncomingBlock(i)); - } - } - - // Drop all inter-phi links and any loads that made it this far. - for (DenseMap >::iterator - I = InsertedScalarizedValues.begin(), E = InsertedScalarizedValues.end(); - I != E; ++I) { - if (PHINode *PN = dyn_cast(I->first)) - PN->dropAllReferences(); - else if (LoadInst *LI = dyn_cast(I->first)) - LI->dropAllReferences(); - } - - // Delete all the phis and loads now that inter-references are dead. - for (DenseMap >::iterator - I = InsertedScalarizedValues.begin(), E = InsertedScalarizedValues.end(); - I != E; ++I) { - if (PHINode *PN = dyn_cast(I->first)) - PN->eraseFromParent(); - else if (LoadInst *LI = dyn_cast(I->first)) - LI->eraseFromParent(); - } - - // The old global is now dead, remove it. - GV->eraseFromParent(); - - ++NumHeapSRA; - return cast(FieldGlobals[0]); -} - /// PerformHeapAllocSRoA - CI is an allocation of an array of structures. Break /// it up into multiple allocations of arrays of the fields. static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, @@ -1767,95 +1464,6 @@ /// pointer global variable with a single value stored it that is a malloc or /// cast of malloc. static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV, - MallocInst *MI, - Module::global_iterator &GVI, - TargetData *TD, - LLVMContext &Context) { - // If this is a malloc of an abstract type, don't touch it. - if (!MI->getAllocatedType()->isSized()) - return false; - - // We can't optimize this global unless all uses of it are *known* to be - // of the malloc value, not of the null initializer value (consider a use - // that compares the global's value against zero to see if the malloc has - // been reached). To do this, we check to see if all uses of the global - // would trap if the global were null: this proves that they must all - // happen after the malloc. - if (!AllUsesOfLoadedValueWillTrapIfNull(GV)) - return false; - - // We can't optimize this if the malloc itself is used in a complex way, - // for example, being stored into multiple globals. This allows the - // malloc to be stored into the specified global, loaded setcc'd, and - // GEP'd. These are all things we could transform to using the global - // for. - { - SmallPtrSet PHIs; - if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(MI, GV, PHIs)) - return false; - } - - - // If we have a global that is only initialized with a fixed size malloc, - // transform the program to use global memory instead of malloc'd memory. - // This eliminates dynamic allocation, avoids an indirection accessing the - // data, and exposes the resultant global to further GlobalOpt. - if (ConstantInt *NElements = dyn_cast(MI->getArraySize())) { - // Restrict this transformation to only working on small allocations - // (2048 bytes currently), as we don't want to introduce a 16M global or - // something. - if (TD && - NElements->getZExtValue()* - TD->getTypeAllocSize(MI->getAllocatedType()) < 2048) { - GVI = OptimizeGlobalAddressOfMalloc(GV, MI, Context); - return true; - } - } - - // If the allocation is an array of structures, consider transforming this - // into multiple malloc'd arrays, one for each field. This is basically - // SRoA for malloc'd memory. - const Type *AllocTy = MI->getAllocatedType(); - - // If this is an allocation of a fixed size array of structs, analyze as a - // variable size array. malloc [100 x struct],1 -> malloc struct, 100 - if (!MI->isArrayAllocation()) - if (const ArrayType *AT = dyn_cast(AllocTy)) - AllocTy = AT->getElementType(); - - if (const StructType *AllocSTy = dyn_cast(AllocTy)) { - // This the structure has an unreasonable number of fields, leave it - // alone. - if (AllocSTy->getNumElements() <= 16 && AllocSTy->getNumElements() != 0 && - AllGlobalLoadUsesSimpleEnoughForHeapSRA(GV, MI)) { - - // If this is a fixed size array, transform the Malloc to be an alloc of - // structs. malloc [100 x struct],1 -> malloc struct, 100 - if (const ArrayType *AT = dyn_cast(MI->getAllocatedType())) { - MallocInst *NewMI = - new MallocInst(AllocSTy, - ConstantInt::get(Type::getInt32Ty(Context), - AT->getNumElements()), - "", MI); - NewMI->takeName(MI); - Value *Cast = new BitCastInst(NewMI, MI->getType(), "tmp", MI); - MI->replaceAllUsesWith(Cast); - MI->eraseFromParent(); - MI = NewMI; - } - - GVI = PerformHeapAllocSRoA(GV, MI, Context); - return true; - } - } - - return false; -} - -/// TryToOptimizeStoreOfMallocToGlobal - This function is called when we see a -/// pointer global variable with a single value stored it that is a malloc or -/// cast of malloc. -static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV, CallInst *CI, BitCastInst *BCI, Module::global_iterator &GVI, @@ -1970,9 +1578,6 @@ // Optimize away any trapping uses of the loaded value. if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC, Context)) return true; - } else if (MallocInst *MI = dyn_cast(StoredOnceVal)) { - if (TryToOptimizeStoreOfMallocToGlobal(GV, MI, GVI, TD, Context)) - return true; } else if (CallInst *CI = extractMallocCall(StoredOnceVal)) { if (getMallocAllocatedType(CI)) { BitCastInst* BCI = NULL; Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Fri Oct 16 20:18:07 2009 @@ -6300,16 +6300,6 @@ return SelectInst::Create(LHSI->getOperand(0), Op1, Op2); break; } - case Instruction::Malloc: - // If we have (malloc != null), and if the malloc has a single use, we - // can assume it is successful and remove the malloc. - if (LHSI->hasOneUse() && isa(RHSC)) { - Worklist.Add(LHSI); - return ReplaceInstUsesWith(I, - ConstantInt::get(Type::getInt1Ty(*Context), - !I.isTrueWhenEqual())); - } - break; case Instruction::Call: // If we have (malloc != null), and if the malloc has a single use, we // can assume it is successful and remove the malloc. @@ -7809,11 +7799,7 @@ Amt = AllocaBuilder.CreateAdd(Amt, Off, "tmp"); } - AllocationInst *New; - if (isa(AI)) - New = AllocaBuilder.CreateMalloc(CastElTy, Amt); - else - New = AllocaBuilder.CreateAlloca(CastElTy, Amt); + AllocationInst *New = AllocaBuilder.CreateAlloca(CastElTy, Amt); New->setAlignment(AI.getAlignment()); New->takeName(&AI); @@ -11213,15 +11199,8 @@ if (const ConstantInt *C = dyn_cast(AI.getArraySize())) { const Type *NewTy = ArrayType::get(AI.getAllocatedType(), C->getZExtValue()); - AllocationInst *New = 0; - - // Create and insert the replacement instruction... - if (isa(AI)) - New = Builder->CreateMalloc(NewTy, 0, AI.getName()); - else { - assert(isa(AI) && "Unknown type of allocation inst!"); - New = Builder->CreateAlloca(NewTy, 0, AI.getName()); - } + assert(isa(AI) && "Unknown type of allocation inst!"); + AllocationInst *New = Builder->CreateAlloca(NewTy, 0, AI.getName()); New->setAlignment(AI.getAlignment()); // Scan to the end of the allocation instructions, to skip over a block of @@ -11294,12 +11273,6 @@ } } - // Change free(malloc) into nothing, if the malloc has a single use. - if (MallocInst *MI = dyn_cast(Op)) - if (MI->hasOneUse()) { - EraseInstFromFunction(FI); - return EraseInstFromFunction(*MI); - } if (isMalloc(Op)) { if (CallInst* CI = extractMallocCallFromBitCast(Op)) { if (Op->hasOneUse() && CI->hasOneUse()) { Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Fri Oct 16 20:18:07 2009 @@ -122,7 +122,7 @@ if (I->getOpcode() == Instruction::PHI || I->getOpcode() == Instruction::Alloca || I->getOpcode() == Instruction::Load || - I->getOpcode() == Instruction::Malloc || isMalloc(I) || + isMalloc(I) || I->getOpcode() == Instruction::Invoke || (I->getOpcode() == Instruction::Call && !isa(I)) || Modified: llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp Fri Oct 16 20:18:07 2009 @@ -1,4 +1,4 @@ -//===- LowerAllocations.cpp - Reduce malloc & free insts to calls ---------===// +//===- LowerAllocations.cpp - Reduce free insts to calls ------------------===// // // The LLVM Compiler Infrastructure // @@ -29,18 +29,15 @@ STATISTIC(NumLowered, "Number of allocations lowered"); namespace { - /// LowerAllocations - Turn malloc and free instructions into @malloc and - /// @free calls. + /// LowerAllocations - Turn free instructions into @free calls. /// class VISIBILITY_HIDDEN LowerAllocations : public BasicBlockPass { Constant *FreeFunc; // Functions in the module we are processing // Initialized by doInitialization - bool LowerMallocArgToInteger; public: static char ID; // Pass ID, replacement for typeid - explicit LowerAllocations(bool LowerToInt = false) - : BasicBlockPass(&ID), FreeFunc(0), - LowerMallocArgToInteger(LowerToInt) {} + explicit LowerAllocations() + : BasicBlockPass(&ID), FreeFunc(0) {} virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); @@ -54,7 +51,7 @@ } /// doPassInitialization - For the lower allocations pass, this ensures that - /// a module contains a declaration for a malloc and a free function. + /// a module contains a declaration for a free function. /// bool doInitialization(Module &M); @@ -76,13 +73,13 @@ // Publically exposed interface to pass... const PassInfo *const llvm::LowerAllocationsID = &X; // createLowerAllocationsPass - Interface to this file... -Pass *llvm::createLowerAllocationsPass(bool LowerMallocArgToInteger) { - return new LowerAllocations(LowerMallocArgToInteger); +Pass *llvm::createLowerAllocationsPass() { + return new LowerAllocations(); } // doInitialization - For the lower allocations pass, this ensures that a -// module contains a declaration for a malloc and a free function. +// module contains a declaration for a free function. // // This function is always successful. // @@ -102,25 +99,9 @@ BasicBlock::InstListType &BBIL = BB.getInstList(); - const TargetData &TD = getAnalysis(); - const Type *IntPtrTy = TD.getIntPtrType(BB.getContext()); - - // Loop over all of the instructions, looking for malloc or free instructions + // Loop over all of the instructions, looking for free instructions for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) { - if (MallocInst *MI = dyn_cast(I)) { - Value *ArraySize = MI->getOperand(0); - if (ArraySize->getType() != IntPtrTy) - ArraySize = CastInst::CreateIntegerCast(ArraySize, IntPtrTy, - false /*ZExt*/, "", I); - Value *MCast = CallInst::CreateMalloc(I, IntPtrTy, - MI->getAllocatedType(), ArraySize); - - // Replace all uses of the old malloc inst with the cast inst - MI->replaceAllUsesWith(MCast); - I = --BBIL.erase(I); // remove and delete the malloc instr... - Changed = true; - ++NumLowered; - } else if (FreeInst *FI = dyn_cast(I)) { + if (FreeInst *FI = dyn_cast(I)) { Value *PtrCast = new BitCastInst(FI->getOperand(0), Type::getInt8PtrTy(BB.getContext()), "", I); Modified: llvm/trunk/lib/VMCore/Instruction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instruction.cpp (original) +++ llvm/trunk/lib/VMCore/Instruction.cpp Fri Oct 16 20:18:07 2009 @@ -127,7 +127,6 @@ case Xor: return "xor"; // Memory instructions... - case Malloc: return "malloc"; case Free: return "free"; case Alloca: return "alloca"; case Load: return "load"; @@ -442,7 +441,6 @@ // overflow-checking arithmetic, etc.) case VAArg: case Alloca: - case Malloc: case Invoke: case PHI: case Store: Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=84299&r1=84298&r2=84299&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Fri Oct 16 20:18:07 2009 @@ -847,7 +847,7 @@ assert(!isa(Amt) && "Passed basic block into allocation size parameter! Use other ctor"); assert(Amt->getType() == Type::getInt32Ty(Context) && - "Malloc/Allocation array size is not a 32-bit integer!"); + "Allocation array size is not a 32-bit integer!"); } return Amt; } @@ -3083,18 +3083,6 @@ return New; } -MallocInst *MallocInst::clone() const { - MallocInst *New = new MallocInst(getAllocatedType(), - (Value*)getOperand(0), - getAlignment()); - New->SubclassOptionalData = SubclassOptionalData; - if (hasMetadata()) { - LLVMContext &Context = getContext(); - Context.pImpl->TheMetadata.ValueIsCloned(this, New); - } - return New; -} - AllocaInst *AllocaInst::clone() const { AllocaInst *New = new AllocaInst(getAllocatedType(), (Value*)getOperand(0), From gohman at apple.com Fri Oct 16 20:37:40 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 17 Oct 2009 01:37:40 -0000 Subject: [llvm-commits] [llvm] r84300 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200910170137.n9H1bfpv001434@zion.cs.uiuc.edu> Author: djg Date: Fri Oct 16 20:37:38 2009 New Revision: 84300 URL: http://llvm.org/viewvc/llvm-project?rev=84300&view=rev Log: Delete an obsolete comment. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=84300&r1=84299&r2=84300&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Oct 16 20:37:38 2009 @@ -1655,8 +1655,7 @@ } /// LegalizeSetCCCondCode - Legalize a SETCC with given LHS and RHS and -/// condition code CC on the current target. This routine assumes LHS and rHS -/// have already been legalized by LegalizeSetCCOperands. It expands SETCC with +/// condition code CC on the current target. This routine expands SETCC with /// illegal condition code into AND / OR of multiple SETCC values. void SelectionDAGLegalize::LegalizeSetCCCondCode(EVT VT, SDValue &LHS, SDValue &RHS, From daniel at zuster.org Fri Oct 16 22:28:09 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 03:28:09 -0000 Subject: [llvm-commits] [llvm] r84302 - in /llvm/trunk/include/llvm: Analysis/CallGraph.h PassSupport.h Message-ID: <200910170328.n9H3S9OQ004789@zion.cs.uiuc.edu> Author: ddunbar Date: Fri Oct 16 22:28:07 2009 New Revision: 84302 URL: http://llvm.org/viewvc/llvm-project?rev=84302&view=rev Log: Add required #includes for freestanding .h files. Modified: llvm/trunk/include/llvm/Analysis/CallGraph.h llvm/trunk/include/llvm/PassSupport.h Modified: llvm/trunk/include/llvm/Analysis/CallGraph.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CallGraph.h?rev=84302&r1=84301&r2=84302&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/CallGraph.h (original) +++ llvm/trunk/include/llvm/Analysis/CallGraph.h Fri Oct 16 22:28:07 2009 @@ -51,9 +51,10 @@ #ifndef LLVM_ANALYSIS_CALLGRAPH_H #define LLVM_ANALYSIS_CALLGRAPH_H +#include "llvm/Function.h" +#include "llvm/Pass.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/Pass.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/ValueHandle.h" #include "llvm/System/IncludeFile.h" Modified: llvm/trunk/include/llvm/PassSupport.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassSupport.h?rev=84302&r1=84301&r2=84302&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassSupport.h (original) +++ llvm/trunk/include/llvm/PassSupport.h Fri Oct 16 22:28:07 2009 @@ -21,7 +21,7 @@ #ifndef LLVM_PASS_SUPPORT_H #define LLVM_PASS_SUPPORT_H -// No need to include Pass.h, we are being included by it! +#include "Pass.h" namespace llvm { From daniel at zuster.org Fri Oct 16 22:28:20 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 03:28:20 -0000 Subject: [llvm-commits] [llvm] r84303 - in /llvm/trunk/test/DebugInfo: 2009-10-16-Phi.ll 2009-10-16-Scope.ll 2009-11-16-Phi.ll 2009-11-16-Scope.ll Message-ID: <200910170328.n9H3SKpg004807@zion.cs.uiuc.edu> Author: ddunbar Date: Fri Oct 16 22:28:20 2009 New Revision: 84303 URL: http://llvm.org/viewvc/llvm-project?rev=84303&view=rev Log: Reclaim a lost month. Added: llvm/trunk/test/DebugInfo/2009-10-16-Phi.ll - copied, changed from r84302, llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll - copied, changed from r84302, llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll Removed: llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll Copied: llvm/trunk/test/DebugInfo/2009-10-16-Phi.ll (from r84302, llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-10-16-Phi.ll?p2=llvm/trunk/test/DebugInfo/2009-10-16-Phi.ll&p1=llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll&r1=84302&r2=84303&rev=84303&view=diff ============================================================================== (empty) Copied: llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll (from r84302, llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll?p2=llvm/trunk/test/DebugInfo/2009-10-16-Scope.ll&p1=llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll&r1=84302&r2=84303&rev=84303&view=diff ============================================================================== (empty) Removed: llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll?rev=84302&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll (original) +++ llvm/trunk/test/DebugInfo/2009-11-16-Phi.ll (removed) @@ -1,13 +0,0 @@ -; RUN: llvm-as %s -disable-output - -define i32 @foo() { -E: - br label %B2 -B1: - br label %B2 -B2: - %0 = phi i32 [ 0, %E ], [ 1, %B1 ], !dbg !0 - ret i32 %0 -} - -!0 = metadata !{i32 42} \ No newline at end of file Removed: llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll?rev=84302&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll (original) +++ llvm/trunk/test/DebugInfo/2009-11-16-Scope.ll (removed) @@ -1,33 +0,0 @@ -; RUN: llc %s -O0 -o /dev/null -; PR 5197 -; There is not any llvm instruction assocated with !5. The code generator -; should be able to handle this. - -define void @bar() nounwind ssp { -entry: - %count_ = alloca i32, align 4 ; [#uses=2] - br label %do.body, !dbg !0 - -do.body: ; preds = %entry - %0 = bitcast i32* %count_ to { }* ; <{ }*> [#uses=1] - call void @llvm.dbg.declare({ }* %0, metadata !4) - %conv = ptrtoint i32* %count_ to i32, !dbg !0 ; [#uses=1] - %call = call i32 @foo(i32 %conv) ssp, !dbg !0 ; [#uses=0] - br label %do.end, !dbg !0 - -do.end: ; preds = %do.body - ret void, !dbg !7 -} - -declare void @llvm.dbg.declare({ }*, metadata) nounwind readnone - -declare i32 @foo(i32) ssp - -!0 = metadata !{i32 5, i32 2, metadata !1, null} -!1 = metadata !{i32 458763, metadata !2}; [DW_TAG_lexical_block ] -!2 = metadata !{i32 458798, i32 0, metadata !3, metadata !"bar", metadata !"bar", metadata !"bar", metadata !3, i32 4, null, i1 false, i1 true}; [DW_TAG_subprogram ] -!3 = metadata !{i32 458769, i32 0, i32 12, metadata !"genmodes.i", metadata !"/Users/yash/Downloads", metadata !"clang 1.1", i1 true, i1 false, metadata !"", i32 0}; [DW_TAG_compile_unit ] -!4 = metadata !{i32 459008, metadata !5, metadata !"count_", metadata !3, i32 5, metadata !6}; [ DW_TAG_auto_variable ] -!5 = metadata !{i32 458763, metadata !1}; [DW_TAG_lexical_block ] -!6 = metadata !{i32 458788, metadata !3, metadata !"int", metadata !3, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5}; [DW_TAG_base_type ] -!7 = metadata !{i32 6, i32 1, metadata !2, null} From daniel at zuster.org Fri Oct 16 22:28:29 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 03:28:29 -0000 Subject: [llvm-commits] [llvm] r84304 - /llvm/trunk/tools/llvm-as/llvm-as.cpp Message-ID: <200910170328.n9H3STYA004824@zion.cs.uiuc.edu> Author: ddunbar Date: Fri Oct 16 22:28:28 2009 New Revision: 84304 URL: http://llvm.org/viewvc/llvm-project?rev=84304&view=rev Log: llvm-as: Simplify, and don't create empty output files with -disable-output. Modified: llvm/trunk/tools/llvm-as/llvm-as.cpp Modified: llvm/trunk/tools/llvm-as/llvm-as.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-as/llvm-as.cpp?rev=84304&r1=84303&r2=84304&view=diff ============================================================================== --- llvm/trunk/tools/llvm-as/llvm-as.cpp (original) +++ llvm/trunk/tools/llvm-as/llvm-as.cpp Fri Oct 16 22:28:28 2009 @@ -50,34 +50,7 @@ DisableVerify("disable-verify", cl::Hidden, cl::desc("Do not run verifier on input LLVM (dangerous!)")); -int main(int argc, char **argv) { - // Print a stack trace if we signal out. - sys::PrintStackTraceOnErrorSignal(); - PrettyStackTraceProgram X(argc, argv); - LLVMContext &Context = getGlobalContext(); - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. - cl::ParseCommandLineOptions(argc, argv, "llvm .ll -> .bc assembler\n"); - - // Parse the file now... - SMDiagnostic Err; - std::auto_ptr M(ParseAssemblyFile(InputFilename, Err, Context)); - if (M.get() == 0) { - Err.Print(argv[0], errs()); - return 1; - } - - if (!DisableVerify) { - std::string Err; - if (verifyModule(*M.get(), ReturnStatusAction, &Err)) { - errs() << argv[0] - << ": assembly parsed, but does not verify as correct!\n"; - errs() << Err; - return 1; - } - } - - if (DumpAsm) errs() << "Here's the assembly:\n" << *M.get(); - +static void WriteOutputFile(const Module *M) { // Infer the output filename if needed. if (OutputFilename.empty()) { if (InputFilename == "-") { @@ -106,12 +79,43 @@ raw_fd_ostream::F_Binary)); if (!ErrorInfo.empty()) { errs() << ErrorInfo << '\n'; + exit(1); + } + + if (Force || !CheckBitcodeOutputToConsole(*Out, true)) + WriteBitcodeToFile(M, *Out); +} + +int main(int argc, char **argv) { + // Print a stack trace if we signal out. + sys::PrintStackTraceOnErrorSignal(); + PrettyStackTraceProgram X(argc, argv); + LLVMContext &Context = getGlobalContext(); + llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. + cl::ParseCommandLineOptions(argc, argv, "llvm .ll -> .bc assembler\n"); + + // Parse the file now... + SMDiagnostic Err; + std::auto_ptr M(ParseAssemblyFile(InputFilename, Err, Context)); + if (M.get() == 0) { + Err.Print(argv[0], errs()); return 1; } + if (!DisableVerify) { + std::string Err; + if (verifyModule(*M.get(), ReturnStatusAction, &Err)) { + errs() << argv[0] + << ": assembly parsed, but does not verify as correct!\n"; + errs() << Err; + return 1; + } + } + + if (DumpAsm) errs() << "Here's the assembly:\n" << *M.get(); + if (!DisableOutput) - if (Force || !CheckBitcodeOutputToConsole(*Out, true)) - WriteBitcodeToFile(M.get(), *Out); + WriteOutputFile(M.get()); + return 0; } - From vhernandez at apple.com Fri Oct 16 23:36:34 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 16 Oct 2009 21:36:34 -0700 Subject: [llvm-commits] [llvm] r84199 - in /llvm/trunk: include/llvm/Analysis/MallocHelper.h lib/Analysis/MallocHelper.cpp lib/Analysis/PointerTracking.cpp lib/Transforms/IPO/GlobalOpt.cpp In-Reply-To: <4AD81ABC.8090905@free.fr> References: <200910152014.n9FKErMI022629@zion.cs.uiuc.edu> <4AD81ABC.8090905@free.fr> Message-ID: <54E42CDA-5CB8-4325-A1DB-6CF0C7FDAD07@apple.com> On Oct 16, 2009, at 12:03 AM, Duncan Sands wrote: > Hi Victor, there doesn't seem to be a testcase. > >> The fix is to classify malloc's into 3 categories: >> 1. non-array mallocs >> 2. array mallocs whose array size can be determined >> 3. mallocs that cannot be determined to be of type 1 or 2 and >> cannot be optimized > > Do you plan to do anything in the case when a variable amount is > being allocated, and it can be proved that the amount is a multiple > of the size of the allocated type? Yes, I'd like to handle that case. I'd also like to handle the case where the malloc argument is produced by shifts and/or adds. > >> -/// getMallocArraySize - Returns the array size of a malloc call. >> The array >> -/// size is computated in 1 of 3 ways: >> -/// 1. If the element type if of size 1, then array size is the >> argument to +/// getMallocArraySize - Returns the array size of a >> malloc call. For array >> +/// mallocs, the size is computated in 1 of 3 ways: > > computated -> computed Will fix that. > >> +/// 1. If the element type is of size 1, then array size is the >> argument to /// malloc. >> /// 2. Else if the malloc's argument is a constant, the array size >> is that >> /// argument divided by the element type's size. > > What if the constant is not a multiple of the size of the malloc'd > type? I had not special-cased that case, but I think the current code properly does not treat that as an optimizeable array malloc. It might miss some examples, but that seems like a reasonable edge case to ignore. Or is there a common situation where such mallocs can occur? > >> /// 3. Else the malloc argument must be a multiplication and the >> array size is >> /// the first operand of the multiplication. > > So you are not caring about the multiplication overflowing and giving > something funny? I am not checking for that. Need to think how to do that. > >> -/// This function returns constant 1 if: >> -/// 1. The malloc call's allocated type cannot be determined. >> -/// 2. IR wasn't created by a call to CallInst::CreateMalloc() >> with a non-NULL >> -/// ArraySize. >> +/// For non-array mallocs, the computed size is constant 1. +/// >> This function returns NULL for all mallocs whose array size cannot be >> +/// determined. > > Just a general comment about writing comments: I don't think the > comment > should be explaining the algorithm getMallocArraySize uses, it > should be > explaining the semantics of getMallocArraySize. Can't you just say > that > if the amount malloc'd is a multiple of the size of the malloced type > then it returns that multiple, otherwise it returns NULL? Good point. Will simplify the comment. > >> +/// isSafeToGetMallocArraySize - Returns true if the array size of >> a malloc can >> +/// be determined. It can be determined in these 3 cases of >> malloc codegen: >> +/// 1. non-array malloc: The malloc's size argument is a constant >> and equals the /// size of the type being malloced. > > The above line should be two lines. Thanks. > >> +/// 2. array malloc: This is a malloc call with one bitcast use >> AND the malloc >> +/// call's size argument is a constant multiple of the size of >> the malloced >> +/// type. > > Rather than talking about one bitcast use, why don't you say: we were > able to determine the type being malloced. OK. > >> +/// 3. array malloc: This is a malloc call with one bitcast use >> AND the malloc >> +/// call's size argument is the result of a multiplication by >> the size of the >> +/// malloced type. >> +/// Otherwise returns false. > > As I mentioned above, I don't think you should describe the > algorithm a > function uses in the comment describing it. Why not only say: > Returns true if the array size of a malloc can be determined. OK. > > Also, why have this logic in its own function? It is only used in > getMallocArraySize, and there is the danger that the two functions > get out of sync. Good point, I thought it read easier factored out this way, but I can change it to ensure it being in sync. > > Ciao, > > Duncan. Thanks for the review. Victor From sabre at nondot.org Fri Oct 16 23:47:44 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 17 Oct 2009 04:47:44 -0000 Subject: [llvm-commits] [llvm] r84309 - /llvm/trunk/docs/CommandGuide/FileCheck.pod Message-ID: <200910170447.n9H4ljp9007247@zion.cs.uiuc.edu> Author: lattner Date: Fri Oct 16 23:47:42 2009 New Revision: 84309 URL: http://llvm.org/viewvc/llvm-project?rev=84309&view=rev Log: check in a bunch of content from TestingGuide. Part of PR5216 Modified: llvm/trunk/docs/CommandGuide/FileCheck.pod Modified: llvm/trunk/docs/CommandGuide/FileCheck.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/FileCheck.pod?rev=84309&r1=84308&r2=84309&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/FileCheck.pod (original) +++ llvm/trunk/docs/CommandGuide/FileCheck.pod Fri Oct 16 23:47:42 2009 @@ -21,9 +21,6 @@ The I file specifies the file that contains the patterns to match. The file to verify is always read from standard input. -The input and output of B is beyond the scope of this short -introduction. Please see the I page in the LLVM documentation. - =head1 OPTIONS =over @@ -58,6 +55,189 @@ with 0. Otherwise, if not, or if an error occurs, it will exit with a non-zero value. +=head1 TUTORIAL + +FileCheck is typically used from LLVM regression tests, being invoked on the RUN +line of the test. A simple example of using FileCheck from a RUN line looks +like this: + + ; RUN: llvm-as < %s | llc -march=x86-64 | FileCheck %s + +This syntax says to pipe the current file ("%s") into llvm-as, pipe that into +llc, then pipe the output of llc into FileCheck. This means that FileCheck will +be verifying its standard input (the llc output) against the filename argument +specified (the original .ll file specified by "%s"). To see how this works, +lets look at the rest of the .ll file (after the RUN line): + + define void @sub1(i32* %p, i32 %v) { + entry: + ; CHECK: sub1: + ; CHECK: subl + %0 = tail call i32 @llvm.atomic.load.sub.i32.p0i32(i32* %p, i32 %v) + ret void + } + + define void @inc4(i64* %p) { + entry: + ; CHECK: inc4: + ; CHECK: incq + %0 = tail call i64 @llvm.atomic.load.add.i64.p0i64(i64* %p, i64 1) + ret void + } + +Here you can see some "CHECK:" lines specified in comments. Now you can see +how the file is piped into llvm-as, then llc, and the machine code output is +what we are verifying. FileCheck checks the machine code output to verify that +it matches what the "CHECK:" lines specify. + +The syntax of the CHECK: lines is very simple: they are fixed strings that +must occur in order. FileCheck defaults to ignoring horizontal whitespace +differences (e.g. a space is allowed to match a tab) but otherwise, the contents +of the CHECK: line is required to match some thing in the test file exactly. + +One nice thing about FileCheck (compared to grep) is that it allows merging +test cases together into logical groups. For example, because the test above +is checking for the "sub1:" and "inc4:" labels, it will not match unless there +is a "subl" in between those labels. If it existed somewhere else in the file, +that would not count: "grep subl" matches if subl exists anywhere in the +file. + + + +=head2 The FileCheck -check-prefix option + +The FileCheck -check-prefix option allows multiple test configurations to be +driven from one .ll file. This is useful in many circumstances, for example, +testing different architectural variants with llc. Here's a simple example: + + ; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin9 -mattr=sse41 \ + ; RUN: | FileCheck %s -check-prefix=X32 + ; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin9 -mattr=sse41 \ + ; RUN: | FileCheck %s -check-prefix=X64 + + define <4 x i32> @pinsrd_1(i32 %s, <4 x i32> %tmp) nounwind { + %tmp1 = insertelement <4 x i32>; %tmp, i32 %s, i32 1 + ret <4 x i32> %tmp1 + ; X32: pinsrd_1: + ; X32: pinsrd $1, 4(%esp), %xmm0 + + ; X64: pinsrd_1: + ; X64: pinsrd $1, %edi, %xmm0 + } + +In this case, we're testing that we get the expected code generation with +both 32-bit and 64-bit code generation. + + + +=head2 The "CHECK-NEXT:" directive + +Sometimes you want to match lines and would like to verify that matches +happen on exactly consequtive lines with no other lines in between them. In +this case, you can use CHECK: and CHECK-NEXT: directives to specify this. If +you specified a custom check prefix, just use "-NEXT:". For +example, something like this works as you'd expect: + + define void @t2(<2 x double>* %r, <2 x double>* %A, double %B) { + %tmp3 = load <2 x double>* %A, align 16 + %tmp7 = insertelement <2 x double> undef, double %B, i32 0 + %tmp9 = shufflevector <2 x double> %tmp3, + <2 x double> %tmp7, + <2 x i32> < i32 0, i32 2 > + store <2 x double> %tmp9, <2 x double>* %r, align 16 + ret void + + ; CHECK: t2: + ; CHECK: movl 8(%esp), %eax + ; CHECK-NEXT: movapd (%eax), %xmm0 + ; CHECK-NEXT: movhpd 12(%esp), %xmm0 + ; CHECK-NEXT: movl 4(%esp), %eax + ; CHECK-NEXT: movapd %xmm0, (%eax) + ; CHECK-NEXT: ret + } + +CHECK-NEXT: directives reject the input unless there is exactly one newline +between it an the previous directive. A CHECK-NEXT cannot be the first +directive in a file. + + + +=head2 The "CHECK-NOT:" directive + +The CHECK-NOT: directive is used to verify that a string doesn't occur +between two matches (or the first match and the beginning of the file). For +example, to verify that a load is removed by a transformation, a test like this +can be used: + + define i8 @coerce_offset0(i32 %V, i32* %P) { + store i32 %V, i32* %P + + %P2 = bitcast i32* %P to i8* + %P3 = getelementptr i8* %P2, i32 2 + + %A = load i8* %P3 + ret i8 %A + ; CHECK: @coerce_offset0 + ; CHECK-NOT: load + ; CHECK: ret i8 + } + + + +=head2 FileCheck Pattern Matching Syntax + +The CHECK: and CHECK-NOT: directives both take a pattern to match. For most +uses of FileCheck, fixed string matching is perfectly sufficient. For some +things, a more flexible form of matching is desired. To support this, FileCheck +allows you to specify regular expressions in matching strings, surrounded by +double braces: B<{{yourregex}}>. Because we want to use fixed string +matching for a majority of what we do, FileCheck has been designed to support +mixing and matching fixed string matching with regular expressions. This allows +you to write things like this: + + ; CHECK: movhpd {{[0-9]+}}(%esp), {{%xmm[0-7]}} + +In this case, any offset from the ESP register will be allowed, and any xmm +register will be allowed. + +Because regular expressions are enclosed with double braces, they are +visually distinct, and you don't need to use escape characters within the double +braces like you would in C. In the rare case that you want to match double +braces explicitly from the input, you can use something ugly like +B<{{[{][{]}}> as your pattern. + + + +=head2 FileCheck Variables + +It is often useful to match a pattern and then verify that it occurs again +later in the file. For codegen tests, this can be useful to allow any register, +but verify that that register is used consistently later. To do this, FileCheck +allows named variables to be defined and substituted into patterns. Here is a +simple example: + + ; CHECK: test5: + ; CHECK: notw [[REGISTER:%[a-z]+]] + ; CHECK: andw {{.*}}[[REGISTER]] + +The first check line matches a regex (%[a-z]+) and captures it into +the variables "REGISTER". The second line verifies that whatever is in REGISTER +occurs later in the file after an "andw". FileCheck variable references are +always contained in [[ ]] pairs, are named, and their names can be +formed with the regex "[a-zA-Z][a-zA-Z0-9]*". If a colon follows the +name, then it is a definition of the variable, if not, it is a use. + +FileCheck variables can be defined multiple times, and uses always get the +latest value. Note that variables are all read at the start of a "CHECK" line +and are all defined at the end. This means that if you have something like +"CHECK: [[XYZ:.*]]x[[XYZ]]" that the check line will read the previous +value of the XYZ variable and define a new one after the match is performed. If +you need to do something like this you can probably take advantage of the fact +that FileCheck is not actually line-oriented when it matches, this allows you to +define two separate CHECK lines that match on the same line. + + + =head1 AUTHORS Maintained by The LLVM Team (L). From sabre at nondot.org Sat Oct 17 00:39:39 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 17 Oct 2009 05:39:39 -0000 Subject: [llvm-commits] [llvm] r84310 - in /llvm/trunk: lib/Transforms/Utils/InlineFunction.cpp test/Transforms/Inline/crash.ll Message-ID: <200910170539.n9H5ddPA008966@zion.cs.uiuc.edu> Author: lattner Date: Sat Oct 17 00:39:39 2009 New Revision: 84310 URL: http://llvm.org/viewvc/llvm-project?rev=84310&view=rev Log: Simplify some code (first hunk) and fix PR5208 (second hunk) by updating the callgraph when introducing a call. Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp llvm/trunk/test/Transforms/Inline/crash.ll Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=84310&r1=84309&r2=84310&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Sat Oct 17 00:39:39 2009 @@ -444,18 +444,15 @@ if (InlinedFunctionInfo.ContainsDynamicAllocas) { Module *M = Caller->getParent(); // Get the two intrinsics we care about. - Constant *StackSave, *StackRestore; - StackSave = Intrinsic::getDeclaration(M, Intrinsic::stacksave); - StackRestore = Intrinsic::getDeclaration(M, Intrinsic::stackrestore); + Function *StackSave = Intrinsic::getDeclaration(M, Intrinsic::stacksave); + Function *StackRestore=Intrinsic::getDeclaration(M,Intrinsic::stackrestore); // If we are preserving the callgraph, add edges to the stacksave/restore // functions for the calls we insert. CallGraphNode *StackSaveCGN = 0, *StackRestoreCGN = 0, *CallerNode = 0; if (CG) { - // We know that StackSave/StackRestore are Function*'s, because they are - // intrinsics which must have the right types. - StackSaveCGN = CG->getOrInsertFunction(cast(StackSave)); - StackRestoreCGN = CG->getOrInsertFunction(cast(StackRestore)); + StackSaveCGN = CG->getOrInsertFunction(StackSave); + StackRestoreCGN = CG->getOrInsertFunction(StackRestore); CallerNode = (*CG)[Caller]; } @@ -480,7 +477,8 @@ for (Function::iterator BB = FirstNewBlock, E = Caller->end(); BB != E; ++BB) if (UnwindInst *UI = dyn_cast(BB->getTerminator())) { - CallInst::Create(StackRestore, SavedPtr, "", UI); + CallInst *CI = CallInst::Create(StackRestore, SavedPtr, "", UI); + if (CG) CallerNode->addCalledFunction(CI, StackRestoreCGN); ++NumStackRestores; } } Modified: llvm/trunk/test/Transforms/Inline/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/crash.ll?rev=84310&r1=84309&r2=84310&view=diff ============================================================================== --- llvm/trunk/test/Transforms/Inline/crash.ll (original) +++ llvm/trunk/test/Transforms/Inline/crash.ll Sat Oct 17 00:39:39 2009 @@ -51,7 +51,38 @@ unreachable } +declare fastcc void @list_Rplacd1284() nounwind ssp -declare fastcc void @list_Rplacd1284() nounwind ssp + +;============================ +; PR5208 + +define void @AAA() { +entry: + %A = alloca i8, i32 undef, align 1 + invoke fastcc void @XXX() + to label %invcont98 unwind label %lpad156 + +invcont98: + unreachable + +lpad156: + unreachable +} + +declare fastcc void @YYY() + +define internal fastcc void @XXX() { +entry: + %B = alloca i8, i32 undef, align 1 + invoke fastcc void @YYY() + to label %bb260 unwind label %lpad + +bb260: + ret void + +lpad: + unwind +} From evan.cheng at apple.com Sat Oct 17 01:05:13 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 17 Oct 2009 06:05:13 -0000 Subject: [llvm-commits] [llvm] r84311 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Message-ID: <200910170605.n9H65D7v009812@zion.cs.uiuc.edu> Author: evancheng Date: Sat Oct 17 01:05:11 2009 New Revision: 84311 URL: http://llvm.org/viewvc/llvm-project?rev=84311&view=rev Log: 80 col violation. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp?rev=84311&r1=84310&r2=84311&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Sat Oct 17 01:05:11 2009 @@ -115,7 +115,8 @@ // Create the stack frame object. Make sure it is aligned for both // the source and expanded destination types. unsigned Alignment = - TLI.getTargetData()->getPrefTypeAlignment(NOutVT.getTypeForEVT(*DAG.getContext())); + TLI.getTargetData()->getPrefTypeAlignment(NOutVT. + getTypeForEVT(*DAG.getContext())); SDValue StackPtr = DAG.CreateStackTemporary(InVT, Alignment); int SPFI = cast(StackPtr.getNode())->getIndex(); const Value *SV = PseudoSourceValue::getFixedStack(SPFI); From evan.cheng at apple.com Sat Oct 17 01:22:26 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 17 Oct 2009 06:22:26 -0000 Subject: [llvm-commits] [llvm] r84315 - in /llvm/trunk: include/llvm/CodeGen/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/MSP430/ lib/Target/PowerPC/ lib/Target/SystemZ/ lib/Target/X86/ Message-ID: <200910170622.n9H6MRhv010440@zion.cs.uiuc.edu> Author: evancheng Date: Sat Oct 17 01:22:26 2009 New Revision: 84315 URL: http://llvm.org/viewvc/llvm-project?rev=84315&view=rev Log: Rename getFixedStack to getStackObject. The stack objects represented are not necessarily fixed. Only those will negative frame indices are "fixed." Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/CodeGen/StackSlotColoring.cpp llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp llvm/trunk/lib/Target/SystemZ/SystemZInstrBuilder.h llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86InstrBuilder.h Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h (original) +++ llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h Sat Oct 17 01:22:26 2009 @@ -47,9 +47,9 @@ return V->getValueID() == PseudoSourceValueVal; } - /// A pseudo source value referencing a fixed stack frame entry, - /// e.g., a spill slot. - static const PseudoSourceValue *getFixedStack(int FI); + /// A pseudo source value referencing a stack frame entry, + /// e.g., a spill slot or an incoming argument on stack. + static const PseudoSourceValue *getStackObject(int FI); /// A pseudo source value referencing the area below the stack frame of /// a function, e.g., the argument space. Modified: llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp (original) +++ llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp Sat Oct 17 01:22:26 2009 @@ -52,29 +52,31 @@ } namespace { - /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue - /// for holding FixedStack values, which must include a frame + /// StackObjectPseudoSourceValue - A specialized PseudoSourceValue + /// for holding StackObject values, which must include a frame /// index. - class VISIBILITY_HIDDEN FixedStackPseudoSourceValue + class VISIBILITY_HIDDEN StackObjectPseudoSourceValue : public PseudoSourceValue { const int FI; public: - explicit FixedStackPseudoSourceValue(int fi) : FI(fi) {} + explicit StackObjectPseudoSourceValue(int fi) : FI(fi) {} virtual bool isConstant(const MachineFrameInfo *MFI) const; virtual void printCustom(raw_ostream &OS) const { - OS << "FixedStack" << FI; + if (FI < 0) + OS << "Fixed"; + OS << "StackObject" << FI; } }; } static ManagedStatic > FSValues; -const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) { +const PseudoSourceValue *PseudoSourceValue::getStackObject(int FI) { const PseudoSourceValue *&V = (*FSValues)[FI]; if (!V) - V = new FixedStackPseudoSourceValue(FI); + V = new StackObjectPseudoSourceValue(FI); return V; } @@ -89,6 +91,7 @@ return false; } -bool FixedStackPseudoSourceValue::isConstant(const MachineFrameInfo *MFI) const{ +bool +StackObjectPseudoSourceValue::isConstant(const MachineFrameInfo *MFI) const { return MFI && MFI->isImmutableObjectIndex(FI); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sat Oct 17 01:22:26 2009 @@ -643,7 +643,7 @@ // Store the vector. SDValue Ch = DAG.getStore(DAG.getEntryNode(), dl, Tmp1, StackPtr, - PseudoSourceValue::getFixedStack(SPFI), 0); + PseudoSourceValue::getStackObject(SPFI), 0); // Truncate or zero extend offset to target pointer type. unsigned CastOpc = IdxVT.bitsGT(PtrVT) ? ISD::TRUNCATE : ISD::ZERO_EXTEND; @@ -654,10 +654,10 @@ SDValue StackPtr2 = DAG.getNode(ISD::ADD, dl, IdxVT, Tmp3, StackPtr); // Store the scalar value. Ch = DAG.getTruncStore(Ch, dl, Tmp2, StackPtr2, - PseudoSourceValue::getFixedStack(SPFI), 0, EltVT); + PseudoSourceValue::getStackObject(SPFI), 0, EltVT); // Load the updated vector. return DAG.getLoad(VT, dl, Ch, StackPtr, - PseudoSourceValue::getFixedStack(SPFI), 0); + PseudoSourceValue::getStackObject(SPFI), 0); } @@ -1518,7 +1518,7 @@ DebugLoc dl = Node->getDebugLoc(); SDValue FIPtr = DAG.CreateStackTemporary(VT); int FI = cast(FIPtr.getNode())->getIndex(); - const Value *SV = PseudoSourceValue::getFixedStack(FI); + const Value *SV = PseudoSourceValue::getStackObject(FI); // Emit a store of each element to the stack slot. SmallVector Stores; @@ -1714,7 +1714,7 @@ FrameIndexSDNode *StackPtrFI = cast(FIPtr); int SPFI = StackPtrFI->getIndex(); - const Value *SV = PseudoSourceValue::getFixedStack(SPFI); + const Value *SV = PseudoSourceValue::getStackObject(SPFI); unsigned SrcSize = SrcOp.getValueType().getSizeInBits(); unsigned SlotSize = SlotVT.getSizeInBits(); @@ -1755,10 +1755,10 @@ SDValue Ch = DAG.getTruncStore(DAG.getEntryNode(), dl, Node->getOperand(0), StackPtr, - PseudoSourceValue::getFixedStack(SPFI), 0, + PseudoSourceValue::getStackObject(SPFI), 0, Node->getValueType(0).getVectorElementType()); return DAG.getLoad(Node->getValueType(0), dl, Ch, StackPtr, - PseudoSourceValue::getFixedStack(SPFI), 0); + PseudoSourceValue::getStackObject(SPFI), 0); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Sat Oct 17 01:22:26 2009 @@ -119,7 +119,7 @@ getTypeForEVT(*DAG.getContext())); SDValue StackPtr = DAG.CreateStackTemporary(InVT, Alignment); int SPFI = cast(StackPtr.getNode())->getIndex(); - const Value *SV = PseudoSourceValue::getFixedStack(SPFI); + const Value *SV = PseudoSourceValue::getStackObject(SPFI); // Emit a store to the stack slot. SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, InOp, StackPtr, SV, 0); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Sat Oct 17 01:22:26 2009 @@ -1058,7 +1058,7 @@ DebugLoc dl = N->getDebugLoc(); SDValue StackPtr = DAG.CreateStackTemporary(VecVT); int SPFI = cast(StackPtr.getNode())->getIndex(); - const Value *SV = PseudoSourceValue::getFixedStack(SPFI); + const Value *SV = PseudoSourceValue::getStackObject(SPFI); SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, SV, 0); // Load back the required element. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sat Oct 17 01:22:26 2009 @@ -3514,7 +3514,7 @@ if (!PtrVal) if (const FrameIndexSDNode *FI = dyn_cast(Ptr.getNode())) - PtrVal = PseudoSourceValue::getFixedStack(FI->getIndex()); + PtrVal = PseudoSourceValue::getStackObject(FI->getIndex()); MachineFunction &MF = getMachineFunction(); unsigned Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOStore; @@ -3567,7 +3567,7 @@ if (!PtrVal) if (const FrameIndexSDNode *FI = dyn_cast(Ptr.getNode())) - PtrVal = PseudoSourceValue::getFixedStack(FI->getIndex()); + PtrVal = PseudoSourceValue::getStackObject(FI->getIndex()); MachineFunction &MF = getMachineFunction(); unsigned Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOStore; @@ -3714,7 +3714,7 @@ if (!SV) if (const FrameIndexSDNode *FI = dyn_cast(Ptr.getNode())) - SV = PseudoSourceValue::getFixedStack(FI->getIndex()); + SV = PseudoSourceValue::getStackObject(FI->getIndex()); MachineFunction &MF = getMachineFunction(); unsigned Flags = MachineMemOperand::MOLoad; @@ -3813,7 +3813,7 @@ if (!SV) if (const FrameIndexSDNode *FI = dyn_cast(Ptr.getNode())) - SV = PseudoSourceValue::getFixedStack(FI->getIndex()); + SV = PseudoSourceValue::getStackObject(FI->getIndex()); MachineFunction &MF = getMachineFunction(); unsigned Flags = MachineMemOperand::MOStore; @@ -3859,7 +3859,7 @@ if (!SV) if (const FrameIndexSDNode *FI = dyn_cast(Ptr.getNode())) - SV = PseudoSourceValue::getFixedStack(FI->getIndex()); + SV = PseudoSourceValue::getStackObject(FI->getIndex()); MachineFunction &MF = getMachineFunction(); unsigned Flags = MachineMemOperand::MOStore; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Sat Oct 17 01:22:26 2009 @@ -4197,7 +4197,7 @@ // Store the stack protector onto the stack. SDValue Result = DAG.getStore(getRoot(), getCurDebugLoc(), Src, FIN, - PseudoSourceValue::getFixedStack(FI), + PseudoSourceValue::getStackObject(FI), 0, true); setValue(&I, Result); DAG.setRoot(Result); Modified: llvm/trunk/lib/CodeGen/StackSlotColoring.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackSlotColoring.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/StackSlotColoring.cpp (original) +++ llvm/trunk/lib/CodeGen/StackSlotColoring.cpp Sat Oct 17 01:22:26 2009 @@ -466,8 +466,8 @@ // Update the memory references. This changes the MachineMemOperands // directly. They may be in use by multiple instructions, however all // instructions using OldFI are being rewritten to use NewFI. - const Value *OldSV = PseudoSourceValue::getFixedStack(OldFI); - const Value *NewSV = PseudoSourceValue::getFixedStack(NewFI); + const Value *OldSV = PseudoSourceValue::getStackObject(OldFI); + const Value *NewSV = PseudoSourceValue::getStackObject(NewFI); for (MachineInstr::mmo_iterator I = MI->memoperands_begin(), E = MI->memoperands_end(); I != E; ++I) if ((*I)->getValue() == OldSV) Modified: llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp Sat Oct 17 01:22:26 2009 @@ -187,7 +187,7 @@ const MachineFrameInfo &MFI = *MF.getFrameInfo(); assert(MFI.getObjectOffset(FrameIndex) != -1); MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FrameIndex), + MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FrameIndex), Flags, /*Offset=*/0, MFI.getObjectSize(FrameIndex), MFI.getObjectAlignment(FrameIndex)); Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Sat Oct 17 01:22:26 2009 @@ -671,7 +671,7 @@ MachineFrameInfo &MFI = *MF.getFrameInfo(); MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), + MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FI), MachineMemOperand::MOStore, 0, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); @@ -709,7 +709,7 @@ MachineFrameInfo &MFI = *MF.getFrameInfo(); MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), + MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FI), MachineMemOperand::MOLoad, 0, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Sat Oct 17 01:22:26 2009 @@ -309,7 +309,7 @@ //from this parameter SDValue FIN = DAG.getFrameIndex(FI, MVT::i16); InVals.push_back(DAG.getLoad(VA.getLocVT(), dl, Chain, FIN, - PseudoSourceValue::getFixedStack(FI), 0)); + PseudoSourceValue::getStackObject(FI), 0)); } } Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Sat Oct 17 01:22:26 2009 @@ -2235,7 +2235,7 @@ int FI = TailCallArgs[i].FrameIdx; // Store relative to framepointer. MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, FIN, - PseudoSourceValue::getFixedStack(FI), + PseudoSourceValue::getStackObject(FI), 0)); } } @@ -2261,7 +2261,7 @@ EVT VT = isPPC64 ? MVT::i64 : MVT::i32; SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewRetAddr, VT); Chain = DAG.getStore(Chain, dl, OldRetAddr, NewRetAddrFrIdx, - PseudoSourceValue::getFixedStack(NewRetAddr), 0); + PseudoSourceValue::getStackObject(NewRetAddr), 0); // When using the 32/64-bit SVR4 ABI there is no need to move the FP stack // slot as the FP is never overwritten. @@ -2271,7 +2271,7 @@ int NewFPIdx = MF.getFrameInfo()->CreateFixedObject(SlotSize, NewFPLoc); SDValue NewFramePtrIdx = DAG.getFrameIndex(NewFPIdx, VT); Chain = DAG.getStore(Chain, dl, OldFP, NewFramePtrIdx, - PseudoSourceValue::getFixedStack(NewFPIdx), 0); + PseudoSourceValue::getStackObject(NewFPIdx), 0); } } return Chain; @@ -3388,7 +3388,7 @@ // STD the extended value into the stack slot. MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FrameIdx), + MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FrameIdx), MachineMemOperand::MOStore, 0, 8, 8); SDValue Ops[] = { DAG.getEntryNode(), Ext64, FIdx }; SDValue Store = Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Sat Oct 17 01:22:26 2009 @@ -322,7 +322,7 @@ // from this parameter SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); ArgValue = DAG.getLoad(LocVT, dl, Chain, FIN, - PseudoSourceValue::getFixedStack(FI), 0); + PseudoSourceValue::getStackObject(FI), 0); } // If this is an 8/16/32-bit value, it is really passed promoted to 64 Modified: llvm/trunk/lib/Target/SystemZ/SystemZInstrBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZInstrBuilder.h?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZInstrBuilder.h (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZInstrBuilder.h Sat Oct 17 01:22:26 2009 @@ -115,7 +115,7 @@ if (TID.mayStore()) Flags |= MachineMemOperand::MOStore; MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), + MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FI), Flags, Offset, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Oct 17 01:22:26 2009 @@ -1373,7 +1373,7 @@ if (Flags.isByVal()) return FIN; return DAG.getLoad(ValVT, dl, Chain, FIN, - PseudoSourceValue::getFixedStack(FI), 0); + PseudoSourceValue::getStackObject(FI), 0); } SDValue @@ -1562,7 +1562,7 @@ SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, MVT::i64); SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, - PseudoSourceValue::getFixedStack(RegSaveFrameIndex), + PseudoSourceValue::getStackObject(RegSaveFrameIndex), Offset); MemOps.push_back(Store); Offset += 8; @@ -1673,7 +1673,7 @@ EVT VT = Is64Bit ? MVT::i64 : MVT::i32; SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT); Chain = DAG.getStore(Chain, dl, RetAddrFrIdx, NewRetAddrFrIdx, - PseudoSourceValue::getFixedStack(NewReturnAddrFI), 0); + PseudoSourceValue::getStackObject(NewReturnAddrFI), 0); return Chain; } @@ -1767,7 +1767,7 @@ SDValue SpillSlot = DAG.CreateStackTemporary(VA.getValVT()); int FI = cast(SpillSlot)->getIndex(); Chain = DAG.getStore(Chain, dl, Arg, SpillSlot, - PseudoSourceValue::getFixedStack(FI), 0); + PseudoSourceValue::getStackObject(FI), 0); Arg = SpillSlot; break; } @@ -1900,7 +1900,7 @@ // Store relative to framepointer. MemOpChains2.push_back( DAG.getStore(ArgChain, dl, Arg, FIN, - PseudoSourceValue::getFixedStack(FI), 0)); + PseudoSourceValue::getStackObject(FI), 0)); } } } @@ -4868,7 +4868,7 @@ SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); SDValue Chain = DAG.getStore(DAG.getEntryNode(), dl, Op.getOperand(0), StackSlot, - PseudoSourceValue::getFixedStack(SSFI), 0); + PseudoSourceValue::getStackObject(SSFI), 0); return BuildFILD(Op, SrcVT, Chain, StackSlot, DAG); } @@ -4909,7 +4909,7 @@ Ops.push_back(InFlag); Chain = DAG.getNode(X86ISD::FST, dl, Tys, &Ops[0], Ops.size()); Result = DAG.getLoad(Op.getValueType(), dl, Chain, StackSlot, - PseudoSourceValue::getFixedStack(SSFI), 0); + PseudoSourceValue::getStackObject(SSFI), 0); } return Result; @@ -5124,7 +5124,7 @@ if (isScalarFPTypeInSSEReg(Op.getOperand(0).getValueType())) { assert(DstTy == MVT::i64 && "Invalid FP_TO_SINT to lower!"); Chain = DAG.getStore(Chain, dl, Value, StackSlot, - PseudoSourceValue::getFixedStack(SSFI), 0); + PseudoSourceValue::getStackObject(SSFI), 0); SDVTList Tys = DAG.getVTList(Op.getOperand(0).getValueType(), MVT::Other); SDValue Ops[] = { Chain, StackSlot, DAG.getValueType(Op.getOperand(0).getValueType()) @@ -7754,7 +7754,7 @@ int64_t Offset = (i - 3) * 16 + VarArgsFPOffset; MachineMemOperand *MMO = F->getMachineMemOperand( - PseudoSourceValue::getFixedStack(RegSaveFrameIndex), + PseudoSourceValue::getStackObject(RegSaveFrameIndex), MachineMemOperand::MOStore, Offset, /*Size=*/16, /*Align=*/16); BuildMI(XMMSaveMBB, DL, TII->get(X86::MOVAPSmr)) Modified: llvm/trunk/lib/Target/X86/X86InstrBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrBuilder.h?rev=84315&r1=84314&r2=84315&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrBuilder.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrBuilder.h Sat Oct 17 01:22:26 2009 @@ -144,7 +144,7 @@ if (TID.mayStore()) Flags |= MachineMemOperand::MOStore; MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), + MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FI), Flags, Offset, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); From clattner at apple.com Sat Oct 17 01:35:13 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 16 Oct 2009 23:35:13 -0700 Subject: [llvm-commits] [llvm] r84180 - in /llvm/trunk/lib/Target/PIC16: AsmPrinter/PIC16AsmPrinter.cpp AsmPrinter/PIC16AsmPrinter.h PIC16.h PIC16ABINames.h PIC16DebugInfo.cpp PIC16ISelLowering.cpp PIC16InstrInfo.cpp PIC16MCAsmInfo.cpp PIC16MemSelOpt.cpp PIC16Section.cpp PIC16Section.h PIC16TargetObjectFile.cpp PIC16TargetObjectFile.h In-Reply-To: <200910151010.n9FAAjfE000588@zion.cs.uiuc.edu> References: <200910151010.n9FAAjfE000588@zion.cs.uiuc.edu> Message-ID: <9B75D8D2-D6FA-42B0-82F9-603E2CFF4552@apple.com> On Oct 15, 2009, at 3:10 AM, Sanjiv Gupta wrote: > Author: sgupta > Date: Thu Oct 15 05:10:43 2009 > New Revision: 84180 > > URL: http://llvm.org/viewvc/llvm-project?rev=84180&view=rev > Log: > Complete Rewrite of AsmPrinter, TargetObjectFile based on new > PIC16Section class > derived from MCSection. Woo very nice! -Chris From sabre at nondot.org Sat Oct 17 01:55:13 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 17 Oct 2009 01:55:13 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200910170655.n9H6tD2R011554@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.27 -> 1.28 --- Log message: simplify --- Diffs of the changes: (+4 -5) index.html | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.27 llvm-www/devmtg/2009-10/index.html:1.28 --- llvm-www/devmtg/2009-10/index.html:1.27 Thu Oct 15 16:44:17 2009 +++ llvm-www/devmtg/2009-10/index.html Sat Oct 17 01:53:47 2009 @@ -43,10 +43,9 @@

        This page lists all of the slides and videos for all of the talks of the day. The talks were held in two rooms - in one room we only were able to -record a screencast, in the other room we have full video. Please note that -the 'mobile' versions of the videos are actually larger (in file size) and -lower quality than the 'computer' versions, because a weaker codec had to be -used.

        +record a screencast, in the other room we have full video. The 'mobile' +versions of the videos are in a generic 'H.264' container, and the 'computer' +versions are in QuickTime format.

        From clattner at apple.com Sat Oct 17 01:59:23 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 16 Oct 2009 23:59:23 -0700 Subject: [llvm-commits] [llvm] r84106 - in /llvm/trunk: docs/ExceptionHandling.html include/llvm/IntrinsicInst.h include/llvm/Intrinsics.td lib/CodeGen/IntrinsicLowering.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/CodeGen/SjLjEHPrepare.cpp lib/VMCore/AutoUpgrade.cpp In-Reply-To: <200910141611.n9EGBcr0012361@zion.cs.uiuc.edu> References: <200910141611.n9EGBcr0012361@zion.cs.uiuc.edu> Message-ID: <5DF034CB-0DEF-41F7-8CD8-EDC627E32AE1@apple.com> On Oct 14, 2009, at 9:11 AM, Duncan Sands wrote: > Author: baldrick > Date: Wed Oct 14 11:11:37 2009 > New Revision: 84106 > > URL: http://llvm.org/viewvc/llvm-project?rev=84106&view=rev > Log: > I don't see any point in having both eh.selector.i32 and > eh.selector.i64, > so get rid of eh.selector.i64 and rename eh.selector.i32 to > eh.selector. > Likewise for eh.typeid.for. This aligns us with gcc, which always > uses a > 32 bit value for the selector on all platforms. My understanding is > that > the register allocator used to assert if the selector intrinsic size > didn't > match the pointer size, and this was the reason for introducing the > two > variants. However my testing shows that this is no longer the case (I > fixed some bugs in selector lowering yesterday, and some more today > in the > fastisel path; these might have caused the original problems). Nice, thank you for adding the autoupgrade code. -Chris From jyasskin at gmail.com Sat Oct 17 02:42:54 2009 From: jyasskin at gmail.com (jyasskin at gmail.com) Date: Sat, 17 Oct 2009 07:42:54 +0000 Subject: [llvm-commits] [PATCH] Add a ValueMap type, whose keys act like WeakVHs Message-ID: <0016363b7bde0f990504761ca9c4@google.com> Reviewers: , Message: This breaks check-lit with the following error: ******************** UNRESOLVED: LLVM-Unit::ADT/Debug/ADTTests/ValueMapTest/1.NoFollowRAUW (103 of 4819) ******************** TEST 'LLVM-Unit::ADT/Debug/ADTTests/ValueMapTest/1.NoFollowRAUW' FAILED ******************** Exception during script execution: Traceback (most recent call last): File "/Users/jyasskin/src/llvm/jit_del/src/utils/lit/lit.py", line 118, in runTest self.litConfig) File "/Users/jyasskin/src/llvm/jit_del/src/utils/lit/TestFormats.py", line 58, in execute out, err, exitCode = TestRunner.executeCommand(cmd) File "/Users/jyasskin/src/llvm/jit_del/src/utils/lit/TestRunner.py", line 23, in executeCommand env=env) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 595, in __init__ errread, errwrite) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1092, in _execute_child raise child_exception OSError: [Errno 20] Not a directory I guess I'll have to figure out how to fix it before submitting. Description: ValueMap is safe to use even when keys get RAUWed and deleted during its lifetime. By default the keys act like WeakVHs, but users can pass a third template parameter to configure how updates work and whether to do anything beyond updating the map on each action. This type should make http://codereview.appspot.com/133043/diff/1/2 quite a bit simpler, but I haven't yet updated it so I could have missed something. Please review this at http://codereview.appspot.com/132055 Affected files: M docs/ProgrammersManual.html A include/llvm/ADT/ValueMap.h M include/llvm/Support/type_traits.h A unittests/ADT/ValueMapTest.cpp From evan.cheng at apple.com Sat Oct 17 02:53:13 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 17 Oct 2009 07:53:13 -0000 Subject: [llvm-commits] [llvm] r84321 - in /llvm/trunk: include/llvm/CodeGen/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/MSP430/ lib/Target/PowerPC/ lib/Target/SystemZ/ lib/Target/X86/ Message-ID: <200910170753.n9H7rFPC021006@zion.cs.uiuc.edu> Author: evancheng Date: Sat Oct 17 02:53:04 2009 New Revision: 84321 URL: http://llvm.org/viewvc/llvm-project?rev=84321&view=rev Log: Revert 84315 for now. Re-thinking the patch. Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/CodeGen/StackSlotColoring.cpp llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp llvm/trunk/lib/Target/SystemZ/SystemZInstrBuilder.h llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86InstrBuilder.h Modified: llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h (original) +++ llvm/trunk/include/llvm/CodeGen/PseudoSourceValue.h Sat Oct 17 02:53:04 2009 @@ -47,9 +47,9 @@ return V->getValueID() == PseudoSourceValueVal; } - /// A pseudo source value referencing a stack frame entry, - /// e.g., a spill slot or an incoming argument on stack. - static const PseudoSourceValue *getStackObject(int FI); + /// A pseudo source value referencing a fixed stack frame entry, + /// e.g., a spill slot. + static const PseudoSourceValue *getFixedStack(int FI); /// A pseudo source value referencing the area below the stack frame of /// a function, e.g., the argument space. Modified: llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp (original) +++ llvm/trunk/lib/CodeGen/PseudoSourceValue.cpp Sat Oct 17 02:53:04 2009 @@ -52,31 +52,29 @@ } namespace { - /// StackObjectPseudoSourceValue - A specialized PseudoSourceValue - /// for holding StackObject values, which must include a frame + /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue + /// for holding FixedStack values, which must include a frame /// index. - class VISIBILITY_HIDDEN StackObjectPseudoSourceValue + class VISIBILITY_HIDDEN FixedStackPseudoSourceValue : public PseudoSourceValue { const int FI; public: - explicit StackObjectPseudoSourceValue(int fi) : FI(fi) {} + explicit FixedStackPseudoSourceValue(int fi) : FI(fi) {} virtual bool isConstant(const MachineFrameInfo *MFI) const; virtual void printCustom(raw_ostream &OS) const { - if (FI < 0) - OS << "Fixed"; - OS << "StackObject" << FI; + OS << "FixedStack" << FI; } }; } static ManagedStatic > FSValues; -const PseudoSourceValue *PseudoSourceValue::getStackObject(int FI) { +const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) { const PseudoSourceValue *&V = (*FSValues)[FI]; if (!V) - V = new StackObjectPseudoSourceValue(FI); + V = new FixedStackPseudoSourceValue(FI); return V; } @@ -91,7 +89,6 @@ return false; } -bool -StackObjectPseudoSourceValue::isConstant(const MachineFrameInfo *MFI) const { +bool FixedStackPseudoSourceValue::isConstant(const MachineFrameInfo *MFI) const{ return MFI && MFI->isImmutableObjectIndex(FI); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sat Oct 17 02:53:04 2009 @@ -643,7 +643,7 @@ // Store the vector. SDValue Ch = DAG.getStore(DAG.getEntryNode(), dl, Tmp1, StackPtr, - PseudoSourceValue::getStackObject(SPFI), 0); + PseudoSourceValue::getFixedStack(SPFI), 0); // Truncate or zero extend offset to target pointer type. unsigned CastOpc = IdxVT.bitsGT(PtrVT) ? ISD::TRUNCATE : ISD::ZERO_EXTEND; @@ -654,10 +654,10 @@ SDValue StackPtr2 = DAG.getNode(ISD::ADD, dl, IdxVT, Tmp3, StackPtr); // Store the scalar value. Ch = DAG.getTruncStore(Ch, dl, Tmp2, StackPtr2, - PseudoSourceValue::getStackObject(SPFI), 0, EltVT); + PseudoSourceValue::getFixedStack(SPFI), 0, EltVT); // Load the updated vector. return DAG.getLoad(VT, dl, Ch, StackPtr, - PseudoSourceValue::getStackObject(SPFI), 0); + PseudoSourceValue::getFixedStack(SPFI), 0); } @@ -1518,7 +1518,7 @@ DebugLoc dl = Node->getDebugLoc(); SDValue FIPtr = DAG.CreateStackTemporary(VT); int FI = cast(FIPtr.getNode())->getIndex(); - const Value *SV = PseudoSourceValue::getStackObject(FI); + const Value *SV = PseudoSourceValue::getFixedStack(FI); // Emit a store of each element to the stack slot. SmallVector Stores; @@ -1714,7 +1714,7 @@ FrameIndexSDNode *StackPtrFI = cast(FIPtr); int SPFI = StackPtrFI->getIndex(); - const Value *SV = PseudoSourceValue::getStackObject(SPFI); + const Value *SV = PseudoSourceValue::getFixedStack(SPFI); unsigned SrcSize = SrcOp.getValueType().getSizeInBits(); unsigned SlotSize = SlotVT.getSizeInBits(); @@ -1755,10 +1755,10 @@ SDValue Ch = DAG.getTruncStore(DAG.getEntryNode(), dl, Node->getOperand(0), StackPtr, - PseudoSourceValue::getStackObject(SPFI), 0, + PseudoSourceValue::getFixedStack(SPFI), 0, Node->getValueType(0).getVectorElementType()); return DAG.getLoad(Node->getValueType(0), dl, Ch, StackPtr, - PseudoSourceValue::getStackObject(SPFI), 0); + PseudoSourceValue::getFixedStack(SPFI), 0); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Sat Oct 17 02:53:04 2009 @@ -119,7 +119,7 @@ getTypeForEVT(*DAG.getContext())); SDValue StackPtr = DAG.CreateStackTemporary(InVT, Alignment); int SPFI = cast(StackPtr.getNode())->getIndex(); - const Value *SV = PseudoSourceValue::getStackObject(SPFI); + const Value *SV = PseudoSourceValue::getFixedStack(SPFI); // Emit a store to the stack slot. SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, InOp, StackPtr, SV, 0); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Sat Oct 17 02:53:04 2009 @@ -1058,7 +1058,7 @@ DebugLoc dl = N->getDebugLoc(); SDValue StackPtr = DAG.CreateStackTemporary(VecVT); int SPFI = cast(StackPtr.getNode())->getIndex(); - const Value *SV = PseudoSourceValue::getStackObject(SPFI); + const Value *SV = PseudoSourceValue::getFixedStack(SPFI); SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, SV, 0); // Load back the required element. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sat Oct 17 02:53:04 2009 @@ -3514,7 +3514,7 @@ if (!PtrVal) if (const FrameIndexSDNode *FI = dyn_cast(Ptr.getNode())) - PtrVal = PseudoSourceValue::getStackObject(FI->getIndex()); + PtrVal = PseudoSourceValue::getFixedStack(FI->getIndex()); MachineFunction &MF = getMachineFunction(); unsigned Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOStore; @@ -3567,7 +3567,7 @@ if (!PtrVal) if (const FrameIndexSDNode *FI = dyn_cast(Ptr.getNode())) - PtrVal = PseudoSourceValue::getStackObject(FI->getIndex()); + PtrVal = PseudoSourceValue::getFixedStack(FI->getIndex()); MachineFunction &MF = getMachineFunction(); unsigned Flags = MachineMemOperand::MOLoad | MachineMemOperand::MOStore; @@ -3714,7 +3714,7 @@ if (!SV) if (const FrameIndexSDNode *FI = dyn_cast(Ptr.getNode())) - SV = PseudoSourceValue::getStackObject(FI->getIndex()); + SV = PseudoSourceValue::getFixedStack(FI->getIndex()); MachineFunction &MF = getMachineFunction(); unsigned Flags = MachineMemOperand::MOLoad; @@ -3813,7 +3813,7 @@ if (!SV) if (const FrameIndexSDNode *FI = dyn_cast(Ptr.getNode())) - SV = PseudoSourceValue::getStackObject(FI->getIndex()); + SV = PseudoSourceValue::getFixedStack(FI->getIndex()); MachineFunction &MF = getMachineFunction(); unsigned Flags = MachineMemOperand::MOStore; @@ -3859,7 +3859,7 @@ if (!SV) if (const FrameIndexSDNode *FI = dyn_cast(Ptr.getNode())) - SV = PseudoSourceValue::getStackObject(FI->getIndex()); + SV = PseudoSourceValue::getFixedStack(FI->getIndex()); MachineFunction &MF = getMachineFunction(); unsigned Flags = MachineMemOperand::MOStore; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Sat Oct 17 02:53:04 2009 @@ -4197,7 +4197,7 @@ // Store the stack protector onto the stack. SDValue Result = DAG.getStore(getRoot(), getCurDebugLoc(), Src, FIN, - PseudoSourceValue::getStackObject(FI), + PseudoSourceValue::getFixedStack(FI), 0, true); setValue(&I, Result); DAG.setRoot(Result); Modified: llvm/trunk/lib/CodeGen/StackSlotColoring.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackSlotColoring.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/StackSlotColoring.cpp (original) +++ llvm/trunk/lib/CodeGen/StackSlotColoring.cpp Sat Oct 17 02:53:04 2009 @@ -466,8 +466,8 @@ // Update the memory references. This changes the MachineMemOperands // directly. They may be in use by multiple instructions, however all // instructions using OldFI are being rewritten to use NewFI. - const Value *OldSV = PseudoSourceValue::getStackObject(OldFI); - const Value *NewSV = PseudoSourceValue::getStackObject(NewFI); + const Value *OldSV = PseudoSourceValue::getFixedStack(OldFI); + const Value *NewSV = PseudoSourceValue::getFixedStack(NewFI); for (MachineInstr::mmo_iterator I = MI->memoperands_begin(), E = MI->memoperands_end(); I != E; ++I) if ((*I)->getValue() == OldSV) Modified: llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp Sat Oct 17 02:53:04 2009 @@ -187,7 +187,7 @@ const MachineFrameInfo &MFI = *MF.getFrameInfo(); assert(MFI.getObjectOffset(FrameIndex) != -1); MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FrameIndex), + MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FrameIndex), Flags, /*Offset=*/0, MFI.getObjectSize(FrameIndex), MFI.getObjectAlignment(FrameIndex)); Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Sat Oct 17 02:53:04 2009 @@ -671,7 +671,7 @@ MachineFrameInfo &MFI = *MF.getFrameInfo(); MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FI), + MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), MachineMemOperand::MOStore, 0, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); @@ -709,7 +709,7 @@ MachineFrameInfo &MFI = *MF.getFrameInfo(); MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FI), + MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), MachineMemOperand::MOLoad, 0, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Sat Oct 17 02:53:04 2009 @@ -309,7 +309,7 @@ //from this parameter SDValue FIN = DAG.getFrameIndex(FI, MVT::i16); InVals.push_back(DAG.getLoad(VA.getLocVT(), dl, Chain, FIN, - PseudoSourceValue::getStackObject(FI), 0)); + PseudoSourceValue::getFixedStack(FI), 0)); } } Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Sat Oct 17 02:53:04 2009 @@ -2235,7 +2235,7 @@ int FI = TailCallArgs[i].FrameIdx; // Store relative to framepointer. MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, FIN, - PseudoSourceValue::getStackObject(FI), + PseudoSourceValue::getFixedStack(FI), 0)); } } @@ -2261,7 +2261,7 @@ EVT VT = isPPC64 ? MVT::i64 : MVT::i32; SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewRetAddr, VT); Chain = DAG.getStore(Chain, dl, OldRetAddr, NewRetAddrFrIdx, - PseudoSourceValue::getStackObject(NewRetAddr), 0); + PseudoSourceValue::getFixedStack(NewRetAddr), 0); // When using the 32/64-bit SVR4 ABI there is no need to move the FP stack // slot as the FP is never overwritten. @@ -2271,7 +2271,7 @@ int NewFPIdx = MF.getFrameInfo()->CreateFixedObject(SlotSize, NewFPLoc); SDValue NewFramePtrIdx = DAG.getFrameIndex(NewFPIdx, VT); Chain = DAG.getStore(Chain, dl, OldFP, NewFramePtrIdx, - PseudoSourceValue::getStackObject(NewFPIdx), 0); + PseudoSourceValue::getFixedStack(NewFPIdx), 0); } } return Chain; @@ -3388,7 +3388,7 @@ // STD the extended value into the stack slot. MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FrameIdx), + MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FrameIdx), MachineMemOperand::MOStore, 0, 8, 8); SDValue Ops[] = { DAG.getEntryNode(), Ext64, FIdx }; SDValue Store = Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Sat Oct 17 02:53:04 2009 @@ -322,7 +322,7 @@ // from this parameter SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); ArgValue = DAG.getLoad(LocVT, dl, Chain, FIN, - PseudoSourceValue::getStackObject(FI), 0); + PseudoSourceValue::getFixedStack(FI), 0); } // If this is an 8/16/32-bit value, it is really passed promoted to 64 Modified: llvm/trunk/lib/Target/SystemZ/SystemZInstrBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZInstrBuilder.h?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZInstrBuilder.h (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZInstrBuilder.h Sat Oct 17 02:53:04 2009 @@ -115,7 +115,7 @@ if (TID.mayStore()) Flags |= MachineMemOperand::MOStore; MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FI), + MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), Flags, Offset, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Oct 17 02:53:04 2009 @@ -1373,7 +1373,7 @@ if (Flags.isByVal()) return FIN; return DAG.getLoad(ValVT, dl, Chain, FIN, - PseudoSourceValue::getStackObject(FI), 0); + PseudoSourceValue::getFixedStack(FI), 0); } SDValue @@ -1562,7 +1562,7 @@ SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, MVT::i64); SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, - PseudoSourceValue::getStackObject(RegSaveFrameIndex), + PseudoSourceValue::getFixedStack(RegSaveFrameIndex), Offset); MemOps.push_back(Store); Offset += 8; @@ -1673,7 +1673,7 @@ EVT VT = Is64Bit ? MVT::i64 : MVT::i32; SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT); Chain = DAG.getStore(Chain, dl, RetAddrFrIdx, NewRetAddrFrIdx, - PseudoSourceValue::getStackObject(NewReturnAddrFI), 0); + PseudoSourceValue::getFixedStack(NewReturnAddrFI), 0); return Chain; } @@ -1767,7 +1767,7 @@ SDValue SpillSlot = DAG.CreateStackTemporary(VA.getValVT()); int FI = cast(SpillSlot)->getIndex(); Chain = DAG.getStore(Chain, dl, Arg, SpillSlot, - PseudoSourceValue::getStackObject(FI), 0); + PseudoSourceValue::getFixedStack(FI), 0); Arg = SpillSlot; break; } @@ -1900,7 +1900,7 @@ // Store relative to framepointer. MemOpChains2.push_back( DAG.getStore(ArgChain, dl, Arg, FIN, - PseudoSourceValue::getStackObject(FI), 0)); + PseudoSourceValue::getFixedStack(FI), 0)); } } } @@ -4868,7 +4868,7 @@ SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); SDValue Chain = DAG.getStore(DAG.getEntryNode(), dl, Op.getOperand(0), StackSlot, - PseudoSourceValue::getStackObject(SSFI), 0); + PseudoSourceValue::getFixedStack(SSFI), 0); return BuildFILD(Op, SrcVT, Chain, StackSlot, DAG); } @@ -4909,7 +4909,7 @@ Ops.push_back(InFlag); Chain = DAG.getNode(X86ISD::FST, dl, Tys, &Ops[0], Ops.size()); Result = DAG.getLoad(Op.getValueType(), dl, Chain, StackSlot, - PseudoSourceValue::getStackObject(SSFI), 0); + PseudoSourceValue::getFixedStack(SSFI), 0); } return Result; @@ -5124,7 +5124,7 @@ if (isScalarFPTypeInSSEReg(Op.getOperand(0).getValueType())) { assert(DstTy == MVT::i64 && "Invalid FP_TO_SINT to lower!"); Chain = DAG.getStore(Chain, dl, Value, StackSlot, - PseudoSourceValue::getStackObject(SSFI), 0); + PseudoSourceValue::getFixedStack(SSFI), 0); SDVTList Tys = DAG.getVTList(Op.getOperand(0).getValueType(), MVT::Other); SDValue Ops[] = { Chain, StackSlot, DAG.getValueType(Op.getOperand(0).getValueType()) @@ -7754,7 +7754,7 @@ int64_t Offset = (i - 3) * 16 + VarArgsFPOffset; MachineMemOperand *MMO = F->getMachineMemOperand( - PseudoSourceValue::getStackObject(RegSaveFrameIndex), + PseudoSourceValue::getFixedStack(RegSaveFrameIndex), MachineMemOperand::MOStore, Offset, /*Size=*/16, /*Align=*/16); BuildMI(XMMSaveMBB, DL, TII->get(X86::MOVAPSmr)) Modified: llvm/trunk/lib/Target/X86/X86InstrBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrBuilder.h?rev=84321&r1=84320&r2=84321&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrBuilder.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrBuilder.h Sat Oct 17 02:53:04 2009 @@ -144,7 +144,7 @@ if (TID.mayStore()) Flags |= MachineMemOperand::MOStore; MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getStackObject(FI), + MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), Flags, Offset, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); From daniel at zuster.org Sat Oct 17 03:12:43 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 08:12:43 -0000 Subject: [llvm-commits] [llvm] r84322 - /llvm/trunk/include/llvm/PassAnalysisSupport.h Message-ID: <200910170812.n9H8Ci9U022414@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Oct 17 03:12:36 2009 New Revision: 84322 URL: http://llvm.org/viewvc/llvm-project?rev=84322&view=rev Log: Add another required #include for freestanding .h files. Modified: llvm/trunk/include/llvm/PassAnalysisSupport.h Modified: llvm/trunk/include/llvm/PassAnalysisSupport.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassAnalysisSupport.h?rev=84322&r1=84321&r2=84322&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassAnalysisSupport.h (original) +++ llvm/trunk/include/llvm/PassAnalysisSupport.h Sat Oct 17 03:12:36 2009 @@ -20,14 +20,13 @@ #define LLVM_PASS_ANALYSIS_SUPPORT_H #include +#include "llvm/Pass.h" #include "llvm/ADT/SmallVector.h" namespace llvm { class StringRef; -// No need to include Pass.h, we are being included by it! - //===----------------------------------------------------------------------===// // AnalysisUsage - Represent the analysis usage information of a pass. This // tracks analyses that the pass REQUIRES (must be available when the pass From evan.cheng at apple.com Sat Oct 17 03:57:09 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 17 Oct 2009 08:57:09 -0000 Subject: [llvm-commits] [llvm] r84324 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Message-ID: <200910170857.n9H8v95t029111@zion.cs.uiuc.edu> Author: evancheng Date: Sat Oct 17 03:57:09 2009 New Revision: 84324 URL: http://llvm.org/viewvc/llvm-project?rev=84324&view=rev Log: Re-arrange some fields. Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=84324&r1=84323&r2=84324&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Sat Oct 17 03:57:09 2009 @@ -86,6 +86,10 @@ // StackObject - Represent a single object allocated on the stack. struct StackObject { + // SPOffset - The offset of this object from the stack pointer on entry to + // the function. This field has no meaning for a variable sized element. + int64_t SPOffset; + // The size of this object on the stack. 0 means a variable sized object, // ~0ULL means a dead object. uint64_t Size; @@ -98,12 +102,8 @@ // default, fixed objects are immutable unless marked otherwise. bool isImmutable; - // SPOffset - The offset of this object from the stack pointer on entry to - // the function. This field has no meaning for a variable sized element. - int64_t SPOffset; - StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false) - : Size(Sz), Alignment(Al), isImmutable(IM), SPOffset(SP) {} + : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM) {} }; /// Objects - The list of stack objects allocated... From evan.cheng at apple.com Sat Oct 17 04:20:41 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 17 Oct 2009 09:20:41 -0000 Subject: [llvm-commits] [llvm] r84326 - in /llvm/trunk: include/llvm/CodeGen/MachineFrameInfo.h lib/CodeGen/PreAllocSplitting.cpp lib/CodeGen/PrologEpilogInserter.cpp lib/CodeGen/RegAllocLocal.cpp lib/CodeGen/VirtRegMap.cpp lib/Target/ARM/ARMBaseInstrInfo.cpp lib/Target/X86/X86InstrBuilder.h Message-ID: <200910170920.n9H9Kqdf030331@zion.cs.uiuc.edu> Author: evancheng Date: Sat Oct 17 04:20:14 2009 New Revision: 84326 URL: http://llvm.org/viewvc/llvm-project?rev=84326&view=rev Log: Distinquish stack slots from other stack objects. They (and fixed objects) get FixedStack PseudoSourceValues. Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp llvm/trunk/lib/CodeGen/RegAllocLocal.cpp llvm/trunk/lib/CodeGen/VirtRegMap.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrBuilder.h Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=84326&r1=84325&r2=84326&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Sat Oct 17 04:20:14 2009 @@ -102,8 +102,14 @@ // default, fixed objects are immutable unless marked otherwise. bool isImmutable; - StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false) - : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM) {} + // isSpillSlot - If true, the stack object is used as spill slot. It + // cannot alias any other memory objects. + bool isSpillSlot; + + StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false, + bool isSS = false) + : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM), + isSpillSlot(isSS) {} }; /// Objects - The list of stack objects allocated... @@ -352,6 +358,14 @@ return Objects[ObjectIdx+NumFixedObjects].isImmutable; } + /// isSpillSlotObjectIndex - Returns true if the specified index corresponds + /// to a spill slot.. + bool isSpillSlotObjectIndex(int ObjectIdx) const { + assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && + "Invalid Object Idx!"); + return Objects[ObjectIdx+NumFixedObjects].isSpillSlot;; + } + /// isDeadObjectIndex - Returns true if the specified index corresponds to /// a dead object. bool isDeadObjectIndex(int ObjectIdx) const { @@ -363,9 +377,9 @@ /// CreateStackObject - Create a new statically sized stack object, returning /// a nonnegative identifier to represent it. /// - int CreateStackObject(uint64_t Size, unsigned Alignment) { + int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS = false) { assert(Size != 0 && "Cannot allocate zero size stack objects!"); - Objects.push_back(StackObject(Size, Alignment)); + Objects.push_back(StackObject(Size, Alignment, 0, false, isSS)); return (int)Objects.size()-NumFixedObjects-1; } Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=84326&r1=84325&r2=84326&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Sat Oct 17 04:20:14 2009 @@ -952,7 +952,7 @@ if (I != IntervalSSMap.end()) { SS = I->second; } else { - SS = MFI->CreateStackObject(RC->getSize(), RC->getAlignment()); + SS = MFI->CreateStackObject(RC->getSize(), RC->getAlignment()); } MachineInstr* FMI = TII->foldMemoryOperand(*MBB->getParent(), Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=84326&r1=84325&r2=84326&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original) +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Sat Oct 17 04:20:14 2009 @@ -259,7 +259,7 @@ // the TargetRegisterClass if the stack alignment is smaller. Use the // min. Align = std::min(Align, StackAlign); - FrameIdx = FFI->CreateStackObject(RC->getSize(), Align); + FrameIdx = FFI->CreateStackObject(RC->getSize(), Align, true); if ((unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx; if ((unsigned)FrameIdx > MaxCSFrameIndex) MaxCSFrameIndex = FrameIdx; } else { Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLocal.cpp?rev=84326&r1=84325&r2=84326&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLocal.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Sat Oct 17 04:20:14 2009 @@ -263,7 +263,7 @@ // Allocate a new stack object for this spill location... int FrameIdx = MF->getFrameInfo()->CreateStackObject(RC->getSize(), - RC->getAlignment()); + RC->getAlignment(),true); // Assign the slot... StackSlotForVirtReg[VirtReg] = FrameIdx; Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=84326&r1=84325&r2=84326&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Sat Oct 17 04:20:14 2009 @@ -118,7 +118,7 @@ "attempt to assign stack slot to already spilled register"); const TargetRegisterClass* RC = MF->getRegInfo().getRegClass(virtReg); int SS = MF->getFrameInfo()->CreateStackObject(RC->getSize(), - RC->getAlignment()); + RC->getAlignment(), /*isSS*/true); if (LowSpillSlot == NO_STACK_SLOT) LowSpillSlot = SS; if (HighSpillSlot == NO_STACK_SLOT || SS > HighSpillSlot) @@ -162,7 +162,7 @@ if (I != EmergencySpillSlots.end()) return I->second; int SS = MF->getFrameInfo()->CreateStackObject(RC->getSize(), - RC->getAlignment()); + RC->getAlignment(), /*isSS*/true); if (LowSpillSlot == NO_STACK_SLOT) LowSpillSlot = SS; if (HighSpillSlot == NO_STACK_SLOT || SS > HighSpillSlot) Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=84326&r1=84325&r2=84326&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Sat Oct 17 04:20:14 2009 @@ -670,8 +670,11 @@ MachineFunction &MF = *MBB.getParent(); MachineFrameInfo &MFI = *MF.getFrameInfo(); + const Value *SV = (MFI.isFixedObjectIndex(FI) || + MFI.isSpillSlotObjectIndex(FI)) + ? PseudoSourceValue::getFixedStack(FI) : PseudoSourceValue::getStack(); MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), + MF.getMachineMemOperand(SV, MachineMemOperand::MOStore, 0, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); @@ -708,8 +711,11 @@ MachineFunction &MF = *MBB.getParent(); MachineFrameInfo &MFI = *MF.getFrameInfo(); + const Value *SV = (MFI.isFixedObjectIndex(FI) || + MFI.isSpillSlotObjectIndex(FI)) + ? PseudoSourceValue::getFixedStack(FI) : PseudoSourceValue::getStack(); MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), + MF.getMachineMemOperand(SV, MachineMemOperand::MOLoad, 0, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); Modified: llvm/trunk/lib/Target/X86/X86InstrBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrBuilder.h?rev=84326&r1=84325&r2=84326&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrBuilder.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrBuilder.h Sat Oct 17 04:20:14 2009 @@ -143,8 +143,11 @@ Flags |= MachineMemOperand::MOLoad; if (TID.mayStore()) Flags |= MachineMemOperand::MOStore; + const Value *SV = (MFI.isFixedObjectIndex(FI) || + MFI.isSpillSlotObjectIndex(FI)) + ? PseudoSourceValue::getFixedStack(FI) : PseudoSourceValue::getStack(); MachineMemOperand *MMO = - MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI), + MF.getMachineMemOperand(SV, Flags, Offset, MFI.getObjectSize(FI), MFI.getObjectAlignment(FI)); From daniel at zuster.org Sat Oct 17 04:33:36 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 09:33:36 -0000 Subject: [llvm-commits] [llvm] r84327 - /llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Message-ID: <200910170933.n9H9XeSH030932@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Oct 17 04:33:00 2009 New Revision: 84327 URL: http://llvm.org/viewvc/llvm-project?rev=84327&view=rev Log: Suppress -Asserts warning. Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=84327&r1=84326&r2=84327&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Sat Oct 17 04:33:00 2009 @@ -153,8 +153,8 @@ MachineBasicBlock *TBB = 0, *FBB = 0; SmallVector Cond; - bool B = TII->AnalyzeBranch(*MBB, TBB, FBB, Cond); - assert(!B && "UpdateTerminators requires analyzable predecessors!"); + assert(!TII->AnalyzeBranch(*MBB, TBB, FBB, Cond) && + "UpdateTerminators requires analyzable predecessors!"); if (Cond.empty()) { if (TBB) { // The block has an unconditional branch. If its successor is now From eocallaghan at auroraux.org Sat Oct 17 05:19:45 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Sat, 17 Oct 2009 10:19:45 -0000 Subject: [llvm-commits] [compiler-rt] r84330 - in /compiler-rt/trunk: CMakeLists.txt test/CMakeLists.txt test/Unit/gcc_personality_test.c test/Unit/int_lib.h test/Unit/modsi3_test.c Message-ID: <200910171019.n9HAJpoY032711@zion.cs.uiuc.edu> Author: evocallaghan Date: Sat Oct 17 05:19:32 2009 New Revision: 84330 URL: http://llvm.org/viewvc/llvm-project?rev=84330&view=rev Log: Comment out broken tests and make the rest build in cmake build system. Modified: compiler-rt/trunk/CMakeLists.txt compiler-rt/trunk/test/CMakeLists.txt compiler-rt/trunk/test/Unit/gcc_personality_test.c compiler-rt/trunk/test/Unit/int_lib.h compiler-rt/trunk/test/Unit/modsi3_test.c Modified: compiler-rt/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=84330&r1=84329&r2=84330&view=diff ============================================================================== --- compiler-rt/trunk/CMakeLists.txt (original) +++ compiler-rt/trunk/CMakeLists.txt Sat Oct 17 05:19:32 2009 @@ -51,4 +51,4 @@ # Tests are being ignored for until the very basics are working. #INCLUDE( MacroAddCheckTest ) -#ADD_SUBDIRECTORY( test ) +ADD_SUBDIRECTORY( test ) Modified: compiler-rt/trunk/test/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/CMakeLists.txt?rev=84330&r1=84329&r2=84330&view=diff ============================================================================== --- compiler-rt/trunk/test/CMakeLists.txt (original) +++ compiler-rt/trunk/test/CMakeLists.txt Sat Oct 17 05:19:32 2009 @@ -16,16 +16,16 @@ # Create Unit/ tests MACRO_ADD_CHECK_TEST( ashldi3_test Unit/ashldi3_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( gcc_personality_test Unit/gcc_personality_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( gcc_personality_test Unit/gcc_personality_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( udivmodti4_test Unit/udivmodti4_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( negvsi2_test Unit/negvsi2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( fixdfdi_test Unit/fixdfdi_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( mulvsi3_test Unit/mulvsi3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( fixdfti_test Unit/fixdfti_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( muldc3_test Unit/muldc3_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( muldc3_test Unit/muldc3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( popcountdi2_test Unit/popcountdi2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( negti2_test Unit/negti2_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( divsc3_test Unit/divsc3_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( divsc3_test Unit/divsc3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( cmpti2_test Unit/cmpti2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( trampoline_setup_test Unit/trampoline_setup_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( mulvti3_test Unit/mulvti3_test.c ${TEST_TARGET_LIBRARIES} ) @@ -47,11 +47,11 @@ MACRO_ADD_CHECK_TEST( udivmoddi4_test Unit/udivmoddi4_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( paritysi2_test Unit/paritysi2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( floatundidf_test Unit/floatundidf_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( divdc3_test Unit/divdc3_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( divdc3_test Unit/divdc3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( floatuntisf_test Unit/floatuntisf_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( ucmpdi2_test Unit/ucmpdi2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( powixf2_test Unit/powixf2_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( mulsc3_test Unit/mulsc3_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( mulsc3_test Unit/mulsc3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( popcountsi2_test Unit/popcountsi2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( cmpdi2_test Unit/cmpdi2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( floattisf_test Unit/floattisf_test.c ${TEST_TARGET_LIBRARIES} ) @@ -79,16 +79,16 @@ MACRO_ADD_CHECK_TEST( absvti2_test Unit/absvti2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( ashrti3_test Unit/ashrti3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( powisf2_test Unit/powisf2_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( mulxc3_test Unit/mulxc3_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( mulxc3_test Unit/mulxc3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( lshrdi3_test Unit/lshrdi3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( udivdi3_test Unit/udivdi3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( clzsi2_test Unit/clzsi2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( addvti3_test Unit/addvti3_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( udivsi3_test Unit/udivsi3_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( udivsi3_test Unit/udivsi3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( clzdi2_test Unit/clzdi2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( floatuntidf_test Unit/floatuntidf_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( umodti3_test Unit/umodti3_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( divxc3_test Unit/divxc3_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( divxc3_test Unit/divxc3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( ctzti2_test Unit/ctzti2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( floatuntixf_test Unit/floatuntixf_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( powidf2_test Unit/powidf2_test.c ${TEST_TARGET_LIBRARIES} ) @@ -96,7 +96,7 @@ MACRO_ADD_CHECK_TEST( modti3_test Unit/modti3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( fixunssfsi_test Unit/fixunssfsi_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( fixunsdfdi_test Unit/fixunsdfdi_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( divsi3_test Unit/divsi3_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( divsi3_test Unit/divsi3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( floattixf_test Unit/floattixf_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( fixunsdfti_test Unit/fixunsdfti_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( subvti3_test Unit/subvti3_test.c ${TEST_TARGET_LIBRARIES} ) @@ -108,10 +108,10 @@ MACRO_ADD_CHECK_TEST( floatdisf_test Unit/floatdisf_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( addvsi3_test Unit/addvsi3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( udivti3_test Unit/udivti3_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( umodsi3_test Unit/umodsi3_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( umodsi3_test Unit/umodsi3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( subvsi3_test Unit/subvsi3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( fixxfdi_test Unit/fixxfdi_test.c ${TEST_TARGET_LIBRARIES} ) -MACRO_ADD_CHECK_TEST( modsi3_test Unit/modsi3_test.c ${TEST_TARGET_LIBRARIES} ) +# MACRO_ADD_CHECK_TEST( modsi3_test Unit/modsi3_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( fixxfti_test Unit/fixxfti_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( ffsdi2_test Unit/ffsdi2_test.c ${TEST_TARGET_LIBRARIES} ) MACRO_ADD_CHECK_TEST( divti3_test Unit/divti3_test.c ${TEST_TARGET_LIBRARIES} ) Modified: compiler-rt/trunk/test/Unit/gcc_personality_test.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/Unit/gcc_personality_test.c?rev=84330&r1=84329&r2=84330&view=diff ============================================================================== --- compiler-rt/trunk/test/Unit/gcc_personality_test.c (original) +++ compiler-rt/trunk/test/Unit/gcc_personality_test.c Sat Oct 17 05:19:32 2009 @@ -1,11 +1,12 @@ -//===-- gcc_personality_test.c - Tests __gcc_personality_v0 -------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// +/* ===-- gcc_personality_test.c - Tests __gcc_personality_v0 -------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + */ #include @@ -19,28 +20,23 @@ extern void done_bar(); -// -// foo() is called by main() in gcc_personality_test_helper.cxx. -// done_bar() is implemented in C++ and will throw an exception. -// main() will catch the exception and verify that the cleanup -// routines for foo() and bar() were called by the personality -// function. -// +/* + * foo() is called by main() in gcc_personality_test_helper.cxx. + * done_bar() is implemented in C++ and will throw an exception. + * main() will catch the exception and verify that the cleanup + * routines for foo() and bar() were called by the personality + * function. + */ - -void bar() -{ +void bar() { int x __attribute__((cleanup(bar_clean))) = 0; register_bar_local(&x); done_bar(); } -void foo() -{ +void foo() { int x __attribute__((cleanup(foo_clean))) = 0; register_foo_local(&x); bar(); done_foo(); } - - Modified: compiler-rt/trunk/test/Unit/int_lib.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/Unit/int_lib.h?rev=84330&r1=84329&r2=84330&view=diff ============================================================================== --- compiler-rt/trunk/test/Unit/int_lib.h (original) +++ compiler-rt/trunk/test/Unit/int_lib.h Sat Oct 17 05:19:32 2009 @@ -45,7 +45,7 @@ si_int high; su_int low; #endif /* _YUGA_LITTLE_ENDIAN */ - }; + }s; } dwords; typedef union @@ -60,7 +60,7 @@ su_int high; su_int low; #endif /* _YUGA_LITTLE_ENDIAN */ - }; + }s; } udwords; #if __x86_64 @@ -80,7 +80,7 @@ di_int high; du_int low; #endif /* _YUGA_LITTLE_ENDIAN */ - }; + }s; } twords; typedef union @@ -95,7 +95,7 @@ du_int high; du_int low; #endif /* _YUGA_LITTLE_ENDIAN */ - }; + }s; } utwords; inline Modified: compiler-rt/trunk/test/Unit/modsi3_test.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/Unit/modsi3_test.c?rev=84330&r1=84329&r2=84330&view=diff ============================================================================== --- compiler-rt/trunk/test/Unit/modsi3_test.c (original) +++ compiler-rt/trunk/test/Unit/modsi3_test.c Sat Oct 17 05:19:32 2009 @@ -1,34 +1,33 @@ -//===-- modsi3_test.c - Test __modsi3 -------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file tests __modsi3 for the compiler_rt library. -// -//===----------------------------------------------------------------------===// +/* ===-- modsi3_test.c - Test __modsi3 -------------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file tests __modsi3 for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ #include "int_lib.h" #include -// Returns: a % b +/* Returns: a % b */ si_int __modsi3(si_int a, si_int b); -int test__modsi3(si_int a, si_int b, si_int expected) -{ +int test__modsi3(si_int a, si_int b, si_int expected) { si_int x = __modsi3(a, b); if (x != expected) - printf("error in __modsi3: %d %% %d = %d, expected %d\n", + fprintf(stderr, "error in __modsi3: %d %% %d = %d, expected %d\n", a, b, x, expected); return x != expected; } -int main() -{ +int main() { if (test__modsi3(0, 1, 0)) return 1; if (test__modsi3(0, -1, 0)) From clattner at apple.com Sat Oct 17 12:44:54 2009 From: clattner at apple.com (Chris Lattner) Date: Sat, 17 Oct 2009 10:44:54 -0700 Subject: [llvm-commits] [llvm] r84327 - /llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp In-Reply-To: <200910170933.n9H9XeSH030932@zion.cs.uiuc.edu> References: <200910170933.n9H9XeSH030932@zion.cs.uiuc.edu> Message-ID: On Oct 17, 2009, at 2:33 AM, Daniel Dunbar wrote: > Author: ddunbar > Date: Sat Oct 17 04:33:00 2009 > New Revision: 84327 > > URL: http://llvm.org/viewvc/llvm-project?rev=84327&view=rev > Log: > Suppress -Asserts warning. Despite the name, I think that AnalyzeBranch does mutate the code in some cases on some targets. Is this true? -Chris > > Modified: > llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp > > Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=84327&r1=84326&r2=84327&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) > +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Sat Oct 17 04:33:00 > 2009 > @@ -153,8 +153,8 @@ > > MachineBasicBlock *TBB = 0, *FBB = 0; > SmallVector Cond; > - bool B = TII->AnalyzeBranch(*MBB, TBB, FBB, Cond); > - assert(!B && "UpdateTerminators requires analyzable > predecessors!"); > + assert(!TII->AnalyzeBranch(*MBB, TBB, FBB, Cond) && > + "UpdateTerminators requires analyzable predecessors!"); > if (Cond.empty()) { > if (TBB) { > // The block has an unconditional branch. If its successor is > now > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From daniel at zuster.org Sat Oct 17 13:12:02 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 18:12:02 -0000 Subject: [llvm-commits] [llvm] r84336 - /llvm/trunk/lib/VMCore/Value.cpp Message-ID: <200910171812.n9HIC4Yu017053@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Oct 17 13:11:57 2009 New Revision: 84336 URL: http://llvm.org/viewvc/llvm-project?rev=84336&view=rev Log: Remove unnecessary include. Modified: llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=84336&r1=84335&r2=84336&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Sat Oct 17 13:11:57 2009 @@ -27,7 +27,6 @@ #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ValueHandle.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/System/RWMutex.h" #include "llvm/System/Threading.h" #include "llvm/ADT/DenseMap.h" From daniel at zuster.org Sat Oct 17 13:21:06 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 18:21:06 -0000 Subject: [llvm-commits] [llvm] r84344 - in /llvm/trunk: include/llvm/ADT/StringExtras.h lib/Support/StringMap.cpp Message-ID: <200910171821.n9HIL7Qj017485@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Oct 17 13:21:06 2009 New Revision: 84344 URL: http://llvm.org/viewvc/llvm-project?rev=84344&view=rev Log: Move StringMap's string has function into StringExtras.h Modified: llvm/trunk/include/llvm/ADT/StringExtras.h llvm/trunk/lib/Support/StringMap.cpp Modified: llvm/trunk/include/llvm/ADT/StringExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=84344&r1=84343&r2=84344&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringExtras.h (original) +++ llvm/trunk/include/llvm/ADT/StringExtras.h Sat Oct 17 13:21:06 2009 @@ -16,6 +16,7 @@ #include "llvm/Support/DataTypes.h" #include "llvm/ADT/APFloat.h" +#include "llvm/ADT/StringRef.h" #include #include #include @@ -225,6 +226,19 @@ /// doesn't satisfy std::isprint into an escape sequence. void EscapeString(std::string &Str); +/// HashString - Hash funtion for strings. +/// +/// This is the Bernstein hash function. +// +// FIXME: Investigate whether a modified bernstein hash function performs +// better: http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx +// X*33+c -> X*33^c +static inline unsigned HashString(StringRef Str, unsigned Result = 0) { + for (unsigned i = 0, e = Str.size(); i != e; ++i) + Result = Result * 33 + Str[i]; + return Result; +} + } // End llvm namespace #endif Modified: llvm/trunk/lib/Support/StringMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringMap.cpp?rev=84344&r1=84343&r2=84344&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringMap.cpp (original) +++ llvm/trunk/lib/Support/StringMap.cpp Sat Oct 17 13:21:06 2009 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringExtras.h" #include using namespace llvm; @@ -46,20 +47,6 @@ } -/// HashString - Compute a hash code for the specified string. -/// -static unsigned HashString(const char *Start, const char *End) { - // Bernstein hash function. - unsigned int Result = 0; - // TODO: investigate whether a modified bernstein hash function performs - // better: http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx - // X*33+c -> X*33^c - while (Start != End) - Result = Result * 33 + *Start++; - Result = Result + (Result >> 5); - return Result; -} - /// LookupBucketFor - Look up the bucket that the specified string should end /// up in. If it already exists as a key in the map, the Item pointer for the /// specified bucket will be non-null. Otherwise, it will be null. In either @@ -71,7 +58,7 @@ init(16); HTSize = NumBuckets; } - unsigned FullHashValue = HashString(Name.begin(), Name.end()); + unsigned FullHashValue = HashString(Name); unsigned BucketNo = FullHashValue & (HTSize-1); unsigned ProbeAmt = 1; @@ -126,7 +113,7 @@ int StringMapImpl::FindKey(const StringRef &Key) const { unsigned HTSize = NumBuckets; if (HTSize == 0) return -1; // Really empty table? - unsigned FullHashValue = HashString(Key.begin(), Key.end()); + unsigned FullHashValue = HashString(Key); unsigned BucketNo = FullHashValue & (HTSize-1); unsigned ProbeAmt = 1; From jyasskin at google.com Sat Oct 17 13:31:35 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Sat, 17 Oct 2009 11:31:35 -0700 Subject: [llvm-commits] [PATCH] Fix lit.py for gtest "typed tests" Message-ID: GTest has a kind of test whose names look like "ValueMapTest/0.Iteration": http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide#Typed_Tests. This broke lit.py, which os.path.join()ed the test name onto the test's path and assumed that it could recover the name as the second result of os.path.split. This patch shifts path components from the testPath to the testName until the testPath exists. -------------- next part -------------- A non-text attachment was scrubbed... Name: lit-fix-for-gtest.patch Type: application/octet-stream Size: 647 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091017/8a28cbd8/attachment.obj From nicholas at mxc.ca Sat Oct 17 14:43:47 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 17 Oct 2009 19:43:47 -0000 Subject: [llvm-commits] [llvm] r84348 - /llvm/trunk/lib/VMCore/Verifier.cpp Message-ID: <200910171943.n9HJhnbK020382@zion.cs.uiuc.edu> Author: nicholas Date: Sat Oct 17 14:43:45 2009 New Revision: 84348 URL: http://llvm.org/viewvc/llvm-project?rev=84348&view=rev Log: Emit newlines at the end of instructions too. Modified: llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=84348&r1=84347&r2=84348&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Sat Oct 17 14:43:45 2009 @@ -339,10 +339,10 @@ void WriteValue(const Value *V) { if (!V) return; if (isa(V)) { - MessagesStr << *V; + MessagesStr << *V << '\n'; } else { WriteAsOperand(MessagesStr, V, true, Mod); - MessagesStr << "\n"; + MessagesStr << '\n'; } } From foldr at codedgers.com Sat Oct 17 15:08:04 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Sat, 17 Oct 2009 20:08:04 -0000 Subject: [llvm-commits] [llvm] r84349 - /llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Message-ID: <200910172008.n9HK87Gn021240@zion.cs.uiuc.edu> Author: foldr Date: Sat Oct 17 15:07:49 2009 New Revision: 84349 URL: http://llvm.org/viewvc/llvm-project?rev=84349&view=rev Log: -O[0-3] options should be also forwarded to opt and llc. This will require implementing OptionPreprocessor to forbid invalid invocations such as 'llvmc -O1 -O2'. Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=84349&r1=84348&r2=84349&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original) +++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Sat Oct 17 15:07:49 2009 @@ -24,6 +24,14 @@ (help "Stop after checking the input for syntax errors")), (switch_option "opt", (help "Enable opt")), + (switch_option "O0", + (help "Turn off optimization")), + (switch_option "O1", + (help "Optimization level 1")), + (switch_option "O2", + (help "Optimization level 2")), + (switch_option "O3", + (help "Optimization level 3")), (switch_option "S", (help "Stop after compilation, do not assemble")), (switch_option "c", @@ -87,6 +95,9 @@ (not_empty "include"), (forward "include"), (not_empty "I"), (forward "I"), (not_empty "D"), (forward "D"), + (switch_on "O1"), (forward "O1"), + (switch_on "O2"), (forward "O2"), + (switch_on "O3"), (forward "O3"), (not_empty "MF"), (forward "MF"), (not_empty "MT"), (forward "MT"))), (sink) @@ -103,7 +114,10 @@ [(in_language "llvm-bitcode"), (out_language "llvm-bitcode"), (output_suffix "bc"), - (actions (case (not_empty "Wo,"), (unpack_values "Wo,"))), + (actions (case (not_empty "Wo,"), (unpack_values "Wo,"), + (switch_on "O1"), (forward "O1"), + (switch_on "O2"), (forward "O2"), + (switch_on "O3"), (forward "O3"))), (cmd_line "opt -f $INFILE -o $OUTFILE") ]>; @@ -132,6 +146,10 @@ (cmd_line "llc -f $INFILE -o $OUTFILE"), (actions (case (switch_on "S"), (stop_compilation), + (switch_on "O0"), (forward "O0"), + (switch_on "O1"), (forward "O1"), + (switch_on "O2"), (forward "O2"), + (switch_on "O3"), (forward "O3"), (not_empty "Wllc,"), (unpack_values "Wllc,"))) ]>; From foldr at codedgers.com Sat Oct 17 15:08:31 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Sat, 17 Oct 2009 20:08:31 -0000 Subject: [llvm-commits] [llvm] r84350 - in /llvm/trunk: test/LLVMC/MultiplePluginPriorities.td utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <200910172008.n9HK8Vxh021261@zion.cs.uiuc.edu> Author: foldr Date: Sat Oct 17 15:08:30 2009 New Revision: 84350 URL: http://llvm.org/viewvc/llvm-project?rev=84350&view=rev Log: Disallow multiple instances of PluginPriority. Several instances of PluginPriority in a single file most probably signifies a programming error. Added: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Added: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiplePluginPriorities.td?rev=84350&view=auto ============================================================================== --- llvm/trunk/test/LLVMC/MultiplePluginPriorities.td (added) +++ llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Sat Oct 17 15:08:30 2009 @@ -0,0 +1,10 @@ +// Check that multiple plugin priorities are not allowed. +// RUN: ignore tblgen -I %p/../../include --gen-llvmc %s |& grep "More than one 'PluginPriority' instance found" + +include "llvm/CompilerDriver/Common.td" + +def Graph : CompilationGraph<[]>; + +def Priority1 : PluginPriority<1>; + +def Priority2 : PluginPriority<2>; Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=84350&r1=84349&r2=84350&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Sat Oct 17 15:08:30 2009 @@ -775,11 +775,17 @@ /// CalculatePriority - Calculate the priority of this plugin. int CalculatePriority(RecordVector::const_iterator B, RecordVector::const_iterator E) { - int total = 0; - for (; B!=E; ++B) { - total += static_cast((*B)->getValueAsInt("priority")); + int priority = 0; + + if (B != E) { + priority = static_cast((*B)->getValueAsInt("priority")); + + if (++B != E) + throw std::string("More than one 'PluginPriority' instance found: " + "most probably an error!"); } - return total; + + return priority; } /// NotInGraph - Helper function object for FilterNotInGraph. From foldr at codedgers.com Sat Oct 17 15:08:47 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Sat, 17 Oct 2009 20:08:47 -0000 Subject: [llvm-commits] [llvm] r84351 - /llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.h Message-ID: <200910172008.n9HK8lnv021282@zion.cs.uiuc.edu> Author: foldr Date: Sat Oct 17 15:08:47 2009 New Revision: 84351 URL: http://llvm.org/viewvc/llvm-project?rev=84351&view=rev Log: This variable is never used. Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.h Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.h?rev=84351&r1=84350&r2=84351&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.h (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.h Sat Oct 17 15:08:47 2009 @@ -21,9 +21,8 @@ /// LLVMCConfigurationEmitter - TableGen backend that generates /// configuration code for LLVMC. class LLVMCConfigurationEmitter : public TableGenBackend { - RecordKeeper &Records; public: - explicit LLVMCConfigurationEmitter(RecordKeeper &R) : Records(R) {} + explicit LLVMCConfigurationEmitter(RecordKeeper&) {} // run - Output the asmwriter, returning true on failure. void run(raw_ostream &o); From foldr at codedgers.com Sat Oct 17 15:09:29 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Sat, 17 Oct 2009 20:09:29 -0000 Subject: [llvm-commits] [llvm] r84352 - in /llvm/trunk: include/llvm/CompilerDriver/Common.td include/llvm/CompilerDriver/Plugin.h lib/CompilerDriver/Main.cpp lib/CompilerDriver/Plugin.cpp tools/llvmc/plugins/Base/Base.td.in utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <200910172009.n9HK9UZB021318@zion.cs.uiuc.edu> Author: foldr Date: Sat Oct 17 15:09:29 2009 New Revision: 84352 URL: http://llvm.org/viewvc/llvm-project?rev=84352&view=rev Log: First draft of the OptionPreprocessor. More to follow... Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td llvm/trunk/include/llvm/CompilerDriver/Plugin.h llvm/trunk/lib/CompilerDriver/Main.cpp llvm/trunk/lib/CompilerDriver/Plugin.cpp llvm/trunk/tools/llvmc/plugins/Base/Base.td.in llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Common.td?rev=84352&r1=84351&r2=84352&view=diff ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/Common.td (original) +++ llvm/trunk/include/llvm/CompilerDriver/Common.td Sat Oct 17 15:09:29 2009 @@ -68,6 +68,8 @@ def default; def single_input_file; def multiple_input_files; +def any_switch_on; +def any_not_empty; // Possible actions. @@ -76,7 +78,9 @@ def forward_as; def stop_compilation; def unpack_values; +def warning; def error; +def unset_option; // Increase/decrease the edge weight. def inc_weight; @@ -90,11 +94,16 @@ int priority = p; } -// Option list - used to specify aliases and sometimes help strings. +// Option list - a single place to specify options. class OptionList l> { list options = l; } +// Option preprocessor - actions taken during plugin loading. +class OptionPreprocessor { + dag preprocessor = d; +} + // Map from suffixes to language names class LangToSuffixes lst> { Modified: llvm/trunk/include/llvm/CompilerDriver/Plugin.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Plugin.h?rev=84352&r1=84351&r2=84352&view=diff ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/Plugin.h (original) +++ llvm/trunk/include/llvm/CompilerDriver/Plugin.h Sat Oct 17 15:09:29 2009 @@ -29,6 +29,11 @@ /// first. virtual int Priority() const { return 0; } + /// PreprocessOptions - The auto-generated function that performs various + /// consistency checks on options (like ensuring that -O2 and -O3 are not + /// used together). + virtual void PreprocessOptions() const = 0; + /// PopulateLanguageMap - The auto-generated function that fills in /// the language map (map from file extensions to language names). virtual void PopulateLanguageMap(LanguageMap&) const = 0; @@ -60,13 +65,10 @@ PluginLoader(); ~PluginLoader(); - /// PopulateLanguageMap - Fills in the language map by calling - /// PopulateLanguageMap methods of all plugins. - void PopulateLanguageMap(LanguageMap& langMap); - - /// PopulateCompilationGraph - Populates the compilation graph by - /// calling PopulateCompilationGraph methods of all plugins. - void PopulateCompilationGraph(CompilationGraph& tools); + /// RunInitialization - Calls PreprocessOptions, PopulateLanguageMap and + /// PopulateCompilationGraph methods of all plugins. This populates the + /// global language map and the compilation graph. + void RunInitialization(LanguageMap& langMap, CompilationGraph& graph) const; private: // noncopyable Modified: llvm/trunk/lib/CompilerDriver/Main.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Main.cpp?rev=84352&r1=84351&r2=84352&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/Main.cpp (original) +++ llvm/trunk/lib/CompilerDriver/Main.cpp Sat Oct 17 15:09:29 2009 @@ -95,8 +95,7 @@ (argc, argv, "LLVM Compiler Driver (Work In Progress)", true); PluginLoader Plugins; - Plugins.PopulateLanguageMap(langMap); - Plugins.PopulateCompilationGraph(graph); + Plugins.RunInitialization(langMap, graph); if (CheckGraph) { int ret = graph.Check(); Modified: llvm/trunk/lib/CompilerDriver/Plugin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Plugin.cpp?rev=84352&r1=84351&r2=84352&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/Plugin.cpp (original) +++ llvm/trunk/lib/CompilerDriver/Plugin.cpp Sat Oct 17 15:09:29 2009 @@ -62,18 +62,17 @@ pluginListInitialized = false; } - void PluginLoader::PopulateLanguageMap(LanguageMap& langMap) { + void PluginLoader::RunInitialization(LanguageMap& langMap, + CompilationGraph& graph) const + { llvm::sys::SmartScopedLock Lock(*PluginMutex); for (PluginList::iterator B = Plugins.begin(), E = Plugins.end(); - B != E; ++B) - (*B)->PopulateLanguageMap(langMap); - } - - void PluginLoader::PopulateCompilationGraph(CompilationGraph& graph) { - llvm::sys::SmartScopedLock Lock(*PluginMutex); - for (PluginList::iterator B = Plugins.begin(), E = Plugins.end(); - B != E; ++B) - (*B)->PopulateCompilationGraph(graph); + B != E; ++B) { + const BasePlugin* BP = *B; + BP->PreprocessOptions(); + BP->PopulateLanguageMap(langMap); + BP->PopulateCompilationGraph(graph); + } } } Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=84352&r1=84351&r2=84352&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original) +++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Sat Oct 17 15:09:29 2009 @@ -65,6 +65,18 @@ (help "Pass options to opt")) ]>; +// Option preprocessor. + +def Preprocess : OptionPreprocessor< +(case (and (switch_on "O3"), (any_switch_on ["O0", "O1", "O2"])), + (unset_option ["O0", "O1", "O2"]), + (and (switch_on "O2"), (any_switch_on ["O0", "O1"])), + (unset_option ["O0", "O1"]), + (and (switch_on "O1"), (switch_on "O0")), + (unset_option "O0")) +>; + + // Tools class llvm_gcc_based : Tool< Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=84352&r1=84351&r2=84352&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Sat Oct 17 15:09:29 2009 @@ -351,6 +351,9 @@ public: /// FindOption - exception-throwing wrapper for find(). const OptionDescription& FindOption(const std::string& OptName) const; + /// FindSwitch - wrapper for FindOption that throws in case the option is not + /// a switch. + const OptionDescription& FindSwitch(const std::string& OptName) const; /// insertDescription - Insert new OptionDescription into /// OptionDescriptions list @@ -372,6 +375,15 @@ throw OptName + ": no such option!"; } +const OptionDescription& +OptionDescriptions::FindSwitch(const std::string& OptName) const +{ + const OptionDescription& OptDesc = this->FindOption(OptName); + if (!OptDesc.isSwitch()) + throw OptName + ": incorrect option type - should be a switch!"; + return OptDesc; +} + void OptionDescriptions::InsertDescription (const OptionDescription& o) { container_type::iterator I = Descriptions.find(o.Name); @@ -996,32 +1008,31 @@ return false; } - -/// EmitCaseTest1Arg - Helper function used by EmitCaseConstructHandler(). -bool EmitCaseTest1Arg(const std::string& TestName, - const DagInit& d, - const OptionDescriptions& OptDescs, - raw_ostream& O) { - checkNumberOfArguments(&d, 1); +/// EmitCaseTest1ArgStr - Helper function used by EmitCaseTest1Arg(); +bool EmitCaseTest1ArgStr(const std::string& TestName, + const DagInit& d, + const OptionDescriptions& OptDescs, + raw_ostream& O) { const std::string& OptName = InitPtrToString(d.getArg(0)); if (TestName == "switch_on") { - const OptionDescription& OptDesc = OptDescs.FindOption(OptName); - if (!OptDesc.isSwitch()) - throw OptName + ": incorrect option type - should be a switch!"; + const OptionDescription& OptDesc = OptDescs.FindSwitch(OptName); O << OptDesc.GenVariableName(); return true; - } else if (TestName == "input_languages_contain") { + } + else if (TestName == "input_languages_contain") { O << "InLangs.count(\"" << OptName << "\") != 0"; return true; - } else if (TestName == "in_language") { + } + else if (TestName == "in_language") { // This works only for single-argument Tool::GenerateAction. Join // tools can process several files in different languages simultaneously. // TODO: make this work with Edge::Weight (if possible). O << "LangMap.GetLanguage(inFile) == \"" << OptName << '\"'; return true; - } else if (TestName == "not_empty" || TestName == "empty") { + } + else if (TestName == "not_empty" || TestName == "empty") { const char* Test = (TestName == "empty") ? "" : "!"; if (OptName == "o") { @@ -1041,6 +1052,47 @@ return false; } +/// EmitCaseTest1ArgList - Helper function used by EmitCaseTest1Arg(); +bool EmitCaseTest1ArgList(const std::string& TestName, + const DagInit& d, + const OptionDescriptions& OptDescs, + raw_ostream& O) { + const ListInit& L = *static_cast(d.getArg(0)); + + if (TestName == "any_switch_on") { + bool isFirst = true; + + for (ListInit::const_iterator B = L.begin(), E = L.end(); B != E; ++B) { + const std::string& OptName = InitPtrToString(*B); + const OptionDescription& OptDesc = OptDescs.FindSwitch(OptName); + + if (isFirst) + isFirst = false; + else + O << " || "; + O << OptDesc.GenVariableName(); + } + + return true; + } + + // TODO: implement any_not_empty, any_empty, switch_on [..], empty [..] + + return false; +} + +/// EmitCaseTest1Arg - Helper function used by EmitCaseConstructHandler(); +bool EmitCaseTest1Arg(const std::string& TestName, + const DagInit& d, + const OptionDescriptions& OptDescs, + raw_ostream& O) { + checkNumberOfArguments(&d, 1); + if (typeid(*d.getArg(0)) == typeid(ListInit)) + return EmitCaseTest1ArgList(TestName, d, OptDescs, O); + else + return EmitCaseTest1ArgStr(TestName, d, OptDescs, O); +} + /// EmitCaseTest2Args - Helper function used by EmitCaseConstructHandler(). bool EmitCaseTest2Args(const std::string& TestName, const DagInit& d, @@ -1130,10 +1182,14 @@ throw TestName + ": unknown edge property!"; } -// Emit code that handles the 'case' construct. -// Takes a function object that should emit code for every case clause. -// Callback's type is -// void F(Init* Statement, unsigned IndentLevel, raw_ostream& O). +/// EmitCaseConstructHandler - Emit code that handles the 'case' +/// construct. Takes a function object that should emit code for every case +/// clause. +/// Callback's type is void F(Init* Statement, unsigned IndentLevel, +/// raw_ostream& O). +/// EmitElseIf parameter controls the type of condition that is emitted ('if +/// (..) {...} else if (...) {} ... else {...}' vs. 'if (..) {...} if(...) +/// {...} ...'). template void EmitCaseConstructHandler(const Init* Dag, unsigned IndentLevel, F Callback, bool EmitElseIf, @@ -1876,10 +1932,108 @@ O << '\n'; } -/// EmitPopulateLanguageMap - Emit the PopulateLanguageMap() function. +/// PreprocessOptionsCallback - Helper function passed to +/// EmitCaseConstructHandler() by EmitPreprocessOptions(). +class PreprocessOptionsCallback { + const OptionDescriptions& OptDescs_; + + void onUnsetOption(Init* i, unsigned IndentLevel, raw_ostream& O) { + const std::string& OptName = InitPtrToString(i); + const OptionDescription& OptDesc = OptDescs_.FindOption(OptName); + const OptionType::OptionType OptType = OptDesc.Type; + + if (OptType == OptionType::Switch) { + O.indent(IndentLevel) << OptDesc.GenVariableName() << " = false;\n"; + } + else if (OptType == OptionType::Parameter + || OptType == OptionType::Prefix) { + O.indent(IndentLevel) << OptDesc.GenVariableName() << " = \"\";\n"; + } + else { + throw std::string("'unset_option' can only be applied to " + "switches or parameter/prefix options."); + } + } + + void processDag(const Init* I, unsigned IndentLevel, raw_ostream& O) + { + const DagInit& d = InitPtrToDag(I); + const std::string& OpName = d.getOperator()->getAsString(); + + // TOFIX: there is some duplication between this function and + // EmitActionHandler. + if (OpName == "warning") { + checkNumberOfArguments(&d, 1); + O.indent(IndentLevel) << "llvm::errs() << \"" + << InitPtrToString(d.getArg(0)) << "\";\n"; + } + else if (OpName == "error") { + checkNumberOfArguments(&d, 1); + O.indent(IndentLevel) << "throw std::runtime_error(\"" + << InitPtrToString(d.getArg(0)) + << "\");\n"; + } + else if (OpName == "unset_option") { + checkNumberOfArguments(&d, 1); + Init* I = d.getArg(0); + if (typeid(*I) == typeid(ListInit)) { + const ListInit& DagList = *static_cast(I); + for (ListInit::const_iterator B = DagList.begin(), E = DagList.end(); + B != E; ++B) + this->onUnsetOption(*B, IndentLevel, O); + } + else { + this->onUnsetOption(I, IndentLevel, O); + } + } + else { + throw "Unknown operator in the option preprocessor: '" + OpName + "'!" + "\nOnly 'warning', 'error' and 'unset_option' are allowed."; + } + } + +public: + + // TODO: Remove duplication. + void operator()(const Init* I, unsigned IndentLevel, raw_ostream& O) { + if (typeid(*I) == typeid(ListInit)) { + const ListInit& DagList = *static_cast(I); + for (ListInit::const_iterator B = DagList.begin(), E = DagList.end(); + B != E; ++B) + this->processDag(*B, IndentLevel, O); + } + else { + this->processDag(I, IndentLevel, O); + } + } + + PreprocessOptionsCallback(const OptionDescriptions& OptDescs) + : OptDescs_(OptDescs) + {} +}; + +/// EmitPreprocessOptions - Emit the PreprocessOptionsLocal() function. +void EmitPreprocessOptions (const RecordKeeper& Records, + const OptionDescriptions& OptDecs, raw_ostream& O) +{ + O << "void PreprocessOptionsLocal() {\n"; + + const RecordVector& OptionPreprocessors = + Records.getAllDerivedDefinitions("OptionPreprocessor"); + + for (RecordVector::const_iterator B = OptionPreprocessors.begin(), + E = OptionPreprocessors.end(); B!=E; ++B) { + DagInit* Case = (*B)->getValueAsDag("preprocessor"); + EmitCaseConstructHandler(Case, Indent1, PreprocessOptionsCallback(OptDecs), + false, OptDecs, O); + } + + O << "}\n\n"; +} + +/// EmitPopulateLanguageMap - Emit the PopulateLanguageMapLocal() function. void EmitPopulateLanguageMap (const RecordKeeper& Records, raw_ostream& O) { - // Generate code O << "void PopulateLanguageMapLocal(LanguageMap& langMap) {\n"; // Get the relevant field out of RecordKeeper @@ -1922,17 +2076,16 @@ O.indent(IndentLevel) << "ret -= "; } else if (OpName == "error") { - O.indent(IndentLevel) - << "throw std::runtime_error(\"" << - (d.getNumArgs() >= 1 ? InitPtrToString(d.getArg(0)) - : "Unknown error!") - << "\");\n"; + checkNumberOfArguments(&d, 1); + O.indent(IndentLevel) << "throw std::runtime_error(\"" + << InitPtrToString(d.getArg(0)) + << "\");\n"; return; } - - else - throw "Unknown operator in edge properties list: " + OpName + '!' + + else { + throw "Unknown operator in edge properties list: '" + OpName + "'!" "\nOnly 'inc_weight', 'dec_weight' and 'error' are allowed."; + } if (d.getNumArgs() > 0) O << InitPtrToInt(d.getArg(0)) << ";\n"; @@ -1981,7 +2134,7 @@ } } -/// EmitPopulateCompilationGraph - Emit the PopulateCompilationGraph() +/// EmitPopulateCompilationGraph - Emit the PopulateCompilationGraphLocal() /// function. void EmitPopulateCompilationGraph (const RecordVector& EdgeVector, const ToolDescriptions& ToolDescs, @@ -2110,6 +2263,8 @@ O << "struct Plugin : public llvmc::BasePlugin {\n\n"; O.indent(Indent1) << "int Priority() const { return " << Priority << "; }\n\n"; + O.indent(Indent1) << "void PreprocessOptions() const\n"; + O.indent(Indent1) << "{ PreprocessOptionsLocal(); }\n\n"; O.indent(Indent1) << "void PopulateLanguageMap(LanguageMap& langMap) const\n"; O.indent(Indent1) << "{ PopulateLanguageMapLocal(langMap); }\n\n"; O.indent(Indent1) @@ -2129,7 +2284,8 @@ << "#include \"llvm/CompilerDriver/Tool.h\"\n\n" << "#include \"llvm/ADT/StringExtras.h\"\n" - << "#include \"llvm/Support/CommandLine.h\"\n\n" + << "#include \"llvm/Support/CommandLine.h\"\n" + << "#include \"llvm/Support/raw_ostream.h\"\n\n" << "#include \n" << "#include \n\n" @@ -2229,8 +2385,11 @@ O << "namespace {\n\n"; - // Emit PopulateLanguageMap() function - // (a language map maps from file extensions to language names). + // Emit PreprocessOptionsLocal() function. + EmitPreprocessOptions(Records, Data.OptDescs, O); + + // Emit PopulateLanguageMapLocal() function + // (language map maps from file extensions to language names). EmitPopulateLanguageMap(Records, O); // Emit Tool classes. @@ -2241,7 +2400,7 @@ // Emit Edge# classes. EmitEdgeClasses(Data.Edges, Data.OptDescs, O); - // Emit PopulateCompilationGraph() function. + // Emit PopulateCompilationGraphLocal() function. EmitPopulateCompilationGraph(Data.Edges, Data.ToolDescs, O); // Emit code for plugin registration. From daniel at zuster.org Sat Oct 17 15:43:09 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 20:43:09 -0000 Subject: [llvm-commits] [llvm] r84355 - in /llvm/trunk: include/llvm/Support/raw_ostream.h lib/Support/raw_ostream.cpp unittests/Support/raw_ostream_test.cpp Message-ID: <200910172043.n9HKh9O1022980@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Oct 17 15:43:08 2009 New Revision: 84355 URL: http://llvm.org/viewvc/llvm-project?rev=84355&view=rev Log: Add raw_ostream::write_escaped, for writing escaped strings. Modified: llvm/trunk/include/llvm/Support/raw_ostream.h llvm/trunk/lib/Support/raw_ostream.cpp llvm/trunk/unittests/Support/raw_ostream_test.cpp Modified: llvm/trunk/include/llvm/Support/raw_ostream.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=84355&r1=84354&r2=84355&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/raw_ostream.h (original) +++ llvm/trunk/include/llvm/Support/raw_ostream.h Sat Oct 17 15:43:08 2009 @@ -216,6 +216,10 @@ /// write_hex - Output \arg N in hexadecimal, without any prefix or padding. raw_ostream &write_hex(unsigned long long N); + /// write_escaped - Output \arg Str, turning '\\', '\t', '\n', '"', and + /// anything that doesn't satisfy std::isprint into an escape sequence. + raw_ostream &write_escaped(StringRef Str); + raw_ostream &write(unsigned char C); raw_ostream &write(const char *Ptr, size_t Size); Modified: llvm/trunk/lib/Support/raw_ostream.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=84355&r1=84354&r2=84355&view=diff ============================================================================== --- llvm/trunk/lib/Support/raw_ostream.cpp (original) +++ llvm/trunk/lib/Support/raw_ostream.cpp Sat Oct 17 15:43:08 2009 @@ -168,6 +168,40 @@ return write(CurPtr, EndPtr-CurPtr); } +raw_ostream &raw_ostream::write_escaped(StringRef Str) { + for (unsigned i = 0, e = Str.size(); i != e; ++i) { + unsigned char c = Str[i]; + + switch (c) { + case '\\': + *this << '\\' << '\\'; + break; + case '\t': + *this << '\\' << 't'; + break; + case '\n': + *this << '\\' << 'n'; + break; + case '"': + *this << '\\' << '"'; + break; + default: + if (std::isprint(c)) { + *this << c; + break; + } + + // Always expand to a 3-character octal escape. + *this << '\\'; + *this << char('0' + ((c >> 6) & 7)); + *this << char('0' + ((c >> 3) & 7)); + *this << char('0' + ((c >> 0) & 7)); + } + } + + return *this; +} + raw_ostream &raw_ostream::operator<<(const void *P) { *this << '0' << 'x'; Modified: llvm/trunk/unittests/Support/raw_ostream_test.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/raw_ostream_test.cpp?rev=84355&r1=84354&r2=84355&view=diff ============================================================================== --- llvm/trunk/unittests/Support/raw_ostream_test.cpp (original) +++ llvm/trunk/unittests/Support/raw_ostream_test.cpp Sat Oct 17 15:43:08 2009 @@ -127,4 +127,20 @@ EXPECT_EQ("hello1world", OS.str()); } +TEST(raw_ostreamTest, WriteEscaped) { + std::string Str; + + Str = ""; + raw_string_ostream(Str).write_escaped("hi"); + EXPECT_EQ("hi", Str); + + Str = ""; + raw_string_ostream(Str).write_escaped("\\\t\n\""); + EXPECT_EQ("\\\\\\t\\n\\\"", Str); + + Str = ""; + raw_string_ostream(Str).write_escaped("\1\10\200"); + EXPECT_EQ("\\001\\010\\200", Str); +} + } From daniel at zuster.org Sat Oct 17 15:43:19 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 20:43:19 -0000 Subject: [llvm-commits] [llvm] r84356 - in /llvm/trunk: lib/Transforms/Hello/Hello.cpp utils/TableGen/ClangDiagnosticsEmitter.cpp utils/TableGen/StringToOffsetTable.h Message-ID: <200910172043.n9HKhJSQ022996@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Oct 17 15:43:19 2009 New Revision: 84356 URL: http://llvm.org/viewvc/llvm-project?rev=84356&view=rev Log: Use raw_ostream::write_escaped instead of EscapeString. Modified: llvm/trunk/lib/Transforms/Hello/Hello.cpp llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp llvm/trunk/utils/TableGen/StringToOffsetTable.h Modified: llvm/trunk/lib/Transforms/Hello/Hello.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Hello/Hello.cpp?rev=84356&r1=84355&r2=84356&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Hello/Hello.cpp (original) +++ llvm/trunk/lib/Transforms/Hello/Hello.cpp Sat Oct 17 15:43:19 2009 @@ -30,9 +30,8 @@ virtual bool runOnFunction(Function &F) { HelloCounter++; - std::string fname = F.getName(); - EscapeString(fname); - errs() << "Hello: " << fname << "\n"; + errs() << "Hello: "; + errs().write_escaped(F.getName()) << '\n'; return false; } }; @@ -49,9 +48,8 @@ virtual bool runOnFunction(Function &F) { HelloCounter++; - std::string fname = F.getName(); - EscapeString(fname); - errs() << "Hello: " << fname << "\n"; + errs() << "Hello: "; + errs().write_escaped(F.getName()) << '\n'; return false; } Modified: llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=84356&r1=84355&r2=84356&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Sat Oct 17 15:43:19 2009 @@ -52,15 +52,12 @@ // Description string. OS << ", \""; - std::string S = R.getValueAsString("Text"); - EscapeString(S); - OS << S << "\""; + OS.write_escaped(R.getValueAsString("Text")) << '"'; // Warning associated with the diagnostic. if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) { - S = DI->getDef()->getValueAsString("GroupName"); - EscapeString(S); - OS << ", \"" << S << "\""; + OS << ", \""; + OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"'; } else { OS << ", 0"; } @@ -151,11 +148,10 @@ OS << "\n#ifdef GET_DIAG_TABLE\n"; for (std::map::iterator I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I) { - std::string S = I->first; - EscapeString(S); // Group option string. - OS << " { \"" << S << "\"," - << std::string(MaxLen-I->first.size()+1, ' '); + OS << " { \""; + OS.write_escaped(I->first) << "\"," + << std::string(MaxLen-I->first.size()+1, ' '); // Diagnostics in the group. if (I->second.DiagsInGroup.empty()) Modified: llvm/trunk/utils/TableGen/StringToOffsetTable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/StringToOffsetTable.h?rev=84356&r1=84355&r2=84356&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/StringToOffsetTable.h (original) +++ llvm/trunk/utils/TableGen/StringToOffsetTable.h Sat Oct 17 15:43:19 2009 @@ -10,9 +10,10 @@ #ifndef TBLGEN_STRING_TO_OFFSET_TABLE_H #define TBLGEN_STRING_TO_OFFSET_TABLE_H +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/raw_ostream.h" namespace llvm { @@ -38,9 +39,13 @@ } void EmitString(raw_ostream &O) { + // Escape the string. + SmallString<256> Str; + raw_svector_ostream(Str).write_escaped(AggregateString); + AggregateString = Str.str(); + O << " \""; unsigned CharsPrinted = 0; - EscapeString(AggregateString); for (unsigned i = 0, e = AggregateString.size(); i != e; ++i) { if (CharsPrinted > 70) { O << "\"\n \""; From daniel at zuster.org Sat Oct 17 15:43:29 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 20:43:29 -0000 Subject: [llvm-commits] [llvm] r84357 - in /llvm/trunk: include/llvm/ADT/StringExtras.h lib/Support/StringExtras.cpp Message-ID: <200910172043.n9HKhTZu023019@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Oct 17 15:43:29 2009 New Revision: 84357 URL: http://llvm.org/viewvc/llvm-project?rev=84357&view=rev Log: Remove llvm::EscapeString, raw_ostream::write_escaped is much faster. Modified: llvm/trunk/include/llvm/ADT/StringExtras.h llvm/trunk/lib/Support/StringExtras.cpp Modified: llvm/trunk/include/llvm/ADT/StringExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=84357&r1=84356&r2=84357&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringExtras.h (original) +++ llvm/trunk/include/llvm/ADT/StringExtras.h Sat Oct 17 15:43:29 2009 @@ -222,10 +222,6 @@ /// \num (where num is a 1-3 byte octal value). void UnescapeString(std::string &Str); -/// EscapeString - Modify the argument string, turning '\\' and anything that -/// doesn't satisfy std::isprint into an escape sequence. -void EscapeString(std::string &Str); - /// HashString - Hash funtion for strings. /// /// This is the Bernstein hash function. Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=84357&r1=84356&r2=84357&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Sat Oct 17 15:43:29 2009 @@ -86,29 +86,3 @@ } } } - -/// EscapeString - Modify the argument string, turning '\\' and anything that -/// doesn't satisfy std::isprint into an escape sequence. -void llvm::EscapeString(std::string &Str) { - for (unsigned i = 0; i != Str.size(); ++i) { - if (Str[i] == '\\') { - ++i; - Str.insert(Str.begin()+i, '\\'); - } else if (Str[i] == '\t') { - Str[i++] = '\\'; - Str.insert(Str.begin()+i, 't'); - } else if (Str[i] == '"') { - Str.insert(Str.begin()+i++, '\\'); - } else if (Str[i] == '\n') { - Str[i++] = '\\'; - Str.insert(Str.begin()+i, 'n'); - } else if (!std::isprint(Str[i])) { - // Always expand to a 3-digit octal escape. - unsigned Char = Str[i]; - Str[i++] = '\\'; - Str.insert(Str.begin()+i++, '0'+((Char/64) & 7)); - Str.insert(Str.begin()+i++, '0'+((Char/8) & 7)); - Str.insert(Str.begin()+i , '0'+( Char & 7)); - } - } -} From daniel at zuster.org Sat Oct 17 15:43:42 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 20:43:42 -0000 Subject: [llvm-commits] [llvm] r84358 - in /llvm/trunk: include/llvm/ADT/StringExtras.h lib/Support/StringExtras.cpp utils/TableGen/AsmWriterEmitter.cpp Message-ID: <200910172043.n9HKhgL4023038@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Oct 17 15:43:42 2009 New Revision: 84358 URL: http://llvm.org/viewvc/llvm-project?rev=84358&view=rev Log: Move UnescapeString to a static function for its sole client; its inefficient and broken. Modified: llvm/trunk/include/llvm/ADT/StringExtras.h llvm/trunk/lib/Support/StringExtras.cpp llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Modified: llvm/trunk/include/llvm/ADT/StringExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringExtras.h?rev=84358&r1=84357&r2=84358&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringExtras.h (original) +++ llvm/trunk/include/llvm/ADT/StringExtras.h Sat Oct 17 15:43:42 2009 @@ -217,11 +217,6 @@ std::vector &OutFragments, const char *Delimiters = " \t\n\v\f\r"); -/// UnescapeString - Modify the argument string, turning two character sequences -/// like '\\' 'n' into '\n'. This handles: \e \a \b \f \n \r \t \v \' \\ and -/// \num (where num is a 1-3 byte octal value). -void UnescapeString(std::string &Str); - /// HashString - Hash funtion for strings. /// /// This is the Bernstein hash function. Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=84358&r1=84357&r2=84358&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Sat Oct 17 15:43:42 2009 @@ -56,33 +56,3 @@ S2 = getToken(S, Delimiters); } } - - - -/// UnescapeString - Modify the argument string, turning two character sequences -/// @verbatim -/// like '\\' 'n' into '\n'. This handles: \e \a \b \f \n \r \t \v \' \ and -/// \num (where num is a 1-3 byte octal value). -/// @endverbatim -void llvm::UnescapeString(std::string &Str) { - for (unsigned i = 0; i != Str.size(); ++i) { - if (Str[i] == '\\' && i != Str.size()-1) { - switch (Str[i+1]) { - default: continue; // Don't execute the code after the switch. - case 'a': Str[i] = '\a'; break; - case 'b': Str[i] = '\b'; break; - case 'e': Str[i] = 27; break; - case 'f': Str[i] = '\f'; break; - case 'n': Str[i] = '\n'; break; - case 'r': Str[i] = '\r'; break; - case 't': Str[i] = '\t'; break; - case 'v': Str[i] = '\v'; break; - case '"': Str[i] = '\"'; break; - case '\'': Str[i] = '\''; break; - case '\\': Str[i] = '\\'; break; - } - // Nuke the second character. - Str.erase(Str.begin()+i+1); - } - } -} Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=84358&r1=84357&r2=84358&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Sat Oct 17 15:43:42 2009 @@ -538,6 +538,29 @@ } +static void UnescapeString(std::string &Str) { + for (unsigned i = 0; i != Str.size(); ++i) { + if (Str[i] == '\\' && i != Str.size()-1) { + switch (Str[i+1]) { + default: continue; // Don't execute the code after the switch. + case 'a': Str[i] = '\a'; break; + case 'b': Str[i] = '\b'; break; + case 'e': Str[i] = 27; break; + case 'f': Str[i] = '\f'; break; + case 'n': Str[i] = '\n'; break; + case 'r': Str[i] = '\r'; break; + case 't': Str[i] = '\t'; break; + case 'v': Str[i] = '\v'; break; + case '"': Str[i] = '\"'; break; + case '\'': Str[i] = '\''; break; + case '\\': Str[i] = '\\'; break; + } + // Nuke the second character. + Str.erase(Str.begin()+i+1); + } + } +} + /// EmitPrintInstruction - Generate the code for the "printInstruction" method /// implementation. void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) { From sabre at nondot.org Sat Oct 17 16:31:19 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 17 Oct 2009 21:31:19 -0000 Subject: [llvm-commits] [llvm] r84364 - in /llvm/trunk/test/Transforms/ConstProp: 2009-09-19-ConstFold-i1-ConstExpr.ll constant-expr.ll Message-ID: <200910172131.n9HLVKQG024652@zion.cs.uiuc.edu> Author: lattner Date: Sat Oct 17 16:31:19 2009 New Revision: 84364 URL: http://llvm.org/viewvc/llvm-project?rev=84364&view=rev Log: rename test Added: llvm/trunk/test/Transforms/ConstProp/constant-expr.ll - copied unchanged from r84352, llvm/trunk/test/Transforms/ConstProp/2009-09-19-ConstFold-i1-ConstExpr.ll Removed: llvm/trunk/test/Transforms/ConstProp/2009-09-19-ConstFold-i1-ConstExpr.ll Removed: llvm/trunk/test/Transforms/ConstProp/2009-09-19-ConstFold-i1-ConstExpr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/2009-09-19-ConstFold-i1-ConstExpr.ll?rev=84363&view=auto ============================================================================== --- llvm/trunk/test/Transforms/ConstProp/2009-09-19-ConstFold-i1-ConstExpr.ll (original) +++ llvm/trunk/test/Transforms/ConstProp/2009-09-19-ConstFold-i1-ConstExpr.ll (removed) @@ -1,41 +0,0 @@ -; RUN: llvm-as < %s | llvm-dis | FileCheck %s - - at X = external global i8 - at Y = external global i8 - at Z = external global i8 - - at A = global i1 add (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @A = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) ; [#uses=0] - at B = global i1 sub (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @B = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) ; [#uses=0] - at C = global i1 mul (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @C = global i1 and (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) ; [#uses=0] - - at D = global i1 sdiv (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @D = global i1 icmp ult (i8* @X, i8* @Y) ; [#uses=0] - at E = global i1 udiv (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @E = global i1 icmp ult (i8* @X, i8* @Y) ; [#uses=0] - at F = global i1 srem (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @F = global i1 false ; [#uses=0] - at G = global i1 urem (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @G = global i1 false ; [#uses=0] - - at H = global i1 icmp ule (i32* bitcast (i8* @X to i32*), i32* bitcast (i8* @Y to i32*)) -; CHECK: @H = global i1 icmp ule (i8* @X, i8* @Y) ; [#uses=0] - - at I = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 false) -; CHECK: @I = global i1 icmp ult (i8* @X, i8* @Y) ; [#uses=0] - at J = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 true) -; CHECK: @J = global i1 icmp uge (i8* @X, i8* @Y) ; [#uses=0] - - at K = global i1 icmp eq (i1 icmp ult (i8* @X, i8* @Y), i1 false) -; CHECK: @K = global i1 icmp uge (i8* @X, i8* @Y) ; [#uses=0] - at L = global i1 icmp eq (i1 icmp ult (i8* @X, i8* @Y), i1 true) -; CHECK: @L = global i1 icmp ult (i8* @X, i8* @Y) ; [#uses=0] - at M = global i1 icmp ne (i1 icmp ult (i8* @X, i8* @Y), i1 true) -; CHECK: @M = global i1 icmp uge (i8* @X, i8* @Y) ; [#uses=0] - at N = global i1 icmp ne (i1 icmp ult (i8* @X, i8* @Y), i1 false) -; CHECK: @N = global i1 icmp ult (i8* @X, i8* @Y) ; [#uses=0] - - at O = global i1 icmp eq (i32 zext (i1 icmp ult (i8* @X, i8* @Y) to i32), i32 0) -; CHECK: @O = global i1 icmp uge (i8* @X, i8* @Y) ; [#uses=0] From sabre at nondot.org Sat Oct 17 16:51:20 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 17 Oct 2009 21:51:20 -0000 Subject: [llvm-commits] [llvm] r84367 - /llvm/trunk/test/Transforms/ConstProp/constant-expr.ll Message-ID: <200910172151.n9HLpKPV025385@zion.cs.uiuc.edu> Author: lattner Date: Sat Oct 17 16:51:19 2009 New Revision: 84367 URL: http://llvm.org/viewvc/llvm-project?rev=84367&view=rev Log: remove # uses from FileCheck lines. Modified: llvm/trunk/test/Transforms/ConstProp/constant-expr.ll Modified: llvm/trunk/test/Transforms/ConstProp/constant-expr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/constant-expr.ll?rev=84367&r1=84366&r2=84367&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ConstProp/constant-expr.ll (original) +++ llvm/trunk/test/Transforms/ConstProp/constant-expr.ll Sat Oct 17 16:51:19 2009 @@ -5,37 +5,38 @@ @Z = external global i8 @A = global i1 add (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @A = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) ; [#uses=0] - at B = global i1 sub (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @B = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) ; [#uses=0] +; CHECK: @A = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) + at B = global i1 sub (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)), align 2 +; CHECK: @B = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) @C = global i1 mul (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @C = global i1 and (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) ; [#uses=0] +; CHECK: @C = global i1 and (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) @D = global i1 sdiv (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @D = global i1 icmp ult (i8* @X, i8* @Y) ; [#uses=0] +; CHECK: @D = global i1 icmp ult (i8* @X, i8* @Y) @E = global i1 udiv (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) -; CHECK: @E = global i1 icmp ult (i8* @X, i8* @Y) ; [#uses=0] +; CHECK: @E = global i1 icmp ult (i8* @X, i8* @Y) @F = global i1 srem (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) ; CHECK: @F = global i1 false ; [#uses=0] @G = global i1 urem (i1 icmp ult (i8* @X, i8* @Y), i1 icmp ult (i8* @X, i8* @Z)) ; CHECK: @G = global i1 false ; [#uses=0] @H = global i1 icmp ule (i32* bitcast (i8* @X to i32*), i32* bitcast (i8* @Y to i32*)) -; CHECK: @H = global i1 icmp ule (i8* @X, i8* @Y) ; [#uses=0] +; CHECK: @H = global i1 icmp ule (i8* @X, i8* @Y) @I = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 false) -; CHECK: @I = global i1 icmp ult (i8* @X, i8* @Y) ; [#uses=0] +; CHECK: @I = global i1 icmp ult (i8* @X, i8* @Y) @J = global i1 xor (i1 icmp ult (i8* @X, i8* @Y), i1 true) -; CHECK: @J = global i1 icmp uge (i8* @X, i8* @Y) ; [#uses=0] +; CHECK: @J = global i1 icmp uge (i8* @X, i8* @Y) @K = global i1 icmp eq (i1 icmp ult (i8* @X, i8* @Y), i1 false) -; CHECK: @K = global i1 icmp uge (i8* @X, i8* @Y) ; [#uses=0] +; CHECK: @K = global i1 icmp uge (i8* @X, i8* @Y) @L = global i1 icmp eq (i1 icmp ult (i8* @X, i8* @Y), i1 true) -; CHECK: @L = global i1 icmp ult (i8* @X, i8* @Y) ; [#uses=0] +; CHECK: @L = global i1 icmp ult (i8* @X, i8* @Y) @M = global i1 icmp ne (i1 icmp ult (i8* @X, i8* @Y), i1 true) -; CHECK: @M = global i1 icmp uge (i8* @X, i8* @Y) ; [#uses=0] +; CHECK: @M = global i1 icmp uge (i8* @X, i8* @Y) @N = global i1 icmp ne (i1 icmp ult (i8* @X, i8* @Y), i1 false) -; CHECK: @N = global i1 icmp ult (i8* @X, i8* @Y) ; [#uses=0] +; CHECK: @N = global i1 icmp ult (i8* @X, i8* @Y) @O = global i1 icmp eq (i32 zext (i1 icmp ult (i8* @X, i8* @Y) to i32), i32 0) -; CHECK: @O = global i1 icmp uge (i8* @X, i8* @Y) ; [#uses=0] +; CHECK: @O = global i1 icmp uge (i8* @X, i8* @Y) + From sabre at nondot.org Sat Oct 17 16:53:27 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 17 Oct 2009 21:53:27 -0000 Subject: [llvm-commits] [llvm] r84368 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/ConstProp/constant-expr.ll Message-ID: <200910172153.n9HLrReE025450@zion.cs.uiuc.edu> Author: lattner Date: Sat Oct 17 16:53:27 2009 New Revision: 84368 URL: http://llvm.org/viewvc/llvm-project?rev=84368&view=rev Log: Teach vm core to more aggressively fold 'trunc' constantexprs, allowing it to simplify the crazy constantexprs in the testcases down to something sensible. This allows -std-compile-opts to completely "devirtualize" the pointers to member functions in the testcase from PR5176. Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/test/Transforms/ConstProp/constant-expr.ll Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=84368&r1=84367&r2=84368&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Sat Oct 17 16:53:27 2009 @@ -179,6 +179,151 @@ } +/// ExtractConstantBytes - V is an integer constant which only has a subset of +/// its bytes used. The bytes used are indicated by ByteStart (which is the +/// first byte used, counting from the least significant byte) and ByteSize, +/// which is the number of bytes used. +/// +/// This function analyzes the specified constant to see if the specified byte +/// range can be returned as a simplified constant. If so, the constant is +/// returned, otherwise null is returned. +/// +static Constant *ExtractConstantBytes(Constant *C, unsigned ByteStart, + unsigned ByteSize) { + assert(isa(C->getType()) && + (cast(C->getType())->getBitWidth() & 7) == 0 && + "Non-byte sized integer input"); + unsigned CSize = cast(C->getType())->getBitWidth()/8; + assert(ByteSize && "Must be accessing some piece"); + assert(ByteStart+ByteSize <= CSize && "Extracting invalid piece from input"); + assert(ByteSize != CSize && "Should not extract everything"); + + // Constant Integers are simple. + if (ConstantInt *CI = dyn_cast(C)) { + APInt V = CI->getValue(); + if (ByteStart) + V = V.lshr(ByteStart*8); + V.trunc(ByteSize*8); + return ConstantInt::get(CI->getContext(), V); + } + + // In the input is a constant expr, we might be able to recursively simplify. + // If not, we definitely can't do anything. + ConstantExpr *CE = dyn_cast(C); + if (CE == 0) return 0; + + switch (CE->getOpcode()) { + default: return 0; + case Instruction::Or: { + Constant *RHS = ExtractConstantBytes(C->getOperand(1), ByteStart, ByteSize); + if (RHS == 0) + return 0; + + // X | -1 -> -1. + if (ConstantInt *RHSC = dyn_cast(RHS)) + if (RHSC->isAllOnesValue()) + return RHSC; + + Constant *LHS = ExtractConstantBytes(C->getOperand(0), ByteStart, ByteSize); + if (LHS == 0) + return 0; + return ConstantExpr::getOr(LHS, RHS); + } + case Instruction::And: { + Constant *RHS = ExtractConstantBytes(C->getOperand(1), ByteStart, ByteSize); + if (RHS == 0) + return 0; + + // X & 0 -> 0. + if (RHS->isNullValue()) + return RHS; + + Constant *LHS = ExtractConstantBytes(C->getOperand(0), ByteStart, ByteSize); + if (LHS == 0) + return 0; + return ConstantExpr::getAnd(LHS, RHS); + } + case Instruction::LShr: { + ConstantInt *Amt = dyn_cast(CE->getOperand(1)); + if (Amt == 0) + return 0; + unsigned ShAmt = Amt->getZExtValue(); + // Cannot analyze non-byte shifts. + if ((ShAmt & 7) != 0) + return 0; + ShAmt >>= 3; + + // If the extract is known to be all zeros, return zero. + if (ByteStart >= CSize-ShAmt) + return Constant::getNullValue(IntegerType::get(CE->getContext(), + ByteSize*8)); + // If the extract is known to be fully in the input, extract it. + if (ByteStart+ByteSize+ShAmt <= CSize) + return ExtractConstantBytes(C->getOperand(0), ByteStart+ShAmt, ByteSize); + + // TODO: Handle the 'partially zero' case. + return 0; + } + + case Instruction::Shl: { + ConstantInt *Amt = dyn_cast(CE->getOperand(1)); + if (Amt == 0) + return 0; + unsigned ShAmt = Amt->getZExtValue(); + // Cannot analyze non-byte shifts. + if ((ShAmt & 7) != 0) + return 0; + ShAmt >>= 3; + + // If the extract is known to be all zeros, return zero. + if (ByteStart+ByteSize <= ShAmt) + return Constant::getNullValue(IntegerType::get(CE->getContext(), + ByteSize*8)); + // If the extract is known to be fully in the input, extract it. + if (ByteStart >= ShAmt) + return ExtractConstantBytes(C->getOperand(0), ByteStart-ShAmt, ByteSize); + + // TODO: Handle the 'partially zero' case. + return 0; + } + + case Instruction::ZExt: { + unsigned SrcBitSize = + cast(C->getOperand(0)->getType())->getBitWidth(); + + // If extracting something that is completely zero, return 0. + if (ByteStart*8 >= SrcBitSize) + return Constant::getNullValue(IntegerType::get(CE->getContext(), + ByteSize*8)); + + // If exactly extracting the input, return it. + if (ByteStart == 0 && ByteSize*8 == SrcBitSize) + return C->getOperand(0); + + // If extracting something completely in the input, if if the input is a + // multiple of 8 bits, recurse. + if ((SrcBitSize&7) == 0 && (ByteStart+ByteSize)*8 <= SrcBitSize) + return ExtractConstantBytes(C->getOperand(0), ByteStart, ByteSize); + + // Otherwise, if extracting a subset of the input, which is not multiple of + // 8 bits, do a shift and trunc to get the bits. + if ((ByteStart+ByteSize)*8 < SrcBitSize) { + assert((SrcBitSize&7) && "Shouldn't get byte sized case here"); + Constant *Res = C->getOperand(0); + if (ByteStart) + Res = ConstantExpr::getLShr(Res, + ConstantInt::get(Res->getType(), ByteStart*8)); + return ConstantExpr::getTrunc(Res, IntegerType::get(C->getContext(), + ByteSize*8)); + } + + // TODO: Handle the 'partially zero' case. + return 0; + } + } +} + + Constant *llvm::ConstantFoldCastInstruction(LLVMContext &Context, unsigned opc, Constant *V, const Type *DestTy) { @@ -236,6 +381,8 @@ // We actually have to do a cast now. Perform the cast according to the // opcode specified. switch (opc) { + default: + llvm_unreachable("Failed to cast constant expression"); case Instruction::FPTrunc: case Instruction::FPExt: if (ConstantFP *FPC = dyn_cast(V)) { @@ -300,23 +447,27 @@ return ConstantInt::get(Context, Result); } return 0; - case Instruction::Trunc: + case Instruction::Trunc: { + uint32_t DestBitWidth = cast(DestTy)->getBitWidth(); if (ConstantInt *CI = dyn_cast(V)) { - uint32_t BitWidth = cast(DestTy)->getBitWidth(); APInt Result(CI->getValue()); - Result.trunc(BitWidth); + Result.trunc(DestBitWidth); return ConstantInt::get(Context, Result); } + + // The input must be a constantexpr. See if we can simplify this based on + // the bytes we are demanding. Only do this if the source and dest are an + // even multiple of a byte. + if ((DestBitWidth & 7) == 0 && + (cast(V->getType())->getBitWidth() & 7) == 0) + if (Constant *Res = ExtractConstantBytes(V, 0, DestBitWidth / 8)) + return Res; + return 0; + } case Instruction::BitCast: return FoldBitCast(Context, V, DestTy); - default: - assert(!"Invalid CE CastInst opcode"); - break; } - - llvm_unreachable("Failed to cast constant expression"); - return 0; } Constant *llvm::ConstantFoldSelectInstruction(LLVMContext&, Modified: llvm/trunk/test/Transforms/ConstProp/constant-expr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/constant-expr.ll?rev=84368&r1=84367&r2=84368&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ConstProp/constant-expr.ll (original) +++ llvm/trunk/test/Transforms/ConstProp/constant-expr.ll Sat Oct 17 16:53:27 2009 @@ -40,3 +40,21 @@ @O = global i1 icmp eq (i32 zext (i1 icmp ult (i8* @X, i8* @Y) to i32), i32 0) ; CHECK: @O = global i1 icmp uge (i8* @X, i8* @Y) + + +; PR5176 + +; CHECK: @T1 = global i1 true + at T1 = global i1 icmp eq (i64 and (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 64) to i64), i64 1), i64 0) + +; CHECK: @T2 = global i1* @B + at T2 = global i1* inttoptr (i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 192)), i256 192) to i64), i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 192)), i256 128) to i64)) to i1*) + +; CHECK: @T3 = global i64 add (i64 ptrtoint (i1* @B to i64), i64 -1) + at T3 = global i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 64) to i64), i64 -1) + +; CHECK: @T4 = global i1* @B + at T4 = global i1* inttoptr (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 64) to i64) to i1*) + +; CHECK: @T5 = global i1* @A + at T5 = global i1* inttoptr (i64 add (i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 192) to i64), i64 trunc (i256 lshr (i256 or (i256 and (i256 and (i256 shl (i256 zext (i64 ptrtoint (i1* @B to i64) to i256), i256 64), i256 -6277101735386680763495507056286727952638980837032266301441), i256 6277101735386680763835789423207666416102355444464034512895), i256 shl (i256 zext (i64 ptrtoint (i1* @A to i64) to i256), i256 192)), i256 128) to i64)) to i1*) \ No newline at end of file From clattner at apple.com Sat Oct 17 18:05:04 2009 From: clattner at apple.com (Chris Lattner) Date: Sat, 17 Oct 2009 16:05:04 -0700 Subject: [llvm-commits] [PATCH] Add a ValueMap type, whose keys act like WeakVHs In-Reply-To: <0016363b7bde0f990504761ca9c4@google.com> References: <0016363b7bde0f990504761ca9c4@google.com> Message-ID: On Oct 17, 2009, at 12:42 AM, jyasskin at gmail.com wrote: > > I guess I'll have to figure out how to fix it before submitting. I'll review it when it is fixed. > > Description: > ValueMap is safe to use even when keys get RAUWed and > deleted > during its lifetime. By default the keys act like WeakVHs, but users > can > pass a third template parameter to configure how updates work and > whether to do anything beyond updating the map on each action. > > This type should make http://codereview.appspot.com/133043/diff/1/2 > quite a bit simpler, but I haven't yet updated it so I could have > missed > something. Sounds nice, what happens when X->RAUW(Y) and both X and Y are already in the map? -Chris From daniel at zuster.org Sat Oct 17 18:15:04 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 23:15:04 -0000 Subject: [llvm-commits] [llvm] r84372 - /llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Message-ID: <200910172315.n9HNF5G7028937@zion.cs.uiuc.edu> Author: ddunbar Date: Sat Oct 17 18:15:04 2009 New Revision: 84372 URL: http://llvm.org/viewvc/llvm-project?rev=84372&view=rev Log: Fix my -Asserts warning fix. Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=84372&r1=84371&r2=84372&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Sat Oct 17 18:15:04 2009 @@ -153,8 +153,9 @@ MachineBasicBlock *TBB = 0, *FBB = 0; SmallVector Cond; - assert(!TII->AnalyzeBranch(*MBB, TBB, FBB, Cond) && - "UpdateTerminators requires analyzable predecessors!"); + bool B = TII->AnalyzeBranch(*MBB, TBB, FBB, Cond); + (void) B; + assert(!B && "UpdateTerminators requires analyzable predecessors!"); if (Cond.empty()) { if (TBB) { // The block has an unconditional branch. If its successor is now From daniel at zuster.org Sat Oct 17 18:15:11 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 16:15:11 -0700 Subject: [llvm-commits] [llvm] r84327 - /llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp In-Reply-To: References: <200910170933.n9H9XeSH030932@zion.cs.uiuc.edu> Message-ID: <6a8523d60910171615j18292a54w884a013f5999efbe@mail.gmail.com> On Sat, Oct 17, 2009 at 10:44 AM, Chris Lattner wrote: > > On Oct 17, 2009, at 2:33 AM, Daniel Dunbar wrote: > >> Author: ddunbar >> Date: Sat Oct 17 04:33:00 2009 >> New Revision: 84327 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84327&view=rev >> Log: >> Suppress -Asserts warning. > > Despite the name, I think that AnalyzeBranch does mutate the code in some > cases on some targets. ?Is this true? Oops, silly me. Fixed in r84372. - Daniel > -Chris > >> >> Modified: >> ? llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp >> >> Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=84327&r1=84326&r2=84327&view=diff >> >> >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) >> +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Sat Oct 17 04:33:00 2009 >> @@ -153,8 +153,8 @@ >> >> ?MachineBasicBlock *TBB = 0, *FBB = 0; >> ?SmallVector Cond; >> - ?bool B = TII->AnalyzeBranch(*MBB, TBB, FBB, Cond); >> - ?assert(!B && "UpdateTerminators requires analyzable predecessors!"); >> + ?assert(!TII->AnalyzeBranch(*MBB, TBB, FBB, Cond) && >> + ? ? ? ? "UpdateTerminators requires analyzable predecessors!"); >> ?if (Cond.empty()) { >> ? ?if (TBB) { >> ? ? ?// The block has an unconditional branch. If its successor is now >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From daniel at zuster.org Sat Oct 17 18:18:59 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 17 Oct 2009 16:18:59 -0700 Subject: [llvm-commits] [PATCH] Fix lit.py for gtest "typed tests" In-Reply-To: References: Message-ID: <6a8523d60910171618j2c1e07bdt55d3b5ca7f7fc4f4@mail.gmail.com> On Sat, Oct 17, 2009 at 11:31 AM, Jeffrey Yasskin wrote: > GTest has a kind of test whose names look like > "ValueMapTest/0.Iteration": > http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide#Typed_Tests. > This broke lit.py, which os.path.join()ed the test name onto the > test's path and assumed that it could recover the name as the second > result of os.path.split. This patch shifts path components from the > testPath to the testName until the testPath exists. LGTM, although I can't tell if its possible to have multiple slashes in the test name from my cursory reading of the doc. If it isn't, maybe better to just have an if instead of a while? - Daniel > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From sabre at nondot.org Sat Oct 17 18:48:54 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 17 Oct 2009 23:48:54 -0000 Subject: [llvm-commits] [llvm] r84373 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200910172348.n9HNmtYO030090@zion.cs.uiuc.edu> Author: lattner Date: Sat Oct 17 18:48:54 2009 New Revision: 84373 URL: http://llvm.org/viewvc/llvm-project?rev=84373&view=rev Log: inline isGEP away. Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84373&r1=84372&r2=84373&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sat Oct 17 18:48:54 2009 @@ -40,10 +40,6 @@ // Useful predicates //===----------------------------------------------------------------------===// -static const GEPOperator *isGEP(const Value *V) { - return dyn_cast(V); -} - static const Value *GetGEPOperands(const Value *V, SmallVector &GEPOps) { assert(GEPOps.empty() && "Expect empty list to populate!"); @@ -53,7 +49,7 @@ // Accumulate all of the chained indexes into the operand array V = cast(V)->getOperand(0); - while (const User *G = isGEP(V)) { + while (const GEPOperator *G = dyn_cast(V)) { if (!isa(GEPOps[0]) || isa(GEPOps[0]) || !cast(GEPOps[0])->isNullValue()) break; // Don't handle folding arbitrary pointer offsets yet... @@ -402,7 +398,7 @@ // Note that we also handle chains of getelementptr instructions as well as // constant expression getelementptrs here. // - if (isGEP(V1) && isGEP(V2)) { + if (isa(V1) && isa(V2)) { const User *GEP1 = cast(V1); const User *GEP2 = cast(V2); @@ -421,13 +417,13 @@ // Drill down into the first non-gep value, to test for must-aliasing of // the base pointers. - while (isGEP(GEP1->getOperand(0)) && + while (isa(GEP1->getOperand(0)) && GEP1->getOperand(1) == Constant::getNullValue(GEP1->getOperand(1)->getType())) GEP1 = cast(GEP1->getOperand(0)); const Value *BasePtr1 = GEP1->getOperand(0); - while (isGEP(GEP2->getOperand(0)) && + while (isa(GEP2->getOperand(0)) && GEP2->getOperand(1) == Constant::getNullValue(GEP2->getOperand(1)->getType())) GEP2 = cast(GEP2->getOperand(0)); @@ -619,11 +615,11 @@ isNonEscapingLocalObject(O1) && O1 != O2) return NoAlias; - if (!isGEP(V1) && isGEP(V2)) { + if (!isa(V1) && isa(V2)) { std::swap(V1, V2); std::swap(V1Size, V2Size); } - if (isGEP(V1)) + if (isa(V1)) return aliasGEP(V1, V1Size, V2, V2Size); if (isa(V2) && !isa(V1)) { From nicholas at mxc.ca Sat Oct 17 18:52:26 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 17 Oct 2009 23:52:26 -0000 Subject: [llvm-commits] [llvm] r84374 - in /llvm/trunk: include/llvm/Instructions.h lib/VMCore/Core.cpp lib/VMCore/Instructions.cpp test/Bindings/Ocaml/vmcore.ml Message-ID: <200910172352.n9HNqQTC030200@zion.cs.uiuc.edu> Author: nicholas Date: Sat Oct 17 18:52:26 2009 New Revision: 84374 URL: http://llvm.org/viewvc/llvm-project?rev=84374&view=rev Log: Fix test/Bindings/Ocaml/vmcore.ml. When IRBuilder::CreateMalloc was removed, LLVMBuildMalloc was reimplemented but with the bug that it didn't insert the resulting instruction. Modified: llvm/trunk/include/llvm/Instructions.h llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/test/Bindings/Ocaml/vmcore.ml Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=84374&r1=84373&r2=84374&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Sat Oct 17 18:52:26 2009 @@ -992,12 +992,14 @@ /// constant 1. /// 2. Call malloc with that argument. /// 3. Bitcast the result of the malloc call to the specified type. - static Value *CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, - const Type *AllocTy, Value *ArraySize = 0, - const Twine &Name = ""); - static Value *CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, - const Type *AllocTy, Value *ArraySize = 0, - Function* MallocF = 0, const Twine &Name = ""); + static Instruction *CreateMalloc(Instruction *InsertBefore, + const Type *IntPtrTy, const Type *AllocTy, + Value *ArraySize = 0, + const Twine &Name = ""); + static Instruction *CreateMalloc(BasicBlock *InsertAtEnd, + const Type *IntPtrTy, const Type *AllocTy, + Value *ArraySize = 0, Function* MallocF = 0, + const Twine &Name = ""); ~CallInst(); Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=84374&r1=84373&r2=84374&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Sat Oct 17 18:52:26 2009 @@ -1700,15 +1700,17 @@ LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name) { const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); - return wrap(CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), IntPtrT, - unwrap(Ty), 0, 0, Twine(Name))); + return wrap(unwrap(B)->Insert(CallInst::CreateMalloc( + unwrap(B)->GetInsertBlock(), IntPtrT, unwrap(Ty), 0, 0, ""), + Twine(Name))); } LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name) { const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); - return wrap(CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), IntPtrT, - unwrap(Ty), unwrap(Val), 0, Twine(Name))); + return wrap(unwrap(B)->Insert(CallInst::CreateMalloc( + unwrap(B)->GetInsertBlock(), IntPtrT, unwrap(Ty), unwrap(Val), 0, ""), + Twine(Name))); } LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=84374&r1=84373&r2=84374&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Sat Oct 17 18:52:26 2009 @@ -460,10 +460,10 @@ return Amt; } -static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd, - const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize, Function* MallocF, - const Twine &NameStr) { +static Instruction *createMalloc(Instruction *InsertBefore, + BasicBlock *InsertAtEnd, const Type *IntPtrTy, + const Type *AllocTy, Value *ArraySize, + Function *MallocF, const Twine &NameStr) { assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) && "createMalloc needs either InsertBefore or InsertAtEnd"); @@ -507,7 +507,7 @@ if (!MallocF->doesNotAlias(0)) MallocF->setDoesNotAlias(0); const PointerType *AllocPtrType = PointerType::getUnqual(AllocTy); CallInst *MCall = NULL; - Value *Result = NULL; + Instruction *Result = NULL; if (InsertBefore) { MCall = CallInst::Create(MallocF, AllocSize, "malloccall", InsertBefore); Result = MCall; @@ -536,9 +536,9 @@ /// constant 1. /// 2. Call malloc with that argument. /// 3. Bitcast the result of the malloc call to the specified type. -Value *CallInst::CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, - const Type *AllocTy, Value *ArraySize, - const Twine &Name) { +Instruction *CallInst::CreateMalloc(Instruction *InsertBefore, + const Type *IntPtrTy, const Type *AllocTy, + Value *ArraySize, const Twine &Name) { return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, ArraySize, NULL, Name); } @@ -551,9 +551,10 @@ /// 3. Bitcast the result of the malloc call to the specified type. /// Note: This function does not add the bitcast to the basic block, that is the /// responsibility of the caller. -Value *CallInst::CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, - const Type *AllocTy, Value *ArraySize, - Function* MallocF, const Twine &Name) { +Instruction *CallInst::CreateMalloc(BasicBlock *InsertAtEnd, + const Type *IntPtrTy, const Type *AllocTy, + Value *ArraySize, Function* MallocF, + const Twine &Name) { return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, ArraySize, MallocF, Name); } Modified: llvm/trunk/test/Bindings/Ocaml/vmcore.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/vmcore.ml?rev=84374&r1=84373&r2=84374&view=diff ============================================================================== --- llvm/trunk/test/Bindings/Ocaml/vmcore.ml (original) +++ llvm/trunk/test/Bindings/Ocaml/vmcore.ml Sat Oct 17 18:52:26 2009 @@ -936,9 +936,9 @@ group "memory"; begin let bb08 = append_block context "Bb08" fn in let b = builder_at_end context bb08 in - - (* RUN: grep {Inst20.*malloc.*i8 } < %t.ll - * RUN: grep {Inst21.*malloc.*i8.*P1} < %t.ll + + (* RUN: grep {Inst20.*malloc} < %t.ll + * RUN: grep {Inst21.*malloc} < %t.ll * RUN: grep {Inst22.*alloca.*i32 } < %t.ll * RUN: grep {Inst23.*alloca.*i32.*P2} < %t.ll * RUN: grep {free.*Inst20} < %t.ll From echristo at apple.com Sat Oct 17 18:56:18 2009 From: echristo at apple.com (Eric Christopher) Date: Sat, 17 Oct 2009 23:56:18 -0000 Subject: [llvm-commits] [llvm] r84382 - in /llvm/trunk/include/llvm: ADT/DenseMapInfo.h Support/ValueHandle.h Message-ID: <200910172356.n9HNuIg0030464@zion.cs.uiuc.edu> Author: echristo Date: Sat Oct 17 18:56:18 2009 New Revision: 84382 URL: http://llvm.org/viewvc/llvm-project?rev=84382&view=rev Log: More warnings patrol: Another unused argument and more implicit conversions. Modified: llvm/trunk/include/llvm/ADT/DenseMapInfo.h llvm/trunk/include/llvm/Support/ValueHandle.h Modified: llvm/trunk/include/llvm/ADT/DenseMapInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMapInfo.h?rev=84382&r1=84381&r2=84382&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/DenseMapInfo.h (original) +++ llvm/trunk/include/llvm/ADT/DenseMapInfo.h Sat Oct 17 18:56:18 2009 @@ -76,7 +76,7 @@ static inline unsigned long getEmptyKey() { return ~0UL; } static inline unsigned long getTombstoneKey() { return ~0UL - 1L; } static unsigned getHashValue(const unsigned long& Val) { - return Val * 37UL; + return (unsigned)(Val * 37UL); } static bool isPod() { return true; } static bool isEqual(const unsigned long& LHS, const unsigned long& RHS) { @@ -89,7 +89,7 @@ static inline unsigned long long getEmptyKey() { return ~0ULL; } static inline unsigned long long getTombstoneKey() { return ~0ULL - 1ULL; } static unsigned getHashValue(const unsigned long long& Val) { - return (unsigned)Val * 37ULL; + return (unsigned)(Val * 37ULL); } static bool isPod() { return true; } static bool isEqual(const unsigned long long& LHS, Modified: llvm/trunk/include/llvm/Support/ValueHandle.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ValueHandle.h?rev=84382&r1=84381&r2=84382&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ValueHandle.h (original) +++ llvm/trunk/include/llvm/Support/ValueHandle.h Sat Oct 17 18:56:18 2009 @@ -361,7 +361,7 @@ /// _before_ any of the uses have actually been replaced. If WeakVH were /// implemented as a CallbackVH, it would use this method to call /// setValPtr(new_value). AssertingVH would do nothing in this method. - virtual void allUsesReplacedWith(Value *new_value) {} + virtual void allUsesReplacedWith(Value *) {} }; // Specialize simplify_type to allow CallbackVH to participate in From sabre at nondot.org Sat Oct 17 18:59:51 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 17 Oct 2009 23:59:51 -0000 Subject: [llvm-commits] [llvm] r84383 - /llvm/trunk/test/Analysis/BasicAA/modref.ll Message-ID: <200910172359.n9HNxp1h030575@zion.cs.uiuc.edu> Author: lattner Date: Sat Oct 17 18:59:51 2009 New Revision: 84383 URL: http://llvm.org/viewvc/llvm-project?rev=84383&view=rev Log: replace a useless test with a useful one Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=84383&r1=84382&r2=84383&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/modref.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/modref.ll Sat Oct 17 18:59:51 2009 @@ -1,15 +1,21 @@ -; A very rudimentary test on AliasAnalysis::getModRefInfo. -; RUN: opt < %s -print-all-alias-modref-info -aa-eval -disable-output |& \ -; RUN: not grep NoModRef +; RUN: opt < %s -basicaa -gvn -S | FileCheck %s -define i32 @callee() { - %X = alloca { i32, i32 } ; <{ i32, i32 }*> [#uses=1] - %Y = getelementptr { i32, i32 }* %X, i64 0, i32 0 ; [#uses=1] - %Z = load i32* %Y ; [#uses=1] - ret i32 %Z -} +declare void @llvm.memset.i32(i8*, i8, i32, i32) + +declare void @external(i32*) -define i32 @caller() { - %X = call i32 @callee( ) ; [#uses=1] - ret i32 %X +define i32 @test0(i8* %P) { + %A = alloca i32 + call void @external(i32* %A) + + store i32 0, i32* %A + + call void @llvm.memset.i32(i8* %P, i8 0, i32 42, i32 1) + + %B = load i32* %A + ret i32 %B + +; CHECK: @test0 +; CHECK: ret i32 0 } + From clattner at apple.com Sat Oct 17 19:04:33 2009 From: clattner at apple.com (Chris Lattner) Date: Sat, 17 Oct 2009 17:04:33 -0700 Subject: [llvm-commits] [llvm] r84175 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp In-Reply-To: <200910150711.n9F7BPF2012926@zion.cs.uiuc.edu> References: <200910150711.n9F7BPF2012926@zion.cs.uiuc.edu> Message-ID: <8C14A2AC-8D15-41A5-AA9A-969636A2DAA2@apple.com> On Oct 15, 2009, at 12:11 AM, Nick Lewycky wrote: > Author: nicholas > Date: Thu Oct 15 02:11:24 2009 > New Revision: 84175 > > URL: http://llvm.org/viewvc/llvm-project?rev=84175&view=rev > Log: > Teach basicaa about memcpy/memmove/memset. The length argument can > be used to > improve alias results if constant, and the source pointer can't be > modified. Hi Nick, Please write some testcases that fail without this and pass with it. I added a placeholder in r84383. I'm pretty sure that this is already handled by logic in AliasAnalysis that knows that memset only looks at its arguments: else if (MRB == AliasAnalysis::AccessesArguments) { bool doesAlias = false; for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end(); AI != AE; ++AI) if (alias(*AI, ~0U, P, Size) != NoAlias) { doesAlias = true; break; } if (!doesAlias) return NoModRef; } If this code isn't needed, please remove it. -Chris > > Modified: > llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp > > Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84175&r1=84174&r2=84175&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) > +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Thu Oct 15 > 02:11:24 2009 > @@ -310,6 +310,28 @@ > if (IntrinsicInst *II = dyn_cast(CS.getInstruction > ())) { > switch (II->getIntrinsicID()) { > default: break; > + case Intrinsic::memcpy: > + case Intrinsic::memmove: { > + unsigned Len = ~0U; > + if (ConstantInt *LenCI = dyn_cast(II- > >getOperand(3))) > + Len = LenCI->getZExtValue(); > + Value *Dest = II->getOperand(1); > + Value *Src = II->getOperand(2); > + if (alias(Dest, Len, P, Size) == NoAlias) { > + if (alias(Src, Len, P, Size) == NoAlias) > + return NoModRef; > + return Ref; > + } > + } > + break; > + case Intrinsic::memset: > + if (ConstantInt *LenCI = dyn_cast(II- > >getOperand(3))) { > + unsigned Len = LenCI->getZExtValue(); > + Value *Dest = II->getOperand(1); > + if (alias(Dest, Len, P, Size) == NoAlias) > + return NoModRef; > + } > + break; > case Intrinsic::atomic_cmp_swap: > case Intrinsic::atomic_swap: > case Intrinsic::atomic_load_add: > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From nicholas at mxc.ca Sat Oct 17 19:42:10 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 18 Oct 2009 00:42:10 -0000 Subject: [llvm-commits] [llvm] r84385 - in /llvm/trunk/test/Analysis/BasicAA: memintrinsic-src.ll memintrisic-size.ll Message-ID: <200910180042.n9I0gBho032021@zion.cs.uiuc.edu> Author: nicholas Date: Sat Oct 17 19:42:07 2009 New Revision: 84385 URL: http://llvm.org/viewvc/llvm-project?rev=84385&view=rev Log: Add a couple new testcases. Added: llvm/trunk/test/Analysis/BasicAA/memintrinsic-src.ll llvm/trunk/test/Analysis/BasicAA/memintrisic-size.ll Added: llvm/trunk/test/Analysis/BasicAA/memintrinsic-src.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/memintrinsic-src.ll?rev=84385&view=auto ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/memintrinsic-src.ll (added) +++ llvm/trunk/test/Analysis/BasicAA/memintrinsic-src.ll Sat Oct 17 19:42:07 2009 @@ -0,0 +1,17 @@ +; RUN: opt -S -gvn -dse < %s | FileCheck %s + +declare void @llvm.memcpy.i8(i8*, i8*, i8, i32) + +define i8 @test1() { +; CHECK: @test1 + %A = alloca i8 + %B = alloca i8 + + store i8 2, i8* %B ;; Not written to by memcpy + + call void @llvm.memcpy.i8(i8* %A, i8* %B, i8 -1, i32 0) + + %C = load i8* %B + ret i8 %C +; CHECK-NEXT: ret i8 2 +} Added: llvm/trunk/test/Analysis/BasicAA/memintrisic-size.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/memintrisic-size.ll?rev=84385&view=auto ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/memintrisic-size.ll (added) +++ llvm/trunk/test/Analysis/BasicAA/memintrisic-size.ll Sat Oct 17 19:42:07 2009 @@ -0,0 +1,13 @@ +; RUN: opt -S -gvn < %s | FileCheck %s + +declare void @llvm.memset.i8(i8*, i8, i8, i32) + +define i8 @test(i8* %P) { + %P2 = getelementptr i8* %P, i32 1000 + store i8 1, i8* %P2 ;; Not dead across memset + call void @llvm.memset.i8(i8* %P, i8 2, i8 127, i32 0) + %A = load i8* %P2 + ret i8 %A +; CHECK: ret i8 1 +} + From nicholas at mxc.ca Sat Oct 17 19:44:15 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 17 Oct 2009 17:44:15 -0700 Subject: [llvm-commits] [llvm] r84175 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp In-Reply-To: <8C14A2AC-8D15-41A5-AA9A-969636A2DAA2@apple.com> References: <200910150711.n9F7BPF2012926@zion.cs.uiuc.edu> <8C14A2AC-8D15-41A5-AA9A-969636A2DAA2@apple.com> Message-ID: <4ADA64DF.20509@mxc.ca> Chris Lattner wrote: > > On Oct 15, 2009, at 12:11 AM, Nick Lewycky wrote: > >> Author: nicholas >> Date: Thu Oct 15 02:11:24 2009 >> New Revision: 84175 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=84175&view=rev >> Log: >> Teach basicaa about memcpy/memmove/memset. The length argument can be >> used to >> improve alias results if constant, and the source pointer can't be >> modified. > > Hi Nick, > > Please write some testcases that fail without this and pass with it. Added in r84385. I'm pretty sure that this is already > handled by logic in AliasAnalysis that knows that memset only looks at > its arguments: No, that isn't enough. memmove/memcpy have an argument that they never write to. The existing logic returns ModRef against that pointer, while we know we can return Ref. Similarly, when alias() isn't given the size, it has to assume that the possible writer will write over the whole thing, and any two pointers which are computed as offset from the same base are potentially aliasing. By pulling the size out of memmove/memcpy/memset, we can return NoModRef in cases where the fallback code could not. Nick From jyasskin at google.com Sat Oct 17 20:37:14 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Sat, 17 Oct 2009 18:37:14 -0700 Subject: [llvm-commits] [PATCH] Fix lit.py for gtest "typed tests" In-Reply-To: <6a8523d60910171618j2c1e07bdt55d3b5ca7f7fc4f4@mail.gmail.com> References: <6a8523d60910171618j2c1e07bdt55d3b5ca7f7fc4f4@mail.gmail.com> Message-ID: On Sat, Oct 17, 2009 at 4:18 PM, Daniel Dunbar wrote: > On Sat, Oct 17, 2009 at 11:31 AM, Jeffrey Yasskin wrote: >> GTest has a kind of test whose names look like >> "ValueMapTest/0.Iteration": >> http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide#Typed_Tests. >> This broke lit.py, which os.path.join()ed the test name onto the >> test's path and assumed that it could recover the name as the second >> result of os.path.split. This patch shifts path components from the >> testPath to the testName until the testPath exists. > > LGTM, although I can't tell if its possible to have multiple slashes > in the test name from my cursory reading of the doc. If it isn't, > maybe better to just have an if instead of a while? I don't think it's possible to have multiple slashes. I was just future-proofing. I'll change it to an if. Thanks! From jyasskin at google.com Sat Oct 17 21:05:42 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Sun, 18 Oct 2009 02:05:42 -0000 Subject: [llvm-commits] [llvm] r84387 - /llvm/trunk/utils/lit/TestFormats.py Message-ID: <200910180205.n9I25g0H002103@zion.cs.uiuc.edu> Author: jyasskin Date: Sat Oct 17 21:05:42 2009 New Revision: 84387 URL: http://llvm.org/viewvc/llvm-project?rev=84387&view=rev Log: Support GoogleTest's "typed tests" (http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide#Typed_Tests) in lit.py. These tests have names like "ValueMapTest/0.Iteration", which broke when lit.py os.path.join()ed them onto the path and then assumed it could os.path.split() them back off. This patch shifts path components from the testPath to the testName until the testPath exists. Modified: llvm/trunk/utils/lit/TestFormats.py Modified: llvm/trunk/utils/lit/TestFormats.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/TestFormats.py?rev=84387&r1=84386&r2=84387&view=diff ============================================================================== --- llvm/trunk/utils/lit/TestFormats.py (original) +++ llvm/trunk/utils/lit/TestFormats.py Sat Oct 17 21:05:42 2009 @@ -53,6 +53,10 @@ def execute(self, test, litConfig): testPath,testName = os.path.split(test.getSourcePath()) + if not os.path.exists(testPath): + # Handle GTest typed tests, whose name includes a '/'. + testPath, namePrefix = os.path.split(testPath) + testName = os.path.join(namePrefix, testName) cmd = [testPath, '--gtest_filter=' + testName] out, err, exitCode = TestRunner.executeCommand(cmd) From jyasskin at google.com Sat Oct 17 21:52:30 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Sat, 17 Oct 2009 19:52:30 -0700 Subject: [llvm-commits] [PATCH] Add a ValueMap type, whose keys act like WeakVHs In-Reply-To: References: <0016363b7bde0f990504761ca9c4@google.com> Message-ID: On Sat, Oct 17, 2009 at 4:05 PM, Chris Lattner wrote: > > On Oct 17, 2009, at 12:42 AM, jyasskin at gmail.com wrote: >> >> I guess I'll have to figure out how to fix it before submitting. > > I'll review it when it is fixed. I've fixed lit.py in r84387. This patch didn't need to change. >> Description: >> ValueMap is safe to use even when keys get RAUWed and >> deleted >> during its lifetime. By default the keys act like WeakVHs, but users >> can >> pass a third template parameter to configure how updates work and >> whether to do anything beyond updating the map on each action. >> >> This type should make http://codereview.appspot.com/133043/diff/1/2 >> quite a bit simpler, but I haven't yet updated it so I could have >> missed >> something. > > Sounds nice, what happens when X->RAUW(Y) and both X and Y are already > in the map? Right now, you wind up with Y mapped to X's old target, and Y's old target lost. ValueMapTest.DefaultCollisionBehavior tests for this. It should be easy to add the ability to configure this behavior (Config::Merge(ValueT& OldTarget, const ValueT& NewTarget), maybe with extra parameters), but I didn't need it for my other changes. From clattner at apple.com Sat Oct 17 22:46:25 2009 From: clattner at apple.com (Chris Lattner) Date: Sat, 17 Oct 2009 20:46:25 -0700 Subject: [llvm-commits] [llvm] r84385 - in /llvm/trunk/test/Analysis/BasicAA: memintrinsic-src.ll memintrisic-size.ll In-Reply-To: <200910180042.n9I0gBho032021@zion.cs.uiuc.edu> References: <200910180042.n9I0gBho032021@zion.cs.uiuc.edu> Message-ID: On Oct 17, 2009, at 5:42 PM, Nick Lewycky wrote: > Author: nicholas > Date: Sat Oct 17 19:42:07 2009 > New Revision: 84385 > > URL: http://llvm.org/viewvc/llvm-project?rev=84385&view=rev > Log: > Add a couple new testcases. Thanks, please pull these into modref.ll. You don't need dse for the first test, gvn is enough to propagate the store across to the load. -Chris > > Added: > llvm/trunk/test/Analysis/BasicAA/memintrinsic-src.ll > llvm/trunk/test/Analysis/BasicAA/memintrisic-size.ll > > Added: llvm/trunk/test/Analysis/BasicAA/memintrinsic-src.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/memintrinsic-src.ll?rev=84385&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/Analysis/BasicAA/memintrinsic-src.ll (added) > +++ llvm/trunk/test/Analysis/BasicAA/memintrinsic-src.ll Sat Oct 17 > 19:42:07 2009 > @@ -0,0 +1,17 @@ > +; RUN: opt -S -gvn -dse < %s | FileCheck %s > + > +declare void @llvm.memcpy.i8(i8*, i8*, i8, i32) > + > +define i8 @test1() { > +; CHECK: @test1 > + %A = alloca i8 > + %B = alloca i8 > + > + store i8 2, i8* %B ;; Not written to by memcpy > + > + call void @llvm.memcpy.i8(i8* %A, i8* %B, i8 -1, i32 0) > + > + %C = load i8* %B > + ret i8 %C > +; CHECK-NEXT: ret i8 2 > +} > > Added: llvm/trunk/test/Analysis/BasicAA/memintrisic-size.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/memintrisic-size.ll?rev=84385&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/Analysis/BasicAA/memintrisic-size.ll (added) > +++ llvm/trunk/test/Analysis/BasicAA/memintrisic-size.ll Sat Oct 17 > 19:42:07 2009 > @@ -0,0 +1,13 @@ > +; RUN: opt -S -gvn < %s | FileCheck %s > + > +declare void @llvm.memset.i8(i8*, i8, i8, i32) > + > +define i8 @test(i8* %P) { > + %P2 = getelementptr i8* %P, i32 1000 > + store i8 1, i8* %P2 ;; Not dead across memset > + call void @llvm.memset.i8(i8* %P, i8 2, i8 127, i32 0) > + %A = load i8* %P2 > + ret i8 %A > +; CHECK: ret i8 1 > +} > + > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Sat Oct 17 22:46:45 2009 From: clattner at apple.com (Chris Lattner) Date: Sat, 17 Oct 2009 20:46:45 -0700 Subject: [llvm-commits] [llvm] r84175 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp In-Reply-To: <4ADA64DF.20509@mxc.ca> References: <200910150711.n9F7BPF2012926@zion.cs.uiuc.edu> <8C14A2AC-8D15-41A5-AA9A-969636A2DAA2@apple.com> <4ADA64DF.20509@mxc.ca> Message-ID: <6D99BC56-338B-427C-8522-7A1F01A2A93B@apple.com> On Oct 17, 2009, at 5:44 PM, Nick Lewycky wrote: > Chris Lattner wrote: >> On Oct 15, 2009, at 12:11 AM, Nick Lewycky wrote: >>> Author: nicholas >>> Date: Thu Oct 15 02:11:24 2009 >>> New Revision: 84175 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=84175&view=rev >>> Log: >>> Teach basicaa about memcpy/memmove/memset. The length argument can >>> be used to >>> improve alias results if constant, and the source pointer can't be >>> modified. >> Hi Nick, >> Please write some testcases that fail without this and pass with it. > > Added in r84385. > > I'm pretty sure that this is already >> handled by logic in AliasAnalysis that knows that memset only looks >> at its arguments: > > No, that isn't enough. memmove/memcpy have an argument that they > never write to. The existing logic returns ModRef against that > pointer, while we know we can return Ref. > > Similarly, when alias() isn't given the size, it has to assume that > the possible writer will write over the whole thing, and any two > pointers which are computed as offset from the same base are > potentially aliasing. By pulling the size out of memmove/memcpy/ > memset, we can return NoModRef in cases where the fallback code > could not. Ok, thanks! From sabre at nondot.org Sat Oct 17 23:05:55 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 18 Oct 2009 04:05:55 -0000 Subject: [llvm-commits] [llvm] r84395 - in /llvm/trunk/include/llvm/Analysis: Dominators.h PostDominators.h Message-ID: <200910180405.n9I45tkU006110@zion.cs.uiuc.edu> Author: lattner Date: Sat Oct 17 23:05:53 2009 New Revision: 84395 URL: http://llvm.org/viewvc/llvm-project?rev=84395&view=rev Log: add nodes_begin/end/iterator for dominfo, patch by Tobias Grosser! Modified: llvm/trunk/include/llvm/Analysis/Dominators.h llvm/trunk/include/llvm/Analysis/PostDominators.h Modified: llvm/trunk/include/llvm/Analysis/Dominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Dominators.h?rev=84395&r1=84394&r2=84395&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/Dominators.h (original) +++ llvm/trunk/include/llvm/Analysis/Dominators.h Sat Oct 17 23:05:53 2009 @@ -25,6 +25,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" @@ -824,26 +825,44 @@ /// DominatorTree GraphTraits specialization so the DominatorTree can be /// iterable by generic graph iterators. /// -template <> struct GraphTraits { +template <> struct GraphTraits { typedef DomTreeNode NodeType; typedef NodeType::iterator ChildIteratorType; static NodeType *getEntryNode(NodeType *N) { return N; } - static inline ChildIteratorType child_begin(NodeType* N) { + static inline ChildIteratorType child_begin(NodeType *N) { return N->begin(); } - static inline ChildIteratorType child_end(NodeType* N) { + static inline ChildIteratorType child_end(NodeType *N) { return N->end(); } + + typedef df_iterator nodes_iterator; + + static nodes_iterator nodes_begin(DomTreeNode *N) { + return df_begin(getEntryNode(N)); + } + + static nodes_iterator nodes_end(DomTreeNode *N) { + return df_end(getEntryNode(N)); + } }; template <> struct GraphTraits - : public GraphTraits { + : public GraphTraits { static NodeType *getEntryNode(DominatorTree *DT) { return DT->getRootNode(); } + + static nodes_iterator nodes_begin(DominatorTree *N) { + return df_begin(getEntryNode(N)); + } + + static nodes_iterator nodes_end(DominatorTree *N) { + return df_end(getEntryNode(N)); + } }; Modified: llvm/trunk/include/llvm/Analysis/PostDominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/PostDominators.h?rev=84395&r1=84394&r2=84395&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/PostDominators.h (original) +++ llvm/trunk/include/llvm/Analysis/PostDominators.h Sat Oct 17 23:05:53 2009 @@ -74,6 +74,21 @@ FunctionPass* createPostDomTree(); +template <> struct GraphTraits + : public GraphTraits { + static NodeType *getEntryNode(PostDominatorTree *DT) { + return DT->getRootNode(); + } + + static nodes_iterator nodes_begin(PostDominatorTree *N) { + return df_begin(getEntryNode(N)); + } + + static nodes_iterator nodes_end(PostDominatorTree *N) { + return df_end(getEntryNode(N)); + } +}; + /// PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is /// used to compute the a post-dominance frontier. /// From sabre at nondot.org Sat Oct 17 23:09:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 18 Oct 2009 04:09:11 -0000 Subject: [llvm-commits] [llvm] r84396 - in /llvm/trunk: include/llvm/Analysis/CFGPrinter.h lib/Analysis/CFGPrinter.cpp Message-ID: <200910180409.n9I49CZC006236@zion.cs.uiuc.edu> Author: lattner Date: Sat Oct 17 23:09:11 2009 New Revision: 84396 URL: http://llvm.org/viewvc/llvm-project?rev=84396&view=rev Log: make DOTGraphTraits public, patch by Tobias Grosser! Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h llvm/trunk/lib/Analysis/CFGPrinter.cpp Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CFGPrinter.h?rev=84396&r1=84395&r2=84396&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/CFGPrinter.h (original) +++ llvm/trunk/include/llvm/Analysis/CFGPrinter.h Sat Oct 17 23:09:11 2009 @@ -15,6 +15,67 @@ #ifndef LLVM_ANALYSIS_CFGPRINTER_H #define LLVM_ANALYSIS_CFGPRINTER_H +#include "llvm/Function.h" +#include "llvm/Instructions.h" +#include "llvm/Assembly/Writer.h" +#include "llvm/Support/CFG.h" +#include "llvm/Support/GraphWriter.h" + +namespace llvm { +template<> +struct DOTGraphTraits : public DefaultDOTGraphTraits { + static std::string getGraphName(const Function *F) { + return "CFG for '" + F->getNameStr() + "' function"; + } + + static std::string getNodeLabel(const BasicBlock *Node, + const Function *Graph, + bool ShortNames) { + if (ShortNames && !Node->getName().empty()) + return Node->getNameStr() + ":"; + + std::string Str; + raw_string_ostream OS(Str); + + if (ShortNames) { + WriteAsOperand(OS, Node, false); + return OS.str(); + } + + if (Node->getName().empty()) { + WriteAsOperand(OS, Node, false); + OS << ":"; + } + + OS << *Node; + std::string OutStr = OS.str(); + if (OutStr[0] == '\n') OutStr.erase(OutStr.begin()); + + // Process string output to make it nicer... + for (unsigned i = 0; i != OutStr.length(); ++i) + if (OutStr[i] == '\n') { // Left justify + OutStr[i] = '\\'; + OutStr.insert(OutStr.begin()+i+1, 'l'); + } else if (OutStr[i] == ';') { // Delete comments! + unsigned Idx = OutStr.find('\n', i+1); // Find end of line + OutStr.erase(OutStr.begin()+i, OutStr.begin()+Idx); + --i; + } + + return OutStr; + } + + static std::string getEdgeSourceLabel(const BasicBlock *Node, + succ_const_iterator I) { + // Label source of conditional branches with "T" or "F" + if (const BranchInst *BI = dyn_cast(Node->getTerminator())) + if (BI->isConditional()) + return (I == succ_begin(Node)) ? "T" : "F"; + return ""; + } +}; +} // End llvm namespace + namespace llvm { class FunctionPass; FunctionPass *createCFGPrinterPass (); Modified: llvm/trunk/lib/Analysis/CFGPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CFGPrinter.cpp?rev=84396&r1=84395&r2=84396&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/CFGPrinter.cpp (original) +++ llvm/trunk/lib/Analysis/CFGPrinter.cpp Sat Oct 17 23:09:11 2009 @@ -17,71 +17,12 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Function.h" -#include "llvm/Instructions.h" -#include "llvm/Pass.h" #include "llvm/Analysis/CFGPrinter.h" -#include "llvm/Assembly/Writer.h" -#include "llvm/Support/CFG.h" + +#include "llvm/Pass.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/GraphWriter.h" using namespace llvm; -namespace llvm { -template<> -struct DOTGraphTraits : public DefaultDOTGraphTraits { - static std::string getGraphName(const Function *F) { - return "CFG for '" + F->getNameStr() + "' function"; - } - - static std::string getNodeLabel(const BasicBlock *Node, - const Function *Graph, - bool ShortNames) { - if (ShortNames && !Node->getName().empty()) - return Node->getNameStr() + ":"; - - std::string Str; - raw_string_ostream OS(Str); - - if (ShortNames) { - WriteAsOperand(OS, Node, false); - return OS.str(); - } - - if (Node->getName().empty()) { - WriteAsOperand(OS, Node, false); - OS << ":"; - } - - OS << *Node; - std::string OutStr = OS.str(); - if (OutStr[0] == '\n') OutStr.erase(OutStr.begin()); - - // Process string output to make it nicer... - for (unsigned i = 0; i != OutStr.length(); ++i) - if (OutStr[i] == '\n') { // Left justify - OutStr[i] = '\\'; - OutStr.insert(OutStr.begin()+i+1, 'l'); - } else if (OutStr[i] == ';') { // Delete comments! - unsigned Idx = OutStr.find('\n', i+1); // Find end of line - OutStr.erase(OutStr.begin()+i, OutStr.begin()+Idx); - --i; - } - - return OutStr; - } - - static std::string getEdgeSourceLabel(const BasicBlock *Node, - succ_const_iterator I) { - // Label source of conditional branches with "T" or "F" - if (const BranchInst *BI = dyn_cast(Node->getTerminator())) - if (BI->isConditional()) - return (I == succ_begin(Node)) ? "T" : "F"; - return ""; - } -}; -} - namespace { struct VISIBILITY_HIDDEN CFGViewer : public FunctionPass { static char ID; // Pass identifcation, replacement for typeid From sabre at nondot.org Sat Oct 17 23:10:40 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 18 Oct 2009 04:10:40 -0000 Subject: [llvm-commits] [llvm] r84397 - in /llvm/trunk: include/llvm/Analysis/DomPrinter.h include/llvm/LinkAllPasses.h lib/Analysis/CMakeLists.txt lib/Analysis/DomPrinter.cpp Message-ID: <200910180410.n9I4AeCh006294@zion.cs.uiuc.edu> Author: lattner Date: Sat Oct 17 23:10:40 2009 New Revision: 84397 URL: http://llvm.org/viewvc/llvm-project?rev=84397&view=rev Log: add function passes for printing various dominator datastructures accessible through opt. Patch by Tobias Grosser! Added: llvm/trunk/include/llvm/Analysis/DomPrinter.h llvm/trunk/lib/Analysis/DomPrinter.cpp Modified: llvm/trunk/include/llvm/LinkAllPasses.h llvm/trunk/lib/Analysis/CMakeLists.txt Added: llvm/trunk/include/llvm/Analysis/DomPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DomPrinter.h?rev=84397&view=auto ============================================================================== --- llvm/trunk/include/llvm/Analysis/DomPrinter.h (added) +++ llvm/trunk/include/llvm/Analysis/DomPrinter.h Sat Oct 17 23:10:40 2009 @@ -0,0 +1,30 @@ +//===-- DomPrinter.h - Dom printer external interface ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines external functions that can be called to explicitly +// instantiate the dominance tree printer. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ANALYSIS_DOMPRINTER_H +#define LLVM_ANALYSIS_DOMPRINTER_H + +namespace llvm { + class FunctionPass; + FunctionPass *createDomPrinterPass(); + FunctionPass *createDomOnlyPrinterPass(); + FunctionPass *createDomViewerPass(); + FunctionPass *createDomOnlyViewerPass(); + FunctionPass *createPostDomPrinterPass(); + FunctionPass *createPostDomOnlyPrinterPass(); + FunctionPass *createPostDomViewerPass(); + FunctionPass *createPostDomOnlyViewerPass(); +} // End llvm namespace + +#endif Modified: llvm/trunk/include/llvm/LinkAllPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=84397&r1=84396&r2=84397&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllPasses.h (original) +++ llvm/trunk/include/llvm/LinkAllPasses.h Sat Oct 17 23:10:40 2009 @@ -16,6 +16,7 @@ #define LLVM_LINKALLPASSES_H #include "llvm/Analysis/AliasSetTracker.h" +#include "llvm/Analysis/DomPrinter.h" #include "llvm/Analysis/FindUsedTypes.h" #include "llvm/Analysis/IntervalPartition.h" #include "llvm/Analysis/Passes.h" @@ -62,6 +63,10 @@ (void) llvm::createDeadInstEliminationPass(); (void) llvm::createDeadStoreEliminationPass(); (void) llvm::createDeadTypeEliminationPass(); + (void) llvm::createDomOnlyPrinterPass(); + (void) llvm::createDomPrinterPass(); + (void) llvm::createDomOnlyViewerPass(); + (void) llvm::createDomViewerPass(); (void) llvm::createEdgeProfilerPass(); (void) llvm::createOptimalEdgeProfilerPass(); (void) llvm::createFunctionInliningPass(); @@ -98,6 +103,10 @@ (void) llvm::createPromoteMemoryToRegisterPass(); (void) llvm::createDemoteRegisterToMemoryPass(); (void) llvm::createPruneEHPass(); + (void) llvm::creat