Re: [llvm-commits] [llvm] r47220 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll
On Feb 16, 2008, at 6:41 PM, Duncan Sands wrote: Hi Chris, Remove any 'nest' parameter attributes if the function is not passed as an argument to a trampoline intrinsic. Nice. Out of curiousity, how does nest do to codegen? 'nest' causes a specific register to be grabbed for the parameter in calls. So removing it doesn't do much :) Ok. Alternatively, maybe ParamAttrsList should have a 'find attribute' function that returns the first argument that has the specified attribute? I think that would only be useful for attributes that can occur at most once, i.e. sret and nest, and since sret is always on the first parameter it's not useful for sret. I did consider a removeAttrEverywhere method, but again it didn't seem generally useful. Fair enough! +static void RemoveNestAttribute(Function *F) { + F-setParamAttrs(StripNest(F-getParamAttrs())); + for (Value::use_iterator UI = F-use_begin(), E = F-use_end(); UI != E;++UI){ +Instruction *User = castInstruction(*UI); +if (CallInst *CI = dyn_castCallInst(User)) { Please use CallSite to handle CallInst/Invoke uniformly. To create a CallSite don't you first need to get your hands on either a CI or an II? Which means doing the dyn_cast and test anyway, to produce the CallSite (this is annoying, maybe it should be possible to create one from an Instruction*). You can just do: CallSite User(castInstruction(*UI)); and then handle user generically. So I don't see that it gains you much. Also, in ChangeCalleesToFastCall a few lines above I see that a certain lattner didn't consider a CallSite useful for the calling convention case :) Heh, CallSite probably didn't exist when that was written, or my commit wasn't adequately reviewed by my peers ;-) -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47237 - /llvm/trunk/lib/Target/X86/README.txt
Author: lattner Date: Sun Feb 17 13:43:57 2008 New Revision: 47237 URL: http://llvm.org/viewvc/llvm-project?rev=47237view=rev Log: move PR2053 to here. Modified: llvm/trunk/lib/Target/X86/README.txt Modified: llvm/trunk/lib/Target/X86/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=47237r1=47236r2=47237view=diff == --- llvm/trunk/lib/Target/X86/README.txt (original) +++ llvm/trunk/lib/Target/X86/README.txt Sun Feb 17 13:43:57 2008 @@ -1516,3 +1516,15 @@ lock ; mov %esp, %esp //===-===// + +The generated code on x86 for checking for signed overflow on a multiply the +obvious way is much longer than it needs to be. + +int x(int a, int b) { + long long prod = (long long)a*b; + return prod 0x7FFF || prod (-0x7FFF-1); +} + +See PR2053 for more details. + +//===-===// ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.2] r47235 - /llvm-gcc-4.2/trunk/gcc/config/i386/i386.h
Author: lattner Date: Sun Feb 17 13:00:29 2008 New Revision: 47235 URL: http://llvm.org/viewvc/llvm-project?rev=47235view=rev Log: Fix support for -m32 on x86_64-unknown-linux-gnu. This has the effect of always making the target triple (in llvm bc files) be i386-* instead of i586-* etc, but this shouldn't impact anything in LLVM (which is driven by cpu attributes) in theory. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.h Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.h?rev=47235r1=47234r2=47235view=diff == --- llvm-gcc-4.2/trunk/gcc/config/i386/i386.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.h Sun Feb 17 13:00:29 2008 @@ -3748,7 +3748,7 @@ * compiler was configured for i[3456]86-os-blah. */ #define LLVM_OVERRIDE_TARGET_ARCH() \ - (TARGET_64BIT ? x86_64 : ) + (TARGET_64BIT ? x86_64 : i386) /* LLVM_TARGET_INTRINSIC_LOWER - To handle builtins, we want to expand the * invocation into normal LLVM code. If the target can handle the builtin, this ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47239 - /llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
Author: lattner Date: Sun Feb 17 14:44:51 2008 New Revision: 47239 URL: http://llvm.org/viewvc/llvm-project?rev=47239view=rev Log: make the logic for breaking up subtracts more explicit, no functionality change. Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=47239r1=47238r2=47239view=diff == --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Sun Feb 17 14:44:51 2008 @@ -391,17 +391,30 @@ return BinaryOperator::createNeg(V, V-getName() + .neg, BI); } +/// ShouldBreakUpSubtract - Return true if we should break up this subtract of +/// X-Y into (X + -Y). +static bool ShouldBreakUpSubtract(Instruction *Sub) { + // If this is a negation, we can't split it up! + if (BinaryOperator::isNeg(Sub)) +return false; + + // Don't bother to break this up unless either the LHS is an associable add or + // if this is only used by one. + if (isReassociableOp(Sub-getOperand(0), Instruction::Add)) +return true; + if (isReassociableOp(Sub-getOperand(1), Instruction::Add)) +return true; + + if (Sub-hasOneUse() isReassociableOp(Sub-use_back(), Instruction::Add)) +return true; + + return false; +} + /// BreakUpSubtract - If we have (X-Y), and if either X is an add, or if this is /// only used by an add, transform this into (X+(0-Y)) to promote better /// reassociation. static Instruction *BreakUpSubtract(Instruction *Sub) { - // Don't bother to break this up unless either the LHS is an associable add or - // if this is only used by one. - if (!isReassociableOp(Sub-getOperand(0), Instruction::Add) - !isReassociableOp(Sub-getOperand(1), Instruction::Add) - !(Sub-hasOneUse() isReassociableOp(Sub-use_back(), Instruction::Add))) -return 0; - // Convert a subtract into an add and a neg instruction... so that sub // instructions can be commuted with other add instructions... // @@ -762,12 +775,12 @@ // If this is a subtract instruction which is not already in negate form, // see if we can convert it to X+-Y. if (BI-getOpcode() == Instruction::Sub) { - if (!BinaryOperator::isNeg(BI)) { + if (ShouldBreakUpSubtract(BI)) { if (Instruction *NI = BreakUpSubtract(BI)) { MadeChange = true; BI = NI; } - } else { + } else if (BinaryOperator::isNeg(BI)) { // Otherwise, this is a negation. See if the operand is a multiply tree // and if this is not an inner node of a multiply tree. if (isReassociableOp(BI-getOperand(1), Instruction::Mul) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47240 - /llvm/trunk/test/Transforms/Reassociate/subtest.ll
Author: lattner Date: Sun Feb 17 14:48:43 2008 New Revision: 47240 URL: http://llvm.org/viewvc/llvm-project?rev=47240view=rev Log: upgrade and simplify this test. Modified: llvm/trunk/test/Transforms/Reassociate/subtest.ll Modified: llvm/trunk/test/Transforms/Reassociate/subtest.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/subtest.ll?rev=47240r1=47239r2=47240view=diff == --- llvm/trunk/test/Transforms/Reassociate/subtest.ll (original) +++ llvm/trunk/test/Transforms/Reassociate/subtest.ll Sun Feb 17 14:48:43 2008 @@ -1,10 +1,11 @@ ; With sub reassociation, constant folding can eliminate the 12 and -12 constants. ; -; RUN: llvm-upgrade %s | llvm-as | opt -reassociate -constprop -instcombine -die | llvm-dis | not grep 12 +; RUN: llvm-as %s | opt -reassociate -instcombine | llvm-dis | not grep 12 -int test(int %A, int %B) { - %X = add int -12, %A - %Y = sub int %X, %B - %Z = add int %Y, 12 - ret int %Z +define i32 @test(i32 %A, i32 %B) { + %X = add i32 -12, %A; i32 [#uses=1] + %Y = sub i32 %X, %B ; i32 [#uses=1] + %Z = add i32 %Y, 12 ; i32 [#uses=1] + ret i32 %Z } + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47242 - /llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
Author: lattner Date: Sun Feb 17 14:54:40 2008 New Revision: 47242 URL: http://llvm.org/viewvc/llvm-project?rev=47242view=rev Log: fix pasto Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=47242r1=47241r2=47242view=diff == --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Sun Feb 17 14:54:40 2008 @@ -404,7 +404,7 @@ isReassociableOp(Sub-getOperand(0), Instruction::Sub)) return true; if (isReassociableOp(Sub-getOperand(1), Instruction::Add) || - isReassociableOp(Sub-getOperand(0), Instruction::Sub)) + isReassociableOp(Sub-getOperand(1), Instruction::Sub)) return true; if (Sub-hasOneUse() (isReassociableOp(Sub-use_back(), Instruction::Add) || ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47244 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/addnegneg.ll
Author: lattner Date: Sun Feb 17 15:03:36 2008 New Revision: 47244 URL: http://llvm.org/viewvc/llvm-project?rev=47244view=rev Log: Fold (-x + -y) - -(x+y) which promotes better association, fixing the second half of PR2047 Added: llvm/trunk/test/Transforms/InstCombine/addnegneg.ll 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=47244r1=47243r2=47244view=diff == --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sun Feb 17 15:03:36 2008 @@ -2090,8 +2090,16 @@ } // -A + B -- B - A - if (Value *V = dyn_castNegVal(LHS)) -return BinaryOperator::createSub(RHS, V); + // -A + -B -- -(A + B) + if (Value *LHSV = dyn_castNegVal(LHS)) { +if (Value *RHSV = dyn_castNegVal(RHS)) { + Instruction *NewAdd = BinaryOperator::createAdd(LHSV, RHSV, sum); + InsertNewInstBefore(NewAdd, I); + return BinaryOperator::createNeg(NewAdd); +} + +return BinaryOperator::createSub(RHS, LHSV); + } // A + -B -- A - B if (!isaConstant(RHS)) Added: llvm/trunk/test/Transforms/InstCombine/addnegneg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/addnegneg.ll?rev=47244view=auto == --- llvm/trunk/test/Transforms/InstCombine/addnegneg.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/addnegneg.ll Sun Feb 17 15:03:36 2008 @@ -0,0 +1,12 @@ +; RUN: llvm-as %s | opt -instcombine | llvm-dis | grep { sub } | count 1 +; PR2047 + +define i32 @l(i32 %a, i32 %b, i32 %c, i32 %d) { +entry: + %b.neg = sub i32 0, %b ; i32 [#uses=1] + %c.neg = sub i32 0, %c ; i32 [#uses=1] + %sub4 = add i32 %c.neg, %b.neg ; i32 [#uses=1] + %sub6 = add i32 %sub4, %d ; i32 [#uses=1] + ret i32 %sub6 +} + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47241 - in /llvm/trunk: lib/Transforms/Scalar/Reassociate.cpp test/Transforms/Reassociate/subtest2.ll
Author: lattner Date: Sun Feb 17 14:51:26 2008 New Revision: 47241 URL: http://llvm.org/viewvc/llvm-project?rev=47241view=rev Log: Split up subtracts into add+negate if they have a reassociable use or operand that is also a subtract. This implements PR2047 and Transforms/Reassociate/subtest2.ll Added: llvm/trunk/test/Transforms/Reassociate/subtest2.ll Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=47241r1=47240r2=47241view=diff == --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Sun Feb 17 14:51:26 2008 @@ -399,13 +399,16 @@ return false; // Don't bother to break this up unless either the LHS is an associable add or - // if this is only used by one. - if (isReassociableOp(Sub-getOperand(0), Instruction::Add)) + // subtract or if this is only used by one. + if (isReassociableOp(Sub-getOperand(0), Instruction::Add) || + isReassociableOp(Sub-getOperand(0), Instruction::Sub)) return true; - if (isReassociableOp(Sub-getOperand(1), Instruction::Add)) + if (isReassociableOp(Sub-getOperand(1), Instruction::Add) || + isReassociableOp(Sub-getOperand(0), Instruction::Sub)) return true; - - if (Sub-hasOneUse() isReassociableOp(Sub-use_back(), Instruction::Add)) + if (Sub-hasOneUse() + (isReassociableOp(Sub-use_back(), Instruction::Add) || + isReassociableOp(Sub-use_back(), Instruction::Sub))) return true; return false; Added: llvm/trunk/test/Transforms/Reassociate/subtest2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/subtest2.ll?rev=47241view=auto == --- llvm/trunk/test/Transforms/Reassociate/subtest2.ll (added) +++ llvm/trunk/test/Transforms/Reassociate/subtest2.ll Sun Feb 17 14:51:26 2008 @@ -0,0 +1,13 @@ +; With sub reassociation, constant folding can eliminate the uses of %a. +; +; RUN: llvm-as %s | opt -reassociate -instcombine | llvm-dis | grep %a | count 1 +; PR2047 + +define i32 @test(i32 %a, i32 %b, i32 %c) nounwind { +entry: + %tmp3 = sub i32 %a, %b ; i32 [#uses=1] + %tmp5 = sub i32 %tmp3, %c ; i32 [#uses=1] + %tmp7 = sub i32 %tmp5, %a ; i32 [#uses=1] + ret i32 %tmp7 +} + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47247 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
Author: resistor Date: Sun Feb 17 15:29:08 2008 New Revision: 47247 URL: http://llvm.org/viewvc/llvm-project?rev=47247view=rev Log: Teach getModRefInfo that memcpy, memmove, and memset don't capture memory addresses. Also, noalias arguments are be considered like stack allocated ones for this purpose, because the only way they can be modref'ed is if they escape somewhere in the current function. 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=47247r1=47246r2=47247view=diff == --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sun Feb 17 15:29:08 2008 @@ -21,7 +21,7 @@ #include llvm/ParameterAttributes.h #include llvm/GlobalVariable.h #include llvm/Instructions.h -#include llvm/Intrinsics.h +#include llvm/IntrinsicInst.h #include llvm/Pass.h #include llvm/Target/TargetData.h #include llvm/ADT/SmallVector.h @@ -228,6 +228,13 @@ // If returned, the address will escape to calling functions, but no // callees could modify it. break; // next use +case Instruction::Call: + // If the call is to a few known safe intrinsics, we know that it does + // not escape + if (isaMemIntrinsic(I)) +return false; + else +return true; default: return true; } @@ -247,8 +254,11 @@ // Allocations and byval arguments are new objects. if (Object (isaAllocationInst(Object) || - (isaArgument(Object) castArgument(Object)-hasByValAttr( { - // Okay, the pointer is to a stack allocated object. If we can prove that + (isaArgument(Object) + (castArgument(Object)-hasByValAttr() || + castArgument(Object)-hasNoAliasAttr() { + // Okay, the pointer is to a stack allocated (or effectively so, for + // for noalias parameters) object. If we can prove that // the pointer never escapes, then we know the call cannot clobber it, // because it simply can't get its address. if (!AddressMightEscape(Object)) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r47213 - in /llvm/trunk/lib: CodeGen/SelectionDAG/LegalizeDAG.cpp Target/ARM/ARMISelLowering.cpp Target/CBackend/CBackend.cpp Target/CellSPU/SPUISelLowering.cpp Target/IA64/I
Thanks. Evan On Feb 16, 2008, at 6:46 AM, Andrew Lenharth wrote: Author: alenhar2 Date: Sat Feb 16 08:46:26 2008 New Revision: 47213 URL: http://llvm.org/viewvc/llvm-project?rev=47213view=rev Log: I cannot find a libgcc function for this builtin. Therefor expanding it to a noop (which is how it use to be treated). If someone who knows the x86 backend better than me could tell me how to get a lock prefix on an instruction, that would be nice to complete x86 support. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/Sparc/SparcISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=47213r1=47212r2=47213view=diff = = = = = = = = == --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sat Feb 16 08:46:26 2008 @@ -1135,11 +1135,21 @@ case ISD::MEMBARRIER: { assert(Node-getNumOperands() == 6 Invalid MemBarrier node!); -SDOperand Ops[6]; -Ops[0] = LegalizeOp(Node-getOperand(0)); // Legalize the chain. -for (int x = 1; x 6; ++x) - Ops[x] = PromoteOp(Node-getOperand(x)); -Result = DAG.UpdateNodeOperands(Result, Ops[0], 6); +switch (TLI.getOperationAction(ISD::MEMBARRIER, MVT::Other)) { +default: assert(0 This action is not supported yet!); +case TargetLowering::Legal: { + SDOperand Ops[6]; + Ops[0] = LegalizeOp(Node-getOperand(0)); // Legalize the chain. + for (int x = 1; x 6; ++x) +Ops[x] = PromoteOp(Node-getOperand(x)); + Result = DAG.UpdateNodeOperands(Result, Ops[0], 6); + break; +} +case TargetLowering::Expand: + //There is no libgcc call for this op + Result = Node-getOperand(0); // Noop +break; +} break; } Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=47213r1=47212r2=47213view=diff = = = = = = = = == --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Sat Feb 16 08:46:26 2008 @@ -210,6 +210,7 @@ setOperationAction(ISD::STACKSAVE, MVT::Other, Expand); setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand); setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32 , Expand); + setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand); if (!Subtarget-hasV6Ops()) { setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16, Expand); Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=47213r1=47212r2=47213view=diff = = = = = = = = == --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Sat Feb 16 08:46:26 2008 @@ -2459,6 +2459,7 @@ if (Function *F = CI-getCalledFunction()) switch (F-getIntrinsicID()) { case Intrinsic::not_intrinsic: + case Intrinsic::memory_barrier: case Intrinsic::vastart: case Intrinsic::vacopy: case Intrinsic::vaend: @@ -2544,6 +2545,9 @@ WroteCallee = true; break; } + case Intrinsic::memory_barrier: +Out 0; __sync_syncronize(); +return; case Intrinsic::vastart: Out 0; ; Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=47213r1=47212r2=47213view=diff = = = = = = = = == --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Sat Feb 16 08:46:26 2008 @@ -181,7 +181,8 @@ setOperationAction(ISD::MEMMOVE, MVT::Other, Expand); setOperationAction(ISD::MEMSET, MVT::Other, Expand); setOperationAction(ISD::MEMCPY, MVT::Other, Expand); - + setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand); + // PowerPC has no SREM/UREM instructions setOperationAction(ISD::SREM, MVT::i32, Expand); setOperationAction(ISD::UREM,
Re: [llvm-commits] [llvm] r47086 - in /llvm/trunk: include/llvm/ADT/APInt.h lib/Support/APInt.cpp
Ping. Is this fixed? Does it affect build with -Werror set? Evan On Feb 13, 2008, at 5:22 PM, Bill Wendling wrote: Hi Dan, +uint32_t APInt::countTrailingOnes() const { + if (isSingleWord()) +return std::min(uint32_t(CountTrailingOnes_64(VAL)), BitWidth); + uint32_t Count = 0; + uint32_t i = 0; + for (; i getNumWords() pVal[i] == -1; ++i) This compare leads to this warning: llvm[1]: Compiling APInt.cpp for Debug build /Volumes/Gir/devel/llvm/llvm.src/lib/Support/APInt.cpp: In member function 'uint32_t llvm::APInt::countTrailingOnes() const': /Volumes/Gir/devel/llvm/llvm.src/lib/Support/APInt.cpp:821: warning: comparison between signed and unsigned integer expressions Could you take a look at it please? -bw ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47248 - in /llvm/trunk: include/llvm/Argument.h lib/VMCore/Function.cpp
Author: resistor Date: Sun Feb 17 17:22:28 2008 New Revision: 47248 URL: http://llvm.org/viewvc/llvm-project?rev=47248view=rev Log: Add a predicate to Argument to check for the StructRet attribute. Modified: llvm/trunk/include/llvm/Argument.h llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/include/llvm/Argument.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Argument.h?rev=47248r1=47247r2=47248view=diff == --- llvm/trunk/include/llvm/Argument.h (original) +++ llvm/trunk/include/llvm/Argument.h Sun Feb 17 17:22:28 2008 @@ -57,6 +57,10 @@ /// it in its containing function. bool hasNoAliasAttr() const; + /// hasSRetAttr - Return true if this argument has the sret attribute on it in + /// its containing function. + bool hasStructRetAttr() const; + virtual void print(std::ostream OS) const; void print(std::ostream *OS) const { if (OS) print(*OS); Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=47248r1=47247r2=47248view=diff == --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Sun Feb 17 17:22:28 2008 @@ -103,6 +103,13 @@ return getParent()-paramHasAttr(getArgNo()+1, ParamAttr::NoAlias); } +/// hasSRetAttr - Return true if this argument has the sret attribute on +/// it in its containing function. +bool Argument::hasStructRetAttr() const { + if (!isaPointerType(getType())) return false; + return getParent()-paramHasAttr(getArgNo()+1, ParamAttr::StructRet); +} + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47249 - /llvm/trunk/include/llvm/Support/CallSite.h
Author: resistor Date: Sun Feb 17 18:10:55 2008 New Revision: 47249 URL: http://llvm.org/viewvc/llvm-project?rev=47249view=rev Log: Add support for setting parameters to CallSite. Modified: llvm/trunk/include/llvm/Support/CallSite.h Modified: llvm/trunk/include/llvm/Support/CallSite.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CallSite.h?rev=47249r1=47248r2=47249view=diff == --- llvm/trunk/include/llvm/Support/CallSite.h (original) +++ llvm/trunk/include/llvm/Support/CallSite.h Sun Feb 17 18:10:55 2008 @@ -114,6 +114,15 @@ return *(arg_begin()+ArgNo); } + void setArgument(unsigned ArgNo, Value* newVal) { +assert(I Not a call or invoke instruction!); +assert(arg_begin() + ArgNo arg_end() Argument # out of range!); +if (I-getOpcode() == Instruction::Call) + I-setOperand(ArgNo+1, newVal); // Skip Function +else + I-setOperand(ArgNo+3, newVal); // Skip Function, BB, BB + } + /// arg_iterator - The type of iterator to use when looping over actual /// arguments at this call site... typedef User::op_iterator arg_iterator; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47250 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
Author: lattner Date: Sun Feb 17 20:11:28 2008 New Revision: 47250 URL: http://llvm.org/viewvc/llvm-project?rev=47250view=rev Log: bitcasts of pointers are always pointers. If we see a memcpy of a pointer, make sure to check later uses of the pointer as well. 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=47250r1=47249r2=47250view=diff == --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sun Feb 17 20:11:28 2008 @@ -219,8 +219,6 @@ return true; break; // next use. case Instruction::BitCast: - if (!isaPointerType(I-getType())) -return true; if (AddressMightEscape(I)) return true; break; // next use @@ -231,10 +229,9 @@ case Instruction::Call: // If the call is to a few known safe intrinsics, we know that it does // not escape - if (isaMemIntrinsic(I)) -return false; - else + if (!isaMemIntrinsic(I)) return true; + break; // next use default: return true; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r47247 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
On Feb 17, 2008, at 1:29 PM, Owen Anderson wrote: Author: resistor Date: Sun Feb 17 15:29:08 2008 New Revision: 47247 URL: http://llvm.org/viewvc/llvm-project?rev=47247view=rev Log: Teach getModRefInfo that memcpy, memmove, and memset don't capture memory addresses. Also, noalias arguments are be considered like stack allocated ones for this purpose, because the only way they can be modref'ed is if they escape somewhere in the current function. Very nice owen. +case Instruction::Call: + // If the call is to a few known safe intrinsics, we know that it does + // not escape + if (isaMemIntrinsic(I)) +return false; + else +return true; I fixed one minor problem with this: if you have a memintrinsic, you have to check other uses. @@ -247,8 +254,11 @@ // Allocations and byval arguments are new objects. if (Object (isaAllocationInst(Object) || - (isaArgument(Object) castArgument(Object)- hasByValAttr( { - // Okay, the pointer is to a stack allocated object. If we can prove that + (isaArgument(Object) + (castArgument(Object)- hasByValAttr() || + castArgument(Object)- hasNoAliasAttr() { + // Okay, the pointer is to a stack allocated (or effectively so, for + // for noalias parameters) object. If we can prove that // the pointer never escapes, then we know the call cannot clobber it, // because it simply can't get its address. if (!AddressMightEscape(Object)) Two problems with this code: 1. This will return nomodref for a memcpy that reads or writes a non escaping alloca. I think that if AddressMightEscape returns false, you should loop over operands of the call, and see if getUnderlyingObject returns Object for any of the pointer arguments to the call. If so, the call really could mod/ref the memory. 2. This code: // If this is a tail call and P points to a stack location, we know that // the tail call cannot access or modify the local stack. if (CallInst *CI = dyn_castCallInst(CS.getInstruction())) if (CI-isTailCall() !isaMallocInst(Object)) return NoModRef; is not safe for noalias arguments, only byval and allocas. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47251 - /llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
Author: lattner Date: Sun Feb 17 20:18:25 2008 New Revision: 47251 URL: http://llvm.org/viewvc/llvm-project?rev=47251view=rev Log: simplify some code, BreakUpSubtract always returns nonnull now. Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=47251r1=47250r2=47251view=diff == --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Sun Feb 17 20:18:25 2008 @@ -779,10 +779,8 @@ // see if we can convert it to X+-Y. if (BI-getOpcode() == Instruction::Sub) { if (ShouldBreakUpSubtract(BI)) { -if (Instruction *NI = BreakUpSubtract(BI)) { - MadeChange = true; - BI = NI; -} +BI = BreakUpSubtract(BI); +MadeChange = true; } else if (BinaryOperator::isNeg(BI)) { // Otherwise, this is a negation. See if the operand is a multiply tree // and if this is not an inner node of a multiply tree. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47252 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
Author: resistor Date: Sun Feb 17 20:31:23 2008 New Revision: 47252 URL: http://llvm.org/viewvc/llvm-project?rev=47252view=rev Log: Fix bugs that Chris noticed in my last patch. 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=47252r1=47251r2=47252view=diff == --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sun Feb 17 20:31:23 2008 @@ -250,22 +250,30 @@ const Value *Object = getUnderlyingObject(P); // Allocations and byval arguments are new objects. if (Object -(isaAllocationInst(Object) || - (isaArgument(Object) - (castArgument(Object)-hasByValAttr() || - castArgument(Object)-hasNoAliasAttr() { +(isaAllocationInst(Object) || isaArgument(Object))) { // Okay, the pointer is to a stack allocated (or effectively so, for // for noalias parameters) object. If we can prove that // the pointer never escapes, then we know the call cannot clobber it, // because it simply can't get its address. - if (!AddressMightEscape(Object)) -return NoModRef; + if (isaAllocationInst(Object) || + castArgument(Object)-hasByValAttr() || + castArgument(Object)-hasNoAliasAttr()) +if (!AddressMightEscape(Object)) { + for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); + CI != CE; ++CI) +if (getUnderlyingObject(CI-get()) == P) + return AliasAnalysis::getModRefInfo(CS, P, Size); + + return NoModRef; +} // If this is a tail call and P points to a stack location, we know that // the tail call cannot access or modify the local stack. - if (CallInst *CI = dyn_castCallInst(CS.getInstruction())) -if (CI-isTailCall() !isaMallocInst(Object)) - return NoModRef; + if (isaAllocationInst(Object) || + castArgument(Object)-hasByValAttr()) +if (CallInst *CI = dyn_castCallInst(CS.getInstruction())) + if (CI-isTailCall() !isaMallocInst(Object)) +return NoModRef; } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47254 - /llvm/trunk/lib/VMCore/Function.cpp
Author: resistor Date: Sun Feb 17 22:06:26 2008 New Revision: 47254 URL: http://llvm.org/viewvc/llvm-project?rev=47254view=rev Log: Duncan pointed out that we can fast fail here, because the sret parameter of a function must be the first parameter. Modified: llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=47254r1=47253r2=47254view=diff == --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Sun Feb 17 22:06:26 2008 @@ -107,7 +107,8 @@ /// it in its containing function. bool Argument::hasStructRetAttr() const { if (!isaPointerType(getType())) return false; - return getParent()-paramHasAttr(getArgNo()+1, ParamAttr::StructRet); + if (getArgNo()) return false; // StructRet param must be first param + return getParent()-paramHasAttr(1, ParamAttr::StructRet); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47255 - /llvm/trunk/docs/LangRef.html
Author: resistor Date: Sun Feb 17 22:09:01 2008 New Revision: 47255 URL: http://llvm.org/viewvc/llvm-project?rev=47255view=rev Log: Make the definition of the noalias attribute clearer. 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=47255r1=47254r2=47255view=diff == --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Sun Feb 17 22:09:01 2008 @@ -827,8 +827,9 @@ that is the return value of the function in the source program./dd dtttnoalias/tt/dt -ddThis indicates that the parameter not alias any other object or any -other noalias objects during the function call. +ddThis indicates that the parameter does not alias any global or any other +parameter. The caller is responsible for ensuring that this is the case, +usually by placing the value in a stack allocation./dd dtttnoreturn/tt/dt ddThis function attribute indicates that the function never returns. This ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47256 - /llvm/trunk/docs/LangRef.html
Author: baldrick Date: Sun Feb 17 22:19:38 2008 New Revision: 47256 URL: http://llvm.org/viewvc/llvm-project?rev=47256view=rev Log: Clarify that 'sret' only applies to pointers, and only applies to the first parameter. 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=47256r1=47255r2=47256view=diff == --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Sun Feb 17 22:19:38 2008 @@ -823,8 +823,9 @@ value, but is also valid on scalars (even though this is silly)./dd dtttsret/tt/dt -ddThis indicates that the parameter specifies the address of a structure -that is the return value of the function in the source program./dd +ddThis indicates that the pointer parameter specifies the address of a +structure that is the return value of the function in the source program. +May only be applied to the first parameter./dd dtttnoalias/tt/dt ddThis indicates that the parameter does not alias any global or any other ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47253 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
Author: resistor Date: Sun Feb 17 21:52:21 2008 New Revision: 47253 URL: http://llvm.org/viewvc/llvm-project?rev=47253view=rev Log: Fix a comment, and a bug where we weren't applying the tail call logic in cases that failed the first test. 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=47253r1=47252r2=47253view=diff == --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sun Feb 17 21:52:21 2008 @@ -252,19 +252,21 @@ if (Object (isaAllocationInst(Object) || isaArgument(Object))) { // Okay, the pointer is to a stack allocated (or effectively so, for - // for noalias parameters) object. If we can prove that - // the pointer never escapes, then we know the call cannot clobber it, - // because it simply can't get its address. + // for noalias parameters) object. If the address of this object doesn't + // escape from this function body to a callee, then we know that no + // callees can mod/ref it unless they are actually passed it. if (isaAllocationInst(Object) || castArgument(Object)-hasByValAttr() || castArgument(Object)-hasNoAliasAttr()) if (!AddressMightEscape(Object)) { + bool passedAsArg = false; for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); CI != CE; ++CI) if (getUnderlyingObject(CI-get()) == P) - return AliasAnalysis::getModRefInfo(CS, P, Size); - - return NoModRef; + passedAsArg = true; + + if (!passedAsArg) +return NoModRef; } // If this is a tail call and P points to a stack location, we know that ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r47247 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
Hi Owen, - (isaArgument(Object) castArgument(Object)-hasByValAttr( { - // Okay, the pointer is to a stack allocated object. If we can prove that + (isaArgument(Object) + (castArgument(Object)-hasByValAttr() || + castArgument(Object)-hasNoAliasAttr() { + // Okay, the pointer is to a stack allocated (or effectively so, for + // for noalias parameters) object. If we can prove that there are now a bunch of places in BasicAliasAnalysis which do the same thing for byval and noalias. That's because byval implies noalias. How about renaming hasNoAliasAttr to isNoAlias and have it check both the noalias and byval attributes? Ciao, Duncan. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r47254 - /llvm/trunk/lib/VMCore/Function.cpp
On Feb 17, 2008, at 8:06 PM, Owen Anderson wrote: Author: resistor Date: Sun Feb 17 22:06:26 2008 New Revision: 47254 URL: http://llvm.org/viewvc/llvm-project?rev=47254view=rev Log: Duncan pointed out that we can fast fail here, because the sret parameter of a function must be the first parameter. getArgNo() is linear time, please compare against F-abegin(). -Chris Modified: llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=47254r1=47253r2=47254view=diff = = = = = = = = == --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Sun Feb 17 22:06:26 2008 @@ -107,7 +107,8 @@ /// it in its containing function. bool Argument::hasStructRetAttr() const { if (!isaPointerType(getType())) return false; - return getParent()-paramHasAttr(getArgNo()+1, ParamAttr::StructRet); + if (getArgNo()) return false; // StructRet param must be first param + return getParent()-paramHasAttr(1, ParamAttr::StructRet); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47257 - /llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll
Author: lattner Date: Mon Feb 18 00:11:00 2008 New Revision: 47257 URL: http://llvm.org/viewvc/llvm-project?rev=47257view=rev Log: upgrade this test. Modified: llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll Modified: llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll?rev=47257r1=47256r2=47257view=diff == --- llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll Mon Feb 18 00:11:00 2008 @@ -1,19 +1,19 @@ -; RUN: llvm-upgrade %s | llvm-as | opt -instcombine | llvm-dis | not grep {call.*stackrestore} +; RUN: llvm-as %s | opt -instcombine | llvm-dis | not grep {call.*stackrestore} ;; Test that llvm.stackrestore is removed when possible. - -int* %test1(uint %P) { -%tmp = call sbyte* %llvm.stacksave() -call void %llvm.stackrestore(sbyte* %tmp) ;; not restoring anything - %A = alloca int, uint %P -ret int* %A +define i32* @test1(i32 %P) { + %tmp = call i8* @llvm.stacksave( ) + call void @llvm.stackrestore( i8* %tmp ) ;; not restoring anything + %A = alloca i32, i32 %P + ret i32* %A } -void %test2(sbyte* %X) { - call void %llvm.stackrestore(sbyte* %X) ;; no allocas before return. +define void @test2(i8* %X) { + call void @llvm.stackrestore( i8* %X ) ;; no allocas before return. ret void } -declare sbyte* %llvm.stacksave() +declare i8* @llvm.stacksave() + +declare void @llvm.stackrestore(i8*) -declare void %llvm.stackrestore(sbyte*) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47258 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/stacksaverestore.ll
Author: lattner Date: Mon Feb 18 00:12:38 2008 New Revision: 47258 URL: http://llvm.org/viewvc/llvm-project?rev=47258view=rev Log: optimize away stackrestore calls that have no intervening alloca or call. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=47258r1=47257r2=47258view=diff == --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Feb 18 00:12:38 2008 @@ -8199,22 +8199,30 @@ } } - // If the stack restore is in a return/unwind block and if there are no - // allocas or calls between the restore and the return, nuke the restore. + // Scan down this block to see if there is another stack restore in the + // same block without an intervening call/alloca. + BasicBlock::iterator BI = II; TerminatorInst *TI = II-getParent()-getTerminator(); - if (isaReturnInst(TI) || isaUnwindInst(TI)) { -BasicBlock::iterator BI = II; -bool CannotRemove = false; -for (++BI; *BI != TI; ++BI) { - if (isaAllocaInst(BI) || - (isaCallInst(BI) !isaIntrinsicInst(BI))) { + bool CannotRemove = false; + for (++BI; *BI != TI; ++BI) { +if (isaAllocaInst(BI)) { + CannotRemove = true; + break; +} +if (isaCallInst(BI)) { + if (!isaIntrinsicInst(BI)) { CannotRemove = true; break; } -} -if (!CannotRemove) + // If there is a stackrestore below this one, remove this one. return EraseInstFromFunction(CI); +} } + + // If the stack restore is in a return/unwind block and if there are no + // allocas or calls between the restore and the return, nuke the restore. + if (!CannotRemove (isaReturnInst(TI) || isaUnwindInst(TI))) +return EraseInstFromFunction(CI); break; } } Modified: llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll?rev=47258r1=47257r2=47258view=diff == --- llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/stacksaverestore.ll Mon Feb 18 00:12:38 2008 @@ -1,4 +1,7 @@ -; RUN: llvm-as %s | opt -instcombine | llvm-dis | not grep {call.*stackrestore} +; RUN: llvm-as %s | opt -instcombine | llvm-dis | grep {call.*stackrestore} | count 1 + +declare i8* @llvm.stacksave() +declare void @llvm.stackrestore(i8*) ;; Test that llvm.stackrestore is removed when possible. define i32* @test1(i32 %P) { @@ -13,7 +16,41 @@ ret void } -declare i8* @llvm.stacksave() +define void @foo(i32 %size) nounwind { +entry: + %tmp118124 = icmp sgt i32 %size, 0 ; i1 [#uses=1] + br i1 %tmp118124, label %bb.preheader, label %return -declare void @llvm.stackrestore(i8*) +bb.preheader: ; preds = %entry + %tmp25 = add i32 %size, -1 ; i32 [#uses=1] + %tmp125 = icmp slt i32 %size, 1 ; i1 [#uses=1] + %smax = select i1 %tmp125, i32 1, i32 %size ; i32 [#uses=1] + br label %bb + +bb:; preds = %bb, %bb.preheader + %i.0.reg2mem.0 = phi i32 [ 0, %bb.preheader ], [ %indvar.next, %bb ] ; i32 [#uses=2] + %tmp = call i8* @llvm.stacksave( ) ; i8* [#uses=1] + %tmp23 = alloca i8, i32 %size ; i8* [#uses=2] + %tmp27 = getelementptr i8* %tmp23, i32 %tmp25 ; i8* [#uses=1] + store i8 0, i8* %tmp27, align 1 + %tmp28 = call i8* @llvm.stacksave( ); i8* [#uses=1] + %tmp52 = alloca i8, i32 %size ; i8* [#uses=1] + %tmp53 = call i8* @llvm.stacksave( ); i8* [#uses=1] + %tmp77 = alloca i8, i32 %size ; i8* [#uses=1] + %tmp78 = call i8* @llvm.stacksave( ); i8* [#uses=1] + %tmp102 = alloca i8, i32 %size ; i8* [#uses=1] + call void @bar( i32 %i.0.reg2mem.0, i8* %tmp23, i8* %tmp52, i8* %tmp77, i8* %tmp102, i32 %size ) nounwind + call void @llvm.stackrestore( i8* %tmp78 ) + call void @llvm.stackrestore( i8* %tmp53 ) + call void @llvm.stackrestore( i8* %tmp28 ) + call void @llvm.stackrestore( i8* %tmp ) + %indvar.next = add i32 %i.0.reg2mem.0, 1; i32 [#uses=2] + %exitcond = icmp eq i32 %indvar.next, %smax ; i1 [#uses=1] + br i1 %exitcond, label %return, label %bb +
Re: [llvm-commits] [llvm] r47086 - in /llvm/trunk: include/llvm/ADT/APInt.h lib/Support/APInt.cpp
Dan submitted a fix last week. -bw On Feb 17, 2008, at 2:16 PM, Evan Cheng wrote: Ping. Is this fixed? Does it affect build with -Werror set? Evan On Feb 13, 2008, at 5:22 PM, Bill Wendling wrote: Hi Dan, +uint32_t APInt::countTrailingOnes() const { + if (isSingleWord()) +return std::min(uint32_t(CountTrailingOnes_64(VAL)), BitWidth); + uint32_t Count = 0; + uint32_t i = 0; + for (; i getNumWords() pVal[i] == -1; ++i) This compare leads to this warning: llvm[1]: Compiling APInt.cpp for Debug build /Volumes/Gir/devel/llvm/llvm.src/lib/Support/APInt.cpp: In member function 'uint32_t llvm::APInt::countTrailingOnes() const': /Volumes/Gir/devel/llvm/llvm.src/lib/Support/APInt.cpp:821: warning: comparison between signed and unsigned integer expressions Could you take a look at it please? -bw ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r47252 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
What are the bugs? -bw On Feb 17, 2008, at 6:31 PM, Owen Anderson wrote: Author: resistor Date: Sun Feb 17 20:31:23 2008 New Revision: 47252 URL: http://llvm.org/viewvc/llvm-project?rev=47252view=rev Log: Fix bugs that Chris noticed in my last patch. 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=47252r1=47251r2=47252view=diff == --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sun Feb 17 20:31:23 2008 @@ -250,22 +250,30 @@ const Value *Object = getUnderlyingObject(P); // Allocations and byval arguments are new objects. if (Object -(isaAllocationInst(Object) || - (isaArgument(Object) - (castArgument(Object)- hasByValAttr() || - castArgument(Object)- hasNoAliasAttr() { +(isaAllocationInst(Object) || isaArgument(Object))) { // Okay, the pointer is to a stack allocated (or effectively so, for // for noalias parameters) object. If we can prove that // the pointer never escapes, then we know the call cannot clobber it, // because it simply can't get its address. - if (!AddressMightEscape(Object)) -return NoModRef; + if (isaAllocationInst(Object) || + castArgument(Object)-hasByValAttr() || + castArgument(Object)-hasNoAliasAttr()) +if (!AddressMightEscape(Object)) { + for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); + CI != CE; ++CI) +if (getUnderlyingObject(CI-get()) == P) + return AliasAnalysis::getModRefInfo(CS, P, Size); + + return NoModRef; +} // If this is a tail call and P points to a stack location, we know that // the tail call cannot access or modify the local stack. - if (CallInst *CI = dyn_castCallInst(CS.getInstruction())) -if (CI-isTailCall() !isaMallocInst(Object)) - return NoModRef; + if (isaAllocationInst(Object) || + castArgument(Object)-hasByValAttr()) +if (CallInst *CI = dyn_castCallInst(CS.getInstruction())) + if (CI-isTailCall() !isaMallocInst(Object)) +return NoModRef; } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r47252 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
On Feb 17, 2008, at 10:27 PM, Bill Wendling wrote: What are the bugs? Specifically, it is good to say what you're fixing in the commit log, so that it shows up in svn log. -Chris -bw On Feb 17, 2008, at 6:31 PM, Owen Anderson wrote: Author: resistor Date: Sun Feb 17 20:31:23 2008 New Revision: 47252 URL: http://llvm.org/viewvc/llvm-project?rev=47252view=rev Log: Fix bugs that Chris noticed in my last patch. 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=47252r1=47251r2=47252view=diff = = --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sun Feb 17 20:31:23 2008 @@ -250,22 +250,30 @@ const Value *Object = getUnderlyingObject(P); // Allocations and byval arguments are new objects. if (Object -(isaAllocationInst(Object) || - (isaArgument(Object) - (castArgument(Object)- hasByValAttr() || - castArgument(Object)- hasNoAliasAttr() { +(isaAllocationInst(Object) || isaArgument(Object))) { // Okay, the pointer is to a stack allocated (or effectively so, for // for noalias parameters) object. If we can prove that // the pointer never escapes, then we know the call cannot clobber it, // because it simply can't get its address. - if (!AddressMightEscape(Object)) -return NoModRef; + if (isaAllocationInst(Object) || + castArgument(Object)-hasByValAttr() || + castArgument(Object)-hasNoAliasAttr()) +if (!AddressMightEscape(Object)) { + for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); + CI != CE; ++CI) +if (getUnderlyingObject(CI-get()) == P) + return AliasAnalysis::getModRefInfo(CS, P, Size); + + return NoModRef; +} // If this is a tail call and P points to a stack location, we know that // the tail call cannot access or modify the local stack. - if (CallInst *CI = dyn_castCallInst(CS.getInstruction())) -if (CI-isTailCall() !isaMallocInst(Object)) - return NoModRef; + if (isaAllocationInst(Object) || + castArgument(Object)-hasByValAttr()) +if (CallInst *CI = dyn_castCallInst(CS.getInstruction())) + if (CI-isTailCall() !isaMallocInst(Object)) +return NoModRef; } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r47261 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Author: lattner Date: Mon Feb 18 01:42:56 2008 New Revision: 47261 URL: http://llvm.org/viewvc/llvm-project?rev=47261view=rev Log: switch simplifycfg from using vectors for most things to smallvectors, this speeds it up 2.3% on eon. Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=47261r1=47260r2=47261view=diff == --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Feb 18 01:42:56 2008 @@ -158,7 +158,7 @@ // If there is more than one pred of succ, and there are PHI nodes in // the successor, then we need to add incoming edges for the PHI nodes // -const std::vectorBasicBlock* BBPreds(pred_begin(BB), pred_end(BB)); +const SmallVectorBasicBlock*, 16 BBPreds(pred_begin(BB), pred_end(BB)); // Loop over all of the PHI nodes in the successor of BB. for (BasicBlock::iterator I = Succ-begin(); isaPHINode(I); ++I) { @@ -174,17 +174,15 @@ PN-addIncoming(OldValPN-getIncomingValue(i), OldValPN-getIncomingBlock(i)); } else { -for (std::vectorBasicBlock*::const_iterator PredI = BBPreds.begin(), - End = BBPreds.end(); PredI != End; ++PredI) { - // Add an incoming value for each of the new incoming values... - PN-addIncoming(OldVal, *PredI); -} +// Add an incoming value for each of the new incoming values. +for (unsigned i = 0, e = BBPreds.size(); i != e; ++i) + PN-addIncoming(OldVal, BBPreds[i]); } } } if (isaPHINode(BB-front())) { -std::vectorBasicBlock* +SmallVectorBasicBlock*, 16 OldSuccPreds(pred_begin(Succ), pred_end(Succ)); // Move all PHI nodes in BB to Succ if they are alive, otherwise @@ -464,7 +462,7 @@ static void ErasePossiblyDeadInstructionTree(Instruction *I) { if (!isInstructionTriviallyDead(I)) return; - std::vectorInstruction* InstrsToInspect; + SmallVectorInstruction*, 16 InstrsToInspect; InstrsToInspect.push_back(I); while (!InstrsToInspect.empty()) { @@ -713,7 +711,7 @@ assert(CV Not a comparison?); bool Changed = false; - std::vectorBasicBlock* Preds(pred_begin(BB), pred_end(BB)); + SmallVectorBasicBlock*, 16 Preds(pred_begin(BB), pred_end(BB)); while (!Preds.empty()) { BasicBlock *Pred = Preds.back(); Preds.pop_back(); @@ -733,7 +731,7 @@ // Based on whether the default edge from PTI goes to BB or not, fill in // PredCases and PredDefault with the new switch cases we would like to // build. - std::vectorBasicBlock* NewSuccessors; + SmallVectorBasicBlock*, 8 NewSuccessors; if (PredDefault == BB) { // If this is the default destination from PTI, only the edges in TI @@ -1233,8 +1231,8 @@ BasicBlock::iterator BBI = BB-getTerminator(); if (BBI == BB-begin() || isaPHINode(--BBI)) { // Find predecessors that end with branches. - std::vectorBasicBlock* UncondBranchPreds; - std::vectorBranchInst* CondBranchPreds; + SmallVectorBasicBlock*, 8 UncondBranchPreds; + SmallVectorBranchInst*, 8 CondBranchPreds; for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { TerminatorInst *PTI = (*PI)-getTerminator(); if (BranchInst *BI = dyn_castBranchInst(PTI)) @@ -1357,7 +1355,7 @@ // destination with call instructions, and any unconditional branch // predecessor with an unwind. // -std::vectorBasicBlock* Preds(pred_begin(BB), pred_end(BB)); +SmallVectorBasicBlock*, 8 Preds(pred_begin(BB), pred_end(BB)); while (!Preds.empty()) { BasicBlock *Pred = Preds.back(); if (BranchInst *BI = dyn_castBranchInst(Pred-getTerminator())) { @@ -1676,7 +1674,7 @@ // If the unreachable instruction is the first in the block, take a gander // at all of the predecessors of this instruction, and simplify them. if (BB-front() == Unreachable) { - std::vectorBasicBlock* Preds(pred_begin(BB), pred_end(BB)); + SmallVectorBasicBlock*, 8 Preds(pred_begin(BB), pred_end(BB)); for (unsigned i = 0, e = Preds.size(); i != e; ++i) { TerminatorInst *TI = Preds[i]-getTerminator(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits