[llvm-commits] [llvm] r46684 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Author: nicholas Date: Sun Feb 3 02:19:11 2008 New Revision: 46684 URL: http://llvm.org/viewvc/llvm-project?rev=46684&view=rev Log: Hack on vectors too. 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=46684&r1=46683&r2=46684&view=diff == --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sun Feb 3 02:19:11 2008 @@ -2124,7 +2124,7 @@ return R; // W*X + Y*Z --> W * (X+Z) iff W == Y - if (I.getType()->isInteger()) { + if (I.getType()->isIntOrIntVector()) { Value *W, *X, *Y, *Z; if (match(LHS, m_Mul(m_Value(W), m_Value(X))) && match(RHS, m_Mul(m_Value(Y), m_Value(Z { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46687 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-01-29-AddICmp.ll
Author: nicholas Date: Sun Feb 3 10:33:09 2008 New Revision: 46687 URL: http://llvm.org/viewvc/llvm-project?rev=46687&view=rev Log: There are some cases where icmp(add) can be folded into a new icmp. Handle them. Added: llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.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=46687&r1=46686&r2=46687&view=diff == --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sun Feb 3 10:33:09 2008 @@ -45,6 +45,7 @@ #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Support/CallSite.h" +#include "llvm/Support/ConstantRange.h" #include "llvm/Support/Debug.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" @@ -5704,6 +5705,37 @@ DivRHS)) return R; break; + + case Instruction::Add: +// Fold: icmp pred (add, X, C1), C2 + +if (!ICI.isEquality()) { + ConstantInt *LHSC = dyn_cast(LHSI->getOperand(1)); + if (!LHSC) break; + const APInt &LHSV = LHSC->getValue(); + + ConstantRange CR = ICI.makeConstantRange(ICI.getPredicate(), RHSV) +.subtract(LHSV); + + if (ICI.isSignedPredicate()) { +if (CR.getLower().isSignBit()) { + return new ICmpInst(ICmpInst::ICMP_SLT, LHSI->getOperand(0), + ConstantInt::get(CR.getUpper())); +} else if (CR.getUpper().isSignBit()) { + return new ICmpInst(ICmpInst::ICMP_SGE, LHSI->getOperand(0), + ConstantInt::get(CR.getLower())); +} + } else { +if (CR.getLower().isMinValue()) { + return new ICmpInst(ICmpInst::ICMP_ULT, LHSI->getOperand(0), + ConstantInt::get(CR.getUpper())); +} else if (CR.getUpper().isMinValue()) { + return new ICmpInst(ICmpInst::ICMP_UGE, LHSI->getOperand(0), + ConstantInt::get(CR.getLower())); +} + } +} +break; } // Simplify icmp_eq and icmp_ne instructions with integer constant RHS. Added: llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll?rev=46687&view=auto == --- llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll Sun Feb 3 10:33:09 2008 @@ -0,0 +1,19 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {a.off} + +define i1 @test1(i32 %a) { + %a.off = add i32 %a, 4 ; [#uses=1] + %C = icmp ult i32 %a.off, 4 ; [#uses=1] + ret i1 %C +} + +define i1 @test2(i32 %a) { + %a.off = sub i32 %a, 4 ; [#uses=1] + %C = icmp ugt i32 %a.off, -5 ; [#uses=1] + ret i1 %C +} + +define i1 @test3(i32 %a) { + %a.off = add i32 %a, 4 ; [#uses=1] + %C = icmp slt i32 %a.off, 2147483652 ; [#uses=1] + ret i1 %C +} ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46688 - /llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll
Author: nicholas Date: Sun Feb 3 10:35:19 2008 New Revision: 46688 URL: http://llvm.org/viewvc/llvm-project?rev=46688&view=rev Log: Tag this test with the PR reference. Modified: llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll Modified: llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll?rev=46688&r1=46687&r2=46688&view=diff == --- llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2008-01-29-AddICmp.ll Sun Feb 3 10:35:19 2008 @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep {a.off} +; PR1949 define i1 @test1(i32 %a) { %a.off = add i32 %a, 4 ; [#uses=1] ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.2] r46690 - in /llvm-gcc-4.2/trunk/gcc: llvm-types.cpp tree.h
Author: johannes Date: Sun Feb 3 15:49:58 2008 New Revision: 46690 URL: http://llvm.org/viewvc/llvm-project?rev=46690&view=rev Log: Fix dumb bug in virtual base class conversion: when a type is used as a vbc, then used as a type for an ordinary field, it can be "restored" even though it wasn't replaced originally, causing havoc later. Use a marker bit instead of repeating the logic. Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp llvm-gcc-4.2/trunk/gcc/tree.h 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=46690&r1=46689&r2=46690&view=diff == --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Sun Feb 3 15:49:58 2008 @@ -232,6 +232,10 @@ // type should be passed in by invisible reference. // bool isPassedByInvisibleReference(tree Type) { + // Don't crash in this case. + if (Type == error_mark_node) +return false; + // FIXME: Search for TREE_ADDRESSABLE in calls.c, and see if there are other // cases that make arguments automatically passed in by reference. return TREE_ADDRESSABLE(Type) || TYPE_SIZE(Type) == 0 || @@ -1655,6 +1659,7 @@ TYPE_SIZE(newTy) = DECL_SIZE(Field); TYPE_SIZE_UNIT(newTy) = DECL_SIZE_UNIT(Field); TYPE_MAIN_VARIANT(newTy) = newTy; +TYPE_STUB_DECL(newTy) = TYPE_STUB_DECL(oldTy); // Change the name. if (TYPE_NAME(oldTy)) { const char *p = "anon"; @@ -1697,8 +1702,10 @@ TREE_CODE(DECL_SIZE(Field))==INTEGER_CST && TREE_CODE(TYPE_SIZE(TREE_TYPE(Field)))==INTEGER_CST && TREE_INT_CST_LOW(DECL_SIZE(Field)) < - TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(Field + TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(Field { TREE_TYPE(Field) = FixBaseClassField(Field); + DECL_FIELD_REPLACED(Field) = 1; +} } // Size of the complete type will be a multiple of its alignment. // In some cases involving empty C++ classes this is not true coming in. @@ -1734,23 +1741,16 @@ static void RestoreBaseClassFields(tree type) { assert(TREE_CODE(type)==RECORD_TYPE); for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { -if (TREE_CODE(Field)==FIELD_DECL && -!DECL_BIT_FIELD_TYPE(Field) && -TREE_CODE(DECL_FIELD_OFFSET(Field))==INTEGER_CST && -TREE_CODE(TREE_TYPE(Field))==RECORD_TYPE && -TYPE_SIZE(TREE_TYPE(Field)) && -DECL_SIZE(Field) && -TREE_CODE(DECL_SIZE(Field))==INTEGER_CST && -TREE_CODE(TYPE_SIZE(TREE_TYPE(Field)))==INTEGER_CST) { +if (TREE_CODE(Field) == FIELD_DECL && DECL_FIELD_REPLACED(Field)) { tree &oldTy = BaseTypesMap[TREE_TYPE(Field)]; - if (oldTy) -TREE_TYPE(Field) = oldTy; + assert(oldTy); + TREE_TYPE(Field) = oldTy; + DECL_FIELD_REPLACED(Field) = 0; } } } - /// DecodeStructFields - This method decodes the specified field, if it is a /// FIELD_DECL, adding or updating the specified StructTypeConversionInfo to /// reflect it. Return tree if field is decoded correctly. Otherwise return 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=46690&r1=46689&r2=46690&view=diff == --- llvm-gcc-4.2/trunk/gcc/tree.h (original) +++ llvm-gcc-4.2/trunk/gcc/tree.h Sun Feb 3 15:49:58 2008 @@ -2724,6 +2724,11 @@ writing debugging information about vfield and vbase decls for C++. */ #define DECL_FCONTEXT(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.fcontext) +/* LLVM LOCAL begin */ +/* In a FIELD_DECL, marks that the type is temporarily replaced in ConvertType. */ +#define DECL_FIELD_REPLACED(NODE) (FIELD_DECL_CHECK (NODE)->decl_common.decl_flag_0) +/* LLVM LOCAL end */ + /* In a FIELD_DECL, indicates this field should be bit-packed. */ #define DECL_PACKED(NODE) (FIELD_DECL_CHECK (NODE)->decl_common.decl_flag_1) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46693 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/memcpy.ll
Author: resistor Date: Sun Feb 3 20:59:58 2008 New Revision: 46693 URL: http://llvm.org/viewvc/llvm-project?rev=46693&view=rev Log: Allow GVN to hack on memcpy's, making them open to further optimization. Added: llvm/trunk/test/Transforms/GVN/memcpy.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=46693&r1=46692&r2=46693&view=diff == --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Sun Feb 3 20:59:58 2008 @@ -19,6 +19,7 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" +#include "llvm/IntrinsicInst.h" #include "llvm/Instructions.h" #include "llvm/Value.h" #include "llvm/ADT/BitVector.h" @@ -736,6 +737,7 @@ SmallVector& toErase); bool processNonLocalLoad(LoadInst* L, SmallVector& toErase); +bool processMemCpy(MemCpyInst* M, SmallVector& toErase); Value *GetValueForBlock(BasicBlock *BB, LoadInst* orig, DenseMap &Phis, bool top_level = false); @@ -1017,6 +1019,84 @@ return deletedLoad; } +/// processMemCpy - perform simplication of memcpy's. If we have memcpy A which +/// copies X to Y, and memcpy B which copies Y to Z, then we can rewrite B to be +/// a memcpy from X to Z (or potentially a memmove, depending on circumstances). +/// This allows later passes to remove the first memcpy altogether. +bool GVN::processMemCpy(MemCpyInst* M, +SmallVector& toErase) { + MemoryDependenceAnalysis& MD = getAnalysis(); + + // First, we have to check that the dependency is another memcpy + Instruction* dep = MD.getDependency(M); + if (dep == MemoryDependenceAnalysis::None || + dep == MemoryDependenceAnalysis::NonLocal || + !isa(dep)) +return false; + + // We can only transforms memcpy's where the dest of one is the source of the + // other + MemCpyInst* MDep = cast(dep); + if (M->getSource() != MDep->getDest()) +return false; + + // Second, the length of the memcpy's must be the same, or the preceeding one + // must be larger than the following one. + Value* DepLength = MDep->getLength(); + uint64_t CpySize = ~0UL; + uint64_t DepSize = ~0UL; + if (isa(DepLength)) { +if (isa(M->getLength())) { + if (cast(DepLength)->getLimitedValue() < + cast(M->getLength())->getLimitedValue()) { +return false; + } else { +CpySize = cast(M->getLength())->getLimitedValue(); +DepSize = cast(DepLength)->getLimitedValue(); + } +} else { + return false; +} + } else { +return false; + } + + // Finally, we have to make sure that the dest of the second does not + // alias the source of the first + AliasAnalysis& AA = getAnalysis(); + if (AA.alias(M->getRawDest(), CpySize, MDep->getRawSource(), DepSize) != + AliasAnalysis::NoAlias) { +// If they don't, we can still make the transformation by first turning M +// into a memmove rather than a memcpy. +bool is32bit = M->getIntrinsicID() == Intrinsic::memcpy_i32; +Function* MemMoveFun = Intrinsic::getDeclaration( + M->getParent()->getParent()->getParent(), + is32bit ? Intrinsic::memmove_i32 : + Intrinsic::memmove_i64); + +std::vector args; +args.push_back(M->getRawDest()); +args.push_back(MDep->getRawSource()); +args.push_back(M->getLength()); +args.push_back(M->getAlignment()); + +new CallInst(MemMoveFun, args.begin(), args.end(), "", M); + +MD.removeInstruction(M); +toErase.push_back(M); + +return true; + } + + // If all checks passed, then we can transform these memcpy's + M->setSource(MDep->getRawSource()); + + // Reset dependence information for the memcpy + MD.removeInstruction(M); + + return true; +} + /// processInstruction - When calculating availability, handle an instruction /// by inserting it into the appropriate sets bool GVN::processInstruction(Instruction* I, @@ -1025,6 +1105,8 @@ SmallVector& toErase) { if (LoadInst* L = dyn_cast(I)) { return processLoad(L, lastSeenLoad, toErase); + } else if (MemCpyInst* M = dyn_cast(I)) { +return processMemCpy(M, toErase); } unsigned num = VN.lookup_or_add(I); Added: llvm/trunk/test/Transforms/GVN/memcpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/memcpy.ll?rev=46693&view=auto == --- llvm/trunk/test/Transforms/GVN/memcpy.ll (added) +++ llvm/trunk/test/Transf
[llvm-commits] [llvm] r46694 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
Author: resistor Date: Sun Feb 3 22:53:00 2008 New Revision: 46694 URL: http://llvm.org/viewvc/llvm-project?rev=46694&view=rev Log: Be more precise when eliminating pointers bue to memcpy's. This allows more stores to be deleted in some cases. Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=46694&r1=46693&r2=46694&view=diff == --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sun Feb 3 22:53:00 2008 @@ -52,7 +52,7 @@ Instruction* dependency, SetVector& possiblyDead); bool handleEndBlock(BasicBlock& BB, SetVector& possiblyDead); -bool RemoveUndeadPointers(Value* pointer, +bool RemoveUndeadPointers(Value* pointer, uint64_t killPointerSize, BasicBlock::iterator& BBI, SmallPtrSet& deadPointers, SetVector& possiblyDead); @@ -322,6 +322,7 @@ } Value* killPointer = 0; +uint64_t killPointerSize = ~0UL; // If we encounter a use of the pointer, it is no longer considered dead if (LoadInst* L = dyn_cast(BBI)) { @@ -346,6 +347,11 @@ killPointer = L->getPointerOperand(); } else if (VAArgInst* V = dyn_cast(BBI)) { killPointer = V->getOperand(0); +} else if (isa(BBI) && + isa(cast(BBI)->getLength())) { + killPointer = cast(BBI)->getSource(); + killPointerSize = cast( + cast(BBI)->getLength())->getZExtValue(); } else if (AllocaInst* A = dyn_cast(BBI)) { deadPointers.erase(A); @@ -444,7 +450,7 @@ TranslatePointerBitCasts(killPointer); // Deal with undead pointers -MadeChange |= RemoveUndeadPointers(killPointer, BBI, +MadeChange |= RemoveUndeadPointers(killPointer, killPointerSize, BBI, deadPointers, possiblyDead); } @@ -453,7 +459,7 @@ /// RemoveUndeadPointers - check for uses of a pointer that make it /// undead when scanning for dead stores to alloca's. -bool DSE::RemoveUndeadPointers(Value* killPointer, +bool DSE::RemoveUndeadPointers(Value* killPointer, uint64_t killPointerSize, BasicBlock::iterator& BBI, SmallPtrSet& deadPointers, SetVector& possiblyDead) { @@ -491,7 +497,7 @@ // See if this pointer could alias it AliasAnalysis::AliasResult A = AA.alias(*I, pointerSize, -killPointer, ~0U); +killPointer, killPointerSize); // If it must-alias and a store, we can delete it if (isa(BBI) && A == AliasAnalysis::MustAlias) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46695 - /llvm/trunk/test/Transforms/GVN/memcpy.ll
Author: resistor Date: Sun Feb 3 22:55:24 2008 New Revision: 46695 URL: http://llvm.org/viewvc/llvm-project?rev=46695&view=rev Log: Make this test more aggressive, to cover recent improvements. Modified: llvm/trunk/test/Transforms/GVN/memcpy.ll Modified: llvm/trunk/test/Transforms/GVN/memcpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/memcpy.ll?rev=46695&r1=46694&r2=46695&view=diff == --- llvm/trunk/test/Transforms/GVN/memcpy.ll (original) +++ llvm/trunk/test/Transforms/GVN/memcpy.ll Sun Feb 3 22:55:24 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -gvn -dse | llvm-dis | not grep {i8* %agg.result21, i8* %tmp219} +; RUN: llvm-as < %s | opt -gvn -dse | llvm-dis | grep memcpy | count 2 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-darwin9" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46696 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td
Author: sampo Date: Sun Feb 3 23:34:34 2008 New Revision: 46696 URL: http://llvm.org/viewvc/llvm-project?rev=46696&view=rev Log: Some more SSE 4.1 intrinsic patterns. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=46696&r1=46695&r2=46696&view=diff == --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Sun Feb 3 23:34:34 2008 @@ -2539,6 +2539,7 @@ } } +// FIXME: are these really two-address? defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb", int_x86_ssse3_pabs_b, int_x86_ssse3_pabs_b_128>; @@ -3045,14 +3046,14 @@ // SSE4.1 Instruction Templates: // -// SS418I - SSE 4.1 instructions with T8 prefix. +// SS48I - SSE 4.1 instructions with T8 prefix. // SS41AI - SSE 4.1 instructions with TA prefix. // -class SS418I o, Format F, dag outs, dag ins, string asm, - list pattern> +class SS48I o, Format F, dag outs, dag ins, string asm, +list pattern> : I, T8, Requires<[HasSSE41]>; -class SS41AI o, Format F, dag outs, dag ins, string asm, - list pattern> +class SS4AI o, Format F, dag outs, dag ins, string asm, +list pattern> : I, TA, Requires<[HasSSE41]>; @@ -3062,74 +3063,136 @@ Intrinsic F32Int, Intrinsic V4F32Int, Intrinsic F64Int, -Intrinsic V2F64Int, -bit Commutable = 0> { +Intrinsic V2F64Int> { // Intrinsic operation, reg. - def SSr_Int : SS41AI { -let isCommutable = Commutable; - } +[(set VR128:$dst, (F32Int VR128:$src1, imm:$src2))]>, +OpSize; // Intrinsic operation, mem. - def SSm_Int : SS41AI; +[(set VR128:$dst, (F32Int sse_load_f32:$src1, imm:$src2))]>, +OpSize; // Vector intrinsic operation, reg - def PSr_Int : SS41AI { -let isCommutable = Commutable; - } +[(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>, +OpSize; // Vector intrinsic operation, mem - def PSm_Int : SS41AI; +[(set VR128:$dst, (V4F32Int (load addr:$src1),imm:$src2))]>, +OpSize; // Intrinsic operation, reg. - def SDr_Int : SS41AI { -let isCommutable = Commutable; - } +[(set VR128:$dst, (F64Int VR128:$src1, imm:$src2))]>, +OpSize; // Intrinsic operation, mem. - def SDm_Int : SS41AI; +[(set VR128:$dst, (F64Int sse_load_f64:$src1, imm:$src2))]>, +OpSize; // Vector intrinsic operation, reg - def PDr_Int : SS41AI { -let isCommutable = Commutable; - } +[(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>, +OpSize; // Vector intrinsic operation, mem - def PDm_Int : SS41AI; +[(set VR128:$dst, (V2F64Int (load addr:$src1),imm:$src2))]>, +OpSize; } // FP round - roundss, roundps, roundsd, roundpd defm ROUND : sse41_fp_unop_rm<0x0A, 0x08, 0x0B, 0x09, "round", int_x86_sse41_round_ss, int_x86_sse41_round_ps, int_x86_sse41_round_sd, int_x86_sse41_round_pd>; + +// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16. +multiclass SS41I_unop_rm_int_v16 opc, string OpcodeStr, + Intrinsic IntId128> { + def rr128 : SS48I, OpSize; + def rm128 : SS48I, OpSize; +} + +defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw", + int_x86_sse41_phminposuw>; + +/// SS41I_binop_rm_int - Simple SSE 4.1 binary operator +let isTwoAddress = 1 in { + multiclass SS41I_binop_rm_int opc, string OpcodeStr, +Intrinsic IntId128, bit Commutable = 0> { +def rr128 : SS48I, + OpSize { + let isCommutable = Commutable; +} +def rm128 : SS48I, OpSize; + } +} + +defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq", + int_x86_sse41_pcmpeqq, 1>; +defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw", + int_x86_sse41_packusdw, 0>; +defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb", + int_x86_sse41_pminsb, 1>; +defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd", + int_x86_sse41_pminsd, 1>; +defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud", + int_x86_sse41_pminud, 1>; +def
[llvm-commits] [llvm-gcc-4.2] r46702 - /llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c
Author: tbrethou Date: Mon Feb 4 00:48:51 2008 New Revision: 46702 URL: http://llvm.org/viewvc/llvm-project?rev=46702&view=rev Log: Merge from mainline. Eliminate a compilation warning. Modified: llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c Modified: llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c?rev=46702&r1=46701&r2=46702&view=diff == --- llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c (original) +++ llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c Mon Feb 4 00:48:51 2008 @@ -15233,11 +15233,14 @@ (inter-module thumbness is fixed up by the linker). */ rtx tem = gen_rtx_SYMBOL_REF (Pmode, function_name); - if (TARGET_MACHO - && ! machopic_data_defined_p (function_rtx)) +#if TARGET_MACHO + if (! machopic_data_defined_p (function_rtx)) tem = gen_rtx_PLUS (GET_MODE (tem), tem, GEN_INT (-8)); else tem = gen_rtx_PLUS (GET_MODE (tem), tem, GEN_INT (-7)); +#else + tem = gen_rtx_PLUS (GET_MODE (tem), tem, GEN_INT (-7)); +#endif /* APPLE LOCAL end ARM 4745175 */ tem = gen_rtx_MINUS (GET_MODE (tem), ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46698 - in /llvm/branches/release_22/lib/Target/X86: X86RegisterInfo.cpp X86RegisterInfo.h X86RegisterInfo.td
Author: tbrethou Date: Mon Feb 4 00:17:46 2008 New Revision: 46698 URL: http://llvm.org/viewvc/llvm-project?rev=46698&view=rev Log: Merge from mainline. Provide correct DWARF register numbering for debug information emission on x86-32/Darwin. This should fix bunch of issues. Modified: llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.cpp llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.h llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.td Modified: llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.cpp?rev=46698&r1=46697&r2=46698&view=diff == --- llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.cpp Mon Feb 4 00:17:46 2008 @@ -64,12 +64,15 @@ unsigned Flavour = DWARFFlavour::X86_64; if (!Subtarget->is64Bit()) { if (Subtarget->isTargetDarwin()) { - Flavour = DWARFFlavour::X86_32_Darwin; + if (isEH) +Flavour = DWARFFlavour::X86_32_DarwinEH; + else +Flavour = DWARFFlavour::X86_32_Generic; } else if (Subtarget->isTargetCygMing()) { // Unsupported by now, just quick fallback - Flavour = DWARFFlavour::X86_32_ELF; + Flavour = DWARFFlavour::X86_32_Generic; } else { - Flavour = DWARFFlavour::X86_32_ELF; + Flavour = DWARFFlavour::X86_32_Generic; } } Modified: llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.h?rev=46698&r1=46697&r2=46698&view=diff == --- llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.h (original) +++ llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.h Mon Feb 4 00:17:46 2008 @@ -36,7 +36,7 @@ /// namespace DWARFFlavour { enum { -X86_64 = 0, X86_32_Darwin = 1, X86_32_ELF = 2 +X86_64 = 0, X86_32_DarwinEH = 1, X86_32_Generic = 2 }; } Modified: llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.td?rev=46698&r1=46697&r2=46698&view=diff == --- llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.td (original) +++ llvm/branches/release_22/lib/Target/X86/X86RegisterInfo.td Mon Feb 4 00:17:46 2008 @@ -25,11 +25,8 @@ // Dwarf numbering is different for 32-bit and 64-bit, and there are // variations by target as well. Currently the first entry is for X86-64, - // second - for X86-32/Darwin and third for X86-32/Linux - - // FIXME: Comments in gcc indicate that Darwin uses different numbering - // for debug info and exception handling info:( The numbering here is - // for exception handling. + // second - for EH on X86-32/Darwin and third is 'generic' one (X86-32/Linux + // and debug information on X86-32/Darwin) // 8-bit registers // Low registers ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46697 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td
Author: sampo Date: Mon Feb 4 00:00:24 2008 New Revision: 46697 URL: http://llvm.org/viewvc/llvm-project?rev=46697&view=rev Log: The rest of the SSE4.1 intrinsic patterns that are obvious to me. Getting Evan's help with the rest. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=46697&r1=46696&r2=46697&view=diff == --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Feb 4 00:00:24 2008 @@ -3066,7 +3066,7 @@ Intrinsic V2F64Int> { // Intrinsic operation, reg. def SSr_Int : SS4AI, @@ -3074,7 +3074,7 @@ // Intrinsic operation, mem. def SSm_Int : SS4AI, @@ -3082,7 +3082,7 @@ // Vector intrinsic operation, reg def PSr_Int : SS4AI, @@ -3090,7 +3090,7 @@ // Vector intrinsic operation, mem def PSm_Int : SS4AI, @@ -3098,7 +3098,7 @@ // Intrinsic operation, reg. def SDr_Int : SS4AI, @@ -3106,7 +3106,7 @@ // Intrinsic operation, mem. def SDm_Int : SS4AI, @@ -3114,7 +3114,7 @@ // Vector intrinsic operation, reg def PDr_Int : SS4AI, @@ -3122,7 +3122,7 @@ // Vector intrinsic operation, mem def PDm_Int : SS4AI, @@ -3196,3 +3196,40 @@ int_x86_sse41_pmulld, 1>; defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>; + +/// SS41I_binop_rmi_int - SSE 4.1 binary operator with immediate +let isTwoAddress = 1 in { + multiclass SS41I_binop_rmi_int opc, string OpcodeStr, + Intrinsic IntId128, bit Commutable = 0> { +def rri128 : SS4AI, + OpSize { + let isCommutable = Commutable; +} +def rmi128 : SS4AI, +OpSize; + } +} + +defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps", +int_x86_sse41_blendps, 0>; +defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd", +int_x86_sse41_blendpd, 0>; +defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw", +int_x86_sse41_pblendw, 0>; +defm DPPS : SS41I_binop_rmi_int<0x40, "dpps", +int_x86_sse41_dpps, 1>; +defm DPPD : SS41I_binop_rmi_int<0x41, "dppd", +int_x86_sse41_dppd, 1>; +defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw", +int_x86_sse41_mpsadbw, 0>; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46699 - /llvm/branches/release_22/lib/CodeGen/ShadowStackCollector.cpp
Author: tbrethou Date: Mon Feb 4 00:29:04 2008 New Revision: 46699 URL: http://llvm.org/viewvc/llvm-project?rev=46699&view=rev Log: Merge from mainline. Don't dump the function! Modified: llvm/branches/release_22/lib/CodeGen/ShadowStackCollector.cpp Modified: llvm/branches/release_22/lib/CodeGen/ShadowStackCollector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_22/lib/CodeGen/ShadowStackCollector.cpp?rev=46699&r1=46698&r2=46699&view=diff == --- llvm/branches/release_22/lib/CodeGen/ShadowStackCollector.cpp (original) +++ llvm/branches/release_22/lib/CodeGen/ShadowStackCollector.cpp Mon Feb 4 00:29:04 2008 @@ -426,8 +426,6 @@ Roots[I].second->eraseFromParent(); } - F.dump(); - Roots.clear(); return true; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.2] r46700 - in /llvm-gcc-4.2/branches/release_22/gcc/config/arm: arm.c arm.h bpabi.h
Author: tbrethou Date: Mon Feb 4 00:46:23 2008 New Revision: 46700 URL: http://llvm.org/viewvc/llvm-project?rev=46700&view=rev Log: Merge from mainline. Fix the build for arm-linux-gnueabi. Modified: llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.h llvm-gcc-4.2/branches/release_22/gcc/config/arm/bpabi.h Modified: llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c?rev=46700&r1=46699&r2=46700&view=diff == --- llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c (original) +++ llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c Mon Feb 4 00:46:23 2008 @@ -15165,13 +15165,14 @@ const char *function_name; /* Darwin/mach-o: use a stub for dynamic references. */ - if (TARGET_MACHO - && (flag_pic || MACHO_DYNAMIC_NO_PIC_P) +#if TARGET_MACHO + if ((flag_pic || MACHO_DYNAMIC_NO_PIC_P) && ! machopic_data_defined_p (function_rtx)) function_name = machopic_indirection_name (function_rtx, true); - else -function_name = XSTR (function_rtx, 0); +#else + function_name = XSTR (function_rtx, 0); +#endif /* APPLE LOCAL ARM end 4745175 */ if (mi_delta < 0) Modified: llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.h?rev=46700&r1=46699&r2=46700&view=diff == --- llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.h Mon Feb 4 00:46:23 2008 @@ -31,6 +31,9 @@ #ifndef TARGET_MACHO #define TARGET_MACHO 0 #endif +#ifndef MACHO_DYNAMIC_NO_PIC_P +#define MACHO_DYNAMIC_NO_PIC_P 0 +#endif /* APPLE LOCAL end ARM darwin target */ /* APPLE LOCAL ARM interworking */ @@ -1830,9 +1833,15 @@ #define SHORT_CALL_FLAG_CHAR '^' #define LONG_CALL_FLAG_CHAR'#' +#define ENCODED_SHORT_CALL_ATTR_P(SYMBOL_NAME) \ + (*(SYMBOL_NAME) == SHORT_CALL_FLAG_CHAR) + #define SYMBOL_SHORT_CALL_ATTR_P(SYMBOL) \ (SYMBOL_REF_FLAGS (SYMBOL) & SYMBOL_SHORT_CALL) +#define ENCODED_LONG_CALL_ATTR_P(SYMBOL_NAME) \ + (*(SYMBOL_NAME) == LONG_CALL_FLAG_CHAR) + #define SYMBOL_LONG_CALL_ATTR_P(SYMBOL) \ (SYMBOL_REF_FLAGS (SYMBOL) & SYMBOL_LONG_CALL) Modified: llvm-gcc-4.2/branches/release_22/gcc/config/arm/bpabi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/release_22/gcc/config/arm/bpabi.h?rev=46700&r1=46699&r2=46700&view=diff == --- llvm-gcc-4.2/branches/release_22/gcc/config/arm/bpabi.h (original) +++ llvm-gcc-4.2/branches/release_22/gcc/config/arm/bpabi.h Mon Feb 4 00:46:23 2008 @@ -35,7 +35,9 @@ /* EABI targets should enable interworking by default. */ #undef TARGET_DEFAULT -#define TARGET_DEFAULT MASK_INTERWORK +/* LLVM Local begin */ +#define TARGET_DEFAULT (0) +/* LLVM Local end */ /* The ARM BPABI functions return a boolean; they use no special calling convention. */ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.2] r46701 - /llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c
Author: tbrethou Date: Mon Feb 4 00:47:14 2008 New Revision: 46701 URL: http://llvm.org/viewvc/llvm-project?rev=46701&view=rev Log: Merge from mainline. Fix my previous patch. It changed the behavior on TARGET_MACHO. Modified: llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c Modified: llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c?rev=46701&r1=46700&r2=46701&view=diff == --- llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c (original) +++ llvm-gcc-4.2/branches/release_22/gcc/config/arm/arm.c Mon Feb 4 00:47:14 2008 @@ -15167,9 +15167,11 @@ /* Darwin/mach-o: use a stub for dynamic references. */ #if TARGET_MACHO if ((flag_pic || MACHO_DYNAMIC_NO_PIC_P) - && ! machopic_data_defined_p (function_rtx)) -function_name = - machopic_indirection_name (function_rtx, true); + && ! machopic_data_defined_p (function_rtx)) + function_name = + machopic_indirection_name (function_rtx, true); + else + function_name = XSTR (function_rtx, 0); #else function_name = XSTR (function_rtx, 0); #endif ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.0] r46704 - /llvm-gcc-4.0/branches/release_22/gcc/llvm-types.cpp
Author: tbrethou Date: Mon Feb 4 01:16:40 2008 New Revision: 46704 URL: http://llvm.org/viewvc/llvm-project?rev=46704&view=rev Log: Patch to not turn gcc's pure/const markings into readonly/readnone if a parameter has a byval attribute. Modified: llvm-gcc-4.0/branches/release_22/gcc/llvm-types.cpp Modified: llvm-gcc-4.0/branches/release_22/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/branches/release_22/gcc/llvm-types.cpp?rev=46704&r1=46703&r2=46704&view=diff == --- llvm-gcc-4.0/branches/release_22/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.0/branches/release_22/gcc/llvm-types.cpp Mon Feb 4 01:16:40 2008 @@ -1043,17 +1043,16 @@ // Check for 'readnone' function attribute. if (flags & ECF_CONST) -// Since they write the return value through a pointer, -// 'sret' functions cannot be 'readnone'. -if (!ABIConverter.isStructReturn()) - RAttributes |= ParamAttr::ReadNone; +RAttributes |= ParamAttr::ReadNone; // Check for 'readonly' function attribute. - if (flags & ECF_PURE) -// Since they write the return value through a pointer, -// 'sret' functions cannot be 'readonly'. -if (!ABIConverter.isStructReturn()) - RAttributes |= ParamAttr::ReadOnly; + if (flags & ECF_PURE && !(flags & ECF_CONST)) + RAttributes |= ParamAttr::ReadOnly; + + // Since they write the return value through a pointer, + // 'sret' functions cannot be 'readnone' or 'readonly'. + if (ABIConverter.isStructReturn()) +RAttributes &= ~(ParamAttr::ReadNone|ParamAttr::ReadOnly); // Compute whether the result needs to be zext or sext'd. RAttributes |= HandleArgumentExtension(TREE_TYPE(type)); @@ -1082,6 +1081,9 @@ LLVM_TARGET_INIT_REGPARM(local_regparam, type); #endif // LLVM_TARGET_ENABLE_REGPARM + // Keep track of whether we see a byval argument. + bool HasByVal = false; + // Check if we have a corresponding decl to inspect. tree DeclArgs = (decl) ? DECL_ARGUMENTS(decl) : NULL; // Loop over all of the arguments, adding them as we go. @@ -1128,13 +1130,27 @@ local_regparam); #endif // LLVM_TARGET_ENABLE_REGPARM -if (Attributes != ParamAttr::None) +if (Attributes != ParamAttr::None) { + HasByVal |= Attributes & ParamAttr::ByVal; Attrs.push_back(ParamAttrsWithIndex::get(ArgTypes.size(), Attributes)); +} if (DeclArgs) DeclArgs = TREE_CHAIN(DeclArgs); } + // If there is a byval argument then it is not safe to mark the function + // 'readnone' or 'readonly': gcc permits a 'const' or 'pure' function to + // write to struct arguments passed by value, but in LLVM this becomes a + // write through the byval pointer argument, which LLVM does not allow for + // readonly/readnone functions. + if (HasByVal && Attrs[0].index == 0) { +uint16_t &RAttrs = Attrs[0].attrs; +RAttrs &= ~(ParamAttr::ReadNone | ParamAttr::ReadOnly); +if (RAttrs == ParamAttr::None) + Attrs.erase(Attrs.begin()); + } + // If the argument list ends with a void type node, it isn't vararg. isVarArg = (Args == 0); assert(RetTy && "Return type not specified!"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.2] r46703 - /llvm-gcc-4.2/branches/release_22/gcc/llvm-types.cpp
Author: tbrethou Date: Mon Feb 4 01:03:17 2008 New Revision: 46703 URL: http://llvm.org/viewvc/llvm-project?rev=46703&view=rev Log: Patch to not turn gcc's pure/const markings into readonly/readnone if a parameter has a byval attribute. Modified: llvm-gcc-4.2/branches/release_22/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/branches/release_22/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/release_22/gcc/llvm-types.cpp?rev=46703&r1=46702&r2=46703&view=diff == --- llvm-gcc-4.2/branches/release_22/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/branches/release_22/gcc/llvm-types.cpp Mon Feb 4 01:03:17 2008 @@ -1123,18 +1123,17 @@ // accepts it). But llvm IR does not allow both, so // set only ReadNone. if (flags & ECF_CONST) -// Since they write the return value through a pointer, -// 'sret' functions cannot be 'readnone'. -if (!ABIConverter.isStructReturn()) - RAttributes |= ParamAttr::ReadNone; +RAttributes |= ParamAttr::ReadNone; // Check for 'readonly' function attribute. if (flags & ECF_PURE && !(flags & ECF_CONST)) -// Since they write the return value through a pointer, -// 'sret' functions cannot be 'readonly'. -if (!ABIConverter.isStructReturn()) - RAttributes |= ParamAttr::ReadOnly; +RAttributes |= ParamAttr::ReadOnly; + // Since they write the return value through a pointer, + // 'sret' functions cannot be 'readnone' or 'readonly'. + if (ABIConverter.isStructReturn()) +RAttributes &= ~(ParamAttr::ReadNone|ParamAttr::ReadOnly); + // Compute whether the result needs to be zext or sext'd. RAttributes |= HandleArgumentExtension(TREE_TYPE(type)); @@ -1162,6 +1161,9 @@ LLVM_TARGET_INIT_REGPARM(local_regparam, type); #endif // LLVM_TARGET_ENABLE_REGPARM + // Keep track of whether we see a byval argument. + bool HasByVal = false; + // Check if we have a corresponding decl to inspect. tree DeclArgs = (decl) ? DECL_ARGUMENTS(decl) : NULL; // Loop over all of the arguments, adding them as we go. @@ -1208,13 +1210,27 @@ local_regparam); #endif // LLVM_TARGET_ENABLE_REGPARM -if (Attributes != ParamAttr::None) +if (Attributes != ParamAttr::None) { + HasByVal |= Attributes & ParamAttr::ByVal; Attrs.push_back(ParamAttrsWithIndex::get(ArgTypes.size(), Attributes)); +} if (DeclArgs) DeclArgs = TREE_CHAIN(DeclArgs); } + // If there is a byval argument then it is not safe to mark the function + // 'readnone' or 'readonly': gcc permits a 'const' or 'pure' function to + // write to struct arguments passed by value, but in LLVM this becomes a + // write through the byval pointer argument, which LLVM does not allow for + // readonly/readnone functions. + if (HasByVal && Attrs[0].index == 0) { +uint16_t &RAttrs = Attrs[0].attrs; +RAttrs &= ~(ParamAttr::ReadNone | ParamAttr::ReadOnly); +if (RAttrs == ParamAttr::None) + Attrs.erase(Attrs.begin()); + } + // If the argument list ends with a void type node, it isn't vararg. isVarArg = (Args == 0); assert(RetTy && "Return type not specified!"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits