From baldrick at free.fr Mon May 9 03:03:33 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 May 2011 08:03:33 -0000 Subject: [llvm-commits] [llvm] r131082 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Message-ID: <20110509080333.BC05E2A6C12D@llvm.org> Author: baldrick Date: Mon May 9 03:03:33 2011 New Revision: 131082 URL: http://llvm.org/viewvc/llvm-project?rev=131082&view=rev Log: Indent properly, no functionality change. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=131082&r1=131081&r2=131082&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon May 9 03:03:33 2011 @@ -6494,18 +6494,18 @@ // (vextract (scalar_to_vector val, 0) -> val SDValue InVec = N->getOperand(0); - if (InVec.getOpcode() == ISD::SCALAR_TO_VECTOR) { - // Check if the result type doesn't match the inserted element type. A - // SCALAR_TO_VECTOR may truncate the inserted element and the - // EXTRACT_VECTOR_ELT may widen the extracted vector. - SDValue InOp = InVec.getOperand(0); - EVT NVT = N->getValueType(0); - if (InOp.getValueType() != NVT) { - assert(InOp.getValueType().isInteger() && NVT.isInteger()); - return DAG.getSExtOrTrunc(InOp, InVec.getDebugLoc(), NVT); - } - return InOp; - } + if (InVec.getOpcode() == ISD::SCALAR_TO_VECTOR) { + // Check if the result type doesn't match the inserted element type. A + // SCALAR_TO_VECTOR may truncate the inserted element and the + // EXTRACT_VECTOR_ELT may widen the extracted vector. + SDValue InOp = InVec.getOperand(0); + EVT NVT = N->getValueType(0); + if (InOp.getValueType() != NVT) { + assert(InOp.getValueType().isInteger() && NVT.isInteger()); + return DAG.getSExtOrTrunc(InOp, InVec.getDebugLoc(), NVT); + } + return InOp; + } // Perform only after legalization to ensure build_vector / vector_shuffle // optimizations have already been done. From baldrick at free.fr Mon May 9 06:19:49 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 May 2011 11:19:49 -0000 Subject: [llvm-commits] [dragonegg] r131083 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp Message-ID: <20110509111949.6D10E2A6C12C@llvm.org> Author: baldrick Date: Mon May 9 06:19:49 2011 New Revision: 131083 URL: http://llvm.org/viewvc/llvm-project?rev=131083&view=rev Log: Add support for VEC_EXTRACT_EVEN_EXPR, VEC_EXTRACT_ODD_EXPR, VEC_INTERLEAVE_HIGH_EXPR and VEC_INTERLEAVE_LOW_EXPR. These may be produced by the GCC vectorizer when GCC optimizations are enabled. Modified: dragonegg/trunk/include/dragonegg/Internals.h dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/include/dragonegg/Internals.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=131083&r1=131082&r2=131083&view=diff ============================================================================== --- dragonegg/trunk/include/dragonegg/Internals.h (original) +++ dragonegg/trunk/include/dragonegg/Internals.h Mon May 9 06:19:49 2011 @@ -717,6 +717,10 @@ tree_node *op1); Value *EmitReg_TRUNC_DIV_EXPR(tree_node *op0, tree_node *op1, bool isExact); Value *EmitReg_TRUNC_MOD_EXPR(tree_node *op0, tree_node *op1); + Value *EmitReg_VEC_EXTRACT_EVEN_EXPR(tree_node *op0, tree_node *op1); + Value *EmitReg_VEC_EXTRACT_ODD_EXPR(tree_node *op0, tree_node *op1); + Value *EmitReg_VEC_INTERLEAVE_HIGH_EXPR(tree_node *op0, tree_node *op1); + Value *EmitReg_VEC_INTERLEAVE_LOW_EXPR(tree_node *op0, tree_node *op1); Value *EmitLoadOfLValue(tree_node *exp); Value *EmitOBJ_TYPE_REF(tree_node *exp); Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131083&r1=131082&r2=131083&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Mon May 9 06:19:49 2011 @@ -6944,6 +6944,56 @@ Builder.CreateURem(LHS, RHS) : Builder.CreateSRem(LHS, RHS); } +Value *TreeToLLVM::EmitReg_VEC_EXTRACT_EVEN_EXPR(tree op0, tree op1) { + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); + unsigned Length = TYPE_VECTOR_SUBPARTS(TREE_TYPE(op0)); + SmallVector Mask; + Mask.reserve(Length); + for (unsigned i = 0; i != Length; ++i) + Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), 2*i)); + return Builder.CreateShuffleVector(LHS, RHS, ConstantVector::get(Mask)); +} + +Value *TreeToLLVM::EmitReg_VEC_EXTRACT_ODD_EXPR(tree op0, tree op1) { + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); + unsigned Length = TYPE_VECTOR_SUBPARTS(TREE_TYPE(op0)); + SmallVector Mask; + Mask.reserve(Length); + for (unsigned i = 0; i != Length; ++i) + Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), 2*i+1)); + return Builder.CreateShuffleVector(LHS, RHS, ConstantVector::get(Mask)); +} + +Value *TreeToLLVM::EmitReg_VEC_INTERLEAVE_HIGH_EXPR(tree op0, tree op1) { + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); + unsigned Length = TYPE_VECTOR_SUBPARTS(TREE_TYPE(op0)); + assert(!(Length & 1) && "Expected an even number of vector elements!"); + SmallVector Mask; + Mask.reserve(Length); + for (unsigned i = Length/2; i != Length; ++i) { + Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), i)); + Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), Length + i)); + } + return Builder.CreateShuffleVector(LHS, RHS, ConstantVector::get(Mask)); +} + +Value *TreeToLLVM::EmitReg_VEC_INTERLEAVE_LOW_EXPR(tree op0, tree op1) { + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); + unsigned Length = TYPE_VECTOR_SUBPARTS(TREE_TYPE(op0)); + assert(!(Length & 1) && "Expected an even number of vector elements!"); + SmallVector Mask; + Mask.reserve(Length); + for (unsigned i = 0, e = Length/2; i != e; ++i) { + Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), i)); + Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), Length + i)); + } + return Builder.CreateShuffleVector(LHS, RHS, ConstantVector::get(Mask)); +} + //===----------------------------------------------------------------------===// // ... Exception Handling ... @@ -7800,7 +7850,7 @@ Value *RHS = 0; switch (code) { default: - DieAbjectly("Unhandled GIMPLE assignment!", stmt); + DieAbjectly("Unsupported GIMPLE assignment!", stmt); // Unary expressions. case ABS_EXPR: @@ -7901,6 +7951,14 @@ RHS = EmitReg_TruthOp(type, rhs1, rhs2, Instruction::Or); break; case TRUTH_XOR_EXPR: RHS = EmitReg_TruthOp(type, rhs1, rhs2, Instruction::Xor); break; + case VEC_EXTRACT_EVEN_EXPR: + RHS = EmitReg_VEC_EXTRACT_EVEN_EXPR(rhs1, rhs2); break; + case VEC_EXTRACT_ODD_EXPR: + RHS = EmitReg_VEC_EXTRACT_ODD_EXPR(rhs1, rhs2); break; + case VEC_INTERLEAVE_HIGH_EXPR: + RHS = EmitReg_VEC_INTERLEAVE_HIGH_EXPR(rhs1, rhs2); break; + case VEC_INTERLEAVE_LOW_EXPR: + RHS = EmitReg_VEC_INTERLEAVE_LOW_EXPR(rhs1, rhs2); break; } assert(RHS->getType() == getRegType(type) && "RHS has wrong type!"); From rafael.espindola at gmail.com Mon May 9 12:52:09 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Mon, 09 May 2011 13:52:09 -0400 Subject: [llvm-commits] [patch] Don't bake build info into the host Message-ID: <4DC829C9.1020302@gmail.com> While working with 32 bit build of llvm on a 64 bit host I noticed that the 32 bit clang was unable to link any program. The problem was that the basic 32 bit files (like crtbegin.o) are in different different paths on i386 and x86_64 hosts. The 32 bit clang was assuming it was running on a 32 bit host and failing to find them. I tracked the problem to getHostTriple. Despite its name, it returns information about the build too. The attached patch creates an explicit getBuildTriple. With this patch the 32 bit clang can link binaries on a 64 bit host. Cheers, Rafael -------------- next part -------------- A non-text attachment was scrubbed... Name: host.patch Type: text/x-patch Size: 2814 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110509/e6739805/attachment.bin From wangmp at apple.com Mon May 9 12:47:27 2011 From: wangmp at apple.com (Mon P Wang) Date: Mon, 09 May 2011 17:47:27 -0000 Subject: [llvm-commits] [llvm] r131085 - in /llvm/trunk: lib/Target/ARM/ARMCodeEmitter.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrNEON.td lib/Target/ARM/ARMMCCodeEmitter.cpp utils/TableGen/EDEmitter.cpp Message-ID: <20110509174727.E19D72A6C12C@llvm.org> Author: wangmp Date: Mon May 9 12:47:27 2011 New Revision: 131085 URL: http://llvm.org/viewvc/llvm-project?rev=131085&view=rev Log: Fixed MC encoding for index_align for VLD1/VST1 (single element from one lane) for size 32 Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp llvm/trunk/utils/TableGen/EDEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=131085&r1=131084&r2=131085&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Mon May 9 12:47:27 2011 @@ -221,6 +221,9 @@ const { return 0; } unsigned getAddrMode6AddressOpValue(const MachineInstr &MI, unsigned Op) const { return 0; } + unsigned getAddrMode6OneLane32AddressOpValue(const MachineInstr &MI, + unsigned Op) + const { return 0; } unsigned getAddrMode6DupAddressOpValue(const MachineInstr &MI, unsigned Op) const { return 0; } unsigned getAddrMode6OffsetOpValue(const MachineInstr &MI, unsigned Op) Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=131085&r1=131084&r2=131085&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Mon May 9 12:47:27 2011 @@ -588,6 +588,15 @@ let EncoderMethod = "getAddrMode6OffsetOpValue"; } +// Special version of addrmode6 to handle alignment encoding for VST1/VLD1 +// (single element from one lane) for size 32. +def addrmode6oneL32 : Operand, + ComplexPattern{ + let PrintMethod = "printAddrMode6Operand"; + let MIOperandInfo = (ops GPR:$addr, i32imm); + let EncoderMethod = "getAddrMode6OneLane32AddressOpValue"; +} + // Special version of addrmode6 to handle alignment encoding for VLD-dup // instructions, specifically VLD4-dup. def addrmode6dup : Operand, Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=131085&r1=131084&r2=131085&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Mon May 9 12:47:27 2011 @@ -531,6 +531,17 @@ imm:$lane))]> { let Rm = 0b1111; } +class VLD1LN32 op11_8, bits<4> op7_4, string Dt, ValueType Ty, + PatFrag LoadOp> + : NLdStLn<1, 0b10, op11_8, op7_4, (outs DPR:$Vd), + (ins addrmode6oneL32:$Rn, DPR:$src, nohash_imm:$lane), + IIC_VLD1ln, "vld1", Dt, "\\{$Vd[$lane]\\}, $Rn", + "$src = $Vd", + [(set DPR:$Vd, (vector_insert (Ty DPR:$src), + (i32 (LoadOp addrmode6oneL32:$Rn)), + imm:$lane))]> { + let Rm = 0b1111; +} class VLD1QLNPseudo : VLDQLNPseudo { let Pattern = [(set QPR:$dst, (vector_insert (Ty QPR:$src), (i32 (LoadOp addrmode6:$addr)), @@ -544,7 +555,7 @@ let Inst{7-6} = lane{1-0}; let Inst{4} = Rn{4}; } -def VLD1LNd32 : VLD1LN<0b1000, {?,0,?,?}, "32", v2i32, load> { +def VLD1LNd32 : VLD1LN32<0b1000, {?,0,?,?}, "32", v2i32, load> { let Inst{7} = lane{0}; let Inst{5} = Rn{4}; let Inst{4} = Rn{4}; @@ -1371,6 +1382,14 @@ [(StoreOp (ExtractOp (Ty DPR:$Vd), imm:$lane), addrmode6:$Rn)]> { let Rm = 0b1111; } +class VST1LN32 op11_8, bits<4> op7_4, string Dt, ValueType Ty, + PatFrag StoreOp, SDNode ExtractOp> + : NLdStLn<1, 0b00, op11_8, op7_4, (outs), + (ins addrmode6oneL32:$Rn, DPR:$Vd, nohash_imm:$lane), + IIC_VST1ln, "vst1", Dt, "\\{$Vd[$lane]\\}, $Rn", "", + [(StoreOp (ExtractOp (Ty DPR:$Vd), imm:$lane), addrmode6oneL32:$Rn)]> { + let Rm = 0b1111; +} class VST1QLNPseudo : VSTQLNPseudo { let Pattern = [(StoreOp (ExtractOp (Ty QPR:$src), imm:$lane), @@ -1386,7 +1405,8 @@ let Inst{7-6} = lane{1-0}; let Inst{4} = Rn{5}; } -def VST1LNd32 : VST1LN<0b1000, {?,0,?,?}, "32", v2i32, store, extractelt> { + +def VST1LNd32 : VST1LN32<0b1000, {?,0,?,?}, "32", v2i32, store, extractelt> { let Inst{7} = lane{0}; let Inst{5-4} = Rn{5-4}; } Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=131085&r1=131084&r2=131085&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Mon May 9 12:47:27 2011 @@ -273,6 +273,8 @@ SmallVectorImpl &Fixups) const; unsigned getAddrMode6AddressOpValue(const MCInst &MI, unsigned Op, SmallVectorImpl &Fixups) const; + unsigned getAddrMode6OneLane32AddressOpValue(const MCInst &MI, unsigned Op, + SmallVectorImpl &Fixups) const; unsigned getAddrMode6DupAddressOpValue(const MCInst &MI, unsigned Op, SmallVectorImpl &Fixups) const; unsigned getAddrMode6OffsetOpValue(const MCInst &MI, unsigned Op, @@ -1178,6 +1180,30 @@ return RegNo | (Align << 4); } +/// getAddrMode6OneLane32AddressOpValue - Encode an addrmode6 register number +/// along with the alignment operand for use in VST1 and VLD1 with size 32. +unsigned ARMMCCodeEmitter:: +getAddrMode6OneLane32AddressOpValue(const MCInst &MI, unsigned Op, + SmallVectorImpl &Fixups) const { + const MCOperand &Reg = MI.getOperand(Op); + const MCOperand &Imm = MI.getOperand(Op + 1); + + unsigned RegNo = getARMRegisterNumbering(Reg.getReg()); + unsigned Align = 0; + + switch (Imm.getImm()) { + default: break; + case 2: + case 4: + case 8: + case 16: Align = 0x00; break; + case 32: Align = 0x03; break; + } + + return RegNo | (Align << 4); +} + + /// getAddrMode6DupAddressOpValue - Encode an addrmode6 register number and /// alignment operand for use in VLD-dup instructions. This is the same as /// getAddrMode6AddressOpValue except for the alignment encoding, which is Modified: llvm/trunk/utils/TableGen/EDEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/EDEmitter.cpp?rev=131085&r1=131084&r2=131085&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/EDEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/EDEmitter.cpp Mon May 9 12:47:27 2011 @@ -635,6 +635,7 @@ MISC("addrmode6", "kOperandTypeARMAddrMode6"); // R, R, I, I MISC("am6offset", "kOperandTypeARMAddrMode6Offset"); // R, I, I MISC("addrmode6dup", "kOperandTypeARMAddrMode6"); // R, R, I, I + MISC("addrmode6oneL32", "kOperandTypeARMAddrMode6"); // R, R, I, I MISC("addrmodepc", "kOperandTypeARMAddrModePC"); // R, I MISC("addrmode7", "kOperandTypeARMAddrMode7"); // R MISC("reglist", "kOperandTypeARMRegisterList"); // I, R, ... From echristo at apple.com Mon May 9 13:04:16 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 09 May 2011 11:04:16 -0700 Subject: [llvm-commits] [PATCH] compiler-rt: Sanity check architectures In-Reply-To: <4DC7610F.9010107@mozilla.com> References: <4DC7610F.9010107@mozilla.com> Message-ID: On May 8, 2011, at 8:35 PM, Patrick Walton wrote: > (rust-dev: This is an LLVM patch you might want to apply if you're > trying to build with clang on the Mac.) > > Hi everyone, > > I've got a quick patch to compiler-rt that makes it do a simple sanity > check on the toolchain before trying to compile for each architecture. > This makes clang able to be built again on Darwin without having to > install the iOS SDK. Seems reasonable to me. Unless I hear an objection I'll apply it a bit later. -eric From echristo at apple.com Mon May 9 13:16:46 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 09 May 2011 18:16:46 -0000 Subject: [llvm-commits] [llvm] r131086 - in /llvm/trunk/lib/Target/Mips: MipsInstrFPU.td MipsInstrFormats.td MipsInstrInfo.td Message-ID: <20110509181646.C79BF2A6C12C@llvm.org> Author: echristo Date: Mon May 9 13:16:46 2011 New Revision: 131086 URL: http://llvm.org/viewvc/llvm-project?rev=131086&view=rev Log: Fix td file comments for Mips. Patch by Liu ! Modified: llvm/trunk/lib/Target/Mips/MipsInstrFPU.td llvm/trunk/lib/Target/Mips/MipsInstrFormats.td llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Modified: llvm/trunk/lib/Target/Mips/MipsInstrFPU.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrFPU.td?rev=131086&r1=131085&r2=131086&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrFPU.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrFPU.td Mon May 9 13:16:46 2011 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file contains the Mips implementation of the TargetInstrInfo class. +// This file describes the Mips FPU instruction set. // //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/Mips/MipsInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrFormats.td?rev=131086&r1=131085&r2=131086&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrFormats.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrFormats.td Mon May 9 13:16:46 2011 @@ -1,4 +1,4 @@ -//===- MipsRegisterInfo.td - Mips Register defs ------------*- tablegen -*-===// +//===- MipsInstrFormats.td - Mips Instruction Formats ------*- tablegen -*-===// // // The LLVM Compiler Infrastructure // Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=131086&r1=131085&r2=131086&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Mon May 9 13:16:46 2011 @@ -1,4 +1,4 @@ -//===- MipsInstrInfo.td - Mips Register defs ---------------*- tablegen -*-===// +//===- MipsInstrInfo.td - Target Description for Mips Target -*- tablegen -*-=// // // The LLVM Compiler Infrastructure // @@ -6,6 +6,10 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// This file contains the Mips implementation of the TargetInstrInfo class. +// +//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // Instruction format superclass From gohman at apple.com Mon May 9 13:44:09 2011 From: gohman at apple.com (Dan Gohman) Date: Mon, 09 May 2011 18:44:09 -0000 Subject: [llvm-commits] [llvm] r131088 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp Message-ID: <20110509184410.1238D2A6C12C@llvm.org> Author: djg Date: Mon May 9 13:44:09 2011 New Revision: 131088 URL: http://llvm.org/viewvc/llvm-project?rev=131088&view=rev Log: Change a few std::maps to DenseMaps. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=131088&r1=131087&r2=131088&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon May 9 13:44:09 2011 @@ -270,30 +270,30 @@ /// BackedgeTakenCounts - Cache the backedge-taken count of the loops for /// this function as they are computed. - std::map BackedgeTakenCounts; + DenseMap BackedgeTakenCounts; /// ConstantEvolutionLoopExitValue - This map contains entries for all of /// the PHI instructions that we attempt to compute constant evolutions for. /// This allows us to avoid potentially expensive recomputation of these /// properties. An instruction maps to null if we are unable to compute its /// exit value. - std::map ConstantEvolutionLoopExitValue; + DenseMap ConstantEvolutionLoopExitValue; /// ValuesAtScopes - This map contains entries for all the expressions /// that we attempt to compute getSCEVAtScope information for, which can /// be expensive in extreme cases. - std::map > ValuesAtScopes; /// LoopDispositions - Memoized computeLoopDisposition results. - std::map > LoopDispositions; /// computeLoopDisposition - Compute a LoopDisposition value. LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L); /// BlockDispositions - Memoized computeBlockDisposition results. - std::map > BlockDispositions; /// computeBlockDisposition - Compute a BlockDisposition value. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=131088&r1=131087&r2=131088&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 9 13:44:09 2011 @@ -3783,7 +3783,7 @@ // update the value. The temporary CouldNotCompute value tells SCEV // code elsewhere that it shouldn't attempt to request a new // backedge-taken count, which could result in infinite recursion. - std::pair::iterator, bool> Pair = + std::pair::iterator, bool> Pair = BackedgeTakenCounts.insert(std::make_pair(L, getCouldNotCompute())); if (!Pair.second) return Pair.first->second; @@ -4433,7 +4433,7 @@ ScalarEvolution::getConstantEvolutionLoopExitValue(PHINode *PN, const APInt &BEs, const Loop *L) { - std::map::const_iterator I = + DenseMap::const_iterator I = ConstantEvolutionLoopExitValue.find(PN); if (I != ConstantEvolutionLoopExitValue.end()) return I->second; From eli.friedman at gmail.com Mon May 9 13:52:42 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 9 May 2011 11:52:42 -0700 Subject: [llvm-commits] [llvm] r131088 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp In-Reply-To: <20110509184410.1238D2A6C12C@llvm.org> References: <20110509184410.1238D2A6C12C@llvm.org> Message-ID: On Mon, May 9, 2011 at 11:44 AM, Dan Gohman wrote: > Author: djg > Date: Mon May ?9 13:44:09 2011 > New Revision: 131088 > > URL: http://llvm.org/viewvc/llvm-project?rev=131088&view=rev > Log: > Change a few std::maps to DenseMaps. > > Modified: > ? ?llvm/trunk/include/llvm/Analysis/ScalarEvolution.h > ? ?llvm/trunk/lib/Analysis/ScalarEvolution.cpp > > Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=131088&r1=131087&r2=131088&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) > +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon May ?9 13:44:09 2011 > @@ -270,30 +270,30 @@ > > ? ? /// BackedgeTakenCounts - Cache the backedge-taken count of the loops for > ? ? /// this function as they are computed. > - ? ?std::map BackedgeTakenCounts; > + ? ?DenseMap BackedgeTakenCounts; > > ? ? /// ConstantEvolutionLoopExitValue - This map contains entries for all of > ? ? /// the PHI instructions that we attempt to compute constant evolutions for. > ? ? /// This allows us to avoid potentially expensive recomputation of these > ? ? /// properties. ?An instruction maps to null if we are unable to compute its > ? ? /// exit value. > - ? ?std::map ConstantEvolutionLoopExitValue; > + ? ?DenseMap ConstantEvolutionLoopExitValue; > > ? ? /// ValuesAtScopes - This map contains entries for all the expressions > ? ? /// that we attempt to compute getSCEVAtScope information for, which can > ? ? /// be expensive in extreme cases. > - ? ?std::map + ? ?DenseMap ? ? ? ? ? ? ?std::map > ValuesAtScopes; > > ? ? /// LoopDispositions - Memoized computeLoopDisposition results. > - ? ?std::map + ? ?DenseMap ? ? ? ? ? ? ?std::map > LoopDispositions; > > ? ? /// computeLoopDisposition - Compute a LoopDisposition value. > ? ? LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L); > > ? ? /// BlockDispositions - Memoized computeBlockDisposition results. > - ? ?std::map + ? ?DenseMap ? ? ? ? ? ? ?std::map > BlockDispositions; Somehow a DenseMap of std::map doesn't strike me as good for performance; copying an std::map isn't cheap. -Eli From Micah.Villmow at amd.com Mon May 9 13:57:17 2011 From: Micah.Villmow at amd.com (Villmow, Micah) Date: Mon, 9 May 2011 13:57:17 -0500 Subject: [llvm-commits] SelectionDAG Loosing debug information Message-ID: I've attached a patch to bug9879 that stops SelectionDAG from dropping debug information. Can someone review to see if this approach is correct or if a better one is preferred? Thanks, Micah -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110509/d3555b6d/attachment.html From joerg at britannica.bec.de Mon May 9 14:34:02 2011 From: joerg at britannica.bec.de (Joerg Sonnenberger) Date: Mon, 9 May 2011 21:34:02 +0200 Subject: [llvm-commits] [patch] Don't bake build info into the host In-Reply-To: <4DC829C9.1020302@gmail.com> References: <4DC829C9.1020302@gmail.com> Message-ID: <20110509193402.GA17559@britannica.bec.de> On Mon, May 09, 2011 at 01:52:09PM -0400, Rafael Avila de Espindola wrote: > While working with 32 bit build of llvm on a 64 bit host I noticed > that the 32 bit clang was unable to link any program. > > The problem was that the basic 32 bit files (like crtbegin.o) are in > different different paths on i386 and x86_64 hosts. The 32 bit clang > was assuming it was running on a 32 bit host and failing to find > them. I think this is related by my earlier patch to cfe-dev about -m32 and the target toolchain. A solution should address both, so let's look at this problem in detail? The problems I have are two fold: The -m32 option changes the target triple, which changes the tools called in a cross-compiling setup here. Worse, the --32 option for as is not necessarily understood. Targetting a 32bit environment on a 64bit host environment needs different builtin paths than a native 32bit environment. With --sysroot, this also applies to the cross-compiling environment. As such, I would like to see the toolchain triple separated from the target triple. The question of running 32bit clang vs 64bit clang on x86_64 systems would boil down to whether -m32 or -m64 is the default, it shouldn't change the toolchain triple and the various checks for "are we building for i386 or i386-on-x86_64" can be adjusted based whether the two triple matchr. This would replace explicit checks for -m32 / -m64. Joerg From rafael.espindola at gmail.com Mon May 9 14:38:32 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Mon, 09 May 2011 15:38:32 -0400 Subject: [llvm-commits] [patch] Don't bake build info into the host In-Reply-To: <20110509193402.GA17559@britannica.bec.de> References: <4DC829C9.1020302@gmail.com> <20110509193402.GA17559@britannica.bec.de> Message-ID: <4DC842B8.2080206@gmail.com> > I think this is related by my earlier patch to cfe-dev about -m32 and > the target toolchain. A solution should address both, so let's look at > this problem in detail? They might be related in a way, but they are not the same problem. In the problem I am seeing clang correctly decides the target, both with and without -m32. The problem I am seeing is that it gets the *host* wrong. > > Joerg Cheers, Rafael From aggarwa4 at illinois.edu Mon May 9 14:41:31 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Mon, 09 May 2011 19:41:31 -0000 Subject: [llvm-commits] [poolalloc] r131091 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Message-ID: <20110509194131.859472A6C12C@llvm.org> Author: aggarwa4 Date: Mon May 9 14:41:31 2011 New Revision: 131091 URL: http://llvm.org/viewvc/llvm-project?rev=131091&view=rev Log: Add an option for using the typesafety pass. Also add some stats on the number of checks inserted. Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=131091&r1=131090&r2=131091&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Mon May 9 14:41:31 2011 @@ -21,6 +21,8 @@ #include "llvm/Support/InstIterator.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Intrinsics.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/Statistic.h" #include #include @@ -28,7 +30,20 @@ using namespace llvm; char TypeChecks::ID = 0; -static RegisterPass TC("typechecks", "Insert runtime type checks", false, true); + +static RegisterPass +TC("typechecks", "Insert runtime type checks", false, true); + +// Pass statistics +STATISTIC(numLoadChecks, "Number of Load Insts that need type checks"); +STATISTIC(numStoreChecks, "Number of Store Insts that need type checks"); + +namespace { + static cl::opt EnableTypeSafeOpt("enable-type-safe-opt", + cl::desc("Use DSA pass"), + cl::Hidden, + cl::init(false)); +} static int tagCounter = 0; static const Type *VoidTy = 0; @@ -92,11 +107,11 @@ } } - // Insert the shadow initialization function at the entry to main. Function *MainF = M.getFunction("main"); if (MainF == 0 || MainF->isDeclaration()) return false; + // Insert the shadow initialization function. modified |= initShadow(M); inst_iterator MainI = inst_begin(MainF); @@ -183,7 +198,7 @@ // Create an internal clone (treated same as internal functions) // Modify the original function // To assume that the metadata for the byval arguments is TOP - + if(F.hasInternalLinkage()) { visitInternalFunction(M, F); } else { @@ -241,7 +256,7 @@ // Perform the cloning. SmallVector Returns; CloneFunctionInto(NewF, &F, ValueMap, Returns); - + // Add calls to the runtime to copy metadata from source to the byval argument pointer. typedef SmallVector RegisteredArgTy; // Keep track of the byval arguments. @@ -266,7 +281,7 @@ CallInst::Create(F, Args.begin(), Args.end(), "", InsertBefore); } } - + // Find all basic blocks which terminate the function. std::set exitBlocks; for (inst_iterator I = inst_begin(NewF), E = inst_end(NewF); I != E; ++I) { @@ -310,7 +325,7 @@ AttrListPtr CallPAL = CI->getAttributes(); Attributes RAttrs = CallPAL.getRetAttributes(); Attributes FnAttrs = CallPAL.getFnAttributes(); - + Function::arg_iterator II = F.arg_begin(); for(unsigned j =1;jgetNumOperands();j++, II++) { @@ -324,7 +339,7 @@ if(II->hasByValAttr()) Args.push_back(CI->getOperand(j)); } - + // Create the new attributes vec. if (FnAttrs != Attribute::None) AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs)); @@ -370,7 +385,7 @@ registeredArguments.push_back(&*I); } } - + // Find all basic blocks which terminate the function. std::set exitBlocks; for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) { @@ -466,7 +481,7 @@ CurrentCtors.insert (CurrentCtors.begin(), RuntimeCtorInit); else CurrentCtors.push_back (RuntimeCtorInit); - + // // Create a new initializer. // @@ -747,6 +762,11 @@ // Insert runtime checks before all load instructions. bool TypeChecks::visitLoadInst(Module &M, LoadInst &LI) { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(LI.getOperand(0), LI.getParent()->getParent())) { + return false; + } + } // Cast the pointer operand to i8* for the runtime function. CastInst *BCI = BitCastInst::CreatePointerCast(LI.getPointerOperand(), VoidPtrTy, "", &LI); @@ -760,7 +780,7 @@ // Create the call to the runtime check and place it before the load instruction. Constant *F = M.getOrInsertFunction("trackLoadInst", VoidTy, VoidPtrTy, Int8Ty, Int64Ty, Int32Ty, NULL); CallInst::Create(F, Args.begin(), Args.end(), "", &LI); - + numLoadChecks++; return true; } @@ -778,6 +798,7 @@ // Create the call to the runtime check and place it before the store instruction. Constant *F = M.getOrInsertFunction("trackStoreInst", VoidTy, VoidPtrTy, Int8Ty, Int64Ty, Int32Ty, NULL); CallInst::Create(F, Args.begin(), Args.end(), "", &SI); + numStoreChecks++; return true; } @@ -797,6 +818,7 @@ // Create the call to the runtime check and place it before the copying store instruction. Constant *F = M.getOrInsertFunction("copyTypeInfo", VoidTy, VoidPtrTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); CallInst::Create(F, Args.begin(), Args.end(), "", &SI); + numStoreChecks++; return true; } From echristo at apple.com Mon May 9 14:49:35 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 09 May 2011 12:49:35 -0700 Subject: [llvm-commits] SelectionDAG Loosing debug information In-Reply-To: References: Message-ID: <68F6BBE4-4D61-4769-8DE6-D8B5CBA2CFC5@apple.com> On May 9, 2011, at 11:57 AM, Villmow, Micah wrote: > I?ve attached a patch to bug9879 that stops SelectionDAG from dropping debug information. Can someone review to see if this approach is correct or if a better one is preferred? > No patch attached. -eric From criswell at uiuc.edu Mon May 9 14:55:01 2011 From: criswell at uiuc.edu (John Criswell) Date: Mon, 09 May 2011 19:55:01 -0000 Subject: [llvm-commits] [poolalloc] r131092 - /poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Message-ID: <20110509195501.7C49F2A6C12C@llvm.org> Author: criswell Date: Mon May 9 14:55:01 2011 New Revision: 131092 URL: http://llvm.org/viewvc/llvm-project?rev=131092&view=rev Log: Fixed compilation on Mac OS X by defining the MAP_ANONYMOUS macro to be equivalent to the MAP_ANON macro. Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=131092&r1=131091&r2=131092&view=diff ============================================================================== --- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original) +++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Mon May 9 14:55:01 2011 @@ -8,6 +8,13 @@ #define DEBUG (0) #define SIZE ((size_t)(70368744177664)) +/* + * Do some macro magic to get mmap macros defined properly on all platforms. + */ +#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS) +# define MAP_ANONYMOUS MAP_ANON +#endif /* defined(MAP_ANON) && !defined(MAP_ANONYMOUS) */ + uint8_t *shadow_begin; uintptr_t maskAddress(void *ptr) { From echristo at apple.com Mon May 9 15:04:44 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 09 May 2011 20:04:44 -0000 Subject: [llvm-commits] [llvm] r131093 - in /llvm/trunk/lib/CodeGen/SelectionDAG: SelectionDAGBuilder.cpp TargetLowering.cpp Message-ID: <20110509200444.234012A6C12C@llvm.org> Author: echristo Date: Mon May 9 15:04:43 2011 New Revision: 131093 URL: http://llvm.org/viewvc/llvm-project?rev=131093&view=rev Log: Look through struct wrapped types for inline asm statments. Patch by Evan Cheng. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=131093&r1=131092&r2=131093&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon May 9 15:04:43 2011 @@ -5268,6 +5268,7 @@ const llvm::Type *OpTy = CallOperandVal->getType(); + // FIXME: code duplicated from TargetLowering::ParseConstraints(). // If this is an indirect operand, the operand is a pointer to the // accessed type. if (isIndirect) { @@ -5277,6 +5278,11 @@ OpTy = PtrTy->getElementType(); } + // Look for vector wrapped in a struct. e.g. { <16 x i8> }. + if (const StructType *STy = dyn_cast(OpTy)) + if (STy->getNumElements() == 1) + OpTy = STy->getElementType(0); + // If OpTy is not a single value, it may be a struct/union that we // can tile with integers. if (!OpTy->isSingleValueType() && OpTy->isSized()) { Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=131093&r1=131092&r2=131093&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Mon May 9 15:04:43 2011 @@ -2812,6 +2812,12 @@ report_fatal_error("Indirect operand for inline asm not a pointer!"); OpTy = PtrTy->getElementType(); } + + // Look for vector wrapped in a struct. e.g. { <16 x i8> }. + if (const StructType *STy = dyn_cast(OpTy)) + if (STy->getNumElements() == 1) + OpTy = STy->getElementType(0); + // If OpTy is not a single value, it may be a struct/union that we // can tile with integers. if (!OpTy->isSingleValueType() && OpTy->isSized()) { From grosbach at apple.com Mon May 9 15:05:25 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 09 May 2011 20:05:25 -0000 Subject: [llvm-commits] [llvm] r131094 - in /llvm/trunk/tools/llvm-mc: Disassembler.cpp Disassembler.h llvm-mc.cpp Message-ID: <20110509200525.9AA492A6C12C@llvm.org> Author: grosbach Date: Mon May 9 15:05:25 2011 New Revision: 131094 URL: http://llvm.org/viewvc/llvm-project?rev=131094&view=rev Log: Tidy up. 80-column and whitespace. Modified: llvm/trunk/tools/llvm-mc/Disassembler.cpp llvm/trunk/tools/llvm-mc/Disassembler.h llvm/trunk/tools/llvm-mc/llvm-mc.cpp Modified: llvm/trunk/tools/llvm-mc/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/Disassembler.cpp?rev=131094&r1=131093&r2=131094&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/Disassembler.cpp (original) +++ llvm/trunk/tools/llvm-mc/Disassembler.cpp Mon May 9 15:05:25 2011 @@ -39,7 +39,7 @@ const ByteArrayTy &Bytes; public: VectorMemoryObject(const ByteArrayTy &bytes) : Bytes(bytes) {} - + uint64_t getBase() const { return 0; } uint64_t getExtent() const { return Bytes.size(); } @@ -57,15 +57,15 @@ SourceMgr &SM, raw_ostream &Out) { // Wrap the vector in a MemoryObject. VectorMemoryObject memoryObject(Bytes); - + // Disassemble it to strings. uint64_t Size; uint64_t Index; - + for (Index = 0; Index < Bytes.size(); Index += Size) { MCInst Inst; - - if (DisAsm.getInstruction(Inst, Size, memoryObject, Index, + + if (DisAsm.getInstruction(Inst, Size, memoryObject, Index, /*REMOVE*/ nulls())) { Printer.printInst(&Inst, Out); Out << "\n"; @@ -76,12 +76,12 @@ Size = 1; // skip illegible bytes } } - + return false; } -static bool ByteArrayFromString(ByteArrayTy &ByteArray, - StringRef &Str, +static bool ByteArrayFromString(ByteArrayTy &ByteArray, + StringRef &Str, SourceMgr &SM) { while (!Str.empty()) { // Strip horizontal whitespace. @@ -89,7 +89,7 @@ Str = Str.substr(Pos); continue; } - + // If this is the end of a line or start of a comment, remove the rest of // the line. if (Str[0] == '\n' || Str[0] == '#') { @@ -104,11 +104,11 @@ } continue; } - + // Get the current token. size_t Next = Str.find_first_of(" \t\n\r#"); StringRef Value = Str.substr(0, Next); - + // Convert to a byte and add to the byte vector. unsigned ByteVal; if (Value.getAsInteger(0, ByteVal) || ByteVal > 255) { @@ -119,11 +119,11 @@ ByteArray.clear(); continue; } - + ByteArray.push_back(std::make_pair((unsigned char)ByteVal, Value.data())); Str = Str.substr(Next); } - + return false; } @@ -133,18 +133,18 @@ raw_ostream &Out) { // Set up disassembler. OwningPtr AsmInfo(T.createAsmInfo(Triple)); - + if (!AsmInfo) { errs() << "error: no assembly info for target " << Triple << "\n"; return -1; } - + OwningPtr DisAsm(T.createMCDisassembler()); if (!DisAsm) { errs() << "error: no disassembler for target " << Triple << "\n"; return -1; } - + int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); OwningPtr IP(T.createMCInstPrinter(TM, AsmPrinterVariant, *AsmInfo)); @@ -152,67 +152,67 @@ errs() << "error: no instruction printer for target " << Triple << '\n'; return -1; } - + bool ErrorOccurred = false; - + SourceMgr SM; SM.AddNewSourceBuffer(&Buffer, SMLoc()); - + // Convert the input to a vector for disassembly. ByteArrayTy ByteArray; StringRef Str = Buffer.getBuffer(); - + ErrorOccurred |= ByteArrayFromString(ByteArray, Str, SM); - + if (!ByteArray.empty()) ErrorOccurred |= PrintInsts(*DisAsm, *IP, ByteArray, SM, Out); - + return ErrorOccurred; } static int byteArrayReader(uint8_t *B, uint64_t A, void *Arg) { ByteArrayTy &ByteArray = *((ByteArrayTy*)Arg); - + if (A >= ByteArray.size()) return -1; - + *B = ByteArray[A].first; - + return 0; } static int verboseEvaluator(uint64_t *V, unsigned R, void *Arg) { EDDisassembler &disassembler = *(EDDisassembler *)((void **)Arg)[0]; raw_ostream &Out = *(raw_ostream *)((void **)Arg)[1]; - + if (const char *regName = disassembler.nameWithRegisterID(R)) Out << "[" << regName << "/" << R << "]"; - + if (disassembler.registerIsStackPointer(R)) Out << "(sp)"; if (disassembler.registerIsProgramCounter(R)) Out << "(pc)"; - + *V = 0; return 0; } -int Disassembler::disassembleEnhanced(const std::string &TS, +int Disassembler::disassembleEnhanced(const std::string &TS, MemoryBuffer &Buffer, raw_ostream &Out) { ByteArrayTy ByteArray; StringRef Str = Buffer.getBuffer(); SourceMgr SM; - + SM.AddNewSourceBuffer(&Buffer, SMLoc()); - + if (ByteArrayFromString(ByteArray, Str, SM)) { return -1; } - + Triple T(TS); EDDisassembler::AssemblySyntax AS; - + switch (T.getArch()) { default: errs() << "error: no default assembly syntax for " << TS.c_str() << "\n"; @@ -226,53 +226,53 @@ AS = EDDisassembler::kEDAssemblySyntaxX86ATT; break; } - + EDDisassembler::initialize(); OwningPtr disassembler(EDDisassembler::getDisassembler(TS.c_str(), AS)); - + if (disassembler == 0) { errs() << "error: couldn't get disassembler for " << TS << '\n'; return -1; } - + while (ByteArray.size()) { OwningPtr inst(disassembler->createInst(byteArrayReader, 0, &ByteArray)); - + if (inst == 0) { errs() << "error: Didn't get an instruction\n"; return -1; } ByteArray.erase (ByteArray.begin(), ByteArray.begin() + inst->byteSize()); - + unsigned numTokens = inst->numTokens(); if ((int)numTokens < 0) { errs() << "error: couldn't count the instruction's tokens\n"; return -1; } - + for (unsigned tokenIndex = 0; tokenIndex != numTokens; ++tokenIndex) { EDToken *token; - + if (inst->getToken(token, tokenIndex)) { errs() << "error: Couldn't get token\n"; return -1; } - + const char *buf; if (token->getString(buf)) { errs() << "error: Couldn't get string for token\n"; return -1; } - + Out << '['; int operandIndex = token->operandID(); - + if (operandIndex >= 0) Out << operandIndex << "-"; - + switch (token->type()) { default: Out << "?"; break; case EDToken::kTokenWhitespace: Out << "w"; break; @@ -281,9 +281,9 @@ case EDToken::kTokenLiteral: Out << "l"; break; case EDToken::kTokenRegister: Out << "r"; break; } - + Out << ":" << buf; - + if (token->type() == EDToken::kTokenLiteral) { Out << "="; if (token->literalSign()) @@ -303,33 +303,34 @@ } Out << "r" << regID; } - + Out << "]"; } - + Out << " "; - + if (inst->isBranch()) Out << "
"; if (inst->isMove()) Out << " "; - + unsigned numOperands = inst->numOperands(); - + if ((int)numOperands < 0) { errs() << "error: Couldn't count operands\n"; return -1; } - - for (unsigned operandIndex = 0; operandIndex != numOperands; ++operandIndex) { + + for (unsigned operandIndex = 0; operandIndex != numOperands; + ++operandIndex) { Out << operandIndex << ":"; - + EDOperand *operand; if (inst->getOperand(operand, operandIndex)) { errs() << "error: couldn't get operand\n"; return -1; } - + uint64_t evaluatedResult; void *Arg[] = { disassembler.get(), &Out }; if (operand->evaluate(evaluatedResult, verboseEvaluator, Arg)) { @@ -338,10 +339,10 @@ } Out << "=" << evaluatedResult << " "; } - + Out << '\n'; } - + return 0; } Modified: llvm/trunk/tools/llvm-mc/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/Disassembler.h?rev=131094&r1=131093&r2=131094&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/Disassembler.h (original) +++ llvm/trunk/tools/llvm-mc/Disassembler.h Mon May 9 15:05:25 2011 @@ -31,12 +31,12 @@ const std::string &tripleString, MemoryBuffer &buffer, raw_ostream &Out); - + static int disassembleEnhanced(const std::string &tripleString, MemoryBuffer &buffer, raw_ostream &Out); }; - + } // namespace llvm #endif Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=131094&r1=131093&r2=131094&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original) +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Mon May 9 15:05:25 2011 @@ -183,10 +183,10 @@ MemoryBuffer *Buffer = BufferPtr.take(); SourceMgr SrcMgr; - + // Tell SrcMgr about this buffer, which is what TGParser will pick up. SrcMgr.AddNewSourceBuffer(Buffer, SMLoc()); - + // Record the location of the include directories so that the lexer can find // it later. SrcMgr.setIncludeDirs(IncludeDirs); @@ -279,7 +279,7 @@ // Keep output if no errors. if (Error == 0) Out->keep(); - + return Error; } @@ -294,20 +294,20 @@ return 1; } MemoryBuffer *Buffer = BufferPtr.take(); - + SourceMgr SrcMgr; - + // Tell SrcMgr about this buffer, which is what the parser will pick up. SrcMgr.AddNewSourceBuffer(Buffer, SMLoc()); - + // Record the location of the include directories so that the lexer can find // it later. SrcMgr.setIncludeDirs(IncludeDirs); - - + + llvm::OwningPtr MAI(TheTarget->createAsmInfo(TripleName)); assert(MAI && "Unable to create target asm info!"); - + // Package up features to be passed to target/subtarget std::string FeaturesStr; if (MCPU.size()) { @@ -378,7 +378,7 @@ *Str.get(), *MAI)); OwningPtr TAP(TheTarget->createAsmParser(*Parser, *TM)); if (!TAP) { - errs() << ProgName + errs() << ProgName << ": error: this target does not support assembly parsing.\n"; return 1; } @@ -404,7 +404,7 @@ errs() << ProgName << ": " << ec.message() << '\n'; return 1; } - + OwningPtr Out(GetOutputStream()); if (!Out) return 1; @@ -459,7 +459,7 @@ llvm::InitializeAllAsmPrinters(); llvm::InitializeAllAsmParsers(); llvm::InitializeAllDisassemblers(); - + cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n"); TripleName = Triple::normalize(TripleName); @@ -474,7 +474,7 @@ case AC_EDisassemble: return DisassembleInput(argv[0], true); } - + return 0; } From aggarwa4 at illinois.edu Mon May 9 15:13:46 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Mon, 09 May 2011 20:13:46 -0000 Subject: [llvm-commits] [poolalloc] r131095 - /poolalloc/trunk/lib/AssistDS/CMakeLists.txt Message-ID: <20110509201346.E68F22A6C12C@llvm.org> Author: aggarwa4 Date: Mon May 9 15:13:46 2011 New Revision: 131095 URL: http://llvm.org/viewvc/llvm-project?rev=131095&view=rev Log: Updated to the correct filenames, to reflect changes done earlier this week. Modified: poolalloc/trunk/lib/AssistDS/CMakeLists.txt Modified: poolalloc/trunk/lib/AssistDS/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/CMakeLists.txt?rev=131095&r1=131094&r2=131095&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/CMakeLists.txt (original) +++ poolalloc/trunk/lib/AssistDS/CMakeLists.txt Mon May 9 15:13:46 2011 @@ -6,7 +6,8 @@ GEPExprArg.cpp IndCloner.cpp Int2PtrCmp.cpp - MergeArrayIndexGEP.cpp + LoadArgs.cpp + MergeGEP.cpp SVADevirt.cpp SimplifyExtractValue.cpp SimplifyGEP.cpp From echristo at apple.com Mon May 9 15:24:43 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 09 May 2011 20:24:43 -0000 Subject: [llvm-commits] [compiler-rt] r131098 - /compiler-rt/trunk/make/platform/clang_darwin.mk Message-ID: <20110509202443.A940D2A6C12C@llvm.org> Author: echristo Date: Mon May 9 15:24:43 2011 New Revision: 131098 URL: http://llvm.org/viewvc/llvm-project?rev=131098&view=rev Log: Check architectures to make sure that we can build for all of them before we try to. Patch by Patrick Walton! Modified: compiler-rt/trunk/make/platform/clang_darwin.mk Modified: compiler-rt/trunk/make/platform/clang_darwin.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_darwin.mk?rev=131098&r1=131097&r2=131098&view=diff ============================================================================== --- compiler-rt/trunk/make/platform/clang_darwin.mk (original) +++ compiler-rt/trunk/make/platform/clang_darwin.mk Mon May 9 15:24:43 2011 @@ -6,6 +6,19 @@ Description := Static runtime libraries for clang/Darwin. +# A function that ensures we don't try to build for architectures that we +# don't have working toolchains for. +CheckArches = \ + $(shell \ + result=""; \ + for arch in $(1); do \ + gcc -arch $$arch; \ + if test $$? == 1; then result="$$result$$arch "; fi; \ + done; \ + echo $$result) + +### + Configs := UniversalArchs := @@ -13,23 +26,23 @@ # still be referenced from Darwin system headers. This symbol is only ever # needed on i386. Configs += eprintf -UniversalArchs.eprintf := i386 +UniversalArchs.eprintf := $(call CheckArches,i386) # Configuration for targetting 10.4. We need a few functions missing from # libgcc_s.10.4.dylib. We only build x86 slices since clang doesn't really # support targetting PowerPC. Configs += 10.4 -UniversalArchs.10.4 := i386 x86_64 +UniversalArchs.10.4 := $(call CheckArches,i386 x86_64) # Configuration for targetting iOS, for some ARMv6 functions, which must be # in the same linkage unit, and for a couple of other functions that didn't # make it into libSystem. Configs += ios -UniversalArchs.ios := i386 x86_64 armv6 armv7 +UniversalArchs.ios := $(call CheckArches,i386 x86_64 armv6 armv7) # Configuration for use with kernel/kexts. Configs += cc_kext -UniversalArchs.cc_kext := armv6 armv7 i386 x86_64 +UniversalArchs.cc_kext := $(call CheckArches,armv6 armv7 i386 x86_64) ### From rafael.espindola at gmail.com Mon May 9 15:30:33 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Mon, 09 May 2011 16:30:33 -0400 Subject: [llvm-commits] .cfi_* and ARM Message-ID: <4DC84EE9.8080402@gmail.com> Devang noticed we were not producing .cfi_* directives for ARM. This is OK for non-debug builds as darwin ARM use SjLj exceptions. The question is what should be done for debug. The pre-cfi setup clang would produce a __debug_frame section. I think what we should do is 1) produce .cfi_* directives if -g is given. This will created a __eh_frame section for now. 2) If __debug_frame is more efficient/needed on ARM we can implement the .cfi_sections directive so that cfi can be used to produce __eh_frame and/or __debug_frame. I should have a patch for 1 in a moment. Thoughts? Cheers, Rafael From echristo at apple.com Mon May 9 15:34:05 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 09 May 2011 13:34:05 -0700 Subject: [llvm-commits] [PATCH] compiler-rt: Sanity check architectures In-Reply-To: References: <4DC7610F.9010107@mozilla.com> Message-ID: On May 9, 2011, at 11:04 AM, Eric Christopher wrote: > > On May 8, 2011, at 8:35 PM, Patrick Walton wrote: > >> (rust-dev: This is an LLVM patch you might want to apply if you're >> trying to build with clang on the Mac.) >> >> Hi everyone, >> >> I've got a quick patch to compiler-rt that makes it do a simple sanity >> check on the toolchain before trying to compile for each architecture. >> This makes clang able to be built again on Darwin without having to >> install the iOS SDK. > > Seems reasonable to me. Unless I hear an objection I'll apply it a bit > later. Committed in: [yendi:llvm/projects/compiler-rt] echristo% svn ci Sending make/platform/clang_darwin.mk Transmitting file data . Committed revision 131098. -eric From rafael.espindola at gmail.com Mon May 9 15:57:18 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Mon, 09 May 2011 16:57:18 -0400 Subject: [llvm-commits] .cfi_* and ARM In-Reply-To: <4DC84EE9.8080402@gmail.com> References: <4DC84EE9.8080402@gmail.com> Message-ID: <4DC8552E.3030705@gmail.com> > I should have a patch for 1 in a moment. Thoughts? The first patch is attached. Cheers, Rafael -------------- next part -------------- A non-text attachment was scrubbed... Name: arm-cfi1.patch Type: text/x-patch Size: 5181 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110509/16148887/attachment-0001.bin From dpatel at apple.com Mon May 9 16:00:58 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 09 May 2011 14:00:58 -0700 Subject: [llvm-commits] .cfi_* and ARM In-Reply-To: <4DC84EE9.8080402@gmail.com> References: <4DC84EE9.8080402@gmail.com> Message-ID: <163A7EC8-97E9-4729-B50F-7C30F8EE1088@apple.com> On May 9, 2011, at 1:30 PM, Rafael Avila de Espindola wrote: > Devang noticed we were not producing .cfi_* directives for ARM. This is OK for non-debug builds as darwin ARM use SjLj exceptions. > > The question is what should be done for debug. The pre-cfi setup clang would produce a __debug_frame section. I think what we should do is > > 1) produce .cfi_* directives if -g is given. This will created a __eh_frame section for now. > 2) If __debug_frame is more efficient/needed on ARM we can implement the .cfi_sections directive so that cfi can be used to produce __eh_frame and/or __debug_frame. I like 2). Efficient __debug_frame based on .cfi_* will be useful to debugger. - Devang > > I should have a patch for 1 in a moment. Thoughts? > > Cheers, > Rafael From anton at korobeynikov.info Mon May 9 16:12:25 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 10 May 2011 01:12:25 +0400 Subject: [llvm-commits] .cfi_* and ARM In-Reply-To: <4DC84EE9.8080402@gmail.com> References: <4DC84EE9.8080402@gmail.com> Message-ID: Hi Rafael, > 2) If __debug_frame is more efficient/needed on ARM we can implement the > .cfi_sections directive so that cfi can be used to produce __eh_frame > and/or __debug_frame. What does binutils do in such a case? Are both *frame sections generated? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From fjahanian at apple.com Mon May 9 17:04:37 2011 From: fjahanian at apple.com (Fariborz Jahanian) Date: Mon, 09 May 2011 22:04:37 -0000 Subject: [llvm-commits] [test-suite] r131105 - /test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout.c Message-ID: <20110509220437.2C27B2A6C12D@llvm.org> Author: fjahanian Date: Mon May 9 17:04:36 2011 New Revision: 131105 URL: http://llvm.org/viewvc/llvm-project?rev=131105&view=rev Log: A rather exhaustive test case for ms_struct attribute. Passes both clang and llvm-gcc. // rdar://8823265 Added: test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout.c Added: test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout.c?rev=131105&view=auto ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout.c (added) +++ test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout.c Mon May 9 17:04:36 2011 @@ -0,0 +1,192 @@ +#include +#include + +extern void abort(); + +#pragma pack(8) + +#define ATTR __attribute__ ((ms_struct)) + +struct one { + int d; + unsigned char a; + unsigned short b:7; + char c; +} ATTR; + +struct two { + int d; + unsigned char a; + unsigned int b:7; + char c; +} ATTR; + +struct three { + short d; + unsigned short a:3; + unsigned short b:9; + unsigned char c:7; +} ATTR; + + +/* Bitfields of size 0 have some truly odd behaviors. */ + +struct four { + unsigned short a:3; + unsigned short b:9; + unsigned int :0; /* forces struct alignment to int */ + unsigned char c:7; +} ATTR; + +struct five { + char a; + int :0; /* ignored; prior field is not a bitfield. */ + char b; + char c; +} ATTR; + +struct six { + char a :8; + int :0; /* not ignored; prior field IS a bitfield, causes + struct alignment as well. */ + char b; + char c; +} ATTR; + +struct seven { + char a:8; + char :0; + int :0; /* Ignored; prior field is zero size bitfield. */ + char b; + char c; +} ATTR; + +struct eight { /* ms size 4 */ + short b:3; + char c; +} ATTR; + +#define LONGLONG long long + +union nine { /* ms size 8 */ + LONGLONG a:3; + char c; +} ATTR; + +struct ten { /* ms size 16 */ + LONGLONG a:3; + LONGLONG b:3; + char c; +} ATTR; + + +#define val(s,f) (s.f) + +#define check_struct(_X) \ +{ \ + if (sizeof (struct _X) != exp_sizeof_##_X ) \ + abort(); \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_union(_X) \ +{ \ + if (sizeof (union _X) != exp_sizeof_##_X ) \ + abort(); \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_struct_size(_X) \ +{ \ + if (sizeof (struct _X) != exp_sizeof_##_X ) \ + abort(); \ +} + +#define check_struct_off(_X) \ +{ \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +#define check_union_size(_X) \ +{ \ + if (sizeof (union _X) != exp_sizeof_##_X ) \ + abort(); \ +} + +#define check_union_off(_X) \ +{ \ + memcpy(&test_##_X, filler, sizeof(test_##_X));\ + if (val(test_##_X,c) != exp_##_X##_c) \ + abort(); \ +} + +int main(){ + + unsigned char filler[16]; + struct one test_one; + struct two test_two; + struct three test_three; + struct four test_four; + struct five test_five; + struct six test_six; + struct seven test_seven; + struct eight test_eight; + union nine test_nine; + struct ten test_ten; + + size_t exp_sizeof_one = 12; + size_t exp_sizeof_two = 16; + size_t exp_sizeof_three =6; + size_t exp_sizeof_four = 8; + size_t exp_sizeof_five = 3; + size_t exp_sizeof_six = 8; + size_t exp_sizeof_seven = 3; + size_t exp_sizeof_eight = 4; + size_t exp_sizeof_nine = 8; + size_t exp_sizeof_ten = 16; + + unsigned char exp_one_c = 8; + unsigned char exp_two_c = 12; + unsigned char exp_three_c = 4; + unsigned char exp_four_c = 4; + char exp_five_c = 2; + char exp_six_c = 5; + char exp_seven_c = 2; + char exp_eight_c = 2; + char exp_nine_c = 0; + char exp_ten_c = 8; + + unsigned char i; + for ( i = 0; i < 16; i++ ) + filler[i] = i; + + check_struct_off (one); + check_struct_off (two); + check_struct_off (three); + check_struct_off (four); + check_struct_off (five); + check_struct_off (six); + check_struct_off (seven); + check_struct_off (eight); + check_union_off (nine); + check_struct_off (ten); + + check_struct_size (one); + check_struct_size (two); + check_struct_size (three); + check_struct_size (four); + check_struct_size (five); + check_struct_size (six); + check_struct_size (seven); + check_struct_size (eight); + check_union_size (nine); + check_struct_size (ten); + + return 0; +}; From dpatel at apple.com Mon May 9 17:14:49 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 09 May 2011 22:14:49 -0000 Subject: [llvm-commits] [llvm] r131106 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20110509221449.768C52A6C12C@llvm.org> Author: dpatel Date: Mon May 9 17:14:49 2011 New Revision: 131106 URL: http://llvm.org/viewvc/llvm-project?rev=131106&view=rev Log: Do not ignore InlinedAt while walking up scope chain to find subprogram node. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=131106&r1=131105&r2=131106&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon May 9 17:14:49 2011 @@ -1815,6 +1815,13 @@ return DebugLoc(); } +/// getScopeNode - Get MDNode for DebugLoc's scope. +static MDNode *getScopeNode(DebugLoc DL, const LLVMContext &Ctx) { + if (MDNode *InlinedAt = DL.getInlinedAt(Ctx)) + return getScopeNode(DebugLoc::getFromDILocation(InlinedAt), Ctx); + return DL.getScope(Ctx); +} + /// beginFunction - Gather pre-function debug information. Assumes being /// emitted immediately after the function entry point. void DwarfDebug::beginFunction(const MachineFunction *MF) { @@ -1831,7 +1838,7 @@ DebugLoc FDL = FindFirstDebugLoc(MF); if (FDL.isUnknown()) return; - const MDNode *Scope = FDL.getScope(MF->getFunction()->getContext()); + const MDNode *Scope = getScopeNode(FDL, MF->getFunction()->getContext()); const MDNode *TheScope = 0; DISubprogram SP = getDISubprogram(Scope); From fjahanian at apple.com Mon May 9 17:19:23 2011 From: fjahanian at apple.com (Fariborz Jahanian) Date: Mon, 09 May 2011 22:19:23 -0000 Subject: [llvm-commits] [test-suite] r131107 - /test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout-1.c Message-ID: <20110509221923.C785B2A6C12C@llvm.org> Author: fjahanian Date: Mon May 9 17:19:23 2011 New Revision: 131107 URL: http://llvm.org/viewvc/llvm-project?rev=131107&view=rev Log: New test for packed ms_struct layout. Added: test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout-1.c Added: test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout-1.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout-1.c?rev=131107&view=auto ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout-1.c (added) +++ test-suite/trunk/SingleSource/UnitTests/ms_struct_pack_layout-1.c Mon May 9 17:19:23 2011 @@ -0,0 +1,20 @@ +extern void abort (); + +union u +{ + int a; +} __attribute__((__ms_struct__, __packed__)); + +struct s +{ + char c; + union u u; +}; + +int main (void) +{ + if (sizeof (struct s) != (sizeof (char) + sizeof (union u))) + abort (); + + return 0; +} From rafael.espindola at gmail.com Mon May 9 17:31:29 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Mon, 09 May 2011 18:31:29 -0400 Subject: [llvm-commits] .cfi_* and ARM In-Reply-To: References: <4DC84EE9.8080402@gmail.com> Message-ID: <4DC86B41.9050603@gmail.com> On 11-05-09 05:12 PM, Anton Korobeynikov wrote: > Hi Rafael, > >> 2) If __debug_frame is more efficient/needed on ARM we can implement the >> .cfi_sections directive so that cfi can be used to produce __eh_frame >> and/or __debug_frame. > What does binutils do in such a case? Are both *frame sections generated? > The .cfi_sections command selects which section. You can say .cfi_sections .eh_frame .cfi_sections .debug_frame or .cfi_sections .eh_frame, .debug_frame Cheers, Rafael From Micah.Villmow at amd.com Mon May 9 18:04:07 2011 From: Micah.Villmow at amd.com (Villmow, Micah) Date: Mon, 9 May 2011 18:04:07 -0500 Subject: [llvm-commits] SelectionDAG Loosing debug information In-Reply-To: <68F6BBE4-4D61-4769-8DE6-D8B5CBA2CFC5@apple.com> References: <68F6BBE4-4D61-4769-8DE6-D8B5CBA2CFC5@apple.com> Message-ID: Patch attached. > -----Original Message----- > From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits- > bounces at cs.uiuc.edu] On Behalf Of Eric Christopher > Sent: Monday, May 09, 2011 12:50 PM > To: Villmow, Micah > Cc: llvm-commits > Subject: Re: [llvm-commits] SelectionDAG Loosing debug information > > > On May 9, 2011, at 11:57 AM, Villmow, Micah wrote: > > > I've attached a patch to bug9879 that stops SelectionDAG from > dropping debug information. Can someone review to see if this approach > is correct or if a better one is preferred? > > > No patch attached. > > -eric > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- A non-text attachment was scrubbed... Name: bug9869.patch Type: application/octet-stream Size: 2286 bytes Desc: bug9869.patch Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110509/9e128eb5/attachment.obj From dpatel at apple.com Mon May 9 18:28:18 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 09 May 2011 16:28:18 -0700 Subject: [llvm-commits] SelectionDAG Loosing debug information In-Reply-To: References: <68F6BBE4-4D61-4769-8DE6-D8B5CBA2CFC5@apple.com> Message-ID: DanglingDebugInfoMap maps llvm::Value to a node. So, the mapping is invalid whenever NodeMap is cleared. Are you sure this patch is the right approach here ? - Devang On May 9, 2011, at 4:04 PM, Villmow, Micah wrote: > Patch attached. > >> -----Original Message----- >> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits- >> bounces at cs.uiuc.edu] On Behalf Of Eric Christopher >> Sent: Monday, May 09, 2011 12:50 PM >> To: Villmow, Micah >> Cc: llvm-commits >> Subject: Re: [llvm-commits] SelectionDAG Loosing debug information >> >> >> On May 9, 2011, at 11:57 AM, Villmow, Micah wrote: >> >>> I've attached a patch to bug9879 that stops SelectionDAG from >> dropping debug information. Can someone review to see if this approach >> is correct or if a better one is preferred? >>> >> No patch attached. >> >> -eric >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From Micah.Villmow at amd.com Mon May 9 18:38:54 2011 From: Micah.Villmow at amd.com (Villmow, Micah) Date: Mon, 9 May 2011 18:38:54 -0500 Subject: [llvm-commits] SelectionDAG Loosing debug information In-Reply-To: References: <68F6BBE4-4D61-4769-8DE6-D8B5CBA2CFC5@apple.com> Message-ID: > -----Original Message----- > From: Devang Patel [mailto:dpatel at apple.com] > Sent: Monday, May 09, 2011 4:28 PM > To: Villmow, Micah > Cc: llvm-commits > Subject: Re: [llvm-commits] SelectionDAG Loosing debug information > > DanglingDebugInfoMap maps llvm::Value to a node. So, the mapping is > invalid whenever NodeMap is cleared. Are you sure this patch is the > right approach here ? [Villmow, Micah] Maybe, I'm not 100% familiar with the code, but it seems to fix the problem we are having. The problem we are having is this: The bitcode attached to the bug has a case where after running inlineAll and then mem2reg, the resulting debug information is attached to a phi node. The debug information references an instruction in a previous basic block but has no references in the current basic block. By my understanding after looking at the code, no nodes are created for the phi node and the debug information is added to the map. However, since no nodes in the current block reference the debug information, there can be no resolving of the dangling reference by the end of the block, which the map then gets cleared. What this change does is allows for all of the dangling references to be resolved by the current or previous block at some point in the future and after all the basic blocks have been processed and there is no possibility of resolving the dangling reference anymore, then it is cleared. I don't see this as being a problem when NodeMap is cleared simply because if the node existed in the current basic block, then the dangling reference wouldn't exist in the DanglingDebugInfoMap as it is replaced once it is resolved. Micah > - > Devang > > On May 9, 2011, at 4:04 PM, Villmow, Micah wrote: > > > Patch attached. > > > >> -----Original Message----- > >> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits- > >> bounces at cs.uiuc.edu] On Behalf Of Eric Christopher > >> Sent: Monday, May 09, 2011 12:50 PM > >> To: Villmow, Micah > >> Cc: llvm-commits > >> Subject: Re: [llvm-commits] SelectionDAG Loosing debug information > >> > >> > >> On May 9, 2011, at 11:57 AM, Villmow, Micah wrote: > >> > >>> I've attached a patch to bug9879 that stops SelectionDAG from > >> dropping debug information. Can someone review to see if this > approach > >> is correct or if a better one is preferred? > >>> > >> No patch attached. > >> > >> -eric > >> _______________________________________________ > >> llvm-commits mailing list > >> llvm-commits at cs.uiuc.edu > >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From dpatel at apple.com Mon May 9 19:03:11 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 May 2011 00:03:11 -0000 Subject: [llvm-commits] [llvm] r131112 - /llvm/trunk/lib/Transforms/IPO/PruneEH.cpp Message-ID: <20110510000311.7931A2A6C12C@llvm.org> Author: dpatel Date: Mon May 9 19:03:11 2011 New Revision: 131112 URL: http://llvm.org/viewvc/llvm-project?rev=131112&view=rev Log: Preserve line number information. Modified: llvm/trunk/lib/Transforms/IPO/PruneEH.cpp Modified: llvm/trunk/lib/Transforms/IPO/PruneEH.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PruneEH.cpp?rev=131112&r1=131111&r2=131112&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/PruneEH.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/PruneEH.cpp Mon May 9 19:03:11 2011 @@ -180,6 +180,7 @@ Call->takeName(II); Call->setCallingConv(II->getCallingConv()); Call->setAttributes(II->getAttributes()); + Call->setDebugLoc(II->getDebugLoc()); // Anything that used the value produced by the invoke instruction // now uses the value produced by the call instruction. Note that we From nobled at dreamwidth.org Mon May 9 19:37:38 2011 From: nobled at dreamwidth.org (nobled) Date: Mon, 9 May 2011 20:37:38 -0400 Subject: [llvm-commits] [PATCH] unittests/ExecutionEngine: use EngineBuilder::setErrorStr() Message-ID: If EngineBuilder::create() returns NULL, this prints the reason why before exiting. --- diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/unittests/ExecutionEngine/ExecutionEngineTest.cpp index 904ee2b..e5daf19 100644 --- a/unittests/ExecutionEngine/ExecutionEngineTest.cpp +++ b/unittests/ExecutionEngine/ExecutionEngineTest.cpp @@ -22,11 +22,14 @@ namespace { class ExecutionEngineTest : public testing::Test { protected: ExecutionEngineTest() - : M(new Module("
", getGlobalContext())), - Engine(EngineBuilder(M).create()) { + : M(new Module("
", getGlobalContext())), Error(""), + Engine(EngineBuilder(M).setErrorStr(&Error).create()) { } virtual void SetUp() { + EXPECT_EQ(Error.empty(), true) + << "Error building ExecutionEngine: " << Error; + ASSERT_TRUE(Engine.get() != NULL); } @@ -36,6 +39,7 @@ protected: } Module *const M; + std::string Error; const OwningPtr Engine; }; -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-unittests-ExecutionEngine-use-EngineBuilder-setError.patch Type: text/x-patch Size: 1326 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110509/d6223961/attachment.bin From rafael.espindola at gmail.com Mon May 9 20:10:18 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 01:10:18 -0000 Subject: [llvm-commits] [llvm] r131117 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCParser/AsmParser.cpp lib/MC/MCStreamer.cpp Message-ID: <20110510011018.83AE92A6C12C@llvm.org> Author: rafael Date: Mon May 9 20:10:18 2011 New Revision: 131117 URL: http://llvm.org/viewvc/llvm-project?rev=131117&view=rev Log: Parsing and plumbing for .cfi_sections. Modified: llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/MC/MCParser/AsmParser.cpp llvm/trunk/lib/MC/MCStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=131117&r1=131116&r2=131117&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon May 9 20:10:18 2011 @@ -50,6 +50,9 @@ MCStreamer(const MCStreamer&); // DO NOT IMPLEMENT MCStreamer &operator=(const MCStreamer&); // DO NOT IMPLEMENT + bool EmitEHFrame; + bool EmitDebugFrame; + std::vector FrameInfos; MCDwarfFrameInfo *getCurrentFrameInfo(); void EnsureValidFrame(); @@ -436,6 +439,7 @@ void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label, int PointerSize); + virtual void EmitCFISections(bool EH, bool Debug); virtual void EmitCFIStartProc(); virtual void EmitCFIEndProc(); virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset); Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=131117&r1=131116&r2=131117&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon May 9 20:10:18 2011 @@ -243,6 +243,8 @@ AddDirectiveHandler<&GenericAsmParser::ParseDirectiveStabs>(".stabs"); // CFI directives. + AddDirectiveHandler<&GenericAsmParser::ParseDirectiveCFISections>( + ".cfi_sections"); AddDirectiveHandler<&GenericAsmParser::ParseDirectiveCFIStartProc>( ".cfi_startproc"); AddDirectiveHandler<&GenericAsmParser::ParseDirectiveCFIEndProc>( @@ -289,6 +291,7 @@ bool ParseDirectiveLine(StringRef, SMLoc DirectiveLoc); bool ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc); bool ParseDirectiveStabs(StringRef, SMLoc DirectiveLoc); + bool ParseDirectiveCFISections(StringRef, SMLoc DirectiveLoc); bool ParseDirectiveCFIStartProc(StringRef, SMLoc DirectiveLoc); bool ParseDirectiveCFIEndProc(StringRef, SMLoc DirectiveLoc); bool ParseDirectiveCFIDefCfa(StringRef, SMLoc DirectiveLoc); @@ -2265,6 +2268,39 @@ return TokError("unsupported directive '" + Directive + "'"); } +/// ParseDirectiveCFISections +/// ::= .cfi_sections section [, section] +bool GenericAsmParser::ParseDirectiveCFISections(StringRef, + SMLoc DirectiveLoc) { + StringRef Name; + bool EH = false; + bool Debug = false; + + if (getParser().ParseIdentifier(Name)) + return TokError("Expected an identifier"); + + if (Name == ".eh_frame") + EH = true; + else if (Name == ".debug_frame") + Debug = true; + + if (getLexer().is(AsmToken::Comma)) { + Lex(); + + if (getParser().ParseIdentifier(Name)) + return TokError("Expected an identifier"); + + if (Name == ".eh_frame") + EH = true; + else if (Name == ".debug_frame") + Debug = true; + } + + getStreamer().EmitCFISections(EH, Debug); + + return false; +} + /// ParseDirectiveCFIStartProc /// ::= .cfi_startproc bool GenericAsmParser::ParseDirectiveCFIStartProc(StringRef, Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=131117&r1=131116&r2=131117&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Mon May 9 20:10:18 2011 @@ -20,7 +20,8 @@ #include using namespace llvm; -MCStreamer::MCStreamer(MCContext &Ctx) : Context(Ctx) { +MCStreamer::MCStreamer(MCContext &Ctx) : Context(Ctx), EmitEHFrame(true), + EmitDebugFrame(false) { const MCSection *section = NULL; SectionStack.push_back(std::make_pair(section, section)); } @@ -176,6 +177,11 @@ LastNonPrivate = Symbol; } +void MCStreamer::EmitCFISections(bool EH, bool Debug) { + EmitEHFrame = EH; + EmitDebugFrame = Debug; +} + void MCStreamer::EmitCFIStartProc() { MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo(); if (CurFrame && !CurFrame->End) From nobled at dreamwidth.org Mon May 9 20:49:25 2011 From: nobled at dreamwidth.org (nobled) Date: Mon, 9 May 2011 21:49:25 -0400 Subject: [llvm-commits] [PATCH] unittests/ExecutionEngine: use EngineBuilder::setErrorStr() In-Reply-To: References: Message-ID: Oops, I meant to paste this in the last message: When I tried this patch, it causes the test to fail all by itself, even though the "Engine.get() != NULL" assert doesn't trigger. It gives this output: Error building ExecutionEngine: Unable to find target for this triple (no targets are registered) Does that indicate a bug in the test? > If EngineBuilder::create() returns NULL, this prints the reason why > before exiting. > > --- > diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp > b/unittests/ExecutionEngine/ExecutionEngineTest.cpp > index 904ee2b..e5daf19 100644 > --- a/unittests/ExecutionEngine/ExecutionEngineTest.cpp > +++ b/unittests/ExecutionEngine/ExecutionEngineTest.cpp > @@ -22,11 +22,14 @@ namespace { > ?class ExecutionEngineTest : public testing::Test { > ?protected: > ? ExecutionEngineTest() > - ? ?: M(new Module("
", getGlobalContext())), > - ? ? ?Engine(EngineBuilder(M).create()) { > + ? ?: M(new Module("
", getGlobalContext())), Error(""), > + ? ?Engine(EngineBuilder(M).setErrorStr(&Error).create()) { > ? } > > ? virtual void SetUp() { > + ? ?EXPECT_EQ(Error.empty(), true) > + ? ? ?<< "Error building ExecutionEngine: " << Error; > + > ? ? ASSERT_TRUE(Engine.get() != NULL); > ? } > > @@ -36,6 +39,7 @@ protected: > ? } > > ? Module *const M; > + ?std::string Error; > ? const OwningPtr Engine; > ?}; > From rafael.espindola at gmail.com Mon May 9 22:01:40 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 03:01:40 -0000 Subject: [llvm-commits] [llvm] r131118 - /llvm/trunk/lib/MC/MCDwarf.cpp Message-ID: <20110510030140.1AC3A2A6C12C@llvm.org> Author: rafael Date: Mon May 9 22:01:39 2011 New Revision: 131118 URL: http://llvm.org/viewvc/llvm-project?rev=131118&view=rev Log: Remove unused argument. Modified: llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=131118&r1=131117&r2=131118&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Mon May 9 22:01:39 2011 @@ -514,8 +514,7 @@ unsigned lsdaEncoding); MCSymbol *EmitFDE(MCStreamer &streamer, const MCSymbol &cieStart, - const MCDwarfFrameInfo &frame, - bool forceLsda); + const MCDwarfFrameInfo &frame); void EmitCFIInstructions(MCStreamer &streamer, const std::vector &Instrs, MCSymbol *BaseLabel); @@ -732,8 +731,7 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCStreamer &streamer, const MCSymbol &cieStart, - const MCDwarfFrameInfo &frame, - bool forceLsda) { + const MCDwarfFrameInfo &frame) { MCContext &context = streamer.getContext(); MCSymbol *fdeStart = context.CreateTempSymbol(); MCSymbol *fdeEnd = context.CreateTempSymbol(); @@ -769,20 +767,14 @@ // Augmentation Data Length unsigned augmentationLength = 0; - if (frame.Lsda || forceLsda) + if (frame.Lsda) augmentationLength += getSizeForEncoding(streamer, frame.LsdaEncoding); streamer.EmitULEB128IntValue(augmentationLength); // Augmentation Data - - // When running in "CodeGen compatibility mode" a FDE with no LSDA can be - // assigned to a CIE that requires one. In that case we output a 0 (as does - // CodeGen). if (frame.Lsda) EmitSymbol(streamer, *frame.Lsda, frame.LsdaEncoding); - else if (forceLsda) - streamer.EmitIntValue(0, getSizeForEncoding(streamer, frame.LsdaEncoding)); // Call Frame Instructions @@ -853,7 +845,7 @@ cieStart = &Emitter.EmitCIE(streamer, frame.Personality, frame.PersonalityEncoding, frame.Lsda, frame.LsdaEncoding); - fdeEnd = Emitter.EmitFDE(streamer, *cieStart, frame, false); + fdeEnd = Emitter.EmitFDE(streamer, *cieStart, frame); if (i != n - 1) streamer.EmitLabel(fdeEnd); } From rafael.espindola at gmail.com Mon May 9 22:14:15 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 03:14:15 -0000 Subject: [llvm-commits] [llvm] r131119 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp lib/MC/MCELFStreamer.cpp lib/MC/MCMachOStreamer.cpp lib/MC/MCStreamer.cpp Message-ID: <20110510031415.84D4B2A6C12C@llvm.org> Author: rafael Date: Mon May 9 22:14:15 2011 New Revision: 131119 URL: http://llvm.org/viewvc/llvm-project?rev=131119&view=rev Log: Factor some code into a new EmitFrames method. Modified: llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCELFStreamer.cpp llvm/trunk/lib/MC/MCMachOStreamer.cpp llvm/trunk/lib/MC/MCStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=131119&r1=131118&r2=131119&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon May 9 22:14:15 2011 @@ -73,6 +73,8 @@ const MCExpr *ForceExpAbs(MCStreamer *Streamer, MCContext &Context, const MCExpr* Expr); + void EmitFrames(bool usingCFI); + public: virtual ~MCStreamer(); Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=131119&r1=131118&r2=131119&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Mon May 9 22:14:15 2011 @@ -1070,8 +1070,8 @@ if (getContext().hasDwarfFiles() && !UseLoc) MCDwarfFileTable::Emit(this); - if (getNumFrameInfos() && !UseCFI) - MCDwarfFrameEmitter::Emit(*this, false); + if (!UseCFI) + EmitFrames(false); } MCStreamer *llvm::createAsmStreamer(MCContext &Context, Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=131119&r1=131118&r2=131119&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCELFStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCELFStreamer.cpp Mon May 9 22:14:15 2011 @@ -345,8 +345,7 @@ } void MCELFStreamer::Finish() { - if (getNumFrameInfos()) - MCDwarfFrameEmitter::Emit(*this, true); + EmitFrames(true); for (std::vector::const_iterator i = LocalCommons.begin(), e = LocalCommons.end(); Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=131119&r1=131118&r2=131119&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Mon May 9 22:14:15 2011 @@ -377,8 +377,7 @@ } void MCMachOStreamer::Finish() { - if (getNumFrameInfos()) - MCDwarfFrameEmitter::Emit(*this, true); + EmitFrames(true); // We have to set the fragment atom associations so we can relax properly for // Mach-O. Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=131119&r1=131118&r2=131119&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Mon May 9 22:14:15 2011 @@ -363,3 +363,11 @@ T.toVector(Str); EmitRawText(Str.str()); } + +void MCStreamer::EmitFrames(bool usingCFI) { + if (!getNumFrameInfos()) + return; + + if (EmitEHFrame) + MCDwarfFrameEmitter::Emit(*this, usingCFI); +} From rafael.espindola at gmail.com Mon May 9 22:26:21 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 03:26:21 -0000 Subject: [llvm-commits] [llvm] r131120 - /llvm/trunk/lib/MC/MCDwarf.cpp Message-ID: <20110510032621.B8FE42A6C12C@llvm.org> Author: rafael Date: Mon May 9 22:26:21 2011 New Revision: 131120 URL: http://llvm.org/viewvc/llvm-project?rev=131120&view=rev Log: Small cleanups. Modified: llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=131120&r1=131119&r2=131120&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Mon May 9 22:26:21 2011 @@ -629,8 +629,6 @@ unsigned lsdaEncoding) { MCContext &context = streamer.getContext(); const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); - const MCSection §ion = *asmInfo.getEHFrameSection(); - streamer.SwitchSection(§ion); MCSymbol *sectionStart; if (asmInfo.isFunctionEHFrameSymbolPrivate()) @@ -683,9 +681,8 @@ // Personality augmentationLength += getSizeForEncoding(streamer, personalityEncoding); } - if (lsda) { + if (lsda) augmentationLength += 1; - } // Encoding of the FDE pointers augmentationLength += 1; @@ -698,10 +695,8 @@ // Personality EmitPersonality(streamer, *personality, personalityEncoding); } - if (lsda) { - // LSDA Encoding - streamer.EmitIntValue(lsdaEncoding, 1); - } + if (lsda) + streamer.EmitIntValue(lsdaEncoding, 1); // LSDA Encoding // Encoding of the FDE pointers streamer.EmitIntValue(asmInfo.getFDEEncoding(UsingCFI), 1); @@ -831,6 +826,8 @@ bool usingCFI) { const MCContext &context = streamer.getContext(); const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); + const MCSection §ion = *asmInfo.getEHFrameSection(); + streamer.SwitchSection(§ion); MCSymbol *fdeEnd = NULL; DenseMap CIEStarts; From rafael.espindola at gmail.com Mon May 9 22:54:12 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 03:54:12 -0000 Subject: [llvm-commits] [llvm] r131121 - in /llvm/trunk: include/llvm/MC/MCDwarf.h include/llvm/Target/TargetAsmInfo.h lib/MC/MCDwarf.cpp lib/MC/MCStreamer.cpp test/MC/ELF/cfi-sections.s Message-ID: <20110510035412.C03C72A6C12C@llvm.org> Author: rafael Date: Mon May 9 22:54:12 2011 New Revision: 131121 URL: http://llvm.org/viewvc/llvm-project?rev=131121&view=rev Log: Add support for producing .deubg_frame sections. Added: llvm/trunk/test/MC/ELF/cfi-sections.s Modified: llvm/trunk/include/llvm/MC/MCDwarf.h llvm/trunk/include/llvm/Target/TargetAsmInfo.h llvm/trunk/lib/MC/MCDwarf.cpp llvm/trunk/lib/MC/MCStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCDwarf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=131121&r1=131120&r2=131121&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCDwarf.h (original) +++ llvm/trunk/include/llvm/MC/MCDwarf.h Mon May 9 22:54:12 2011 @@ -281,7 +281,8 @@ // // This emits the frame info section. // - static void Emit(MCStreamer &streamer, bool usingCFI); + static void Emit(MCStreamer &streamer, bool usingCFI, + bool isEH); static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta); static void EncodeAdvanceLoc(uint64_t AddrDelta, raw_ostream &OS); }; Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=131121&r1=131120&r2=131121&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Mon May 9 22:54:12 2011 @@ -58,6 +58,10 @@ return TLOF->getEHFrameSection(); } + const MCSection *getDwarfFrameSection() const { + return TLOF->getDwarfFrameSection(); + } + unsigned getFDEEncoding(bool CFI) const { return TLOF->getFDEEncoding(CFI); } Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=131121&r1=131120&r2=131121&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Mon May 9 22:54:12 2011 @@ -501,10 +501,12 @@ int CFAOffset; int CIENum; bool UsingCFI; + bool IsEH; public: - FrameEmitterImpl(bool usingCFI) : CFAOffset(0), CIENum(0), - UsingCFI(usingCFI) { + FrameEmitterImpl(bool usingCFI, bool isEH) : CFAOffset(0), CIENum(0), + UsingCFI(usingCFI), + IsEH(isEH) { } const MCSymbol &EmitCIE(MCStreamer &streamer, @@ -647,20 +649,23 @@ streamer.EmitAbsValue(Length, 4); // CIE ID - streamer.EmitIntValue(0, 4); + unsigned CIE_ID = IsEH ? 0 : -1; + streamer.EmitIntValue(CIE_ID, 4); // Version streamer.EmitIntValue(dwarf::DW_CIE_VERSION, 1); // Augmentation String SmallString<8> Augmentation; - Augmentation += "z"; - if (personality) - Augmentation += "P"; - if (lsda) - Augmentation += "L"; - Augmentation += "R"; - streamer.EmitBytes(Augmentation.str(), 0); + if (IsEH) { + Augmentation += "z"; + if (personality) + Augmentation += "P"; + if (lsda) + Augmentation += "L"; + Augmentation += "R"; + streamer.EmitBytes(Augmentation.str(), 0); + } streamer.EmitIntValue(0, 1); // Code Alignment Factor @@ -675,30 +680,32 @@ // Augmentation Data Length (optional) unsigned augmentationLength = 0; - if (personality) { - // Personality Encoding - augmentationLength += 1; - // Personality - augmentationLength += getSizeForEncoding(streamer, personalityEncoding); - } - if (lsda) + if (IsEH) { + if (personality) { + // Personality Encoding + augmentationLength += 1; + // Personality + augmentationLength += getSizeForEncoding(streamer, personalityEncoding); + } + if (lsda) + augmentationLength += 1; + // Encoding of the FDE pointers augmentationLength += 1; - // Encoding of the FDE pointers - augmentationLength += 1; - streamer.EmitULEB128IntValue(augmentationLength); + streamer.EmitULEB128IntValue(augmentationLength); - // Augmentation Data (optional) - if (personality) { - // Personality Encoding - streamer.EmitIntValue(personalityEncoding, 1); - // Personality - EmitPersonality(streamer, *personality, personalityEncoding); - } - if (lsda) - streamer.EmitIntValue(lsdaEncoding, 1); // LSDA Encoding - // Encoding of the FDE pointers - streamer.EmitIntValue(asmInfo.getFDEEncoding(UsingCFI), 1); + // Augmentation Data (optional) + if (personality) { + // Personality Encoding + streamer.EmitIntValue(personalityEncoding, 1); + // Personality + EmitPersonality(streamer, *personality, personalityEncoding); + } + if (lsda) + streamer.EmitIntValue(lsdaEncoding, 1); // LSDA Encoding + // Encoding of the FDE pointers + streamer.EmitIntValue(asmInfo.getFDEEncoding(UsingCFI), 1); + } // Initial Instructions @@ -718,7 +725,7 @@ EmitCFIInstructions(streamer, Instructions, NULL); // Padding - streamer.EmitValueToAlignment(4); + streamer.EmitValueToAlignment(IsEH ? 4 : asmInfo.getPointerSize()); streamer.EmitLabel(sectionEnd); return *sectionStart; @@ -752,31 +759,35 @@ unsigned size = getSizeForEncoding(streamer, fdeEncoding); // PC Begin - EmitSymbol(streamer, *frame.Begin, fdeEncoding); + unsigned PCBeginEncoding = IsEH ? fdeEncoding : dwarf::DW_EH_PE_absptr; + unsigned PCBeginSize = getSizeForEncoding(streamer, PCBeginEncoding); + EmitSymbol(streamer, *frame.Begin, PCBeginEncoding); // PC Range const MCExpr *Range = MakeStartMinusEndExpr(streamer, *frame.Begin, *frame.End, 0); streamer.EmitAbsValue(Range, size); - // Augmentation Data Length - unsigned augmentationLength = 0; - - if (frame.Lsda) - augmentationLength += getSizeForEncoding(streamer, frame.LsdaEncoding); - - streamer.EmitULEB128IntValue(augmentationLength); - - // Augmentation Data - if (frame.Lsda) - EmitSymbol(streamer, *frame.Lsda, frame.LsdaEncoding); + if (IsEH) { + // Augmentation Data Length + unsigned augmentationLength = 0; + + if (frame.Lsda) + augmentationLength += getSizeForEncoding(streamer, frame.LsdaEncoding); + + streamer.EmitULEB128IntValue(augmentationLength); + + // Augmentation Data + if (frame.Lsda) + EmitSymbol(streamer, *frame.Lsda, frame.LsdaEncoding); + } // Call Frame Instructions EmitCFIInstructions(streamer, frame.Instructions, frame.Begin); // Padding - streamer.EmitValueToAlignment(size); + streamer.EmitValueToAlignment(PCBeginSize); return fdeEnd; } @@ -823,21 +834,24 @@ } void MCDwarfFrameEmitter::Emit(MCStreamer &streamer, - bool usingCFI) { + bool usingCFI, + bool isEH) { const MCContext &context = streamer.getContext(); const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); - const MCSection §ion = *asmInfo.getEHFrameSection(); + const MCSection §ion = isEH ? + *asmInfo.getEHFrameSection() : *asmInfo.getDwarfFrameSection(); streamer.SwitchSection(§ion); MCSymbol *fdeEnd = NULL; DenseMap CIEStarts; - FrameEmitterImpl Emitter(usingCFI); + FrameEmitterImpl Emitter(usingCFI, isEH); + const MCSymbol *DummyDebugKey = NULL; for (unsigned i = 0, n = streamer.getNumFrameInfos(); i < n; ++i) { const MCDwarfFrameInfo &frame = streamer.getFrameInfo(i); CIEKey key(frame.Personality, frame.PersonalityEncoding, frame.LsdaEncoding); - const MCSymbol *&cieStart = CIEStarts[key]; + const MCSymbol *&cieStart = isEH ? CIEStarts[key] : DummyDebugKey; if (!cieStart) cieStart = &Emitter.EmitCIE(streamer, frame.Personality, frame.PersonalityEncoding, frame.Lsda, Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=131121&r1=131120&r2=131121&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Mon May 9 22:54:12 2011 @@ -369,5 +369,8 @@ return; if (EmitEHFrame) - MCDwarfFrameEmitter::Emit(*this, usingCFI); + MCDwarfFrameEmitter::Emit(*this, usingCFI, true); + + if (EmitDebugFrame) + MCDwarfFrameEmitter::Emit(*this, usingCFI, false); } Added: llvm/trunk/test/MC/ELF/cfi-sections.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-sections.s?rev=131121&view=auto ============================================================================== --- llvm/trunk/test/MC/ELF/cfi-sections.s (added) +++ llvm/trunk/test/MC/ELF/cfi-sections.s Mon May 9 22:54:12 2011 @@ -0,0 +1,42 @@ +// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck -check-prefix=ELF_64 %s +// RUN: llvm-mc -filetype=obj -triple i686-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck -check-prefix=ELF_32 %s + + +// The only difference in gas' output in this test is that we don't produce +// the relocations to .debug_frame (we know their values). + +.cfi_sections .debug_frame + +f1: + .cfi_startproc + nop + .cfi_endproc + +f2: + .cfi_startproc + nop + .cfi_endproc + +// ELF_64: (('sh_name', 0x00000011) # '.debug_frame' +// ELF_64-NEXT: ('sh_type', 0x00000001) +// ELF_64-NEXT: ('sh_flags', 0x00000000) +// ELF_64-NEXT: ('sh_addr', 0x00000000) +// ELF_64-NEXT: ('sh_offset', 0x00000048) +// ELF_64-NEXT: ('sh_size', 0x00000048) +// ELF_64-NEXT: ('sh_link', 0x00000000) +// ELF_64-NEXT: ('sh_info', 0x00000000) +// ELF_64-NEXT: ('sh_addralign', 0x00000008) +// ELF_64-NEXT: ('sh_entsize', 0x00000000) +// ELF_64-NEXT: ('_section_data', '14000000 ffffffff 01000178 100c0708 90010000 00000000 14000000 1c000000 00000000 00000000 01000000 00000000 14000000 34000000 00000000 00000000 01000000 00000000') + +// ELF_32: (('sh_name', 0x00000010) # '.debug_frame' +// ELF_32-NEXT: ('sh_type', 0x00000001) +// ELF_32-NEXT: ('sh_flags', 0x00000000) +// ELF_32-NEXT: ('sh_addr', 0x00000000) +// ELF_32-NEXT: ('sh_offset', 0x00000038) +// ELF_32-NEXT: ('sh_size', 0x00000034) +// ELF_32-NEXT: ('sh_link', 0x00000000) +// ELF_32-NEXT: ('sh_info', 0x00000000) +// ELF_32-NEXT: ('sh_addralign', 0x00000004) +// ELF_32-NEXT: ('sh_entsize', 0x00000000) +// ELF_32-NEXT: ('_section_data', '10000000 ffffffff 0100017c 080c0404 88010000 0c000000 18000000 00000000 01000000 0c000000 28000000 01000000 01000000') From baldrick at free.fr Tue May 10 06:27:06 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 May 2011 11:27:06 -0000 Subject: [llvm-commits] [dragonegg] r131122 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp Message-ID: <20110510112706.20E152A6C12C@llvm.org> Author: baldrick Date: Tue May 10 06:27:05 2011 New Revision: 131122 URL: http://llvm.org/viewvc/llvm-project?rev=131122&view=rev Log: Add support for VEC_PACK_TRUNC_EXPR, which may be produced by GCC's tree vectorizer when GCC optimizations are enabled. The resulting code is gross though due to the type legalizer scalarizing the floating conversion from <2 x double> to <2 x float>. This fixes PR9726. Modified: dragonegg/trunk/include/dragonegg/Internals.h dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/include/dragonegg/Internals.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=131122&r1=131121&r2=131122&view=diff ============================================================================== --- dragonegg/trunk/include/dragonegg/Internals.h (original) +++ dragonegg/trunk/include/dragonegg/Internals.h Tue May 10 06:27:05 2011 @@ -721,6 +721,8 @@ Value *EmitReg_VEC_EXTRACT_ODD_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_VEC_INTERLEAVE_HIGH_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_VEC_INTERLEAVE_LOW_EXPR(tree_node *op0, tree_node *op1); + Value *EmitReg_VEC_PACK_TRUNC_EXPR(tree_node *type, tree_node *op0, + tree_node *op1); Value *EmitLoadOfLValue(tree_node *exp); Value *EmitOBJ_TYPE_REF(tree_node *exp); Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131122&r1=131121&r2=131122&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Tue May 10 06:27:05 2011 @@ -6994,6 +6994,32 @@ return Builder.CreateShuffleVector(LHS, RHS, ConstantVector::get(Mask)); } +Value *TreeToLLVM::EmitReg_VEC_PACK_TRUNC_EXPR(tree type, tree op0, tree op1) { + // Eg: <4 x float> = VEC_PACK_TRUNC_EXPR(<2 x double>, <2 x double>). + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); + + // Truncate the input elements to the output element type, eg: <2 x double> + // -> <2 x float>. + unsigned Length = TYPE_VECTOR_SUBPARTS(TREE_TYPE(op0)); + const Type *TruncTy = VectorType::get(getRegType(TREE_TYPE(type)), Length); + if (FLOAT_TYPE_P(TREE_TYPE(type))) { + LHS = Builder.CreateFPTrunc(LHS, TruncTy); + RHS = Builder.CreateFPTrunc(RHS, TruncTy); + } else { + LHS = Builder.CreateTrunc(LHS, TruncTy); + RHS = Builder.CreateTrunc(RHS, TruncTy); + } + + // Concatenate the truncated inputs into one vector of twice the length, + // eg: <2 x float>, <2 x float> -> <4 x float>. + SmallVector Mask; + Mask.reserve(2*Length); + for (unsigned i = 0, e = 2*Length; i != e; ++i) + Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), i)); + return Builder.CreateShuffleVector(LHS, RHS, ConstantVector::get(Mask)); +} + //===----------------------------------------------------------------------===// // ... Exception Handling ... @@ -7959,6 +7985,8 @@ RHS = EmitReg_VEC_INTERLEAVE_HIGH_EXPR(rhs1, rhs2); break; case VEC_INTERLEAVE_LOW_EXPR: RHS = EmitReg_VEC_INTERLEAVE_LOW_EXPR(rhs1, rhs2); break; + case VEC_PACK_TRUNC_EXPR: + RHS = EmitReg_VEC_PACK_TRUNC_EXPR(type, rhs1, rhs2); break; } assert(RHS->getType() == getRegType(type) && "RHS has wrong type!"); From justin.holewinski at gmail.com Tue May 10 07:32:11 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Tue, 10 May 2011 12:32:11 -0000 Subject: [llvm-commits] [llvm] r131123 - in /llvm/trunk/lib/Target/PTX: PTXInstrInfo.td PTXSubtarget.h Message-ID: <20110510123211.DD3752A6C12C@llvm.org> Author: jholewinski Date: Tue May 10 07:32:11 2011 New Revision: 131123 URL: http://llvm.org/viewvc/llvm-project?rev=131123&view=rev Log: PTX: add PTX 2.3 setting in PTX sub-target. Patch by Wei-Ren Chen Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td llvm/trunk/lib/Target/PTX/PTXSubtarget.h Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=131123&r1=131122&r2=131123&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Tue May 10 07:32:11 2011 @@ -36,6 +36,8 @@ def DoesNotSupportPTX21 : Predicate<"!getSubtarget().supportsPTX21()">; def SupportsPTX22 : Predicate<"getSubtarget().supportsPTX22()">; def DoesNotSupportPTX22 : Predicate<"!getSubtarget().supportsPTX22()">; +def SupportsPTX23 : Predicate<"getSubtarget().supportsPTX23()">; +def DoesNotSupportPTX23 : Predicate<"!getSubtarget().supportsPTX23()">; //===----------------------------------------------------------------------===// // Instruction Pattern Stuff Modified: llvm/trunk/lib/Target/PTX/PTXSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXSubtarget.h?rev=131123&r1=131122&r2=131123&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXSubtarget.h (original) +++ llvm/trunk/lib/Target/PTX/PTXSubtarget.h Tue May 10 07:32:11 2011 @@ -72,6 +72,8 @@ bool supportsPTX22() const { return PTXVersion >= PTX_VERSION_2_2; } + bool supportsPTX23() const { return PTXVersion >= PTX_VERSION_2_3; } + std::string ParseSubtargetFeatures(const std::string &FS, const std::string &CPU); }; // class PTXSubtarget From justin.holewinski at gmail.com Tue May 10 07:37:54 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Tue, 10 May 2011 08:37:54 -0400 Subject: [llvm-commits] Patch for review - subtarget ptx23 In-Reply-To: <20110507132258.GA77528@cs.nctu.edu.tw> References: <20110507132258.GA77528@cs.nctu.edu.tw> Message-ID: On Sat, May 7, 2011 at 9:22 AM, ?????? wrote: > Hi, Justin > > I add subtarget ptx23 in PTXInstrInfo.td and a helper function > in PTXSubtarget.h. > Committed in r131123. Sorry for the delay, the e-mail slipped through the cracks. > > Regards, > chenwj > > -- > Wei-Ren Chen (??????) > Computer Systems Lab, Institute of Information Science, > Academia Sinica, Taiwan (R.O.C.) > Tel:886-2-2788-3799 #1667 > -- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110510/02e54af4/attachment-0001.html From baldrick at free.fr Tue May 10 07:44:08 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 May 2011 14:44:08 +0200 Subject: [llvm-commits] [PATCH] A patch to add vector SHL/SRL/SRA support for x86 In-Reply-To: <6594DDFF12B03D4E89690887C2486994027D601E8B@hasmsx504.ger.corp.intel.com> References: <6594DDFF12B03D4E89690887C2486994027D601E8B@hasmsx504.ger.corp.intel.com> Message-ID: <4DC93318.6010704@free.fr> Hi Nadav, > + setOperationAction(ISD::SRA, MVT::v4i32, Custom); > + setOperationAction(ISD::SRA, MVT::v8i16, Custom); so there is no v2i64 arithmetic right shift? > + // Must have SSE2 > + if(! Subtarget->hasSSE2()) return SDValue(); There should be a space between "if" and "(" and no space after "!". This problem occurs also in the SSE 4.1 test. > - if (VT == MVT::v4i32) { > + // Optimize shl/srl with constant shift amount There should be a full stop at the end of the comment. The comment doesn't mention sra but it is handled too. Otherwise it looks OK to me. Ciao, Duncan. From rafael.espindola at gmail.com Tue May 10 08:39:48 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 13:39:48 -0000 Subject: [llvm-commits] [llvm] r131124 - in /llvm/trunk/lib/MC: MCAsmStreamer.cpp MCStreamer.cpp Message-ID: <20110510133948.694C72A6C12C@llvm.org> Author: rafael Date: Tue May 10 08:39:48 2011 New Revision: 131124 URL: http://llvm.org/viewvc/llvm-project?rev=131124&view=rev Log: Add CFIStartSections to the asm printer. Add an assert that at least one of the sections is created. Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCStreamer.cpp Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=131124&r1=131123&r2=131124&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Tue May 10 08:39:48 2011 @@ -193,6 +193,7 @@ unsigned Isa, unsigned Discriminator, StringRef FileName); + virtual void EmitCFISections(bool EH, bool Debug); virtual void EmitCFIStartProc(); virtual void EmitCFIEndProc(); virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset); @@ -764,6 +765,24 @@ EmitEOL(); } +void MCAsmStreamer::EmitCFISections(bool EH, bool Debug) { + MCStreamer::EmitCFISections(EH, Debug); + + if (!UseCFI) + return; + + OS << "\t.cfi_sections "; + if (EH) { + OS << ".eh_frame"; + if (Debug) + OS << ", .debug_frame"; + } else if (Debug) { + OS << ".debug_frame"; + } + + EmitEOL(); +} + void MCAsmStreamer::EmitCFIStartProc() { MCStreamer::EmitCFIStartProc(); Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=131124&r1=131123&r2=131124&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Tue May 10 08:39:48 2011 @@ -178,6 +178,7 @@ } void MCStreamer::EmitCFISections(bool EH, bool Debug) { + assert(EH || Debug); EmitEHFrame = EH; EmitDebugFrame = Debug; } From baldrick at free.fr Tue May 10 08:51:38 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 10 May 2011 13:51:38 -0000 Subject: [llvm-commits] [dragonegg] r131125 - /dragonegg/trunk/src/Convert.cpp Message-ID: <20110510135138.9F9EF2A6C12C@llvm.org> Author: baldrick Date: Tue May 10 08:51:38 2011 New Revision: 131125 URL: http://llvm.org/viewvc/llvm-project?rev=131125&view=rev Log: Add support for non-constant constructors for vectors of pointers, fixing PR9724. Modified: dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131125&r1=131124&r2=131125&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Tue May 10 08:51:38 2011 @@ -2426,7 +2426,7 @@ unsigned HOST_WIDE_INT idx; tree value; FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value) { - Value *Elt = EmitMemory(value); + Value *Elt = EmitRegister(value); if (const VectorType *EltTy = dyn_cast(Elt->getType())) { // GCC allows vectors to be built up from vectors. Extract all of the @@ -2436,6 +2436,10 @@ BuildVecOps.push_back(Builder.CreateExtractElement(Elt, Index)); } } else { + // LLVM does not support vectors of pointers, so turn any pointers into + // integers. + if (isa(Elt->getType())) + Elt = Builder.CreatePtrToInt(Elt, TD.getIntPtrType(Context)); assert(Elt->getType() == VTy->getElementType() && "Unexpected type for vector constructor!"); BuildVecOps.push_back(Elt); From justin.holewinski at gmail.com Tue May 10 09:53:13 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Tue, 10 May 2011 14:53:13 -0000 Subject: [llvm-commits] [llvm] r131128 - in /llvm/trunk/test/CodeGen/PTX: cvt.ll fneg.ll selp.ll Message-ID: <20110510145313.EA3E92A6C12C@llvm.org> Author: jholewinski Date: Tue May 10 09:53:13 2011 New Revision: 131128 URL: http://llvm.org/viewvc/llvm-project?rev=131128&view=rev Log: PTX: add test cases for cvt, fneg, and selp Patch by Dan Bailey Added: llvm/trunk/test/CodeGen/PTX/cvt.ll llvm/trunk/test/CodeGen/PTX/fneg.ll llvm/trunk/test/CodeGen/PTX/selp.ll Added: llvm/trunk/test/CodeGen/PTX/cvt.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/cvt.ll?rev=131128&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PTX/cvt.ll (added) +++ llvm/trunk/test/CodeGen/PTX/cvt.ll Tue May 10 09:53:13 2011 @@ -0,0 +1,234 @@ +; RUN: llc < %s -march=ptx32 | FileCheck %s + +; preds +; (note: we convert back to i32 to return) + +define ptx_device i32 @cvt_pred_i16(i16 %x, i1 %y) { +; CHECK: cvt.pred.u16 p0, rh1; +; CHECK: ret; + %a = trunc i16 %x to i1 + %b = and i1 %a, %y + %c = zext i1 %b to i32 + ret i32 %c +} + +define ptx_device i32 @cvt_pred_i32(i32 %x, i1 %y) { +; CHECK: cvt.pred.u32 p0, r1; +; CHECK: ret; + %a = trunc i32 %x to i1 + %b = and i1 %a, %y + %c = zext i1 %b to i32 + ret i32 %c +} + +define ptx_device i32 @cvt_pred_i64(i64 %x, i1 %y) { +; CHECK: cvt.pred.u64 p0, rd1; +; CHECK: ret; + %a = trunc i64 %x to i1 + %b = and i1 %a, %y + %c = zext i1 %b to i32 + ret i32 %c +} + +define ptx_device i32 @cvt_pred_f32(float %x, i1 %y) { +; CHECK: cvt.rni.pred.f32 p0, f1; +; CHECK: ret; + %a = fptoui float %x to i1 + %b = and i1 %a, %y + %c = zext i1 %b to i32 + ret i32 %c +} + +define ptx_device i32 @cvt_pred_f64(double %x, i1 %y) { +; CHECK: cvt.rni.pred.f64 p0, fd1; +; CHECK: ret; + %a = fptoui double %x to i1 + %b = and i1 %a, %y + %c = zext i1 %b to i32 + ret i32 %c +} + +; i16 + +define ptx_device i16 @cvt_i16_preds(i1 %x) { +; CHECK: cvt.u16.pred rh0, p1; +; CHECK: ret; + %a = zext i1 %x to i16 + ret i16 %a +} + +define ptx_device i16 @cvt_i16_i32(i32 %x) { +; CHECK: cvt.u16.u32 rh0, r1; +; CHECK: ret; + %a = trunc i32 %x to i16 + ret i16 %a +} + +define ptx_device i16 @cvt_i16_i64(i64 %x) { +; CHECK: cvt.u16.u64 rh0, rd1; +; CHECK: ret; + %a = trunc i64 %x to i16 + ret i16 %a +} + +define ptx_device i16 @cvt_i16_f32(float %x) { +; CHECK: cvt.rni.u16.f32 rh0, f1; +; CHECK: ret; + %a = fptoui float %x to i16 + ret i16 %a +} + +define ptx_device i16 @cvt_i16_f64(double %x) { +; CHECK: cvt.rni.u16.f64 rh0, fd1; +; CHECK: ret; + %a = fptoui double %x to i16 + ret i16 %a +} + +; i32 + +define ptx_device i32 @cvt_i32_preds(i1 %x) { +; CHECK: cvt.u32.pred r0, p1; +; CHECK: ret; + %a = zext i1 %x to i32 + ret i32 %a +} + +define ptx_device i32 @cvt_i32_i16(i16 %x) { +; CHECK: cvt.u32.u16 r0, rh1; +; CHECK: ret; + %a = zext i16 %x to i32 + ret i32 %a +} + +define ptx_device i32 @cvt_i32_i64(i64 %x) { +; CHECK: cvt.u32.u64 r0, rd1; +; CHECK: ret; + %a = trunc i64 %x to i32 + ret i32 %a +} + +define ptx_device i32 @cvt_i32_f32(float %x) { +; CHECK: cvt.rni.u32.f32 r0, f1; +; CHECK: ret; + %a = fptoui float %x to i32 + ret i32 %a +} + +define ptx_device i32 @cvt_i32_f64(double %x) { +; CHECK: cvt.rni.u32.f64 r0, fd1; +; CHECK: ret; + %a = fptoui double %x to i32 + ret i32 %a +} + +; i64 + +define ptx_device i64 @cvt_i64_preds(i1 %x) { +; CHECK: cvt.u64.pred rd0, p1; +; CHECK: ret; + %a = zext i1 %x to i64 + ret i64 %a +} + +define ptx_device i64 @cvt_i64_i16(i16 %x) { +; CHECK: cvt.u64.u16 rd0, rh1; +; CHECK: ret; + %a = zext i16 %x to i64 + ret i64 %a +} + +define ptx_device i64 @cvt_i64_i32(i32 %x) { +; CHECK: cvt.u64.u32 rd0, r1; +; CHECK: ret; + %a = zext i32 %x to i64 + ret i64 %a +} + +define ptx_device i64 @cvt_i64_f32(float %x) { +; CHECK: cvt.rni.u64.f32 rd0, f1; +; CHECK: ret; + %a = fptoui float %x to i64 + ret i64 %a +} + +define ptx_device i64 @cvt_i64_f64(double %x) { +; CHECK: cvt.rni.u64.f64 rd0, fd1; +; CHECK: ret; + %a = fptoui double %x to i64 + ret i64 %a +} + +; f32 + +define ptx_device float @cvt_f32_preds(i1 %x) { +; CHECK: cvt.rn.f32.pred f0, p1; +; CHECK: ret; + %a = uitofp i1 %x to float + ret float %a +} + +define ptx_device float @cvt_f32_i16(i16 %x) { +; CHECK: cvt.rn.f32.u16 f0, rh1; +; CHECK: ret; + %a = uitofp i16 %x to float + ret float %a +} + +define ptx_device float @cvt_f32_i32(i32 %x) { +; CHECK: cvt.rn.f32.u32 f0, r1; +; CHECK: ret; + %a = uitofp i32 %x to float + ret float %a +} + +define ptx_device float @cvt_f32_i64(i64 %x) { +; CHECK: cvt.rn.f32.u64 f0, rd1; +; CHECK: ret; + %a = uitofp i64 %x to float + ret float %a +} + +define ptx_device float @cvt_f32_f64(double %x) { +; CHECK: cvt.rn.f32.f64 f0, fd1; +; CHECK: ret; + %a = fptrunc double %x to float + ret float %a +} + +; f64 + +define ptx_device double @cvt_f64_preds(i1 %x) { +; CHECK: cvt.rn.f64.pred fd0, p1; +; CHECK: ret; + %a = uitofp i1 %x to double + ret double %a +} + +define ptx_device double @cvt_f64_i16(i16 %x) { +; CHECK: cvt.rn.f64.u16 fd0, rh1; +; CHECK: ret; + %a = uitofp i16 %x to double + ret double %a +} + +define ptx_device double @cvt_f64_i32(i32 %x) { +; CHECK: cvt.rn.f64.u32 fd0, r1; +; CHECK: ret; + %a = uitofp i32 %x to double + ret double %a +} + +define ptx_device double @cvt_f64_i64(i64 %x) { +; CHECK: cvt.rn.f64.u64 fd0, rd1; +; CHECK: ret; + %a = uitofp i64 %x to double + ret double %a +} + +define ptx_device double @cvt_f64_f32(float %x) { +; CHECK: cvt.f64.f32 fd0, f1; +; CHECK: ret; + %a = fpext float %x to double + ret double %a +} Added: llvm/trunk/test/CodeGen/PTX/fneg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/fneg.ll?rev=131128&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PTX/fneg.ll (added) +++ llvm/trunk/test/CodeGen/PTX/fneg.ll Tue May 10 09:53:13 2011 @@ -0,0 +1,15 @@ +; RUN: llc < %s -march=ptx32 | FileCheck %s + +define ptx_device float @t1_f32(float %x) { +; CHECK: neg.f32 f0, f1; +; CHECK-NEXT: ret; + %y = fsub float -0.000000e+00, %x + ret float %y +} + +define ptx_device double @t1_f64(double %x) { +; CHECK: neg.f64 fd0, fd1; +; CHECK-NEXT: ret; + %y = fsub double -0.000000e+00, %x + ret double %y +} Added: llvm/trunk/test/CodeGen/PTX/selp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/selp.ll?rev=131128&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PTX/selp.ll (added) +++ llvm/trunk/test/CodeGen/PTX/selp.ll Tue May 10 09:53:13 2011 @@ -0,0 +1,25 @@ +; RUN: llc < %s -march=ptx32 | FileCheck %s + +define ptx_device i32 @test_selp_i32(i1 %x, i32 %y, i32 %z) { +; CHECK: selp.u32 r0, r1, r2, p1; + %a = select i1 %x, i32 %y, i32 %z + ret i32 %a +} + +define ptx_device i64 @test_selp_i64(i1 %x, i64 %y, i64 %z) { +; CHECK: selp.u64 rd0, rd1, rd2, p1; + %a = select i1 %x, i64 %y, i64 %z + ret i64 %a +} + +define ptx_device float @test_selp_f32(i1 %x, float %y, float %z) { +; CHECK: selp.f32 f0, f1, f2, p1; + %a = select i1 %x, float %y, float %z + ret float %a +} + +define ptx_device double @test_selp_f64(i1 %x, double %y, double %z) { +; CHECK: selp.f64 fd0, fd1, fd2, p1; + %a = select i1 %x, double %y, double %z + ret double %a +} From justin.holewinski at gmail.com Tue May 10 09:58:53 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Tue, 10 May 2011 10:58:53 -0400 Subject: [llvm-commits] [llvm] r130356 - /llvm/trunk/lib/Target/PTX/PTXInstrInfo.td In-Reply-To: <4DC9511B.8070908@dneg.com> References: <20110428001954.B0DD02A6C134@llvm.org> <4DC9511B.8070908@dneg.com> Message-ID: On Tue, May 10, 2011 at 10:52 AM, Dan Bailey wrote: > Justin, > > Sorry for not spotting this earlier, bitwise.ll seems to have been added, > but I think these three tests were missed off their various commit - cvt.ll, > fneg.ll, selp.ll > > I've attached them again here as a patch, could we get them added in > please? > Whoops, looks like I forgot to add them those files to the commits. Fixed in r131128. > > Thanks, > Dan > > > Justin Holewinski wrote: > >> Author: jholewinski >> Date: Wed Apr 27 19:19:54 2011 >> New Revision: 130356 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=130356&view=rev >> Log: >> PTX: mov fix and rounding correction for cvt >> >> - fix typo in MOV >> - correct fp rounding on CVT >> - new cvt.ll test >> >> Patch by Dan Bailey >> >> Modified: >> llvm/trunk/lib/Target/PTX/PTXInstrInfo.td >> >> Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=130356&r1=130355&r2=130356&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) >> +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Wed Apr 27 19:19:54 2011 >> @@ -740,7 +740,7 @@ >> def MOVU32ri >> : InstPTX<(outs RRegu32:$d), (ins i32imm:$a), "mov.u32\t$d, $a", >> [(set RRegu32:$d, imm:$a)]>; >> - def MOVU164ri >> + def MOVU64ri >> : InstPTX<(outs RRegu64:$d), (ins i64imm:$a), "mov.u64\t$d, $a", >> [(set RRegu64:$d, imm:$a)]>; >> def MOVF32ri >> @@ -802,11 +802,11 @@ >> [(set Preds:$d, (trunc RRegu64:$a))]>; >> def CVT_pred_f32 >> - : InstPTX<(outs Preds:$d), (ins RRegf32:$a), "cvt.pred.f32\t$d, $a", >> + : InstPTX<(outs Preds:$d), (ins RRegf32:$a), "cvt.rni.pred.f32\t$d, >> $a", >> [(set Preds:$d, (fp_to_uint RRegf32:$a))]>; >> def CVT_pred_f64 >> - : InstPTX<(outs Preds:$d), (ins RRegf64:$a), "cvt.pred.f64\t$d, $a", >> + : InstPTX<(outs Preds:$d), (ins RRegf64:$a), "cvt.rni.pred.f64\t$d, >> $a", >> [(set Preds:$d, (fp_to_uint RRegf64:$a))]>; >> // Conversion to u16 >> @@ -824,11 +824,11 @@ >> [(set RRegu16:$d, (trunc RRegu64:$a))]>; >> def CVT_u16_f32 >> - : InstPTX<(outs RRegu16:$d), (ins RRegf32:$a), "cvt.u16.f32\t$d, $a", >> + : InstPTX<(outs RRegu16:$d), (ins RRegf32:$a), "cvt.rni.u16.f32\t$d, >> $a", >> [(set RRegu16:$d, (fp_to_uint RRegf32:$a))]>; >> def CVT_u16_f64 >> - : InstPTX<(outs RRegu16:$d), (ins RRegf64:$a), "cvt.u16.f64\t$d, $a", >> + : InstPTX<(outs RRegu16:$d), (ins RRegf64:$a), "cvt.rni.u16.f64\t$d, >> $a", >> [(set RRegu16:$d, (fp_to_uint RRegf64:$a))]>; >> // Conversion to u32 >> @@ -846,11 +846,11 @@ >> [(set RRegu32:$d, (trunc RRegu64:$a))]>; >> def CVT_u32_f32 >> - : InstPTX<(outs RRegu32:$d), (ins RRegf32:$a), "cvt.u32.f32\t$d, $a", >> + : InstPTX<(outs RRegu32:$d), (ins RRegf32:$a), "cvt.rni.u32.f32\t$d, >> $a", >> [(set RRegu32:$d, (fp_to_uint RRegf32:$a))]>; >> def CVT_u32_f64 >> - : InstPTX<(outs RRegu32:$d), (ins RRegf64:$a), "cvt.u32.f64\t$d, $a", >> + : InstPTX<(outs RRegu32:$d), (ins RRegf64:$a), "cvt.rni.u32.f64\t$d, >> $a", >> [(set RRegu32:$d, (fp_to_uint RRegf64:$a))]>; >> // Conversion to u64 >> @@ -868,51 +868,51 @@ >> [(set RRegu64:$d, (zext RRegu32:$a))]>; >> def CVT_u64_f32 >> - : InstPTX<(outs RRegu64:$d), (ins RRegf32:$a), "cvt.u64.f32\t$d, $a", >> + : InstPTX<(outs RRegu64:$d), (ins RRegf32:$a), "cvt.rni.u64.f32\t$d, >> $a", >> [(set RRegu64:$d, (fp_to_uint RRegf32:$a))]>; >> def CVT_u64_f64 >> - : InstPTX<(outs RRegu64:$d), (ins RRegf64:$a), "cvt.u64.f32\t$d, $a", >> + : InstPTX<(outs RRegu64:$d), (ins RRegf64:$a), "cvt.rni.u64.f64\t$d, >> $a", >> [(set RRegu64:$d, (fp_to_uint RRegf64:$a))]>; >> // Conversion to f32 >> def CVT_f32_pred >> - : InstPTX<(outs RRegf32:$d), (ins Preds:$a), "cvt.f32.pred\t$d, $a", >> + : InstPTX<(outs RRegf32:$d), (ins Preds:$a), "cvt.rn.f32.pred\t$d, $a", >> [(set RRegf32:$d, (uint_to_fp Preds:$a))]>; >> def CVT_f32_u16 >> - : InstPTX<(outs RRegf32:$d), (ins RRegu16:$a), "cvt.f32.u16\t$d, $a", >> + : InstPTX<(outs RRegf32:$d), (ins RRegu16:$a), "cvt.rn.f32.u16\t$d, >> $a", >> [(set RRegf32:$d, (uint_to_fp RRegu16:$a))]>; >> def CVT_f32_u32 >> - : InstPTX<(outs RRegf32:$d), (ins RRegu32:$a), "cvt.f32.u32\t$d, $a", >> + : InstPTX<(outs RRegf32:$d), (ins RRegu32:$a), "cvt.rn.f32.u32\t$d, >> $a", >> [(set RRegf32:$d, (uint_to_fp RRegu32:$a))]>; >> def CVT_f32_u64 >> - : InstPTX<(outs RRegf32:$d), (ins RRegu64:$a), "cvt.f32.u64\t$d, $a", >> + : InstPTX<(outs RRegf32:$d), (ins RRegu64:$a), "cvt.rn.f32.u64\t$d, >> $a", >> [(set RRegf32:$d, (uint_to_fp RRegu64:$a))]>; >> def CVT_f32_f64 >> - : InstPTX<(outs RRegf32:$d), (ins RRegf64:$a), "cvt.f32.f64\t$d, $a", >> + : InstPTX<(outs RRegf32:$d), (ins RRegf64:$a), "cvt.rn.f32.f64\t$d, >> $a", >> [(set RRegf32:$d, (fround RRegf64:$a))]>; >> // Conversion to f64 >> def CVT_f64_pred >> - : InstPTX<(outs RRegf64:$d), (ins Preds:$a), "cvt.f64.pred\t$d, $a", >> + : InstPTX<(outs RRegf64:$d), (ins Preds:$a), "cvt.rn.f64.pred\t$d, $a", >> [(set RRegf64:$d, (uint_to_fp Preds:$a))]>; >> def CVT_f64_u16 >> - : InstPTX<(outs RRegf64:$d), (ins RRegu16:$a), "cvt.f64.u16\t$d, $a", >> + : InstPTX<(outs RRegf64:$d), (ins RRegu16:$a), "cvt.rn.f64.u16\t$d, >> $a", >> [(set RRegf64:$d, (uint_to_fp RRegu16:$a))]>; >> def CVT_f64_u32 >> - : InstPTX<(outs RRegf64:$d), (ins RRegu32:$a), "cvt.f64.u32\t$d, $a", >> + : InstPTX<(outs RRegf64:$d), (ins RRegu32:$a), "cvt.rn.f64.u32\t$d, >> $a", >> [(set RRegf64:$d, (uint_to_fp RRegu32:$a))]>; >> def CVT_f64_u64 >> - : InstPTX<(outs RRegf64:$d), (ins RRegu64:$a), "cvt.f64.u64\t$d, $a", >> + : InstPTX<(outs RRegf64:$d), (ins RRegu64:$a), "cvt.rn.f64.u64\t$d, >> $a", >> [(set RRegf64:$d, (uint_to_fp RRegu64:$a))]>; >> def CVT_f64_f32 >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> >> > -- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110510/bab1a724/attachment.html From eli.friedman at gmail.com Tue May 10 10:02:19 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 10 May 2011 08:02:19 -0700 Subject: [llvm-commits] [PATCH] A patch to add vector SHL/SRL/SRA support for x86 In-Reply-To: <6594DDFF12B03D4E89690887C2486994027D6A1A4E@hasmsx504.ger.corp.intel.com> References: <6594DDFF12B03D4E89690887C2486994027D601E8B@hasmsx504.ger.corp.intel.com> <6594DDFF12B03D4E89690887C2486994027D6A19C2@hasmsx504.ger.corp.intel.com> <6594DDFF12B03D4E89690887C2486994027D6A1A4E@hasmsx504.ger.corp.intel.com> Message-ID: On Sun, May 8, 2011 at 11:39 AM, Rotem, Nadav wrote: > Hi Eli, > > Do you suggest that we remove PerformShiftCombine altogether ? ?Can you think of a scenario which would require us to have this in the DAGCombining phase ? > > Would you oppose keeping both translations if I refactor the code to use the same utility function ? I can't think of any particular reason we need to run this in the DAGCombine phase; the primary issue, the legalization of BUILD_VECTOR, isn't an issue anymore. -Eli From rafael.espindola at gmail.com Tue May 10 10:20:24 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 15:20:24 -0000 Subject: [llvm-commits] [llvm] r131129 - in /llvm/trunk: lib/MC/MCDwarf.cpp test/MC/ELF/cfi-sections.s Message-ID: <20110510152024.172AA2A6C12C@llvm.org> Author: rafael Date: Tue May 10 10:20:23 2011 New Revision: 131129 URL: http://llvm.org/viewvc/llvm-project?rev=131129&view=rev Log: In a debug_frame the cfi offset is to the start of the debug_frame section! Modified: llvm/trunk/lib/MC/MCDwarf.cpp llvm/trunk/test/MC/ELF/cfi-sections.s Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=131129&r1=131128&r2=131129&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Tue May 10 10:20:23 2011 @@ -752,9 +752,13 @@ streamer.EmitLabel(fdeStart); // CIE Pointer - const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart, - 0); - streamer.EmitAbsValue(offset, 4); + if (IsEH) { + const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart, + 0); + streamer.EmitAbsValue(offset, 4); + } else { + streamer.EmitSymbolValue(&cieStart, 4); + } unsigned fdeEncoding = asmInfo.getFDEEncoding(UsingCFI); unsigned size = getSizeForEncoding(streamer, fdeEncoding); Modified: llvm/trunk/test/MC/ELF/cfi-sections.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-sections.s?rev=131129&r1=131128&r2=131129&view=diff ============================================================================== --- llvm/trunk/test/MC/ELF/cfi-sections.s (original) +++ llvm/trunk/test/MC/ELF/cfi-sections.s Tue May 10 10:20:23 2011 @@ -1,10 +1,6 @@ // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck -check-prefix=ELF_64 %s // RUN: llvm-mc -filetype=obj -triple i686-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck -check-prefix=ELF_32 %s - -// The only difference in gas' output in this test is that we don't produce -// the relocations to .debug_frame (we know their values). - .cfi_sections .debug_frame f1: @@ -27,7 +23,7 @@ // ELF_64-NEXT: ('sh_info', 0x00000000) // ELF_64-NEXT: ('sh_addralign', 0x00000008) // ELF_64-NEXT: ('sh_entsize', 0x00000000) -// ELF_64-NEXT: ('_section_data', '14000000 ffffffff 01000178 100c0708 90010000 00000000 14000000 1c000000 00000000 00000000 01000000 00000000 14000000 34000000 00000000 00000000 01000000 00000000') +// ELF_64-NEXT: ('_section_data', '14000000 ffffffff 01000178 100c0708 90010000 00000000 14000000 00000000 00000000 00000000 01000000 00000000 14000000 00000000 00000000 00000000 01000000 00000000') // ELF_32: (('sh_name', 0x00000010) # '.debug_frame' // ELF_32-NEXT: ('sh_type', 0x00000001) @@ -39,4 +35,4 @@ // ELF_32-NEXT: ('sh_info', 0x00000000) // ELF_32-NEXT: ('sh_addralign', 0x00000004) // ELF_32-NEXT: ('sh_entsize', 0x00000000) -// ELF_32-NEXT: ('_section_data', '10000000 ffffffff 0100017c 080c0404 88010000 0c000000 18000000 00000000 01000000 0c000000 28000000 01000000 01000000') +// ELF_32-NEXT: ('_section_data', '10000000 ffffffff 0100017c 080c0404 88010000 0c000000 00000000 00000000 01000000 0c000000 00000000 01000000 01000000') From criswell at uiuc.edu Tue May 10 11:20:40 2011 From: criswell at uiuc.edu (John Criswell) Date: Tue, 10 May 2011 16:20:40 -0000 Subject: [llvm-commits] [poolalloc] r131131 - in /poolalloc/trunk/lib: DSA/StdLibPass.cpp PoolAllocate/PASimple.cpp PoolAllocate/TransformFunctionBody.cpp Message-ID: <20110510162040.5C8862A6C12D@llvm.org> Author: criswell Date: Tue May 10 11:20:40 2011 New Revision: 131131 URL: http://llvm.org/viewvc/llvm-project?rev=131131&view=rev Log: Added support for inserting pools into the Cif run-time functions. Added support to DSA for analyzing the Cif run-time functions. Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp poolalloc/trunk/lib/PoolAllocate/PASimple.cpp poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=131131&r1=131130&r2=131131&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Tue May 10 11:20:40 2011 @@ -266,6 +266,9 @@ {"sc.pool_unregister", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, {"sc.pool_argvregister", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + // CIF Intrinsics + {"__if_pool_get_label", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"__if_pool_set_label", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, // CStdLib Runtime Wrapper Functions {"pool_strncpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, {"pool_strcpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=131131&r1=131130&r2=131131&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Tue May 10 11:20:40 2011 @@ -99,7 +99,9 @@ (funcname == "sc.pool_unregister_global") || (funcname == "sc.pool_register") || (funcname == "sc.pool_unregister") || - (funcname == "sc.get_actual_val")) { + (funcname == "sc.get_actual_val") || + (funcname == "__if_pool_get_label") || + (funcname == "__if_pool_set_label")) { return 1; } Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=131131&r1=131130&r2=131131&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Tue May 10 11:20:40 2011 @@ -872,7 +872,9 @@ (CF->getName() == "sc.pool_unregister_global") || (CF->getName() == "sc.pool_register") || (CF->getName() == "sc.pool_unregister") || - (CF->getName() == "sc.get_actual_val")) { + (CF->getName() == "sc.get_actual_val") || + (CF->getName() == "__if_pool_get_label") || + (CF->getName() == "__if_pool_set_label")) { visitRuntimeCheck (CS); } else if ((argc = PAInfo.getCStdLibPoolArguments(CF->getName())) > 0) { visitCStdLibCheck(CS, argc); From dpatel at apple.com Tue May 10 12:37:15 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 May 2011 10:37:15 -0700 Subject: [llvm-commits] SelectionDAG Loosing debug information In-Reply-To: References: <68F6BBE4-4D61-4769-8DE6-D8B5CBA2CFC5@apple.com> Message-ID: <902AF332-0CF6-4A06-BADA-27A26582A867@apple.com> On May 9, 2011, at 4:38 PM, Villmow, Micah wrote: > >> -----Original Message----- >> From: Devang Patel [mailto:dpatel at apple.com] >> Sent: Monday, May 09, 2011 4:28 PM >> To: Villmow, Micah >> Cc: llvm-commits >> Subject: Re: [llvm-commits] SelectionDAG Loosing debug information >> >> DanglingDebugInfoMap maps llvm::Value to a node. So, the mapping is >> invalid whenever NodeMap is cleared. Are you sure this patch is the >> right approach here ? > [Villmow, Micah] Maybe, I'm not 100% familiar with the code, but it > seems to fix the problem we are having. The problem we are having is this: > The bitcode attached to the bug has a case where after running inlineAll > and then mem2reg, the resulting debug information is attached to a > phi node. The debug information references an instruction in a previous > basic block but has no references in the current basic block. By my > understanding after looking at the code, no nodes are created for the > phi node and the debug information is added to the map. However, since > no nodes in the current block reference the debug information, there > can be no resolving of the dangling reference by the end of the > block, which the map then gets cleared. > > What this change does is allows for all of the dangling references to > be resolved by the current or previous block at some point in the future > and after all the basic blocks have been processed and there is no > possibility of resolving the dangling reference anymore, then it is cleared. > > I don't see this as being a problem when NodeMap is cleared simply because > if the node existed in the current basic block, then the dangling reference > wouldn't exist in the DanglingDebugInfoMap as it is replaced once it is resolved. OK this makes. Go ahead and apply the patch, please include a test case also. Thanks, - Devang > Micah >> - >> Devang >> >> On May 9, 2011, at 4:04 PM, Villmow, Micah wrote: >> >>> Patch attached. >>> >>>> -----Original Message----- >>>> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits- >>>> bounces at cs.uiuc.edu] On Behalf Of Eric Christopher >>>> Sent: Monday, May 09, 2011 12:50 PM >>>> To: Villmow, Micah >>>> Cc: llvm-commits >>>> Subject: Re: [llvm-commits] SelectionDAG Loosing debug information >>>> >>>> >>>> On May 9, 2011, at 11:57 AM, Villmow, Micah wrote: >>>> >>>>> I've attached a patch to bug9879 that stops SelectionDAG from >>>> dropping debug information. Can someone review to see if this >> approach >>>> is correct or if a better one is preferred? >>>>> >>>> No patch attached. >>>> >>>> -eric >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110510/d40914ff/attachment.html From stoklund at 2pi.dk Tue May 10 12:37:42 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 May 2011 17:37:42 -0000 Subject: [llvm-commits] [llvm] r131133 - in /llvm/trunk/lib/CodeGen: RegAllocBase.h RegAllocBasic.cpp RegAllocGreedy.cpp SplitKit.cpp Message-ID: <20110510173742.102DD2A6C12C@llvm.org> Author: stoklund Date: Tue May 10 12:37:41 2011 New Revision: 131133 URL: http://llvm.org/viewvc/llvm-project?rev=131133&view=rev Log: Fix PR9883. Make sure all caches are invalidated when a live range is repaired. The previous invalidation missed the alias interference caches. Also add a stats counter for the number of repaired ranges. Modified: llvm/trunk/lib/CodeGen/RegAllocBase.h llvm/trunk/lib/CodeGen/RegAllocBasic.cpp llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocBase.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocBase.h?rev=131133&r1=131132&r2=131133&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocBase.h (original) +++ llvm/trunk/lib/CodeGen/RegAllocBase.h Tue May 10 12:37:41 2011 @@ -113,6 +113,10 @@ return Queries[PhysReg]; } + // Invalidate all cached information about virtual registers - live ranges may + // have changed. + void invalidateVirtRegs() { ++UserTag; } + // The top-level driver. The output is a VirtRegMap that us updated with // physical register assignments. // Modified: llvm/trunk/lib/CodeGen/RegAllocBasic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocBasic.cpp?rev=131133&r1=131132&r2=131133&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocBasic.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Tue May 10 12:37:41 2011 @@ -309,7 +309,7 @@ } // Invalidate all interference queries, live ranges could have changed. - ++UserTag; + invalidateVirtRegs(); // selectOrSplit requests the allocator to return an available physical // register if possible and populate a list of new live intervals that Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=131133&r1=131132&r2=131133&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Tue May 10 12:37:41 2011 @@ -1325,9 +1325,7 @@ // an assertion when the coalescer is fixed. if (SA->didRepairRange()) { // VirtReg has changed, so all cached queries are invalid. - Order.rewind(); - while (unsigned PhysReg = Order.next()) - query(VirtReg, PhysReg).clear(); + invalidateVirtRegs(); if (unsigned PhysReg = tryAssign(VirtReg, Order, NewVRegs)) return PhysReg; } Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=131133&r1=131132&r2=131133&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue May 10 12:37:41 2011 @@ -32,6 +32,7 @@ STATISTIC(NumSimple, "Number of splits that were simple"); STATISTIC(NumCopies, "Number of copies inserted for splitting"); STATISTIC(NumRemats, "Number of rematerialized defs for splitting"); +STATISTIC(NumRepairs, "Number of invalid live ranges repaired"); //===----------------------------------------------------------------------===// // Split Analysis @@ -123,6 +124,7 @@ // FIXME: calcLiveBlockInfo found inconsistencies in the live range. // I am looking at you, SimpleRegisterCoalescing! DidRepairRange = true; + ++NumRepairs; DEBUG(dbgs() << "*** Fixing inconsistent live interval! ***\n"); const_cast(LIS) .shrinkToUses(const_cast(CurLI)); From nadav.rotem at intel.com Tue May 10 12:44:10 2011 From: nadav.rotem at intel.com (Rotem, Nadav) Date: Tue, 10 May 2011 20:44:10 +0300 Subject: [llvm-commits] [PATCH] A patch to add vector SHL/SRL/SRA support for x86 In-Reply-To: <4DC93318.6010704@free.fr> References: <6594DDFF12B03D4E89690887C2486994027D601E8B@hasmsx504.ger.corp.intel.com> <4DC93318.6010704@free.fr> Message-ID: <6594DDFF12B03D4E89690887C2486994027D6A1E69@hasmsx504.ger.corp.intel.com> There is no v2i64 sra instruction. I will make the corrections and commit. Thanks. -----Original Message----- From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Duncan Sands Sent: Tuesday, May 10, 2011 15:44 To: llvm-commits at cs.uiuc.edu Subject: Re: [llvm-commits] [PATCH] A patch to add vector SHL/SRL/SRA support for x86 Hi Nadav, > + setOperationAction(ISD::SRA, MVT::v4i32, Custom); > + setOperationAction(ISD::SRA, MVT::v8i16, Custom); so there is no v2i64 arithmetic right shift? > + // Must have SSE2 > + if(! Subtarget->hasSSE2()) return SDValue(); There should be a space between "if" and "(" and no space after "!". This problem occurs also in the SSE 4.1 test. > - if (VT == MVT::v4i32) { > + // Optimize shl/srl with constant shift amount There should be a full stop at the end of the comment. The comment doesn't mention sra but it is handled too. Otherwise it looks OK to me. Ciao, Duncan. _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. From stoklund at 2pi.dk Tue May 10 12:52:59 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 May 2011 17:52:59 -0000 Subject: [llvm-commits] [llvm] r131134 - /llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Message-ID: <20110510175259.34AD22A6C12C@llvm.org> Author: stoklund Date: Tue May 10 12:52:59 2011 New Revision: 131134 URL: http://llvm.org/viewvc/llvm-project?rev=131134&view=rev Log: Downgrade a tablegen warning to an error. Ambiguous sub-register index compositions are OK as long as the backend writer knows what he is doing. Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=131134&r1=131133&r2=131134&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Tue May 10 12:52:59 2011 @@ -293,14 +293,13 @@ if (i1d->second == Reg3) { std::pair Ins = Composite.insert(std::make_pair(IdxPair, i1d->first)); - // Conflicting composition? + // Conflicting composition? Emit a warning but allow it. if (!Ins.second && Ins.first->second != i1d->first) { - errs() << "Error: SubRegIndex " << getQualifiedName(Idx1) + errs() << "Warning: SubRegIndex " << getQualifiedName(Idx1) << " and " << getQualifiedName(IdxPair.second) << " compose ambiguously as " << getQualifiedName(Ins.first->second) << " or " << getQualifiedName(i1d->first) << "\n"; - abort(); } } } From daniel at zuster.org Tue May 10 13:01:26 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 May 2011 18:01:26 -0000 Subject: [llvm-commits] [zorg] r131135 - /zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html Message-ID: <20110510180126.C1C9D2A6C12C@llvm.org> Author: ddunbar Date: Tue May 10 13:01:26 2011 New Revision: 131135 URL: http://llvm.org/viewvc/llvm-project?rev=131135&view=rev Log: LNT/simple: Show line breaks in run_info values. Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html?rev=131135&r1=131134&r2=131135&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html Tue May 10 13:01:26 2011 @@ -71,7 +71,7 @@ {% for key,item in run.info|dictsort(true) %} {{key}} - {{item.value}} + {{item.value.replace("\n","
")|safe}} {% endfor %} From daniel at zuster.org Tue May 10 13:01:29 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 May 2011 18:01:29 -0000 Subject: [llvm-commits] [zorg] r131136 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110510180129.646F22A6C12D@llvm.org> Author: ddunbar Date: Tue May 10 13:01:29 2011 New Revision: 131136 URL: http://llvm.org/viewvc/llvm-project?rev=131136&view=rev Log: LNT/nt: Add support for --machine-param and --run-param flags, to allow users to arbitrarily plop key=value pairs into the machine and run info. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=131136&r1=131135&r2=131136&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Tue May 10 13:01:29 2011 @@ -514,9 +514,6 @@ machdep_info['uname'] = capture(["uname","-a"], include_stderr=True).strip() machdep_info['name'] = capture(["uname","-n"], include_stderr=True).strip() - # Create the machine entry. - machine = lnt.testing.Machine(nick, machine_info) - # FIXME: Hack, use better method of getting versions. Ideally, from binaries # so we are more likely to be accurate. if llvm_source_version is not None: @@ -559,10 +556,25 @@ if 'run_order' in run_info: run_info['run_order'] = '%7d' % int(run_info['run_order']) + # Add any user specified parameters. + for target,params in ((machine_info, opts.machine_parameters), + (run_info, opts.run_parameters)): + for entry in params: + if '=' not in entry: + name,value = entry,'' + else: + name,value = entry.split('=', 1) + if name in target: + warning("user parameter %r overwrote existing value: %r" % ( + name, target.get(name))) + print target,name,value + target[name] = value + # Generate the test report. lnt_report_path = os.path.join(basedir, 'report.json') print >>sys.stderr, '%s: generating report: %r' % (timestamp(), lnt_report_path) + machine = lnt.testing.Machine(nick, machine_info) run = lnt.testing.Run(start_time, end_time, info = run_info) report = lnt.testing.Report(machine, run, test_samples) @@ -789,6 +801,14 @@ group.add_option("", "--run-order", dest="run_order", metavar="STR", help="String to use to identify and order this run", action="store", type=str, default=None) + group.add_option("", "--machine-param", dest="machine_parameters", + metavar="NAME=VAL", + help="Add 'NAME' = 'VAL' to the machine parameters", + type=str, action="append", default=[]) + group.add_option("", "--run-param", dest="run_parameters", + metavar="NAME=VAL", + help="Add 'NAME' = 'VAL' to the run parameters", + type=str, action="append", default=[]) parser.add_option_group(group) (opts, args) = parser.parse_args(args) From jason.w.kim.2009 at gmail.com Tue May 10 13:07:25 2011 From: jason.w.kim.2009 at gmail.com (Jason W Kim) Date: Tue, 10 May 2011 18:07:25 -0000 Subject: [llvm-commits] [llvm] r131137 - /llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Message-ID: <20110510180725.451A62A6C12C@llvm.org> Author: jasonwkim Date: Tue May 10 13:07:25 2011 New Revision: 131137 URL: http://llvm.org/viewvc/llvm-project?rev=131137&view=rev Log: First cut at getting debugging support for ARM/MC/ELF/.o DWARF stuff also gets fixed up by ELFARMAsmBackend::ApplyFixup(), but the offset is not guaranteed to be mod 4 == 0 as in text/data. Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=131137&r1=131136&r2=131137&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Tue May 10 13:07:25 2011 @@ -404,7 +404,6 @@ if (!Value) return; // Doesn't change encoding. unsigned Offset = Fixup.getOffset(); - assert(Offset % NumBytes == 0 && "Offset mod NumBytes is nonzero!"); // For each byte of the fragment that the fixup touches, mask in the bits from // the fixup value. The Value has been "split up" into the appropriate From nobled at dreamwidth.org Tue May 10 13:35:11 2011 From: nobled at dreamwidth.org (nobled) Date: Tue, 10 May 2011 14:35:11 -0400 Subject: [llvm-commits] [PATCH] ExecutionEngine: fix ErrorStr handling Message-ID: > Oops, I meant to paste this in the last message: > > When I tried this patch, it causes the test to fail all by itself, > even though the "Engine.get() != NULL" assert doesn't trigger. It > gives this output: > > Error building ExecutionEngine: Unable to find target for this triple > (no targets are registered) > > Does that indicate a bug in the test? > I found the actual bug; the ExecutionEngine code was still setting ErrorStr in the case whenever using the JIT failed, even if the fallback to the interpreter was successful. The attached patch fixes that case, and now the first patch works fine. Okay to commit? >> If EngineBuilder::create() returns NULL, this prints the reason why >> before exiting. >> >> --- >> diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp >> b/unittests/ExecutionEngine/ExecutionEngineTest.cpp >> index 904ee2b..e5daf19 100644 >> --- a/unittests/ExecutionEngine/ExecutionEngineTest.cpp >> +++ b/unittests/ExecutionEngine/ExecutionEngineTest.cpp >> @@ -22,11 +22,14 @@ namespace { >> ?class ExecutionEngineTest : public testing::Test { >> ?protected: >> ? ExecutionEngineTest() >> - ? ?: M(new Module("
", getGlobalContext())), >> - ? ? ?Engine(EngineBuilder(M).create()) { >> + ? ?: M(new Module("
", getGlobalContext())), Error(""), >> + ? ?Engine(EngineBuilder(M).setErrorStr(&Error).create()) { >> ? } >> >> ? virtual void SetUp() { >> + ? ?EXPECT_EQ(Error.empty(), true) >> + ? ? ?<< "Error building ExecutionEngine: " << Error; >> + >> ? ? ASSERT_TRUE(Engine.get() != NULL); >> ? } >> >> @@ -36,6 +39,7 @@ protected: >> ? } >> >> ? Module *const M; >> + ?std::string Error; >> ? const OwningPtr Engine; >> ?}; >> > -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-ExecutionEngine-fix-ErrorStr-handling.patch Type: text/x-patch Size: 1887 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110510/38487d0f/attachment.bin From echristo at apple.com Tue May 10 13:36:16 2011 From: echristo at apple.com (Eric Christopher) Date: Tue, 10 May 2011 18:36:16 -0000 Subject: [llvm-commits] [llvm] r131139 - /llvm/trunk/lib/Target/X86/X86InstrCompiler.td Message-ID: <20110510183616.6EE312A6C12C@llvm.org> Author: echristo Date: Tue May 10 13:36:16 2011 New Revision: 131139 URL: http://llvm.org/viewvc/llvm-project?rev=131139&view=rev Log: Refactor lock versions of binary operators to be a little less cut and paste. Modified: llvm/trunk/lib/Target/X86/X86InstrCompiler.td Modified: llvm/trunk/lib/Target/X86/X86InstrCompiler.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrCompiler.td?rev=131139&r1=131138&r2=131139&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrCompiler.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrCompiler.td Tue May 10 13:36:16 2011 @@ -543,85 +543,95 @@ Requires<[In64BitMode]>, LOCK; -// Optimized codegen when the non-memory output is not used. +// RegOpc corresponds to the mr version of the instruction +// ImmOpc corresponds to the mi version of the instruction +// ImmOpc8 corresponds to the mi8 version of the instruction +// ImmMod corresponds to the instruction format of the mi and mi8 versions +multiclass LOCK_ArithBinOp RegOpc, bits<8> ImmOpc, bits<8> ImmOpc8, + Format ImmMod, string mnemonic> { let Defs = [EFLAGS], mayLoad = 1, mayStore = 1, isCodeGenOnly = 1 in { -def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2), - "lock\n\t" - "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), - "lock\n\t" - "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK; -def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), - "lock\n\t" - "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), - "lock\n\t" - "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2), - "lock\n\t" - "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2), - "lock\n\t" - "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2), - "lock\n\t" - "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_ADD64mi32 : RIi32<0x81, MRM0m, (outs), - (ins i64mem:$dst, i64i32imm :$src2), - "lock\n\t" - "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; - -def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2), - "lock\n\t" - "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK; -def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2), - "lock\n\t" - "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_ADD64mi8 : RIi8<0x83, MRM0m, (outs), - (ins i64mem:$dst, i64i8imm :$src2), - "lock\n\t" - "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; - -def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2), - "lock\n\t" - "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), - "lock\n\t" - "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK; -def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), - "lock\n\t" - "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), - "lock\n\t" - "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; +def #NAME#8mr : I<{RegOpc{7}, RegOpc{6}, RegOpc{5}, RegOpc{4}, + RegOpc{3}, RegOpc{2}, RegOpc{1}, 0 }, + MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2), + !strconcat("lock\n\t", mnemonic, "{b}\t", + "{$src2, $dst|$dst, $src2}"), + []>, LOCK; +def #NAME#16mr : I<{RegOpc{7}, RegOpc{6}, RegOpc{5}, RegOpc{4}, + RegOpc{3}, RegOpc{2}, RegOpc{1}, 1 }, + MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), + !strconcat("lock\n\t", mnemonic, "{w}\t", + "{$src2, $dst|$dst, $src2}"), + []>, OpSize, LOCK; +def #NAME#32mr : I<{RegOpc{7}, RegOpc{6}, RegOpc{5}, RegOpc{4}, + RegOpc{3}, RegOpc{2}, RegOpc{1}, 1 }, + MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), + !strconcat("lock\n\t", mnemonic, "{l}\t", + "{$src2, $dst|$dst, $src2}"), + []>, LOCK; +def #NAME#64mr : RI<{RegOpc{7}, RegOpc{6}, RegOpc{5}, RegOpc{4}, + RegOpc{3}, RegOpc{2}, RegOpc{1}, 1 }, + MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), + !strconcat("lock\n\t", mnemonic, "{q}\t", + "{$src2, $dst|$dst, $src2}"), + []>, LOCK; + +def #NAME#8mi : Ii8<{ImmOpc{7}, ImmOpc{6}, ImmOpc{5}, ImmOpc{4}, + ImmOpc{3}, ImmOpc{2}, ImmOpc{1}, 0 }, + ImmMod, (outs), (ins i8mem :$dst, i8imm :$src2), + !strconcat("lock\n\t", mnemonic, "{b}\t", + "{$src2, $dst|$dst, $src2}"), + []>, LOCK; + +def #NAME#16mi : Ii16<{ImmOpc{7}, ImmOpc{6}, ImmOpc{5}, ImmOpc{4}, + ImmOpc{3}, ImmOpc{2}, ImmOpc{1}, 1 }, + ImmMod, (outs), (ins i16mem :$dst, i16imm :$src2), + !strconcat("lock\n\t", mnemonic, "{w}\t", + "{$src2, $dst|$dst, $src2}"), + []>, LOCK; + +def #NAME#32mi : Ii32<{ImmOpc{7}, ImmOpc{6}, ImmOpc{5}, ImmOpc{4}, + ImmOpc{3}, ImmOpc{2}, ImmOpc{1}, 1 }, + ImmMod, (outs), (ins i32mem :$dst, i32imm :$src2), + !strconcat("lock\n\t", mnemonic, "{l}\t", + "{$src2, $dst|$dst, $src2}"), + []>, LOCK; + +def #NAME#64mi32 : RIi32<{ImmOpc{7}, ImmOpc{6}, ImmOpc{5}, ImmOpc{4}, + ImmOpc{3}, ImmOpc{2}, ImmOpc{1}, 1 }, + ImmMod, (outs), (ins i64mem :$dst, i64i32imm :$src2), + !strconcat("lock\n\t", mnemonic, "{q}\t", + "{$src2, $dst|$dst, $src2}"), + []>, LOCK; + +def #NAME#16mi8 : Ii8<{ImmOpc8{7}, ImmOpc8{6}, ImmOpc8{5}, ImmOpc8{4}, + ImmOpc8{3}, ImmOpc8{2}, ImmOpc8{1}, 1 }, + ImmMod, (outs), (ins i16mem :$dst, i16i8imm :$src2), + !strconcat("lock\n\t", mnemonic, "{w}\t", + "{$src2, $dst|$dst, $src2}"), + []>, LOCK; +def #NAME#32mi8 : Ii8<{ImmOpc8{7}, ImmOpc8{6}, ImmOpc8{5}, ImmOpc8{4}, + ImmOpc8{3}, ImmOpc8{2}, ImmOpc8{1}, 1 }, + ImmMod, (outs), (ins i32mem :$dst, i32i8imm :$src2), + !strconcat("lock\n\t", mnemonic, "{l}\t", + "{$src2, $dst|$dst, $src2}"), + []>, LOCK; +def #NAME#64mi8 : RIi8<{ImmOpc8{7}, ImmOpc8{6}, ImmOpc8{5}, ImmOpc8{4}, + ImmOpc8{3}, ImmOpc8{2}, ImmOpc8{1}, 1 }, + ImmMod, (outs), (ins i64mem :$dst, i64i8imm :$src2), + !strconcat("lock\n\t", mnemonic, "{q}\t", + "{$src2, $dst|$dst, $src2}"), + []>, LOCK; +} -def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2), - "lock\n\t" - "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2), - "lock\n\t" - "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK; -def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2), - "lock\n\t" - "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_SUB64mi32 : RIi32<0x81, MRM5m, (outs), - (ins i64mem:$dst, i64i32imm:$src2), - "lock\n\t" - "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; +} +defm LOCK_ADD : LOCK_ArithBinOp<0x00, 0x80, 0x83, MRM0m, "add">; +defm LOCK_SUB : LOCK_ArithBinOp<0x28, 0x80, 0x83, MRM5m, "sub">; -def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2), - "lock\n\t" - "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK; -def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2), - "lock\n\t" - "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; -def LOCK_SUB64mi8 : RIi8<0x83, MRM5m, (outs), - (ins i64mem:$dst, i64i8imm :$src2), - "lock\n\t" - "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; +// Optimized codegen when the non-memory output is not used. +let Defs = [EFLAGS], mayLoad = 1, mayStore = 1, isCodeGenOnly = 1 in { def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "lock\n\t" From rafael.espindola at gmail.com Tue May 10 13:39:09 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 18:39:09 -0000 Subject: [llvm-commits] [llvm] r131140 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfCFIException.cpp lib/CodeGen/AsmPrinter/DwarfException.h test/DebugInfo/debug_frame.ll Message-ID: <20110510183909.B59FF2A6C12C@llvm.org> Author: rafael Date: Tue May 10 13:39:09 2011 New Revision: 131140 URL: http://llvm.org/viewvc/llvm-project?rev=131140&view=rev Log: Use .cfi_sections to put the unwind info in .debug_frame when possible. With this clang will use .debug_frame in, for example, clang -g -c -m32 test.c This matches gcc's behaviour. It looks like .debug_frame is a bit bigger than .eh_frame, but has the big advantage of not being allocated. Added: llvm/trunk/test/DebugInfo/debug_frame.ll Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=131140&r1=131139&r2=131140&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Tue May 10 13:39:09 2011 @@ -185,7 +185,12 @@ void emitPrologLabel(const MachineInstr &MI); - bool needsCFIMoves(); + enum CFIMoveType { + CFI_M_None, + CFI_M_EH, + CFI_M_Debug + }; + CFIMoveType needsCFIMoves(); /// EmitConstantPool - Print to the current output stream assembly /// representations of the constants in the constant pool MCP. This is Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=131140&r1=131139&r2=131140&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue May 10 13:39:09 2011 @@ -592,17 +592,17 @@ return true; } -bool AsmPrinter::needsCFIMoves() { +AsmPrinter::CFIMoveType AsmPrinter::needsCFIMoves() { if (UnwindTablesMandatory) - return true; + return CFI_M_EH; - if (MMI->hasDebugInfo()) - return true; + if (!MF->getFunction()->doesNotThrow()) + return CFI_M_EH; - if (MF->getFunction()->doesNotThrow()) - return false; + if (MMI->hasDebugInfo()) + return CFI_M_Debug; - return true; + return CFI_M_None; } void AsmPrinter::emitPrologLabel(const MachineInstr &MI) { @@ -611,7 +611,7 @@ if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) return; - if (!needsCFIMoves()) + if (needsCFIMoves() == CFI_M_None) return; MachineModuleInfo &MMI = MF->getMMI(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=131140&r1=131139&r2=131140&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Tue May 10 13:39:09 2011 @@ -49,6 +49,9 @@ /// EndModule - Emit all exception information that should come after the /// content. void DwarfCFIException::EndModule() { + if (moveTypeModule == AsmPrinter::CFI_M_Debug) + Asm->OutStreamer.EmitCFISections(false, true); + if (!Asm->MAI->isExceptionHandlingDwarf()) return; @@ -87,7 +90,13 @@ bool hasLandingPads = !MMI->getLandingPads().empty(); // See if we need frame move info. - shouldEmitMoves = Asm->needsCFIMoves(); + AsmPrinter::CFIMoveType MoveType = Asm->needsCFIMoves(); + if (MoveType == AsmPrinter::CFI_M_EH || + (MoveType == AsmPrinter::CFI_M_Debug && + moveTypeModule == AsmPrinter::CFI_M_None)) + moveTypeModule = MoveType; + + shouldEmitMoves = MoveType != AsmPrinter::CFI_M_None; const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); unsigned PerEncoding = TLOF.getPersonalityEncoding(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h?rev=131140&r1=131139&r2=131140&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Tue May 10 13:39:09 2011 @@ -15,6 +15,7 @@ #define LLVM_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H #include "llvm/ADT/DenseMap.h" +#include "llvm/CodeGen/AsmPrinter.h" #include namespace llvm { @@ -152,6 +153,8 @@ /// should be emitted. bool shouldEmitMoves; + AsmPrinter::CFIMoveType moveTypeModule; + public: //===--------------------------------------------------------------------===// // Main entry points. Added: llvm/trunk/test/DebugInfo/debug_frame.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debug_frame.ll?rev=131140&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/debug_frame.ll (added) +++ llvm/trunk/test/DebugInfo/debug_frame.ll Tue May 10 13:39:09 2011 @@ -0,0 +1,18 @@ +; RUN: llc %s -o - | FileCheck %s + +; Test that we produce a .debug_frame, not an .eh_frame + +; CHECK: .cfi_sections .debug_frame + +define void @f() nounwind { +entry: + ret void +} + +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"f", metadata !"f", metadata !"", metadata !1, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, void ()* @f, null, null} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/llvm/build", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/llvm/build", metadata !"clang version 3.0 ()", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{null} From rafael.espindola at gmail.com Tue May 10 14:51:53 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 19:51:53 -0000 Subject: [llvm-commits] [llvm] r131146 - in /llvm/trunk: lib/MC/MCDwarf.cpp test/DebugInfo/eh_symbol.ll Message-ID: <20110510195153.8C9B92A6C12C@llvm.org> Author: rafael Date: Tue May 10 14:51:53 2011 New Revision: 131146 URL: http://llvm.org/viewvc/llvm-project?rev=131146&view=rev Log: The EH symbols are only needed in eh_frame, not debug_frame. Added: llvm/trunk/test/DebugInfo/eh_symbol.ll Modified: llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=131146&r1=131145&r2=131146&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Tue May 10 14:51:53 2011 @@ -633,7 +633,7 @@ const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); MCSymbol *sectionStart; - if (asmInfo.isFunctionEHFrameSymbolPrivate()) + if (asmInfo.isFunctionEHFrameSymbolPrivate() || !IsEH) sectionStart = context.CreateTempSymbol(); else sectionStart = context.GetOrCreateSymbol(Twine("EH_frame") + Twine(CIENum)); @@ -739,7 +739,7 @@ MCSymbol *fdeEnd = context.CreateTempSymbol(); const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); - if (!asmInfo.isFunctionEHFrameSymbolPrivate()) { + if (!asmInfo.isFunctionEHFrameSymbolPrivate() && IsEH) { MCSymbol *EHSym = context.GetOrCreateSymbol( frame.Function->getName() + Twine(".eh")); streamer.EmitEHSymAttributes(frame.Function, EHSym); Added: llvm/trunk/test/DebugInfo/eh_symbol.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/eh_symbol.ll?rev=131146&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/eh_symbol.ll (added) +++ llvm/trunk/test/DebugInfo/eh_symbol.ll Tue May 10 14:51:53 2011 @@ -0,0 +1,18 @@ +; RUN: llc -mtriple=i386-apple-macosx -disable-cfi %s -o - | FileCheck %s + +; test that we don't produce foo.eh symbols is a debug_frame section. +; CHECK-NOT: .globl _f.eh + +define i32 @f() nounwind readnone optsize { +entry: + ret i32 42 +} + +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"f", metadata !"f", metadata !"", metadata !1, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i32 ()* @f, null, null} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/tmpfs/build", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/tmpfs/build", metadata !"clang version 3.0 ()", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] From gohman at apple.com Tue May 10 15:27:02 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 10 May 2011 13:27:02 -0700 Subject: [llvm-commits] [llvm] r131088 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp In-Reply-To: References: <20110509184410.1238D2A6C12C@llvm.org> Message-ID: <9210C882-2CA3-4C8F-A857-C34811C20655@apple.com> On May 9, 2011, at 11:52 AM, Eli Friedman wrote: > On Mon, May 9, 2011 at 11:44 AM, Dan Gohman wrote: >> >> /// BlockDispositions - Memoized computeBlockDisposition results. >> - std::map> + DenseMap> std::map > BlockDispositions; > > Somehow a DenseMap of std::map doesn't strike me as good for > performance; copying an std::map isn't cheap. True, which I believe why this change wasn't made earlier. But it also doesn't happen very often. I haven't seen slowdowns in a variety of tests. Dan From rafael.espindola at gmail.com Tue May 10 15:35:06 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 20:35:06 -0000 Subject: [llvm-commits] [llvm] r131148 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoDarwin.cpp Message-ID: <20110510203506.235212A6C12C@llvm.org> Author: rafael Date: Tue May 10 15:35:05 2011 New Revision: 131148 URL: http://llvm.org/viewvc/llvm-project?rev=131148&view=rev Log: Rename DwarfRequiresRelocationForStmtList to DwarfRequiresRelocationForSectionOffset as this is not specific to StmtList. Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/MC/MCAsmInfo.cpp llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=131148&r1=131147&r2=131148&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Tue May 10 15:35:05 2011 @@ -276,9 +276,9 @@ /// DwarfSectionOffsetDirective - Special section offset directive. const char* DwarfSectionOffsetDirective; // Defaults to NULL - /// DwarfRequiresRelocationForStmtList - True if DW_AT_stmt_list needs - /// a relocation to the correct offset. - bool DwarfRequiresRelocationForStmtList; // Defaults to true; + /// DwarfRequiresRelocationForSectionOffset - True if we need to produce a + // relocation when we want a section offset in dwarf. + bool DwarfRequiresRelocationForSectionOffset; // Defaults to true; // DwarfUsesLabelOffsetDifference - True if Dwarf2 output can // use EmitLabelOffsetDifference. @@ -468,8 +468,8 @@ const char *getDwarfSectionOffsetDirective() const { return DwarfSectionOffsetDirective; } - bool doesDwarfRequireRelocationForStmtList() const { - return DwarfRequiresRelocationForStmtList; + bool doesDwarfRequireRelocationForSectionOffset() const { + return DwarfRequiresRelocationForSectionOffset; } bool doesDwarfUsesLabelOffsetForRanges() const { return DwarfUsesLabelOffsetForRanges; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=131148&r1=131147&r2=131148&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue May 10 15:35:05 2011 @@ -860,7 +860,7 @@ NewCU->addUInt(Die, dwarf::DW_AT_entry_pc, dwarf::DW_FORM_addr, 0); // DW_AT_stmt_list is a offset of line number information for this // compile unit in debug_line section. - if(Asm->MAI->doesDwarfRequireRelocationForStmtList()) + if(Asm->MAI->doesDwarfRequireRelocationForSectionOffset()) NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, Asm->GetTempSymbol("section_line")); else Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=131148&r1=131147&r2=131148&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Tue May 10 15:35:05 2011 @@ -75,7 +75,7 @@ SupportsDebugInformation = false; ExceptionsType = ExceptionHandling::None; DwarfUsesInlineInfoSection = false; - DwarfRequiresRelocationForStmtList = true; + DwarfRequiresRelocationForSectionOffset = true; DwarfSectionOffsetDirective = 0; DwarfUsesLabelOffsetForRanges = true; HasMicrosoftFastStdCallMangling = false; Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=131148&r1=131147&r2=131148&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Tue May 10 15:35:05 2011 @@ -56,6 +56,6 @@ HasNoDeadStrip = true; HasSymbolResolver = true; - DwarfRequiresRelocationForStmtList = false; + DwarfRequiresRelocationForSectionOffset = false; DwarfUsesLabelOffsetForRanges = false; } From drb at dneg.com Tue May 10 09:52:11 2011 From: drb at dneg.com (Dan Bailey) Date: Tue, 10 May 2011 15:52:11 +0100 Subject: [llvm-commits] [llvm] r130356 - /llvm/trunk/lib/Target/PTX/PTXInstrInfo.td In-Reply-To: <20110428001954.B0DD02A6C134@llvm.org> References: <20110428001954.B0DD02A6C134@llvm.org> Message-ID: <4DC9511B.8070908@dneg.com> Justin, Sorry for not spotting this earlier, bitwise.ll seems to have been added, but I think these three tests were missed off their various commit - cvt.ll, fneg.ll, selp.ll I've attached them again here as a patch, could we get them added in please? Thanks, Dan Justin Holewinski wrote: > Author: jholewinski > Date: Wed Apr 27 19:19:54 2011 > New Revision: 130356 > > URL: http://llvm.org/viewvc/llvm-project?rev=130356&view=rev > Log: > PTX: mov fix and rounding correction for cvt > > - fix typo in MOV > - correct fp rounding on CVT > - new cvt.ll test > > Patch by Dan Bailey > > Modified: > llvm/trunk/lib/Target/PTX/PTXInstrInfo.td > > Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=130356&r1=130355&r2=130356&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) > +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Wed Apr 27 19:19:54 2011 > @@ -740,7 +740,7 @@ > def MOVU32ri > : InstPTX<(outs RRegu32:$d), (ins i32imm:$a), "mov.u32\t$d, $a", > [(set RRegu32:$d, imm:$a)]>; > - def MOVU164ri > + def MOVU64ri > : InstPTX<(outs RRegu64:$d), (ins i64imm:$a), "mov.u64\t$d, $a", > [(set RRegu64:$d, imm:$a)]>; > def MOVF32ri > @@ -802,11 +802,11 @@ > [(set Preds:$d, (trunc RRegu64:$a))]>; > > def CVT_pred_f32 > - : InstPTX<(outs Preds:$d), (ins RRegf32:$a), "cvt.pred.f32\t$d, $a", > + : InstPTX<(outs Preds:$d), (ins RRegf32:$a), "cvt.rni.pred.f32\t$d, $a", > [(set Preds:$d, (fp_to_uint RRegf32:$a))]>; > > def CVT_pred_f64 > - : InstPTX<(outs Preds:$d), (ins RRegf64:$a), "cvt.pred.f64\t$d, $a", > + : InstPTX<(outs Preds:$d), (ins RRegf64:$a), "cvt.rni.pred.f64\t$d, $a", > [(set Preds:$d, (fp_to_uint RRegf64:$a))]>; > > // Conversion to u16 > @@ -824,11 +824,11 @@ > [(set RRegu16:$d, (trunc RRegu64:$a))]>; > > def CVT_u16_f32 > - : InstPTX<(outs RRegu16:$d), (ins RRegf32:$a), "cvt.u16.f32\t$d, $a", > + : InstPTX<(outs RRegu16:$d), (ins RRegf32:$a), "cvt.rni.u16.f32\t$d, $a", > [(set RRegu16:$d, (fp_to_uint RRegf32:$a))]>; > > def CVT_u16_f64 > - : InstPTX<(outs RRegu16:$d), (ins RRegf64:$a), "cvt.u16.f64\t$d, $a", > + : InstPTX<(outs RRegu16:$d), (ins RRegf64:$a), "cvt.rni.u16.f64\t$d, $a", > [(set RRegu16:$d, (fp_to_uint RRegf64:$a))]>; > > // Conversion to u32 > @@ -846,11 +846,11 @@ > [(set RRegu32:$d, (trunc RRegu64:$a))]>; > > def CVT_u32_f32 > - : InstPTX<(outs RRegu32:$d), (ins RRegf32:$a), "cvt.u32.f32\t$d, $a", > + : InstPTX<(outs RRegu32:$d), (ins RRegf32:$a), "cvt.rni.u32.f32\t$d, $a", > [(set RRegu32:$d, (fp_to_uint RRegf32:$a))]>; > > def CVT_u32_f64 > - : InstPTX<(outs RRegu32:$d), (ins RRegf64:$a), "cvt.u32.f64\t$d, $a", > + : InstPTX<(outs RRegu32:$d), (ins RRegf64:$a), "cvt.rni.u32.f64\t$d, $a", > [(set RRegu32:$d, (fp_to_uint RRegf64:$a))]>; > > // Conversion to u64 > @@ -868,51 +868,51 @@ > [(set RRegu64:$d, (zext RRegu32:$a))]>; > > def CVT_u64_f32 > - : InstPTX<(outs RRegu64:$d), (ins RRegf32:$a), "cvt.u64.f32\t$d, $a", > + : InstPTX<(outs RRegu64:$d), (ins RRegf32:$a), "cvt.rni.u64.f32\t$d, $a", > [(set RRegu64:$d, (fp_to_uint RRegf32:$a))]>; > > def CVT_u64_f64 > - : InstPTX<(outs RRegu64:$d), (ins RRegf64:$a), "cvt.u64.f32\t$d, $a", > + : InstPTX<(outs RRegu64:$d), (ins RRegf64:$a), "cvt.rni.u64.f64\t$d, $a", > [(set RRegu64:$d, (fp_to_uint RRegf64:$a))]>; > > // Conversion to f32 > > def CVT_f32_pred > - : InstPTX<(outs RRegf32:$d), (ins Preds:$a), "cvt.f32.pred\t$d, $a", > + : InstPTX<(outs RRegf32:$d), (ins Preds:$a), "cvt.rn.f32.pred\t$d, $a", > [(set RRegf32:$d, (uint_to_fp Preds:$a))]>; > > def CVT_f32_u16 > - : InstPTX<(outs RRegf32:$d), (ins RRegu16:$a), "cvt.f32.u16\t$d, $a", > + : InstPTX<(outs RRegf32:$d), (ins RRegu16:$a), "cvt.rn.f32.u16\t$d, $a", > [(set RRegf32:$d, (uint_to_fp RRegu16:$a))]>; > > def CVT_f32_u32 > - : InstPTX<(outs RRegf32:$d), (ins RRegu32:$a), "cvt.f32.u32\t$d, $a", > + : InstPTX<(outs RRegf32:$d), (ins RRegu32:$a), "cvt.rn.f32.u32\t$d, $a", > [(set RRegf32:$d, (uint_to_fp RRegu32:$a))]>; > > def CVT_f32_u64 > - : InstPTX<(outs RRegf32:$d), (ins RRegu64:$a), "cvt.f32.u64\t$d, $a", > + : InstPTX<(outs RRegf32:$d), (ins RRegu64:$a), "cvt.rn.f32.u64\t$d, $a", > [(set RRegf32:$d, (uint_to_fp RRegu64:$a))]>; > > def CVT_f32_f64 > - : InstPTX<(outs RRegf32:$d), (ins RRegf64:$a), "cvt.f32.f64\t$d, $a", > + : InstPTX<(outs RRegf32:$d), (ins RRegf64:$a), "cvt.rn.f32.f64\t$d, $a", > [(set RRegf32:$d, (fround RRegf64:$a))]>; > > // Conversion to f64 > > def CVT_f64_pred > - : InstPTX<(outs RRegf64:$d), (ins Preds:$a), "cvt.f64.pred\t$d, $a", > + : InstPTX<(outs RRegf64:$d), (ins Preds:$a), "cvt.rn.f64.pred\t$d, $a", > [(set RRegf64:$d, (uint_to_fp Preds:$a))]>; > > def CVT_f64_u16 > - : InstPTX<(outs RRegf64:$d), (ins RRegu16:$a), "cvt.f64.u16\t$d, $a", > + : InstPTX<(outs RRegf64:$d), (ins RRegu16:$a), "cvt.rn.f64.u16\t$d, $a", > [(set RRegf64:$d, (uint_to_fp RRegu16:$a))]>; > > def CVT_f64_u32 > - : InstPTX<(outs RRegf64:$d), (ins RRegu32:$a), "cvt.f64.u32\t$d, $a", > + : InstPTX<(outs RRegf64:$d), (ins RRegu32:$a), "cvt.rn.f64.u32\t$d, $a", > [(set RRegf64:$d, (uint_to_fp RRegu32:$a))]>; > > def CVT_f64_u64 > - : InstPTX<(outs RRegf64:$d), (ins RRegu64:$a), "cvt.f64.u64\t$d, $a", > + : InstPTX<(outs RRegf64:$d), (ins RRegu64:$a), "cvt.rn.f64.u64\t$d, $a", > [(set RRegf64:$d, (uint_to_fp RRegu64:$a))]>; > > def CVT_f64_f32 > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: llvm_patch_drb_100511_1600_tests Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110510/8ac41d54/attachment.pl From theraven at theravensnest.org Tue May 10 12:23:56 2011 From: theraven at theravensnest.org (David Chisnall) Date: Tue, 10 May 2011 18:23:56 +0100 Subject: [llvm-commits] Review Request: Allow Plugins to Modify Standard Pass List Message-ID: Hello the people, This patch makes it possible for plugins to register new passes that are inserted (at a specified position) in any of the default lists of passes. It's a fairly major change to some widely-used functionality, so I'd like it to be carefully reviewed before I commit it. David P.S. Currently it only allows passes to be added, but it would be a fairly trivial modification to allow them to be replaced / removed. -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm.diff Type: application/octet-stream Size: 38435 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110510/73a5445a/attachment-0001.obj From rafael.espindola at gmail.com Tue May 10 15:59:42 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 20:59:42 -0000 Subject: [llvm-commits] [llvm] r131149 - in /llvm/trunk: lib/MC/MCDwarf.cpp test/MC/MachO/debug_frame.s Message-ID: <20110510205944.09EBA2A6C12C@llvm.org> Author: rafael Date: Tue May 10 15:59:42 2011 New Revision: 131149 URL: http://llvm.org/viewvc/llvm-project?rev=131149&view=rev Log: On MachO, unlike ELF, there should be no relocation to produce the CIE pointer. Added: llvm/trunk/test/MC/MachO/debug_frame.s Modified: llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=131149&r1=131148&r2=131149&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Tue May 10 15:59:42 2011 @@ -502,11 +502,12 @@ int CIENum; bool UsingCFI; bool IsEH; + const MCSymbol *SectionStart; public: - FrameEmitterImpl(bool usingCFI, bool isEH) : CFAOffset(0), CIENum(0), - UsingCFI(usingCFI), - IsEH(isEH) { + FrameEmitterImpl(bool usingCFI, bool isEH, const MCSymbol *sectionStart) : + CFAOffset(0), CIENum(0), UsingCFI(usingCFI), IsEH(isEH), + SectionStart(sectionStart) { } const MCSymbol &EmitCIE(MCStreamer &streamer, @@ -737,9 +738,9 @@ MCContext &context = streamer.getContext(); MCSymbol *fdeStart = context.CreateTempSymbol(); MCSymbol *fdeEnd = context.CreateTempSymbol(); - const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); + const TargetAsmInfo &TAsmInfo = context.getTargetAsmInfo(); - if (!asmInfo.isFunctionEHFrameSymbolPrivate() && IsEH) { + if (!TAsmInfo.isFunctionEHFrameSymbolPrivate() && IsEH) { MCSymbol *EHSym = context.GetOrCreateSymbol( frame.Function->getName() + Twine(".eh")); streamer.EmitEHSymAttributes(frame.Function, EHSym); @@ -751,15 +752,21 @@ streamer.EmitAbsValue(Length, 4); streamer.EmitLabel(fdeStart); + // CIE Pointer + const MCAsmInfo &asmInfo = context.getAsmInfo(); if (IsEH) { const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart, 0); streamer.EmitAbsValue(offset, 4); + } else if (!asmInfo.doesDwarfRequireRelocationForSectionOffset()) { + const MCExpr *offset = MakeStartMinusEndExpr(streamer, *SectionStart, + cieStart, 0); + streamer.EmitAbsValue(offset, 4); } else { streamer.EmitSymbolValue(&cieStart, 4); } - unsigned fdeEncoding = asmInfo.getFDEEncoding(UsingCFI); + unsigned fdeEncoding = TAsmInfo.getFDEEncoding(UsingCFI); unsigned size = getSizeForEncoding(streamer, fdeEncoding); // PC Begin @@ -840,15 +847,17 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &streamer, bool usingCFI, bool isEH) { - const MCContext &context = streamer.getContext(); + MCContext &context = streamer.getContext(); const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); const MCSection §ion = isEH ? *asmInfo.getEHFrameSection() : *asmInfo.getDwarfFrameSection(); streamer.SwitchSection(§ion); + MCSymbol *SectionStart = context.CreateTempSymbol(); + streamer.EmitLabel(SectionStart); MCSymbol *fdeEnd = NULL; DenseMap CIEStarts; - FrameEmitterImpl Emitter(usingCFI, isEH); + FrameEmitterImpl Emitter(usingCFI, isEH, SectionStart); const MCSymbol *DummyDebugKey = NULL; for (unsigned i = 0, n = streamer.getNumFrameInfos(); i < n; ++i) { Added: llvm/trunk/test/MC/MachO/debug_frame.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/debug_frame.s?rev=131149&view=auto ============================================================================== --- llvm/trunk/test/MC/MachO/debug_frame.s (added) +++ llvm/trunk/test/MC/MachO/debug_frame.s Tue May 10 15:59:42 2011 @@ -0,0 +1,38 @@ +// RUN: llvm-mc -triple i386-apple-darwin %s -filetype=obj -o - | macho-dump | FileCheck %s + +// Check that we don't produce a relocation for the CIE pointer and therefore +// we have only one relocation in __debug_frame. + + .section __TEXT,__text,regular,pure_instructions + .globl _f + .align 4, 0x90 +_f: ## @f +Ltmp0: + .cfi_startproc +## BB#0: ## %entry + movl $42, %eax + ret +Ltmp1: + .cfi_endproc +Leh_func_end0: + + .cfi_sections .debug_frame +Ltext_end: + +// CHECK: (('section_name', '__debug_frame\x00\x00\x00') +// CHECK-NEXT: ('segment_name', '__DWARF\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('address', 8) +// CHECK-NEXT: ('size', 36) +// CHECK-NEXT: ('offset', 332) +// CHECK-NEXT: ('alignment', 2) +// CHECK-NEXT: ('reloc_offset', 368) +// CHECK-NEXT: ('num_reloc', 1) +// CHECK-NEXT: ('flags', 0x2000000) +// CHECK-NEXT: ('reserved1', 0) +// CHECK-NEXT: ('reserved2', 0) +// CHECK-NEXT: ), +// CHECK-NEXT: ('_relocations', [ +// CHECK-NEXT: # Relocation 0 +// CHECK-NEXT: (('word-0', 0x1c), +// CHECK-NEXT: ('word-1', 0x4000001)), +// CHECK-NEXT: ]) From aggarwa4 at illinois.edu Tue May 10 16:04:25 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 10 May 2011 21:04:25 -0000 Subject: [llvm-commits] [poolalloc] r131150 - /poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Message-ID: <20110510210425.923352A6C12C@llvm.org> Author: aggarwa4 Date: Tue May 10 16:04:25 2011 New Revision: 131150 URL: http://llvm.org/viewvc/llvm-project?rev=131150&view=rev Log: Updated the mapping from address to metadata address. Fixed mmap does not seem to be working for this size, so use a table approach. Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=131150&r1=131149&r2=131150&view=diff ============================================================================== --- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original) +++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Tue May 10 16:04:25 2011 @@ -16,19 +16,22 @@ #endif /* defined(MAP_ANON) && !defined(MAP_ANONYMOUS) */ uint8_t *shadow_begin; +uint8_t *shadow_end; uintptr_t maskAddress(void *ptr) { uintptr_t p = (uintptr_t)ptr; + uintptr_t res = (uintptr_t)ptr; - if ((p & 0x600000000000) == 0x600000000000) { - return (p & 0x3FFFFFFFFFFF); - } else if ((p | 0x1FFFFFFFFFFF) == 0x1FFFFFFFFFFF) { - return p; + if (p < (uintptr_t)shadow_begin) { + res = p; + } else if (p >= (uintptr_t)shadow_end) { + res = (p - (uintptr_t)SIZE); } else { fprintf(stderr, "Address out of range!\n"); fflush(stderr); assert(0 && "MAP_FAILED"); } + return res; } /** @@ -42,6 +45,7 @@ fflush(stderr); assert(0 && "MAP_FAILED"); } + shadow_end = (uint8_t*)((uintptr_t)shadow_begin + (uintptr_t)SIZE); } /** From rafael.espindola at gmail.com Tue May 10 16:04:45 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 21:04:45 -0000 Subject: [llvm-commits] [llvm] r131151 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/CMakeLists.txt lib/CodeGen/AsmPrinter/DwarfException.h lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp test/CodeGen/ARM/debug-info-sreg2.ll Message-ID: <20110510210445.83D962A6C12C@llvm.org> Author: rafael Date: Tue May 10 16:04:45 2011 New Revision: 131151 URL: http://llvm.org/viewvc/llvm-project?rev=131151&view=rev Log: Produce a __debug_frame section on darwin ARM when appropriate. Removed: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=131151&r1=131150&r2=131151&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue May 10 16:04:45 2011 @@ -193,8 +193,6 @@ case ExceptionHandling::None: return false; case ExceptionHandling::SjLj: - DE = new DwarfSjLjException(this); - return false; case ExceptionHandling::DwarfCFI: DE = new DwarfCFIException(this); return false; @@ -593,11 +591,13 @@ } AsmPrinter::CFIMoveType AsmPrinter::needsCFIMoves() { - if (UnwindTablesMandatory) - return CFI_M_EH; + if (MAI->getExceptionHandlingType() == ExceptionHandling::DwarfCFI) { + if (UnwindTablesMandatory) + return CFI_M_EH; - if (!MF->getFunction()->doesNotThrow()) - return CFI_M_EH; + if (!MF->getFunction()->doesNotThrow()) + return CFI_M_EH; + } if (MMI->hasDebugInfo()) return CFI_M_Debug; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt?rev=131151&r1=131150&r2=131151&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt Tue May 10 16:04:45 2011 @@ -8,7 +8,6 @@ DwarfCompileUnit.cpp DwarfDebug.cpp DwarfException.cpp - DwarfSjLjException.cpp OcamlGCPrinter.cpp ) Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h?rev=131151&r1=131150&r2=131151&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Tue May 10 16:04:45 2011 @@ -174,26 +174,6 @@ virtual void EndFunction(); }; -class DwarfSjLjException : public DwarfException { -public: - //===--------------------------------------------------------------------===// - // Main entry points. - // - DwarfSjLjException(AsmPrinter *A); - virtual ~DwarfSjLjException(); - - /// EndModule - Emit all exception information that should come after the - /// content. - virtual void EndModule(); - - /// BeginFunction - Gather pre-function exception information. Assumes being - /// emitted immediately after the function entry point. - virtual void BeginFunction(const MachineFunction *MF); - - /// EndFunction - Gather and emit post-function exception information. - virtual void EndFunction(); -}; - class ARMException : public DwarfException { /// shouldEmitTable - Per-function flag to indicate if EH tables should /// be emitted. Removed: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp?rev=131150&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp (removed) @@ -1,46 +0,0 @@ -//===-- CodeGen/AsmPrinter/DwarfSjLjException.cpp - Dwarf Exception Impl --==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file is a simple implementation of DwarfException that just produces -// the exception table for use with SjLj. -// -//===----------------------------------------------------------------------===// - -#include "DwarfException.h" -#include "llvm/CodeGen/MachineLocation.h" -#include "llvm/CodeGen/MachineModuleInfo.h" -using namespace llvm; - -DwarfSjLjException::DwarfSjLjException(AsmPrinter *A) : DwarfException(A) { -} - -DwarfSjLjException::~DwarfSjLjException() {} - -/// EndModule - Emit all exception information that should come after the -/// content. -void DwarfSjLjException::EndModule() { -} - -/// BeginFunction - Gather pre-function exception information. Assumes it's -/// being emitted immediately after the function entry point. -void DwarfSjLjException::BeginFunction(const MachineFunction *MF) { -} - -/// EndFunction - Gather and emit post-function exception information. -/// -void DwarfSjLjException::EndFunction() { - // Record if this personality index uses a landing pad. - bool HasLandingPad = !MMI->getLandingPads().empty(); - - // Map all labels and get rid of any dead landing pads. - MMI->TidyLandingPads(); - - if (HasLandingPad) - EmitExceptionTable(); -} Modified: llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll?rev=131151&r1=131150&r2=131151&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll (original) +++ llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll Tue May 10 16:04:45 2011 @@ -4,8 +4,8 @@ target triple = "thumbv7-apple-macosx10.6.7" ;CHECK: Ldebug_loc0: -;CHECK-NEXT: .long Ltmp0 -;CHECK-NEXT: .long Ltmp2 +;CHECK-NEXT: .long Ltmp1 +;CHECK-NEXT: .long Ltmp3 ;CHECK-NEXT: .short 6 @ Loc expr size ;CHECK-NEXT: .byte 144 @ DW_OP_regx for S register From stuart at apple.com Tue May 10 16:20:03 2011 From: stuart at apple.com (Stuart Hastings) Date: Tue, 10 May 2011 21:20:03 -0000 Subject: [llvm-commits] [llvm] r131152 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <20110510212003.5946B2A6C12C@llvm.org> Author: stuart Date: Tue May 10 16:20:03 2011 New Revision: 131152 URL: http://llvm.org/viewvc/llvm-project?rev=131152&view=rev Log: Correctly walk through nested and adjacent CALLSEQ_START nodes. No test case; I've only seen this on a release branch, and I can't get it to reproduce on trunk. rdar://problem/7662569 Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=131152&r1=131151&r2=131152&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue May 10 16:20:03 2011 @@ -324,6 +324,7 @@ case ISD::CALLSEQ_START: if (!nested) return Node; + Node = Node->getOperand(0).getNode(); nested--; break; case ISD::CALLSEQ_END: @@ -331,7 +332,7 @@ break; } } - return 0; + return (Node->getOpcode() == ISD::CALLSEQ_START) ? Node : 0; } /// LegalizeAllNodesNotLeadingTo - Recursively walk the uses of N, looking to From csdavec at swan.ac.uk Tue May 10 16:36:48 2011 From: csdavec at swan.ac.uk (David Chisnall) Date: Tue, 10 May 2011 21:36:48 -0000 Subject: [llvm-commits] [llvm] r131155 - in /llvm/trunk: include/llvm/PassSupport.h include/llvm/Support/StandardPasses.h lib/VMCore/StandardPasses.cpp Message-ID: <20110510213648.3D39B2A6C12C@llvm.org> Author: theraven Date: Tue May 10 16:36:48 2011 New Revision: 131155 URL: http://llvm.org/viewvc/llvm-project?rev=131155&view=rev Log: Add support for plugins add passes to the default set of passes. The standard set of passes used by front ends can now be modified by LLVM plugins, without needing to modify any front ends. Still to do: - Allow replacing / removing passes (infrastructure there, just needs an infrastructure exposed) - Defining sets of passes to be added or removed as a group - Extending the support to allow user-defined groups of optimisations - Allow plugins to be specified for loading automatically (e.g. from plugins.conf or some similar mechanism) Reviewed by Nick Lewycky. Added: llvm/trunk/lib/VMCore/StandardPasses.cpp Modified: llvm/trunk/include/llvm/PassSupport.h llvm/trunk/include/llvm/Support/StandardPasses.h Modified: llvm/trunk/include/llvm/PassSupport.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassSupport.h?rev=131155&r1=131154&r2=131155&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassSupport.h (original) +++ llvm/trunk/include/llvm/PassSupport.h Tue May 10 16:36:48 2011 @@ -29,6 +29,8 @@ namespace llvm { + class PassManagerBase; + //===--------------------------------------------------------------------------- /// PassInfo class - An instance of this class exists for every pass known by /// the system, and can be obtained from a live Pass by calling its @@ -207,6 +209,149 @@ } }; + /// Unique identifiers for the default standard passes. The addresses of + /// these symbols are used to uniquely identify passes from the default list. + namespace DefaultStandardPasses { + extern unsigned char AggressiveDCEID; + extern unsigned char ArgumentPromotionID; + extern unsigned char BasicAliasAnalysisID; + extern unsigned char CFGSimplificationID; + extern unsigned char ConstantMergeID; + extern unsigned char CorrelatedValuePropagationID; + extern unsigned char DeadArgEliminationID; + extern unsigned char DeadStoreEliminationID; + extern unsigned char DeadTypeEliminationID; + extern unsigned char EarlyCSEID; + extern unsigned char FunctionAttrsID; + extern unsigned char FunctionInliningID; + extern unsigned char GVNID; + extern unsigned char GlobalDCEID; + extern unsigned char GlobalOptimizerID; + extern unsigned char GlobalsModRefID; + extern unsigned char IPSCCPID; + extern unsigned char IndVarSimplifyID; + extern unsigned char InlinerPlaceholderID; + extern unsigned char InstructionCombiningID; + extern unsigned char JumpThreadingID; + extern unsigned char LICMID; + extern unsigned char LoopDeletionID; + extern unsigned char LoopIdiomID; + extern unsigned char LoopRotateID; + extern unsigned char LoopUnrollID; + extern unsigned char LoopUnswitchID; + extern unsigned char MemCpyOptID; + extern unsigned char PruneEHID; + extern unsigned char ReassociateID; + extern unsigned char SCCPID; + extern unsigned char ScalarReplAggregatesID; + extern unsigned char SimplifyLibCallsID; + extern unsigned char StripDeadPrototypesID; + extern unsigned char TailCallEliminationID; + extern unsigned char TypeBasedAliasAnalysisID; + } + + +class RegisterStandardPass; +/// RegisterStandardPass - Registers a pass as a member of a standard set. +class StandardPass { + friend class RegisterStandardPassLists; + public: + /// Predefined standard sets of passes + enum StandardSet { + AliasAnalysis, + Function, + Module, + LTO + }; + /// Flags to specify whether a pass should be enabled. Passes registered + /// with the standard sets may specify a minimum optimization level and one + /// or more flags that must be set when constructing the set for the pass to + /// be used. + enum OptimizationFlags { + /// Optimize for size was requested. + OptimizeSize = 1<<0, + /// Allow passes which may make global module changes. + UnitAtATime = 1<<1, + /// UnrollLoops - Allow loop unrolling. + UnrollLoops = 1<<2, + /// Allow library calls to be simplified. + SimplifyLibCalls = 1<<3, + /// Whether the module may have code using exceptions. + HaveExceptions = 1<<4, + // Run an inliner pass as part of this set. + RunInliner = 1<<5 + }; + enum OptimizationFlagComponents { + /// The low bits are used to store the optimization level. When requesting + /// passes, this should store the requested optimisation level. When + /// setting passes, this should set the minimum optimization level at which + /// the pass will run. + OptimizationLevelMask = 0xf, + /// The maximum optimisation level at which the pass is run. + MaxOptimizationLevelMask = 0xf0, + // Flags that must be set + RequiredFlagMask = 0xff00, + // Flags that may not be set. + DisallowedFlagMask = 0xff0000, + MaxOptimizationLevelShift = 4, + RequiredFlagShift = 8, + DisallowedFlagShift = 16 + }; + /// Returns the optimisation level from a set of flags. + static unsigned OptimizationLevel(unsigned flags) { + return flags & OptimizationLevelMask; + } + /// Returns the maximum optimization level for this set of flags + static unsigned MaxOptimizationLevel(unsigned flags) { + return (flags & MaxOptimizationLevelMask) >> 4; + } + /// Constructs a set of flags from the specified minimum and maximum + /// optimisation level + static unsigned OptimizationFlags(unsigned minLevel=0, unsigned maxLevel=0xf, + unsigned requiredFlags=0, + unsigned disallowedFlags=0) { + return ((minLevel & OptimizationLevelMask) | + ((maxLevel<> RequiredFlagShift; + } + /// Returns the flags that must not be set for this to match + static unsigned DisallowedFlags(unsigned flags) { + return (flags & DisallowedFlagMask) >> RequiredFlagShift; + } + /// Register a standard pass in the specified set. If flags is non-zero, + /// then the pass will only be returned when the specified flags are set. + template + class RegisterStandardPass { + RegisterStandardPass(StandardSet set, unsigned char *runBefore=0, + unsigned flags=0, unsigned char *ID=0) { + // Use the pass's ID if one is not specified + RegisterDefaultPass(PassInfo::NormalCtor_t(callDefaultCtor), + ID ? ID : &passName::ID, runBefore, set, flags); + }; + }; + /// Adds the passes from the specified set to a pass manager. + static void AddPassesFromSet(PassManagerBase *PM, + StandardSet Set, + unsigned Flags=0, + bool VerifyEach=false, + Pass *Inliner=0); + private: + /// Registers the default passes. This is set by RegisterStandardPassLists + /// and is called lazily. + static void (*RegisterDefaultPasses)(void); + /// Registers the pass + static void RegisterDefaultPass(PassInfo::NormalCtor_t constructor, + unsigned char *newPass, + unsigned char *oldPass, + StandardSet set, + unsigned flags=0); +}; + /// RegisterAnalysisGroup - Register a Pass as a member of an analysis _group_. /// Analysis groups are used to define an interface (which need not derive from Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=131155&r1=131154&r2=131155&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue May 10 16:36:48 2011 @@ -20,6 +20,7 @@ #define LLVM_SUPPORT_STANDARDPASSES_H #include "llvm/PassManager.h" +#include "llvm/PassSupport.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Transforms/Scalar.h" @@ -27,12 +28,259 @@ namespace llvm { + /// RegisterStandardPassLists solves a circular dependency problem. The + /// default list of passes has to live somewhere. It can't live in the core + /// modules, because these don't link to the libraries that actually define + /// the passes. It's in this header, so that a copy is created in every + /// library that requests the default set, while still allowing plugins to + /// register new passes without requiring them to link anything more than + /// VMCore. + class RegisterStandardPassLists { + public: + RegisterStandardPassLists() { + StandardPass::RegisterDefaultPasses = RegisterStandardPassList; + } + private: + /// Passes must be registered with functions that take no arguments, so we + /// have to wrap their existing constructors. + static Pass *createDefaultScalarReplAggregatesPass(void) { + return createScalarReplAggregatesPass(-1, false); + } + static Pass *createDefaultLoopUnswitchPass(void) { + return createLoopUnswitchPass(false); + } + static Pass *createSizeOptimizingLoopUnswitchPass(void) { + return createLoopUnswitchPass(true); + } + static void RegisterStandardPassList(void) { + // Standard alias analysis passes + + // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that + // BasicAliasAnalysis wins if they disagree. This is intended to help + // support "obvious" type-punning idioms. +#define DEFAULT_ALIAS_ANALYSIS_PASS(pass, flags)\ + StandardPass::RegisterDefaultPass(\ + PassInfo::NormalCtor_t(create ## pass ## Pass),\ + &DefaultStandardPasses::pass ## ID, 0, StandardPass::AliasAnalysis, flags) + DEFAULT_ALIAS_ANALYSIS_PASS(BasicAliasAnalysis, 0); + DEFAULT_ALIAS_ANALYSIS_PASS(TypeBasedAliasAnalysis, 0); +#undef DEFAULT_ALIAS_ANALYSIS_PASS + +#define DEFAULT_FUNCTION_PASS(pass, flags)\ + StandardPass::RegisterDefaultPass(\ + PassInfo::NormalCtor_t(create ## pass ## Pass),\ + &DefaultStandardPasses::pass ## ID, 0, StandardPass::Function, flags) + DEFAULT_FUNCTION_PASS(CFGSimplification, + StandardPass::OptimizationFlags(1)); + DEFAULT_FUNCTION_PASS(ScalarReplAggregates, + StandardPass::OptimizationFlags(1)); + DEFAULT_FUNCTION_PASS(EarlyCSE, StandardPass::OptimizationFlags(1)); +#undef DEFAULT_FUNCTION_PASS + +#define DEFAULT_MODULE_PASS(pass, flags)\ + StandardPass::RegisterDefaultPass(\ + PassInfo::NormalCtor_t(create ## pass ## Pass),\ + &DefaultStandardPasses::pass ## ID, 0, StandardPass::Module, flags) + // Optimize out global vars + DEFAULT_MODULE_PASS(GlobalOptimizer, StandardPass::UnitAtATime); + // IP SCCP + DEFAULT_MODULE_PASS(IPSCCP, + StandardPass::OptimizationFlags(0, 0, StandardPass::UnitAtATime)); + // Dead argument elimination + DEFAULT_MODULE_PASS(DeadArgElimination, + StandardPass::OptimizationFlags(0, 0, StandardPass::UnitAtATime)); + // Clean up after IPCP & DAE + DEFAULT_MODULE_PASS(InstructionCombining, + StandardPass::OptimizationFlags(0, 0, StandardPass::UnitAtATime)); + // Clean up after IPCP & DAE + DEFAULT_MODULE_PASS(CFGSimplification, + StandardPass::OptimizationFlags(0, 0, StandardPass::UnitAtATime)); + + // Placeholder that will be replaced by an inliner if one is specified + StandardPass::RegisterDefaultPass(0, + &DefaultStandardPasses::InlinerPlaceholderID , 0, + StandardPass::Module); + // Remove dead EH info + DEFAULT_MODULE_PASS(PruneEH, StandardPass::OptimizationFlags(0, 0, + StandardPass::UnitAtATime | StandardPass::HaveExceptions)); + // Set readonly/readnone attrs + DEFAULT_MODULE_PASS(FunctionAttrs, StandardPass::OptimizationFlags(0, 0, + StandardPass::UnitAtATime)); + // Scalarize uninlined fn args + DEFAULT_MODULE_PASS(ArgumentPromotion, 2); + // Start of function pass. + // Break up aggregate allocas, using SSAUpdater. + StandardPass::RegisterDefaultPass( + PassInfo::NormalCtor_t(createDefaultScalarReplAggregatesPass), + &DefaultStandardPasses::ScalarReplAggregatesID, 0, + StandardPass::Module); + // Catch trivial redundancies + DEFAULT_MODULE_PASS(EarlyCSE, 0); + // Library Call Optimizations + DEFAULT_MODULE_PASS(SimplifyLibCalls, StandardPass::SimplifyLibCalls); + // Thread jumps + DEFAULT_MODULE_PASS(JumpThreading, 0); + // Propagate conditionals + DEFAULT_MODULE_PASS(CorrelatedValuePropagation, 0); + // Merge & remove BBs + DEFAULT_MODULE_PASS(CFGSimplification, 0); + // Combine silly seq's + DEFAULT_MODULE_PASS(InstructionCombining, 0); + // Eliminate tail calls + DEFAULT_MODULE_PASS(TailCallElimination, 0); + // Merge & remove BBs + DEFAULT_MODULE_PASS(CFGSimplification, 0); + // Reassociate expressions + DEFAULT_MODULE_PASS(Reassociate, 0); + // Rotate Loop + DEFAULT_MODULE_PASS(LoopRotate, 0); + // Hoist loop invariants + DEFAULT_MODULE_PASS(LICM, 0); + // Optimize for size if the optimzation level is 0-2 + StandardPass::RegisterDefaultPass( + PassInfo::NormalCtor_t(createSizeOptimizingLoopUnswitchPass), + &DefaultStandardPasses::LoopUnswitchID, 0, + StandardPass::Module, + StandardPass::OptimizationFlags(0, 2)); + // Optimize for size if the optimzation level is >2, and OptimizeSize is + // set + StandardPass::RegisterDefaultPass( + PassInfo::NormalCtor_t(createSizeOptimizingLoopUnswitchPass), + &DefaultStandardPasses::LoopUnswitchID, 0, + StandardPass::Module, + StandardPass::OptimizationFlags(0, 3, StandardPass::OptimizeSize)); + // Don't optimize for size if optimisation level is >2 and OptimizeSize + // is not set + StandardPass::RegisterDefaultPass( + PassInfo::NormalCtor_t(createSizeOptimizingLoopUnswitchPass), + &DefaultStandardPasses::LoopUnswitchID, 0, + StandardPass::Module, + StandardPass::OptimizationFlags(0, 3, 0, StandardPass::OptimizeSize)); + DEFAULT_MODULE_PASS(InstructionCombining, 0); + // Canonicalize indvars + DEFAULT_MODULE_PASS(IndVarSimplify, 0); + // Recognize idioms like memset. + DEFAULT_MODULE_PASS(LoopIdiom, 0); + // Delete dead loops + DEFAULT_MODULE_PASS(LoopDeletion, 0); + // Unroll small loops + DEFAULT_MODULE_PASS(LoopUnroll, StandardPass::UnrollLoops); + // Remove redundancies + DEFAULT_MODULE_PASS(GVN, 2); + // Remove memcpy / form memset + DEFAULT_MODULE_PASS(MemCpyOpt, 0); + // Constant prop with SCCP + DEFAULT_MODULE_PASS(SCCP, 0); + + // Run instcombine after redundancy elimination to exploit opportunities + // opened up by them. + DEFAULT_MODULE_PASS(InstructionCombining, 0); + // Thread jumps + DEFAULT_MODULE_PASS(JumpThreading, 0); + DEFAULT_MODULE_PASS(CorrelatedValuePropagation, 0); + // Delete dead stores + DEFAULT_MODULE_PASS(DeadStoreElimination, 0); + // Delete dead instructions + DEFAULT_MODULE_PASS(AggressiveDCE, 0); + // Merge & remove BBs + DEFAULT_MODULE_PASS(CFGSimplification, 0); + // Clean up after everything. + DEFAULT_MODULE_PASS(InstructionCombining, 0); + + // Get rid of dead prototypes + DEFAULT_MODULE_PASS(StripDeadPrototypes, StandardPass::UnitAtATime); + // Eliminate dead types + DEFAULT_MODULE_PASS(DeadTypeElimination, StandardPass::UnitAtATime); + + // GlobalOpt already deletes dead functions and globals, at -O3 try a + // late pass of GlobalDCE. It is capable of deleting dead cycles. + // Remove dead fns and globals. + DEFAULT_MODULE_PASS(GlobalDCE, 3 | StandardPass::UnitAtATime); + // Merge dup global constants + DEFAULT_MODULE_PASS(ConstantMerge, 2 | StandardPass::UnitAtATime); +#undef DEFAULT_MODULE_PASS + +#define DEFAULT_LTO_PASS(pass, flags)\ + StandardPass::RegisterDefaultPass(\ + PassInfo::NormalCtor_t(create ## pass ## Pass),\ + &DefaultStandardPasses::pass ## ID, 0, StandardPass::LTO, flags) + + // LTO passes + + // Propagate constants at call sites into the functions they call. This + // opens opportunities for globalopt (and inlining) by substituting + // function pointers passed as arguments to direct uses of functions. + DEFAULT_LTO_PASS(IPSCCP, 0); + + // Now that we internalized some globals, see if we can hack on them! + DEFAULT_LTO_PASS(GlobalOptimizer, 0); + + // Linking modules together can lead to duplicated global constants, only + // keep one copy of each constant... + DEFAULT_LTO_PASS(ConstantMerge, 0); + + // Remove unused arguments from functions... + DEFAULT_LTO_PASS(DeadArgElimination, 0); + + // Reduce the code after globalopt and ipsccp. Both can open up + // significant simplification opportunities, and both can propagate + // functions through function pointers. When this happens, we often have + // to resolve varargs calls, etc, so let instcombine do this. + DEFAULT_LTO_PASS(InstructionCombining, 0); + + // Inline small functions + DEFAULT_LTO_PASS(FunctionInlining, + StandardPass::OptimizationFlags(0, 0xf, StandardPass::RunInliner)); + // Remove dead EH info. + DEFAULT_LTO_PASS(PruneEH, 0); + // Optimize globals again if we ran the inliner. + DEFAULT_LTO_PASS(GlobalOptimizer, + StandardPass::OptimizationFlags(0, 0xf, StandardPass::RunInliner)); + DEFAULT_LTO_PASS(GlobalDCE, 0); + + // If we didn't decide to inline a function, check to see if we can + // transform it to pass arguments by value instead of by reference. + DEFAULT_LTO_PASS(ArgumentPromotion, 0); + + // The IPO passes may leave cruft around. Clean up after them. + DEFAULT_LTO_PASS(InstructionCombining, 0); + DEFAULT_LTO_PASS(JumpThreading, 0); + // Break up allocas + DEFAULT_LTO_PASS(ScalarReplAggregates, 0); + + // Run a few AA driven optimizations here and now, to cleanup the code. + // Add nocapture. + DEFAULT_LTO_PASS(FunctionAttrs, 0); + // IP alias analysis. + DEFAULT_LTO_PASS(GlobalsModRef, 0); + + // Hoist loop invariants. + DEFAULT_LTO_PASS(LICM, 0); + // Remove redundancies. + DEFAULT_LTO_PASS(GVN, 0); + // Remove dead memcpys. + DEFAULT_LTO_PASS(MemCpyOpt, 0); + // Nuke dead stores. + DEFAULT_LTO_PASS(DeadStoreElimination, 0); + + // Cleanup and simplify the code after the scalar optimizations. + DEFAULT_LTO_PASS(InstructionCombining, 0); + + DEFAULT_LTO_PASS(JumpThreading, 0); + + // Delete basic blocks, which optimization passes may have killed. + DEFAULT_LTO_PASS(CFGSimplification, 0); + + // Now that we have optimized the program, discard unreachable functions. + DEFAULT_LTO_PASS(GlobalDCE, 0); +#undef DEFAULT_LTO_PASS + } + }; + static RegisterStandardPassLists AutoRegister; + + static inline void createStandardAliasAnalysisPasses(PassManagerBase *PM) { - // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that - // BasicAliasAnalysis wins if they disagree. This is intended to help - // support "obvious" type-punning idioms. - PM->add(createTypeBasedAliasAnalysisPass()); - PM->add(createBasicAliasAnalysisPass()); + StandardPass::AddPassesFromSet(PM, StandardPass::AliasAnalysis); } /// createStandardFunctionPasses - Add the standard list of function passes to @@ -42,12 +290,7 @@ /// -O1, etc. static inline void createStandardFunctionPasses(PassManagerBase *PM, unsigned OptimizationLevel) { - if (OptimizationLevel > 0) { - createStandardAliasAnalysisPasses(PM); - PM->add(createCFGSimplificationPass()); - PM->add(createScalarReplAggregatesPass()); - PM->add(createEarlyCSEPass()); - } + StandardPass::AddPassesFromSet(PM, StandardPass::Function, OptimizationLevel); } /// createStandardModulePasses - Add the standard list of module passes to the @@ -78,84 +321,16 @@ PM->add(InliningPass); return; } - - if (UnitAtATime) { - PM->add(createGlobalOptimizerPass()); // Optimize out global vars - - PM->add(createIPSCCPPass()); // IP SCCP - PM->add(createDeadArgEliminationPass()); // Dead argument elimination - - PM->add(createInstructionCombiningPass());// Clean up after IPCP & DAE - PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE - } - - // Start of CallGraph SCC passes. - if (UnitAtATime && HaveExceptions) - PM->add(createPruneEHPass()); // Remove dead EH info - if (InliningPass) - PM->add(InliningPass); - if (UnitAtATime) - PM->add(createFunctionAttrsPass()); // Set readonly/readnone attrs - if (OptimizationLevel > 2) - PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args - - // Start of function pass. - // Break up aggregate allocas, using SSAUpdater. - PM->add(createScalarReplAggregatesPass(-1, false)); - PM->add(createEarlyCSEPass()); // Catch trivial redundancies - if (SimplifyLibCalls) - PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations - PM->add(createJumpThreadingPass()); // Thread jumps. - PM->add(createCorrelatedValuePropagationPass()); // Propagate conditionals - PM->add(createCFGSimplificationPass()); // Merge & remove BBs - PM->add(createInstructionCombiningPass()); // Combine silly seq's - - PM->add(createTailCallEliminationPass()); // Eliminate tail calls - PM->add(createCFGSimplificationPass()); // Merge & remove BBs - PM->add(createReassociatePass()); // Reassociate expressions - PM->add(createLoopRotatePass()); // Rotate Loop - PM->add(createLICMPass()); // Hoist loop invariants - PM->add(createLoopUnswitchPass(OptimizeSize || OptimizationLevel < 3)); - PM->add(createInstructionCombiningPass()); - PM->add(createIndVarSimplifyPass()); // Canonicalize indvars - PM->add(createLoopIdiomPass()); // Recognize idioms like memset. - PM->add(createLoopDeletionPass()); // Delete dead loops - if (UnrollLoops) - PM->add(createLoopUnrollPass()); // Unroll small loops - if (OptimizationLevel > 1) - PM->add(createGVNPass()); // Remove redundancies - PM->add(createMemCpyOptPass()); // Remove memcpy / form memset - PM->add(createSCCPPass()); // Constant prop with SCCP - - // Run instcombine after redundancy elimination to exploit opportunities - // opened up by them. - PM->add(createInstructionCombiningPass()); - PM->add(createJumpThreadingPass()); // Thread jumps - PM->add(createCorrelatedValuePropagationPass()); - PM->add(createDeadStoreEliminationPass()); // Delete dead stores - PM->add(createAggressiveDCEPass()); // Delete dead instructions - PM->add(createCFGSimplificationPass()); // Merge & remove BBs - PM->add(createInstructionCombiningPass()); // Clean up after everything. - - if (UnitAtATime) { - PM->add(createStripDeadPrototypesPass()); // Get rid of dead prototypes - PM->add(createDeadTypeEliminationPass()); // Eliminate dead types - // GlobalOpt already deletes dead functions and globals, at -O3 try a - // late pass of GlobalDCE. It is capable of deleting dead cycles. - if (OptimizationLevel > 2) - PM->add(createGlobalDCEPass()); // Remove dead fns and globals. + StandardPass::AddPassesFromSet(PM, StandardPass::Module, + StandardPass::OptimizationFlags(OptimizationLevel, + (OptimizeSize ? StandardPass::OptimizeSize : 0) | + (UnitAtATime ? StandardPass::UnitAtATime : 0) | + (UnrollLoops ? StandardPass::UnrollLoops : 0) | + (SimplifyLibCalls ? StandardPass::SimplifyLibCalls : 0) | + (HaveExceptions ? StandardPass::HaveExceptions : 0)), + InliningPass); - if (OptimizationLevel > 1) - PM->add(createConstantMergePass()); // Merge dup global constants - } - } - - static inline void addOnePass(PassManagerBase *PM, Pass *P, bool AndVerify) { - PM->add(P); - - if (AndVerify) - PM->add(createVerifierPass()); } /// createStandardLTOPasses - Add the standard list of module passes suitable @@ -174,70 +349,15 @@ // Now that composite has been compiled, scan through the module, looking // for a main function. If main is defined, mark all other functions // internal. - if (Internalize) - addOnePass(PM, createInternalizePass(true), VerifyEach); - - // Propagate constants at call sites into the functions they call. This - // opens opportunities for globalopt (and inlining) by substituting function - // pointers passed as arguments to direct uses of functions. - addOnePass(PM, createIPSCCPPass(), VerifyEach); - - // Now that we internalized some globals, see if we can hack on them! - addOnePass(PM, createGlobalOptimizerPass(), VerifyEach); - - // Linking modules together can lead to duplicated global constants, only - // keep one copy of each constant... - addOnePass(PM, createConstantMergePass(), VerifyEach); - - // Remove unused arguments from functions... - addOnePass(PM, createDeadArgEliminationPass(), VerifyEach); - - // Reduce the code after globalopt and ipsccp. Both can open up significant - // simplification opportunities, and both can propagate functions through - // function pointers. When this happens, we often have to resolve varargs - // calls, etc, so let instcombine do this. - addOnePass(PM, createInstructionCombiningPass(), VerifyEach); - - // Inline small functions - if (RunInliner) - addOnePass(PM, createFunctionInliningPass(), VerifyEach); - - addOnePass(PM, createPruneEHPass(), VerifyEach); // Remove dead EH info. - // Optimize globals again if we ran the inliner. - if (RunInliner) - addOnePass(PM, createGlobalOptimizerPass(), VerifyEach); - addOnePass(PM, createGlobalDCEPass(), VerifyEach); // Remove dead functions. - - // If we didn't decide to inline a function, check to see if we can - // transform it to pass arguments by value instead of by reference. - addOnePass(PM, createArgumentPromotionPass(), VerifyEach); - - // The IPO passes may leave cruft around. Clean up after them. - addOnePass(PM, createInstructionCombiningPass(), VerifyEach); - addOnePass(PM, createJumpThreadingPass(), VerifyEach); - // Break up allocas - addOnePass(PM, createScalarReplAggregatesPass(), VerifyEach); - - // Run a few AA driven optimizations here and now, to cleanup the code. - addOnePass(PM, createFunctionAttrsPass(), VerifyEach); // Add nocapture. - addOnePass(PM, createGlobalsModRefPass(), VerifyEach); // IP alias analysis. - - addOnePass(PM, createLICMPass(), VerifyEach); // Hoist loop invariants. - addOnePass(PM, createGVNPass(), VerifyEach); // Remove redundancies. - addOnePass(PM, createMemCpyOptPass(), VerifyEach); // Remove dead memcpys. - // Nuke dead stores. - addOnePass(PM, createDeadStoreEliminationPass(), VerifyEach); - - // Cleanup and simplify the code after the scalar optimizations. - addOnePass(PM, createInstructionCombiningPass(), VerifyEach); - - addOnePass(PM, createJumpThreadingPass(), VerifyEach); - - // Delete basic blocks, which optimization passes may have killed. - addOnePass(PM, createCFGSimplificationPass(), VerifyEach); + if (Internalize) { + PM->add(createInternalizePass(true)); + if (VerifyEach) + PM->add(createVerifierPass()); + } - // Now that we have optimized the program, discard unreachable functions. - addOnePass(PM, createGlobalDCEPass(), VerifyEach); + StandardPass::AddPassesFromSet(PM, StandardPass::LTO, + StandardPass::OptimizationFlags(0, 0, RunInliner ? + StandardPass::RunInliner : 0), VerifyEach); } } Added: llvm/trunk/lib/VMCore/StandardPasses.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/StandardPasses.cpp?rev=131155&view=auto ============================================================================== --- llvm/trunk/lib/VMCore/StandardPasses.cpp (added) +++ llvm/trunk/lib/VMCore/StandardPasses.cpp Tue May 10 16:36:48 2011 @@ -0,0 +1,240 @@ +//=========-- StandardPasses.cpp - Standard pass lists -----*- C++ -*-=======// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines utility functions for creating a "standard" set of +// optimization passes, so that compilers and tools which use optimization +// passes use the same set of standard passes. +// +//===----------------------------------------------------------------------===// + +#include "llvm/PassManager.h" +#include "llvm/Analysis/Passes.h" +#include "llvm/Analysis/Verifier.h" +#include "llvm/Analysis/Verifier.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/Mutex.h" +#include "llvm/Support/DynamicLibrary.h" +#include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/IPO.h" + + +using namespace llvm::DefaultStandardPasses; +using namespace llvm; + +namespace { + +/// Entry in the standard passes list. +struct StandardPassEntry { + /// Function called to create the pass + PassInfo::NormalCtor_t createPass; + /// Unique identifier for this pass + unsigned char *passID; + /// Flags specifying when this pass should be run + unsigned flags; + + StandardPassEntry(PassInfo::NormalCtor_t constructor, unsigned char *ID, + unsigned f) : createPass(constructor), passID(ID), flags(f) {}; +}; + +/// Standard alias analysis passes +static llvm::SmallVector AAPasses; +/// Standard function passes +static llvm::SmallVector FunctionPasses; +/// Standard module passes +static llvm::SmallVector ModulePasses; +/// Standard link-time optimization passes +static llvm::SmallVector LTOPasses; + +/// Entry in the unresolved standard pass list. IF a pass is inserted in front +/// of a pass that is not yet registered in the standard pass list then it is +/// stored in a separate list and resolved later. +struct UnresolvedStandardPass : public StandardPassEntry { + /// The set into which this is stored + StandardPass::StandardSet set; + /// The unique ID of the pass that should follow this one in the sequence + unsigned char *next; + UnresolvedStandardPass(PassInfo::NormalCtor_t constructor, + unsigned char *newPass, + unsigned char *oldPass, + StandardPass::StandardSet s, + unsigned f) + : StandardPassEntry(constructor, newPass, f), set(s), next(oldPass) {} +}; + +/// The passes that can not be inserted into the correct lists yet because of +/// their place in the sequence. +static llvm::SmallVector UnresolvedPasses; + +/// Returns a reference to the pass list for the corresponding set of +/// optimisations. +llvm::SmallVectorImpl& +PassList(StandardPass::StandardSet set) { + switch (set) { + case StandardPass::AliasAnalysis: return AAPasses; + case StandardPass::Function: return FunctionPasses; + case StandardPass::Module: return ModulePasses; + case StandardPass::LTO: return LTOPasses; + } + // We could use a map of standard pass lists to allow definition of new + // default sets + llvm_unreachable("Invalid standard optimization set requested"); +} + +static ManagedStatic > Lock; + +/// Registers the default set of standard passes. This is called lazily when +/// an attempt is made to read or modify the standard pass list +void RegisterDefaultStandardPasses(void(*doRegister)(void)) { + // Only initialize the standard passes once + static bool initialized = false; + if (initialized) return; + + llvm::sys::SmartScopedLock Guard(*Lock); + if (initialized) return; + if (doRegister) { + // We must set initialized to true before calling this function, because + // the doRegister() function will probably call RegisterDefaultPasses(), + // which will call this function, and we'd end up with infinite recursion + // and breakage if we didn't. + initialized = true; + doRegister(); + } +} + +} // Anonymous namespace + +void (*StandardPass::RegisterDefaultPasses)(void); + +void StandardPass::RegisterDefaultPass(PassInfo::NormalCtor_t constructor, + unsigned char *newPass, + unsigned char *oldPass, + StandardPass::StandardSet set, + unsigned flags) { + // Make sure that the standard sets are already regstered + RegisterDefaultStandardPasses(RegisterDefaultPasses); + // Get the correct list to modify + llvm::SmallVectorImpl &passList = PassList(set); + + // If there is no old pass specified, then we are adding a new final pass, so + // just push it onto the end. + if (!oldPass) { + StandardPassEntry pass(constructor, newPass, flags); + passList.push_back(pass); + return; + } + + // Find the correct place to insert the pass. This is a linear search, but + // this shouldn't be too slow since the SmallVector will store the values in + // a contiguous block of memory. Each entry is just three words of memory, so + // in most cases we are only going to be looking in one or two cache lines. + // The extra memory accesses from a more complex search structure would + // offset any performance gain (unless someone decides to + for (SmallVectorImpl::iterator i = passList.begin(), + e=passList.end(); i != e; ++i) { + if (i->passID == oldPass) { + StandardPassEntry pass(constructor, newPass, flags); + passList.insert(i, pass); + // If we've added a new pass, then there may have gained the ability to + // insert one of the previously unresolved ones. If so, insert the new + // one. + for (SmallVectorImpl::iterator + u = UnresolvedPasses.begin(), eu = UnresolvedPasses.end(); + u!=eu; ++u){ + if (u->next == newPass && u->set == set) { + UnresolvedStandardPass p = *u; + UnresolvedPasses.erase(u); + RegisterDefaultPass(p.createPass, p.passID, p.next, p.set, p.flags); + } + } + return; + } + } + // If we get to here, then we didn't find the correct place to insert the new + // pass + UnresolvedStandardPass pass(constructor, newPass, oldPass, set, flags); + UnresolvedPasses.push_back(pass); +} + +void StandardPass::AddPassesFromSet(PassManagerBase *PM, + StandardSet set, + unsigned flags, + bool VerifyEach, + Pass *inliner) { + RegisterDefaultStandardPasses(RegisterDefaultPasses); + unsigned level = OptimizationLevel(flags); + flags = RequiredFlags(flags); + llvm::SmallVectorImpl& passList = PassList(set); + // Add all of the passes from this set + for (SmallVectorImpl::iterator i = passList.begin(), + e=passList.end(); i != e ; ++i) { + // Skip passes that don't have conditions that match the ones specified + // here. For a pass to match: + // - Its minimum optimisation level must be less than or equal to the + // specified level. + // - Its maximum optimisation level must be greater than or equal to the + // specified level + // - All of its required flags must be set + // - None of its disallowed flags may be set + if ((level >= OptimizationLevel(i->flags)) && + ((level <= MaxOptimizationLevel(i->flags)) + || MaxOptimizationLevel(i->flags) == 0) && + ((RequiredFlags(i->flags) & flags) == RequiredFlags(i->flags)) && + ((DisallowedFlags(i->flags) & flags) == 0)) { + // This is quite an ugly way of allowing us to specify an inliner pass to + // insert. Ideally, we'd replace this with a general mechanism allowing + // callers to replace arbitrary passes in the list. + Pass *p = inliner; + if ((&InlinerPlaceholderID != i->passID) && i->createPass) + p = i->createPass(); + if (p) { + PM->add(p); + if (VerifyEach) + PM->add(createVerifierPass()); + } + } + } +} + +unsigned char DefaultStandardPasses::AggressiveDCEID; +unsigned char DefaultStandardPasses::ArgumentPromotionID; +unsigned char DefaultStandardPasses::BasicAliasAnalysisID; +unsigned char DefaultStandardPasses::CFGSimplificationID; +unsigned char DefaultStandardPasses::ConstantMergeID; +unsigned char DefaultStandardPasses::CorrelatedValuePropagationID; +unsigned char DefaultStandardPasses::DeadArgEliminationID; +unsigned char DefaultStandardPasses::DeadStoreEliminationID; +unsigned char DefaultStandardPasses::DeadTypeEliminationID; +unsigned char DefaultStandardPasses::EarlyCSEID; +unsigned char DefaultStandardPasses::FunctionAttrsID; +unsigned char DefaultStandardPasses::FunctionInliningID; +unsigned char DefaultStandardPasses::GVNID; +unsigned char DefaultStandardPasses::GlobalDCEID; +unsigned char DefaultStandardPasses::GlobalOptimizerID; +unsigned char DefaultStandardPasses::GlobalsModRefID; +unsigned char DefaultStandardPasses::IPSCCPID; +unsigned char DefaultStandardPasses::IndVarSimplifyID; +unsigned char DefaultStandardPasses::InlinerPlaceholderID; +unsigned char DefaultStandardPasses::InstructionCombiningID; +unsigned char DefaultStandardPasses::JumpThreadingID; +unsigned char DefaultStandardPasses::LICMID; +unsigned char DefaultStandardPasses::LoopDeletionID; +unsigned char DefaultStandardPasses::LoopIdiomID; +unsigned char DefaultStandardPasses::LoopRotateID; +unsigned char DefaultStandardPasses::LoopUnrollID; +unsigned char DefaultStandardPasses::LoopUnswitchID; +unsigned char DefaultStandardPasses::MemCpyOptID; +unsigned char DefaultStandardPasses::PruneEHID; +unsigned char DefaultStandardPasses::ReassociateID; +unsigned char DefaultStandardPasses::SCCPID; +unsigned char DefaultStandardPasses::ScalarReplAggregatesID; +unsigned char DefaultStandardPasses::SimplifyLibCallsID; +unsigned char DefaultStandardPasses::StripDeadPrototypesID; +unsigned char DefaultStandardPasses::TailCallEliminationID; +unsigned char DefaultStandardPasses::TypeBasedAliasAnalysisID; From eli.friedman at gmail.com Tue May 10 16:50:58 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 10 May 2011 21:50:58 -0000 Subject: [llvm-commits] [llvm] r131156 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Message-ID: <20110510215058.9864B2A6C12C@llvm.org> Author: efriedma Date: Tue May 10 16:50:58 2011 New Revision: 131156 URL: http://llvm.org/viewvc/llvm-project?rev=131156&view=rev Log: Disable my little CopyToReg argument hack with fast-isel. rdar://problem/9413587 . Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=131156&r1=131155&r2=131156&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue May 10 16:50:58 2011 @@ -6440,10 +6440,11 @@ // If this argument is live outside of the entry block, insert a copy from // wherever we got it to the vreg that other BB's will reference it as. - if (Res.getOpcode() == ISD::CopyFromReg) { + if (!EnableFastISel && Res.getOpcode() == ISD::CopyFromReg) { // If we can, though, try to skip creating an unnecessary vreg. // FIXME: This isn't very clean... it would be nice to make this more - // general. + // general. It's also subtly incompatible with the hacks FastISel + // uses with vregs. unsigned Reg = cast(Res.getOperand(1))->getReg(); if (TargetRegisterInfo::isVirtualRegister(Reg)) { FuncInfo->ValueMap[I] = Reg; From rafael.espindola at gmail.com Tue May 10 16:54:59 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 21:54:59 -0000 Subject: [llvm-commits] [llvm] r131157 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Message-ID: <20110510215459.9F9DA2A6C12C@llvm.org> Author: rafael Date: Tue May 10 16:54:59 2011 New Revision: 131157 URL: http://llvm.org/viewvc/llvm-project?rev=131157&view=rev Log: Initialize moveTypeModule. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=131157&r1=131156&r2=131157&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Tue May 10 16:54:59 2011 @@ -41,8 +41,8 @@ DwarfCFIException::DwarfCFIException(AsmPrinter *A) : DwarfException(A), - shouldEmitPersonality(false), shouldEmitLSDA(false), shouldEmitMoves(false) - {} + shouldEmitPersonality(false), shouldEmitLSDA(false), shouldEmitMoves(false), + moveTypeModule(AsmPrinter::CFI_M_None) {} DwarfCFIException::~DwarfCFIException() {} From nicholas at mxc.ca Tue May 10 17:16:06 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 10 May 2011 22:16:06 -0000 Subject: [llvm-commits] [llvm] r131159 - in /llvm/trunk: include/llvm/PassSupport.h include/llvm/Support/StandardPasses.h lib/VMCore/StandardPasses.cpp Message-ID: <20110510221606.AFA622A6C12C@llvm.org> Author: nicholas Date: Tue May 10 17:16:06 2011 New Revision: 131159 URL: http://llvm.org/viewvc/llvm-project?rev=131159&view=rev Log: Revert r131155 for now. It makes VMCore depend on Analysis and Transforms headers. Modified: llvm/trunk/include/llvm/PassSupport.h llvm/trunk/include/llvm/Support/StandardPasses.h llvm/trunk/lib/VMCore/StandardPasses.cpp Modified: llvm/trunk/include/llvm/PassSupport.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassSupport.h?rev=131159&r1=131158&r2=131159&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassSupport.h (original) +++ llvm/trunk/include/llvm/PassSupport.h Tue May 10 17:16:06 2011 @@ -29,8 +29,6 @@ namespace llvm { - class PassManagerBase; - //===--------------------------------------------------------------------------- /// PassInfo class - An instance of this class exists for every pass known by /// the system, and can be obtained from a live Pass by calling its @@ -209,149 +207,6 @@ } }; - /// Unique identifiers for the default standard passes. The addresses of - /// these symbols are used to uniquely identify passes from the default list. - namespace DefaultStandardPasses { - extern unsigned char AggressiveDCEID; - extern unsigned char ArgumentPromotionID; - extern unsigned char BasicAliasAnalysisID; - extern unsigned char CFGSimplificationID; - extern unsigned char ConstantMergeID; - extern unsigned char CorrelatedValuePropagationID; - extern unsigned char DeadArgEliminationID; - extern unsigned char DeadStoreEliminationID; - extern unsigned char DeadTypeEliminationID; - extern unsigned char EarlyCSEID; - extern unsigned char FunctionAttrsID; - extern unsigned char FunctionInliningID; - extern unsigned char GVNID; - extern unsigned char GlobalDCEID; - extern unsigned char GlobalOptimizerID; - extern unsigned char GlobalsModRefID; - extern unsigned char IPSCCPID; - extern unsigned char IndVarSimplifyID; - extern unsigned char InlinerPlaceholderID; - extern unsigned char InstructionCombiningID; - extern unsigned char JumpThreadingID; - extern unsigned char LICMID; - extern unsigned char LoopDeletionID; - extern unsigned char LoopIdiomID; - extern unsigned char LoopRotateID; - extern unsigned char LoopUnrollID; - extern unsigned char LoopUnswitchID; - extern unsigned char MemCpyOptID; - extern unsigned char PruneEHID; - extern unsigned char ReassociateID; - extern unsigned char SCCPID; - extern unsigned char ScalarReplAggregatesID; - extern unsigned char SimplifyLibCallsID; - extern unsigned char StripDeadPrototypesID; - extern unsigned char TailCallEliminationID; - extern unsigned char TypeBasedAliasAnalysisID; - } - - -class RegisterStandardPass; -/// RegisterStandardPass - Registers a pass as a member of a standard set. -class StandardPass { - friend class RegisterStandardPassLists; - public: - /// Predefined standard sets of passes - enum StandardSet { - AliasAnalysis, - Function, - Module, - LTO - }; - /// Flags to specify whether a pass should be enabled. Passes registered - /// with the standard sets may specify a minimum optimization level and one - /// or more flags that must be set when constructing the set for the pass to - /// be used. - enum OptimizationFlags { - /// Optimize for size was requested. - OptimizeSize = 1<<0, - /// Allow passes which may make global module changes. - UnitAtATime = 1<<1, - /// UnrollLoops - Allow loop unrolling. - UnrollLoops = 1<<2, - /// Allow library calls to be simplified. - SimplifyLibCalls = 1<<3, - /// Whether the module may have code using exceptions. - HaveExceptions = 1<<4, - // Run an inliner pass as part of this set. - RunInliner = 1<<5 - }; - enum OptimizationFlagComponents { - /// The low bits are used to store the optimization level. When requesting - /// passes, this should store the requested optimisation level. When - /// setting passes, this should set the minimum optimization level at which - /// the pass will run. - OptimizationLevelMask = 0xf, - /// The maximum optimisation level at which the pass is run. - MaxOptimizationLevelMask = 0xf0, - // Flags that must be set - RequiredFlagMask = 0xff00, - // Flags that may not be set. - DisallowedFlagMask = 0xff0000, - MaxOptimizationLevelShift = 4, - RequiredFlagShift = 8, - DisallowedFlagShift = 16 - }; - /// Returns the optimisation level from a set of flags. - static unsigned OptimizationLevel(unsigned flags) { - return flags & OptimizationLevelMask; - } - /// Returns the maximum optimization level for this set of flags - static unsigned MaxOptimizationLevel(unsigned flags) { - return (flags & MaxOptimizationLevelMask) >> 4; - } - /// Constructs a set of flags from the specified minimum and maximum - /// optimisation level - static unsigned OptimizationFlags(unsigned minLevel=0, unsigned maxLevel=0xf, - unsigned requiredFlags=0, - unsigned disallowedFlags=0) { - return ((minLevel & OptimizationLevelMask) | - ((maxLevel<> RequiredFlagShift; - } - /// Returns the flags that must not be set for this to match - static unsigned DisallowedFlags(unsigned flags) { - return (flags & DisallowedFlagMask) >> RequiredFlagShift; - } - /// Register a standard pass in the specified set. If flags is non-zero, - /// then the pass will only be returned when the specified flags are set. - template - class RegisterStandardPass { - RegisterStandardPass(StandardSet set, unsigned char *runBefore=0, - unsigned flags=0, unsigned char *ID=0) { - // Use the pass's ID if one is not specified - RegisterDefaultPass(PassInfo::NormalCtor_t(callDefaultCtor), - ID ? ID : &passName::ID, runBefore, set, flags); - }; - }; - /// Adds the passes from the specified set to a pass manager. - static void AddPassesFromSet(PassManagerBase *PM, - StandardSet Set, - unsigned Flags=0, - bool VerifyEach=false, - Pass *Inliner=0); - private: - /// Registers the default passes. This is set by RegisterStandardPassLists - /// and is called lazily. - static void (*RegisterDefaultPasses)(void); - /// Registers the pass - static void RegisterDefaultPass(PassInfo::NormalCtor_t constructor, - unsigned char *newPass, - unsigned char *oldPass, - StandardSet set, - unsigned flags=0); -}; - /// RegisterAnalysisGroup - Register a Pass as a member of an analysis _group_. /// Analysis groups are used to define an interface (which need not derive from Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=131159&r1=131158&r2=131159&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue May 10 17:16:06 2011 @@ -20,7 +20,6 @@ #define LLVM_SUPPORT_STANDARDPASSES_H #include "llvm/PassManager.h" -#include "llvm/PassSupport.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Transforms/Scalar.h" @@ -28,259 +27,12 @@ namespace llvm { - /// RegisterStandardPassLists solves a circular dependency problem. The - /// default list of passes has to live somewhere. It can't live in the core - /// modules, because these don't link to the libraries that actually define - /// the passes. It's in this header, so that a copy is created in every - /// library that requests the default set, while still allowing plugins to - /// register new passes without requiring them to link anything more than - /// VMCore. - class RegisterStandardPassLists { - public: - RegisterStandardPassLists() { - StandardPass::RegisterDefaultPasses = RegisterStandardPassList; - } - private: - /// Passes must be registered with functions that take no arguments, so we - /// have to wrap their existing constructors. - static Pass *createDefaultScalarReplAggregatesPass(void) { - return createScalarReplAggregatesPass(-1, false); - } - static Pass *createDefaultLoopUnswitchPass(void) { - return createLoopUnswitchPass(false); - } - static Pass *createSizeOptimizingLoopUnswitchPass(void) { - return createLoopUnswitchPass(true); - } - static void RegisterStandardPassList(void) { - // Standard alias analysis passes - - // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that - // BasicAliasAnalysis wins if they disagree. This is intended to help - // support "obvious" type-punning idioms. -#define DEFAULT_ALIAS_ANALYSIS_PASS(pass, flags)\ - StandardPass::RegisterDefaultPass(\ - PassInfo::NormalCtor_t(create ## pass ## Pass),\ - &DefaultStandardPasses::pass ## ID, 0, StandardPass::AliasAnalysis, flags) - DEFAULT_ALIAS_ANALYSIS_PASS(BasicAliasAnalysis, 0); - DEFAULT_ALIAS_ANALYSIS_PASS(TypeBasedAliasAnalysis, 0); -#undef DEFAULT_ALIAS_ANALYSIS_PASS - -#define DEFAULT_FUNCTION_PASS(pass, flags)\ - StandardPass::RegisterDefaultPass(\ - PassInfo::NormalCtor_t(create ## pass ## Pass),\ - &DefaultStandardPasses::pass ## ID, 0, StandardPass::Function, flags) - DEFAULT_FUNCTION_PASS(CFGSimplification, - StandardPass::OptimizationFlags(1)); - DEFAULT_FUNCTION_PASS(ScalarReplAggregates, - StandardPass::OptimizationFlags(1)); - DEFAULT_FUNCTION_PASS(EarlyCSE, StandardPass::OptimizationFlags(1)); -#undef DEFAULT_FUNCTION_PASS - -#define DEFAULT_MODULE_PASS(pass, flags)\ - StandardPass::RegisterDefaultPass(\ - PassInfo::NormalCtor_t(create ## pass ## Pass),\ - &DefaultStandardPasses::pass ## ID, 0, StandardPass::Module, flags) - // Optimize out global vars - DEFAULT_MODULE_PASS(GlobalOptimizer, StandardPass::UnitAtATime); - // IP SCCP - DEFAULT_MODULE_PASS(IPSCCP, - StandardPass::OptimizationFlags(0, 0, StandardPass::UnitAtATime)); - // Dead argument elimination - DEFAULT_MODULE_PASS(DeadArgElimination, - StandardPass::OptimizationFlags(0, 0, StandardPass::UnitAtATime)); - // Clean up after IPCP & DAE - DEFAULT_MODULE_PASS(InstructionCombining, - StandardPass::OptimizationFlags(0, 0, StandardPass::UnitAtATime)); - // Clean up after IPCP & DAE - DEFAULT_MODULE_PASS(CFGSimplification, - StandardPass::OptimizationFlags(0, 0, StandardPass::UnitAtATime)); - - // Placeholder that will be replaced by an inliner if one is specified - StandardPass::RegisterDefaultPass(0, - &DefaultStandardPasses::InlinerPlaceholderID , 0, - StandardPass::Module); - // Remove dead EH info - DEFAULT_MODULE_PASS(PruneEH, StandardPass::OptimizationFlags(0, 0, - StandardPass::UnitAtATime | StandardPass::HaveExceptions)); - // Set readonly/readnone attrs - DEFAULT_MODULE_PASS(FunctionAttrs, StandardPass::OptimizationFlags(0, 0, - StandardPass::UnitAtATime)); - // Scalarize uninlined fn args - DEFAULT_MODULE_PASS(ArgumentPromotion, 2); - // Start of function pass. - // Break up aggregate allocas, using SSAUpdater. - StandardPass::RegisterDefaultPass( - PassInfo::NormalCtor_t(createDefaultScalarReplAggregatesPass), - &DefaultStandardPasses::ScalarReplAggregatesID, 0, - StandardPass::Module); - // Catch trivial redundancies - DEFAULT_MODULE_PASS(EarlyCSE, 0); - // Library Call Optimizations - DEFAULT_MODULE_PASS(SimplifyLibCalls, StandardPass::SimplifyLibCalls); - // Thread jumps - DEFAULT_MODULE_PASS(JumpThreading, 0); - // Propagate conditionals - DEFAULT_MODULE_PASS(CorrelatedValuePropagation, 0); - // Merge & remove BBs - DEFAULT_MODULE_PASS(CFGSimplification, 0); - // Combine silly seq's - DEFAULT_MODULE_PASS(InstructionCombining, 0); - // Eliminate tail calls - DEFAULT_MODULE_PASS(TailCallElimination, 0); - // Merge & remove BBs - DEFAULT_MODULE_PASS(CFGSimplification, 0); - // Reassociate expressions - DEFAULT_MODULE_PASS(Reassociate, 0); - // Rotate Loop - DEFAULT_MODULE_PASS(LoopRotate, 0); - // Hoist loop invariants - DEFAULT_MODULE_PASS(LICM, 0); - // Optimize for size if the optimzation level is 0-2 - StandardPass::RegisterDefaultPass( - PassInfo::NormalCtor_t(createSizeOptimizingLoopUnswitchPass), - &DefaultStandardPasses::LoopUnswitchID, 0, - StandardPass::Module, - StandardPass::OptimizationFlags(0, 2)); - // Optimize for size if the optimzation level is >2, and OptimizeSize is - // set - StandardPass::RegisterDefaultPass( - PassInfo::NormalCtor_t(createSizeOptimizingLoopUnswitchPass), - &DefaultStandardPasses::LoopUnswitchID, 0, - StandardPass::Module, - StandardPass::OptimizationFlags(0, 3, StandardPass::OptimizeSize)); - // Don't optimize for size if optimisation level is >2 and OptimizeSize - // is not set - StandardPass::RegisterDefaultPass( - PassInfo::NormalCtor_t(createSizeOptimizingLoopUnswitchPass), - &DefaultStandardPasses::LoopUnswitchID, 0, - StandardPass::Module, - StandardPass::OptimizationFlags(0, 3, 0, StandardPass::OptimizeSize)); - DEFAULT_MODULE_PASS(InstructionCombining, 0); - // Canonicalize indvars - DEFAULT_MODULE_PASS(IndVarSimplify, 0); - // Recognize idioms like memset. - DEFAULT_MODULE_PASS(LoopIdiom, 0); - // Delete dead loops - DEFAULT_MODULE_PASS(LoopDeletion, 0); - // Unroll small loops - DEFAULT_MODULE_PASS(LoopUnroll, StandardPass::UnrollLoops); - // Remove redundancies - DEFAULT_MODULE_PASS(GVN, 2); - // Remove memcpy / form memset - DEFAULT_MODULE_PASS(MemCpyOpt, 0); - // Constant prop with SCCP - DEFAULT_MODULE_PASS(SCCP, 0); - - // Run instcombine after redundancy elimination to exploit opportunities - // opened up by them. - DEFAULT_MODULE_PASS(InstructionCombining, 0); - // Thread jumps - DEFAULT_MODULE_PASS(JumpThreading, 0); - DEFAULT_MODULE_PASS(CorrelatedValuePropagation, 0); - // Delete dead stores - DEFAULT_MODULE_PASS(DeadStoreElimination, 0); - // Delete dead instructions - DEFAULT_MODULE_PASS(AggressiveDCE, 0); - // Merge & remove BBs - DEFAULT_MODULE_PASS(CFGSimplification, 0); - // Clean up after everything. - DEFAULT_MODULE_PASS(InstructionCombining, 0); - - // Get rid of dead prototypes - DEFAULT_MODULE_PASS(StripDeadPrototypes, StandardPass::UnitAtATime); - // Eliminate dead types - DEFAULT_MODULE_PASS(DeadTypeElimination, StandardPass::UnitAtATime); - - // GlobalOpt already deletes dead functions and globals, at -O3 try a - // late pass of GlobalDCE. It is capable of deleting dead cycles. - // Remove dead fns and globals. - DEFAULT_MODULE_PASS(GlobalDCE, 3 | StandardPass::UnitAtATime); - // Merge dup global constants - DEFAULT_MODULE_PASS(ConstantMerge, 2 | StandardPass::UnitAtATime); -#undef DEFAULT_MODULE_PASS - -#define DEFAULT_LTO_PASS(pass, flags)\ - StandardPass::RegisterDefaultPass(\ - PassInfo::NormalCtor_t(create ## pass ## Pass),\ - &DefaultStandardPasses::pass ## ID, 0, StandardPass::LTO, flags) - - // LTO passes - - // Propagate constants at call sites into the functions they call. This - // opens opportunities for globalopt (and inlining) by substituting - // function pointers passed as arguments to direct uses of functions. - DEFAULT_LTO_PASS(IPSCCP, 0); - - // Now that we internalized some globals, see if we can hack on them! - DEFAULT_LTO_PASS(GlobalOptimizer, 0); - - // Linking modules together can lead to duplicated global constants, only - // keep one copy of each constant... - DEFAULT_LTO_PASS(ConstantMerge, 0); - - // Remove unused arguments from functions... - DEFAULT_LTO_PASS(DeadArgElimination, 0); - - // Reduce the code after globalopt and ipsccp. Both can open up - // significant simplification opportunities, and both can propagate - // functions through function pointers. When this happens, we often have - // to resolve varargs calls, etc, so let instcombine do this. - DEFAULT_LTO_PASS(InstructionCombining, 0); - - // Inline small functions - DEFAULT_LTO_PASS(FunctionInlining, - StandardPass::OptimizationFlags(0, 0xf, StandardPass::RunInliner)); - // Remove dead EH info. - DEFAULT_LTO_PASS(PruneEH, 0); - // Optimize globals again if we ran the inliner. - DEFAULT_LTO_PASS(GlobalOptimizer, - StandardPass::OptimizationFlags(0, 0xf, StandardPass::RunInliner)); - DEFAULT_LTO_PASS(GlobalDCE, 0); - - // If we didn't decide to inline a function, check to see if we can - // transform it to pass arguments by value instead of by reference. - DEFAULT_LTO_PASS(ArgumentPromotion, 0); - - // The IPO passes may leave cruft around. Clean up after them. - DEFAULT_LTO_PASS(InstructionCombining, 0); - DEFAULT_LTO_PASS(JumpThreading, 0); - // Break up allocas - DEFAULT_LTO_PASS(ScalarReplAggregates, 0); - - // Run a few AA driven optimizations here and now, to cleanup the code. - // Add nocapture. - DEFAULT_LTO_PASS(FunctionAttrs, 0); - // IP alias analysis. - DEFAULT_LTO_PASS(GlobalsModRef, 0); - - // Hoist loop invariants. - DEFAULT_LTO_PASS(LICM, 0); - // Remove redundancies. - DEFAULT_LTO_PASS(GVN, 0); - // Remove dead memcpys. - DEFAULT_LTO_PASS(MemCpyOpt, 0); - // Nuke dead stores. - DEFAULT_LTO_PASS(DeadStoreElimination, 0); - - // Cleanup and simplify the code after the scalar optimizations. - DEFAULT_LTO_PASS(InstructionCombining, 0); - - DEFAULT_LTO_PASS(JumpThreading, 0); - - // Delete basic blocks, which optimization passes may have killed. - DEFAULT_LTO_PASS(CFGSimplification, 0); - - // Now that we have optimized the program, discard unreachable functions. - DEFAULT_LTO_PASS(GlobalDCE, 0); -#undef DEFAULT_LTO_PASS - } - }; - static RegisterStandardPassLists AutoRegister; - - static inline void createStandardAliasAnalysisPasses(PassManagerBase *PM) { - StandardPass::AddPassesFromSet(PM, StandardPass::AliasAnalysis); + // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that + // BasicAliasAnalysis wins if they disagree. This is intended to help + // support "obvious" type-punning idioms. + PM->add(createTypeBasedAliasAnalysisPass()); + PM->add(createBasicAliasAnalysisPass()); } /// createStandardFunctionPasses - Add the standard list of function passes to @@ -290,7 +42,12 @@ /// -O1, etc. static inline void createStandardFunctionPasses(PassManagerBase *PM, unsigned OptimizationLevel) { - StandardPass::AddPassesFromSet(PM, StandardPass::Function, OptimizationLevel); + if (OptimizationLevel > 0) { + createStandardAliasAnalysisPasses(PM); + PM->add(createCFGSimplificationPass()); + PM->add(createScalarReplAggregatesPass()); + PM->add(createEarlyCSEPass()); + } } /// createStandardModulePasses - Add the standard list of module passes to the @@ -321,16 +78,84 @@ PM->add(InliningPass); return; } + + if (UnitAtATime) { + PM->add(createGlobalOptimizerPass()); // Optimize out global vars + + PM->add(createIPSCCPPass()); // IP SCCP + PM->add(createDeadArgEliminationPass()); // Dead argument elimination + + PM->add(createInstructionCombiningPass());// Clean up after IPCP & DAE + PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE + } + + // Start of CallGraph SCC passes. + if (UnitAtATime && HaveExceptions) + PM->add(createPruneEHPass()); // Remove dead EH info + if (InliningPass) + PM->add(InliningPass); + if (UnitAtATime) + PM->add(createFunctionAttrsPass()); // Set readonly/readnone attrs + if (OptimizationLevel > 2) + PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args + + // Start of function pass. + // Break up aggregate allocas, using SSAUpdater. + PM->add(createScalarReplAggregatesPass(-1, false)); + PM->add(createEarlyCSEPass()); // Catch trivial redundancies + if (SimplifyLibCalls) + PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations + PM->add(createJumpThreadingPass()); // Thread jumps. + PM->add(createCorrelatedValuePropagationPass()); // Propagate conditionals + PM->add(createCFGSimplificationPass()); // Merge & remove BBs + PM->add(createInstructionCombiningPass()); // Combine silly seq's + + PM->add(createTailCallEliminationPass()); // Eliminate tail calls + PM->add(createCFGSimplificationPass()); // Merge & remove BBs + PM->add(createReassociatePass()); // Reassociate expressions + PM->add(createLoopRotatePass()); // Rotate Loop + PM->add(createLICMPass()); // Hoist loop invariants + PM->add(createLoopUnswitchPass(OptimizeSize || OptimizationLevel < 3)); + PM->add(createInstructionCombiningPass()); + PM->add(createIndVarSimplifyPass()); // Canonicalize indvars + PM->add(createLoopIdiomPass()); // Recognize idioms like memset. + PM->add(createLoopDeletionPass()); // Delete dead loops + if (UnrollLoops) + PM->add(createLoopUnrollPass()); // Unroll small loops + if (OptimizationLevel > 1) + PM->add(createGVNPass()); // Remove redundancies + PM->add(createMemCpyOptPass()); // Remove memcpy / form memset + PM->add(createSCCPPass()); // Constant prop with SCCP + + // Run instcombine after redundancy elimination to exploit opportunities + // opened up by them. + PM->add(createInstructionCombiningPass()); + PM->add(createJumpThreadingPass()); // Thread jumps + PM->add(createCorrelatedValuePropagationPass()); + PM->add(createDeadStoreEliminationPass()); // Delete dead stores + PM->add(createAggressiveDCEPass()); // Delete dead instructions + PM->add(createCFGSimplificationPass()); // Merge & remove BBs + PM->add(createInstructionCombiningPass()); // Clean up after everything. + + if (UnitAtATime) { + PM->add(createStripDeadPrototypesPass()); // Get rid of dead prototypes + PM->add(createDeadTypeEliminationPass()); // Eliminate dead types - StandardPass::AddPassesFromSet(PM, StandardPass::Module, - StandardPass::OptimizationFlags(OptimizationLevel, - (OptimizeSize ? StandardPass::OptimizeSize : 0) | - (UnitAtATime ? StandardPass::UnitAtATime : 0) | - (UnrollLoops ? StandardPass::UnrollLoops : 0) | - (SimplifyLibCalls ? StandardPass::SimplifyLibCalls : 0) | - (HaveExceptions ? StandardPass::HaveExceptions : 0)), - InliningPass); + // GlobalOpt already deletes dead functions and globals, at -O3 try a + // late pass of GlobalDCE. It is capable of deleting dead cycles. + if (OptimizationLevel > 2) + PM->add(createGlobalDCEPass()); // Remove dead fns and globals. + if (OptimizationLevel > 1) + PM->add(createConstantMergePass()); // Merge dup global constants + } + } + + static inline void addOnePass(PassManagerBase *PM, Pass *P, bool AndVerify) { + PM->add(P); + + if (AndVerify) + PM->add(createVerifierPass()); } /// createStandardLTOPasses - Add the standard list of module passes suitable @@ -349,15 +174,70 @@ // Now that composite has been compiled, scan through the module, looking // for a main function. If main is defined, mark all other functions // internal. - if (Internalize) { - PM->add(createInternalizePass(true)); - if (VerifyEach) - PM->add(createVerifierPass()); - } + if (Internalize) + addOnePass(PM, createInternalizePass(true), VerifyEach); + + // Propagate constants at call sites into the functions they call. This + // opens opportunities for globalopt (and inlining) by substituting function + // pointers passed as arguments to direct uses of functions. + addOnePass(PM, createIPSCCPPass(), VerifyEach); + + // Now that we internalized some globals, see if we can hack on them! + addOnePass(PM, createGlobalOptimizerPass(), VerifyEach); + + // Linking modules together can lead to duplicated global constants, only + // keep one copy of each constant... + addOnePass(PM, createConstantMergePass(), VerifyEach); + + // Remove unused arguments from functions... + addOnePass(PM, createDeadArgEliminationPass(), VerifyEach); + + // Reduce the code after globalopt and ipsccp. Both can open up significant + // simplification opportunities, and both can propagate functions through + // function pointers. When this happens, we often have to resolve varargs + // calls, etc, so let instcombine do this. + addOnePass(PM, createInstructionCombiningPass(), VerifyEach); + + // Inline small functions + if (RunInliner) + addOnePass(PM, createFunctionInliningPass(), VerifyEach); + + addOnePass(PM, createPruneEHPass(), VerifyEach); // Remove dead EH info. + // Optimize globals again if we ran the inliner. + if (RunInliner) + addOnePass(PM, createGlobalOptimizerPass(), VerifyEach); + addOnePass(PM, createGlobalDCEPass(), VerifyEach); // Remove dead functions. + + // If we didn't decide to inline a function, check to see if we can + // transform it to pass arguments by value instead of by reference. + addOnePass(PM, createArgumentPromotionPass(), VerifyEach); + + // The IPO passes may leave cruft around. Clean up after them. + addOnePass(PM, createInstructionCombiningPass(), VerifyEach); + addOnePass(PM, createJumpThreadingPass(), VerifyEach); + // Break up allocas + addOnePass(PM, createScalarReplAggregatesPass(), VerifyEach); + + // Run a few AA driven optimizations here and now, to cleanup the code. + addOnePass(PM, createFunctionAttrsPass(), VerifyEach); // Add nocapture. + addOnePass(PM, createGlobalsModRefPass(), VerifyEach); // IP alias analysis. + + addOnePass(PM, createLICMPass(), VerifyEach); // Hoist loop invariants. + addOnePass(PM, createGVNPass(), VerifyEach); // Remove redundancies. + addOnePass(PM, createMemCpyOptPass(), VerifyEach); // Remove dead memcpys. + // Nuke dead stores. + addOnePass(PM, createDeadStoreEliminationPass(), VerifyEach); + + // Cleanup and simplify the code after the scalar optimizations. + addOnePass(PM, createInstructionCombiningPass(), VerifyEach); + + addOnePass(PM, createJumpThreadingPass(), VerifyEach); + + // Delete basic blocks, which optimization passes may have killed. + addOnePass(PM, createCFGSimplificationPass(), VerifyEach); - StandardPass::AddPassesFromSet(PM, StandardPass::LTO, - StandardPass::OptimizationFlags(0, 0, RunInliner ? - StandardPass::RunInliner : 0), VerifyEach); + // Now that we have optimized the program, discard unreachable functions. + addOnePass(PM, createGlobalDCEPass(), VerifyEach); } } Modified: llvm/trunk/lib/VMCore/StandardPasses.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/StandardPasses.cpp?rev=131159&r1=131158&r2=131159&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/StandardPasses.cpp (original) +++ llvm/trunk/lib/VMCore/StandardPasses.cpp Tue May 10 17:16:06 2011 @@ -1,240 +0,0 @@ -//=========-- StandardPasses.cpp - Standard pass lists -----*- C++ -*-=======// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines utility functions for creating a "standard" set of -// optimization passes, so that compilers and tools which use optimization -// passes use the same set of standard passes. -// -//===----------------------------------------------------------------------===// - -#include "llvm/PassManager.h" -#include "llvm/Analysis/Passes.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Mutex.h" -#include "llvm/Support/DynamicLibrary.h" -#include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/IPO.h" - - -using namespace llvm::DefaultStandardPasses; -using namespace llvm; - -namespace { - -/// Entry in the standard passes list. -struct StandardPassEntry { - /// Function called to create the pass - PassInfo::NormalCtor_t createPass; - /// Unique identifier for this pass - unsigned char *passID; - /// Flags specifying when this pass should be run - unsigned flags; - - StandardPassEntry(PassInfo::NormalCtor_t constructor, unsigned char *ID, - unsigned f) : createPass(constructor), passID(ID), flags(f) {}; -}; - -/// Standard alias analysis passes -static llvm::SmallVector AAPasses; -/// Standard function passes -static llvm::SmallVector FunctionPasses; -/// Standard module passes -static llvm::SmallVector ModulePasses; -/// Standard link-time optimization passes -static llvm::SmallVector LTOPasses; - -/// Entry in the unresolved standard pass list. IF a pass is inserted in front -/// of a pass that is not yet registered in the standard pass list then it is -/// stored in a separate list and resolved later. -struct UnresolvedStandardPass : public StandardPassEntry { - /// The set into which this is stored - StandardPass::StandardSet set; - /// The unique ID of the pass that should follow this one in the sequence - unsigned char *next; - UnresolvedStandardPass(PassInfo::NormalCtor_t constructor, - unsigned char *newPass, - unsigned char *oldPass, - StandardPass::StandardSet s, - unsigned f) - : StandardPassEntry(constructor, newPass, f), set(s), next(oldPass) {} -}; - -/// The passes that can not be inserted into the correct lists yet because of -/// their place in the sequence. -static llvm::SmallVector UnresolvedPasses; - -/// Returns a reference to the pass list for the corresponding set of -/// optimisations. -llvm::SmallVectorImpl& -PassList(StandardPass::StandardSet set) { - switch (set) { - case StandardPass::AliasAnalysis: return AAPasses; - case StandardPass::Function: return FunctionPasses; - case StandardPass::Module: return ModulePasses; - case StandardPass::LTO: return LTOPasses; - } - // We could use a map of standard pass lists to allow definition of new - // default sets - llvm_unreachable("Invalid standard optimization set requested"); -} - -static ManagedStatic > Lock; - -/// Registers the default set of standard passes. This is called lazily when -/// an attempt is made to read or modify the standard pass list -void RegisterDefaultStandardPasses(void(*doRegister)(void)) { - // Only initialize the standard passes once - static bool initialized = false; - if (initialized) return; - - llvm::sys::SmartScopedLock Guard(*Lock); - if (initialized) return; - if (doRegister) { - // We must set initialized to true before calling this function, because - // the doRegister() function will probably call RegisterDefaultPasses(), - // which will call this function, and we'd end up with infinite recursion - // and breakage if we didn't. - initialized = true; - doRegister(); - } -} - -} // Anonymous namespace - -void (*StandardPass::RegisterDefaultPasses)(void); - -void StandardPass::RegisterDefaultPass(PassInfo::NormalCtor_t constructor, - unsigned char *newPass, - unsigned char *oldPass, - StandardPass::StandardSet set, - unsigned flags) { - // Make sure that the standard sets are already regstered - RegisterDefaultStandardPasses(RegisterDefaultPasses); - // Get the correct list to modify - llvm::SmallVectorImpl &passList = PassList(set); - - // If there is no old pass specified, then we are adding a new final pass, so - // just push it onto the end. - if (!oldPass) { - StandardPassEntry pass(constructor, newPass, flags); - passList.push_back(pass); - return; - } - - // Find the correct place to insert the pass. This is a linear search, but - // this shouldn't be too slow since the SmallVector will store the values in - // a contiguous block of memory. Each entry is just three words of memory, so - // in most cases we are only going to be looking in one or two cache lines. - // The extra memory accesses from a more complex search structure would - // offset any performance gain (unless someone decides to - for (SmallVectorImpl::iterator i = passList.begin(), - e=passList.end(); i != e; ++i) { - if (i->passID == oldPass) { - StandardPassEntry pass(constructor, newPass, flags); - passList.insert(i, pass); - // If we've added a new pass, then there may have gained the ability to - // insert one of the previously unresolved ones. If so, insert the new - // one. - for (SmallVectorImpl::iterator - u = UnresolvedPasses.begin(), eu = UnresolvedPasses.end(); - u!=eu; ++u){ - if (u->next == newPass && u->set == set) { - UnresolvedStandardPass p = *u; - UnresolvedPasses.erase(u); - RegisterDefaultPass(p.createPass, p.passID, p.next, p.set, p.flags); - } - } - return; - } - } - // If we get to here, then we didn't find the correct place to insert the new - // pass - UnresolvedStandardPass pass(constructor, newPass, oldPass, set, flags); - UnresolvedPasses.push_back(pass); -} - -void StandardPass::AddPassesFromSet(PassManagerBase *PM, - StandardSet set, - unsigned flags, - bool VerifyEach, - Pass *inliner) { - RegisterDefaultStandardPasses(RegisterDefaultPasses); - unsigned level = OptimizationLevel(flags); - flags = RequiredFlags(flags); - llvm::SmallVectorImpl& passList = PassList(set); - // Add all of the passes from this set - for (SmallVectorImpl::iterator i = passList.begin(), - e=passList.end(); i != e ; ++i) { - // Skip passes that don't have conditions that match the ones specified - // here. For a pass to match: - // - Its minimum optimisation level must be less than or equal to the - // specified level. - // - Its maximum optimisation level must be greater than or equal to the - // specified level - // - All of its required flags must be set - // - None of its disallowed flags may be set - if ((level >= OptimizationLevel(i->flags)) && - ((level <= MaxOptimizationLevel(i->flags)) - || MaxOptimizationLevel(i->flags) == 0) && - ((RequiredFlags(i->flags) & flags) == RequiredFlags(i->flags)) && - ((DisallowedFlags(i->flags) & flags) == 0)) { - // This is quite an ugly way of allowing us to specify an inliner pass to - // insert. Ideally, we'd replace this with a general mechanism allowing - // callers to replace arbitrary passes in the list. - Pass *p = inliner; - if ((&InlinerPlaceholderID != i->passID) && i->createPass) - p = i->createPass(); - if (p) { - PM->add(p); - if (VerifyEach) - PM->add(createVerifierPass()); - } - } - } -} - -unsigned char DefaultStandardPasses::AggressiveDCEID; -unsigned char DefaultStandardPasses::ArgumentPromotionID; -unsigned char DefaultStandardPasses::BasicAliasAnalysisID; -unsigned char DefaultStandardPasses::CFGSimplificationID; -unsigned char DefaultStandardPasses::ConstantMergeID; -unsigned char DefaultStandardPasses::CorrelatedValuePropagationID; -unsigned char DefaultStandardPasses::DeadArgEliminationID; -unsigned char DefaultStandardPasses::DeadStoreEliminationID; -unsigned char DefaultStandardPasses::DeadTypeEliminationID; -unsigned char DefaultStandardPasses::EarlyCSEID; -unsigned char DefaultStandardPasses::FunctionAttrsID; -unsigned char DefaultStandardPasses::FunctionInliningID; -unsigned char DefaultStandardPasses::GVNID; -unsigned char DefaultStandardPasses::GlobalDCEID; -unsigned char DefaultStandardPasses::GlobalOptimizerID; -unsigned char DefaultStandardPasses::GlobalsModRefID; -unsigned char DefaultStandardPasses::IPSCCPID; -unsigned char DefaultStandardPasses::IndVarSimplifyID; -unsigned char DefaultStandardPasses::InlinerPlaceholderID; -unsigned char DefaultStandardPasses::InstructionCombiningID; -unsigned char DefaultStandardPasses::JumpThreadingID; -unsigned char DefaultStandardPasses::LICMID; -unsigned char DefaultStandardPasses::LoopDeletionID; -unsigned char DefaultStandardPasses::LoopIdiomID; -unsigned char DefaultStandardPasses::LoopRotateID; -unsigned char DefaultStandardPasses::LoopUnrollID; -unsigned char DefaultStandardPasses::LoopUnswitchID; -unsigned char DefaultStandardPasses::MemCpyOptID; -unsigned char DefaultStandardPasses::PruneEHID; -unsigned char DefaultStandardPasses::ReassociateID; -unsigned char DefaultStandardPasses::SCCPID; -unsigned char DefaultStandardPasses::ScalarReplAggregatesID; -unsigned char DefaultStandardPasses::SimplifyLibCallsID; -unsigned char DefaultStandardPasses::StripDeadPrototypesID; -unsigned char DefaultStandardPasses::TailCallEliminationID; -unsigned char DefaultStandardPasses::TypeBasedAliasAnalysisID; From rafael.espindola at gmail.com Tue May 10 17:19:33 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 22:19:33 -0000 Subject: [llvm-commits] [llvm] r131160 - /llvm/trunk/lib/VMCore/CMakeLists.txt Message-ID: <20110510221933.881402A6C12C@llvm.org> Author: rafael Date: Tue May 10 17:19:33 2011 New Revision: 131160 URL: http://llvm.org/viewvc/llvm-project?rev=131160&view=rev Log: Fix cmake build. Modified: llvm/trunk/lib/VMCore/CMakeLists.txt Modified: llvm/trunk/lib/VMCore/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/CMakeLists.txt?rev=131160&r1=131159&r2=131160&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/CMakeLists.txt (original) +++ llvm/trunk/lib/VMCore/CMakeLists.txt Tue May 10 17:19:33 2011 @@ -28,6 +28,7 @@ PassManager.cpp PassRegistry.cpp PrintModulePass.cpp + StandardPasses.cpp Type.cpp TypeSymbolTable.cpp Use.cpp From nlewycky at google.com Tue May 10 17:30:23 2011 From: nlewycky at google.com (Nick Lewycky) Date: Tue, 10 May 2011 15:30:23 -0700 Subject: [llvm-commits] [llvm] r131155 - in /llvm/trunk: include/llvm/PassSupport.h include/llvm/Support/StandardPasses.h lib/VMCore/StandardPasses.cpp In-Reply-To: <20110510213648.3D39B2A6C12C@llvm.org> References: <20110510213648.3D39B2A6C12C@llvm.org> Message-ID: Sorry, but I had to back this out. The reason this functionality hasn't happened so far is that it's tricky. :-) This broke our build because it introduces a new dependency from VMCore on the headers of Analysis and Transforms. Unfortunately, it can't go into Support either since that can't depend on Analysis or Transforms either. I'm not sure how to fix this, but now you have another requirement on your design! Nick On 10 May 2011 14:36, David Chisnall wrote: > Author: theraven > Date: Tue May 10 16:36:48 2011 > New Revision: 131155 > > URL: http://llvm.org/viewvc/llvm-project?rev=131155&view=rev > Log: > Add support for plugins add passes to the default set of passes. The > standard set of passes used by front ends can now be modified by LLVM > plugins, without needing to modify any front ends. > > Still to do: > > - Allow replacing / removing passes (infrastructure there, just needs an > infrastructure exposed) > - Defining sets of passes to be added or removed as a group > - Extending the support to allow user-defined groups of optimisations > - Allow plugins to be specified for loading automatically (e.g. from > plugins.conf or some similar mechanism) > > Reviewed by Nick Lewycky. > > > Added: > llvm/trunk/lib/VMCore/StandardPasses.cpp > Modified: > llvm/trunk/include/llvm/PassSupport.h > llvm/trunk/include/llvm/Support/StandardPasses.h > > Modified: llvm/trunk/include/llvm/PassSupport.h > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassSupport.h?rev=131155&r1=131154&r2=131155&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/PassSupport.h (original) > +++ llvm/trunk/include/llvm/PassSupport.h Tue May 10 16:36:48 2011 > @@ -29,6 +29,8 @@ > > namespace llvm { > > + class PassManagerBase; > + > > //===--------------------------------------------------------------------------- > /// PassInfo class - An instance of this class exists for every pass known > by > /// the system, and can be obtained from a live Pass by calling its > @@ -207,6 +209,149 @@ > } > }; > > + /// Unique identifiers for the default standard passes. The addresses > of > + /// these symbols are used to uniquely identify passes from the default > list. > + namespace DefaultStandardPasses { > + extern unsigned char AggressiveDCEID; > + extern unsigned char ArgumentPromotionID; > + extern unsigned char BasicAliasAnalysisID; > + extern unsigned char CFGSimplificationID; > + extern unsigned char ConstantMergeID; > + extern unsigned char CorrelatedValuePropagationID; > + extern unsigned char DeadArgEliminationID; > + extern unsigned char DeadStoreEliminationID; > + extern unsigned char DeadTypeEliminationID; > + extern unsigned char EarlyCSEID; > + extern unsigned char FunctionAttrsID; > + extern unsigned char FunctionInliningID; > + extern unsigned char GVNID; > + extern unsigned char GlobalDCEID; > + extern unsigned char GlobalOptimizerID; > + extern unsigned char GlobalsModRefID; > + extern unsigned char IPSCCPID; > + extern unsigned char IndVarSimplifyID; > + extern unsigned char InlinerPlaceholderID; > + extern unsigned char InstructionCombiningID; > + extern unsigned char JumpThreadingID; > + extern unsigned char LICMID; > + extern unsigned char LoopDeletionID; > + extern unsigned char LoopIdiomID; > + extern unsigned char LoopRotateID; > + extern unsigned char LoopUnrollID; > + extern unsigned char LoopUnswitchID; > + extern unsigned char MemCpyOptID; > + extern unsigned char PruneEHID; > + extern unsigned char ReassociateID; > + extern unsigned char SCCPID; > + extern unsigned char ScalarReplAggregatesID; > + extern unsigned char SimplifyLibCallsID; > + extern unsigned char StripDeadPrototypesID; > + extern unsigned char TailCallEliminationID; > + extern unsigned char TypeBasedAliasAnalysisID; > + } > + > + > +class RegisterStandardPass; > +/// RegisterStandardPass - Registers a pass as a member of a standard set. > +class StandardPass { > + friend class RegisterStandardPassLists; > + public: > + /// Predefined standard sets of passes > + enum StandardSet { > + AliasAnalysis, > + Function, > + Module, > + LTO > + }; > + /// Flags to specify whether a pass should be enabled. Passes > registered > + /// with the standard sets may specify a minimum optimization level and > one > + /// or more flags that must be set when constructing the set for the > pass to > + /// be used. > + enum OptimizationFlags { > + /// Optimize for size was requested. > + OptimizeSize = 1<<0, > + /// Allow passes which may make global module changes. > + UnitAtATime = 1<<1, > + /// UnrollLoops - Allow loop unrolling. > + UnrollLoops = 1<<2, > + /// Allow library calls to be simplified. > + SimplifyLibCalls = 1<<3, > + /// Whether the module may have code using exceptions. > + HaveExceptions = 1<<4, > + // Run an inliner pass as part of this set. > + RunInliner = 1<<5 > + }; > + enum OptimizationFlagComponents { > + /// The low bits are used to store the optimization level. When > requesting > + /// passes, this should store the requested optimisation level. When > + /// setting passes, this should set the minimum optimization level at > which > + /// the pass will run. > + OptimizationLevelMask = 0xf, > + /// The maximum optimisation level at which the pass is run. > + MaxOptimizationLevelMask = 0xf0, > + // Flags that must be set > + RequiredFlagMask = 0xff00, > + // Flags that may not be set. > + DisallowedFlagMask = 0xff0000, > + MaxOptimizationLevelShift = 4, > + RequiredFlagShift = 8, > + DisallowedFlagShift = 16 > + }; > + /// Returns the optimisation level from a set of flags. > + static unsigned OptimizationLevel(unsigned flags) { > + return flags & OptimizationLevelMask; > + } > + /// Returns the maximum optimization level for this set of flags > + static unsigned MaxOptimizationLevel(unsigned flags) { > + return (flags & MaxOptimizationLevelMask) >> 4; > + } > + /// Constructs a set of flags from the specified minimum and maximum > + /// optimisation level > + static unsigned OptimizationFlags(unsigned minLevel=0, unsigned > maxLevel=0xf, > + unsigned requiredFlags=0, > + unsigned disallowedFlags=0) { > + return ((minLevel & OptimizationLevelMask) | > + ((maxLevel< MaxOptimizationLevelMask) > + | ((requiredFlags< + | ((disallowedFlags< DisallowedFlagMask)); > + } > + /// Returns the flags that must be set for this to match > + static unsigned RequiredFlags(unsigned flags) { > + return (flags & RequiredFlagMask) >> RequiredFlagShift; > + } > + /// Returns the flags that must not be set for this to match > + static unsigned DisallowedFlags(unsigned flags) { > + return (flags & DisallowedFlagMask) >> RequiredFlagShift; > + } > + /// Register a standard pass in the specified set. If flags is > non-zero, > + /// then the pass will only be returned when the specified flags are > set. > + template > + class RegisterStandardPass { > + RegisterStandardPass(StandardSet set, unsigned char *runBefore=0, > + unsigned flags=0, unsigned char *ID=0) { > + // Use the pass's ID if one is not specified > + > RegisterDefaultPass(PassInfo::NormalCtor_t(callDefaultCtor), > + ID ? ID : &passName::ID, runBefore, set, flags); > + }; > + }; > + /// Adds the passes from the specified set to a pass manager. > + static void AddPassesFromSet(PassManagerBase *PM, > + StandardSet Set, > + unsigned Flags=0, > + bool VerifyEach=false, > + Pass *Inliner=0); > + private: > + /// Registers the default passes. This is set by > RegisterStandardPassLists > + /// and is called lazily. > + static void (*RegisterDefaultPasses)(void); > + /// Registers the pass > + static void RegisterDefaultPass(PassInfo::NormalCtor_t constructor, > + unsigned char *newPass, > + unsigned char *oldPass, > + StandardSet set, > + unsigned flags=0); > +}; > + > > /// RegisterAnalysisGroup - Register a Pass as a member of an analysis > _group_. > /// Analysis groups are used to define an interface (which need not derive > from > > Modified: llvm/trunk/include/llvm/Support/StandardPasses.h > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=131155&r1=131154&r2=131155&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) > +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue May 10 16:36:48 > 2011 > @@ -20,6 +20,7 @@ > #define LLVM_SUPPORT_STANDARDPASSES_H > > #include "llvm/PassManager.h" > +#include "llvm/PassSupport.h" > #include "llvm/Analysis/Passes.h" > #include "llvm/Analysis/Verifier.h" > #include "llvm/Transforms/Scalar.h" > @@ -27,12 +28,259 @@ > > namespace llvm { > > + /// RegisterStandardPassLists solves a circular dependency problem. The > + /// default list of passes has to live somewhere. It can't live in the > core > + /// modules, because these don't link to the libraries that actually > define > + /// the passes. It's in this header, so that a copy is created in every > + /// library that requests the default set, while still allowing plugins > to > + /// register new passes without requiring them to link anything more > than > + /// VMCore. > + class RegisterStandardPassLists { > + public: > + RegisterStandardPassLists() { > + StandardPass::RegisterDefaultPasses = RegisterStandardPassList; > + } > + private: > + /// Passes must be registered with functions that take no arguments, > so we > + /// have to wrap their existing constructors. > + static Pass *createDefaultScalarReplAggregatesPass(void) { > + return createScalarReplAggregatesPass(-1, false); > + } > + static Pass *createDefaultLoopUnswitchPass(void) { > + return createLoopUnswitchPass(false); > + } > + static Pass *createSizeOptimizingLoopUnswitchPass(void) { > + return createLoopUnswitchPass(true); > + } > + static void RegisterStandardPassList(void) { > + // Standard alias analysis passes > + > + // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that > + // BasicAliasAnalysis wins if they disagree. This is intended to > help > + // support "obvious" type-punning idioms. > +#define DEFAULT_ALIAS_ANALYSIS_PASS(pass, flags)\ > + StandardPass::RegisterDefaultPass(\ > + PassInfo::NormalCtor_t(create ## pass ## Pass),\ > + &DefaultStandardPasses::pass ## ID, 0, StandardPass::AliasAnalysis, > flags) > + DEFAULT_ALIAS_ANALYSIS_PASS(BasicAliasAnalysis, 0); > + DEFAULT_ALIAS_ANALYSIS_PASS(TypeBasedAliasAnalysis, 0); > +#undef DEFAULT_ALIAS_ANALYSIS_PASS > + > +#define DEFAULT_FUNCTION_PASS(pass, flags)\ > + StandardPass::RegisterDefaultPass(\ > + PassInfo::NormalCtor_t(create ## pass ## Pass),\ > + &DefaultStandardPasses::pass ## ID, 0, StandardPass::Function, > flags) > + DEFAULT_FUNCTION_PASS(CFGSimplification, > + StandardPass::OptimizationFlags(1)); > + DEFAULT_FUNCTION_PASS(ScalarReplAggregates, > + StandardPass::OptimizationFlags(1)); > + DEFAULT_FUNCTION_PASS(EarlyCSE, StandardPass::OptimizationFlags(1)); > +#undef DEFAULT_FUNCTION_PASS > + > +#define DEFAULT_MODULE_PASS(pass, flags)\ > + StandardPass::RegisterDefaultPass(\ > + PassInfo::NormalCtor_t(create ## pass ## Pass),\ > + &DefaultStandardPasses::pass ## ID, 0, StandardPass::Module, flags) > + // Optimize out global vars > + DEFAULT_MODULE_PASS(GlobalOptimizer, StandardPass::UnitAtATime); > + // IP SCCP > + DEFAULT_MODULE_PASS(IPSCCP, > + StandardPass::OptimizationFlags(0, 0, > StandardPass::UnitAtATime)); > + // Dead argument elimination > + DEFAULT_MODULE_PASS(DeadArgElimination, > + StandardPass::OptimizationFlags(0, 0, > StandardPass::UnitAtATime)); > + // Clean up after IPCP & DAE > + DEFAULT_MODULE_PASS(InstructionCombining, > + StandardPass::OptimizationFlags(0, 0, > StandardPass::UnitAtATime)); > + // Clean up after IPCP & DAE > + DEFAULT_MODULE_PASS(CFGSimplification, > + StandardPass::OptimizationFlags(0, 0, > StandardPass::UnitAtATime)); > + > + // Placeholder that will be replaced by an inliner if one is > specified > + StandardPass::RegisterDefaultPass(0, > + &DefaultStandardPasses::InlinerPlaceholderID , 0, > + StandardPass::Module); > + // Remove dead EH info > + DEFAULT_MODULE_PASS(PruneEH, StandardPass::OptimizationFlags(0, 0, > + StandardPass::UnitAtATime | StandardPass::HaveExceptions)); > + // Set readonly/readnone attrs > + DEFAULT_MODULE_PASS(FunctionAttrs, > StandardPass::OptimizationFlags(0, 0, > + StandardPass::UnitAtATime)); > + // Scalarize uninlined fn args > + DEFAULT_MODULE_PASS(ArgumentPromotion, 2); > + // Start of function pass. > + // Break up aggregate allocas, using SSAUpdater. > + StandardPass::RegisterDefaultPass( > + PassInfo::NormalCtor_t(createDefaultScalarReplAggregatesPass), > + &DefaultStandardPasses::ScalarReplAggregatesID, 0, > + StandardPass::Module); > + // Catch trivial redundancies > + DEFAULT_MODULE_PASS(EarlyCSE, 0); > + // Library Call Optimizations > + DEFAULT_MODULE_PASS(SimplifyLibCalls, > StandardPass::SimplifyLibCalls); > + // Thread jumps > + DEFAULT_MODULE_PASS(JumpThreading, 0); > + // Propagate conditionals > + DEFAULT_MODULE_PASS(CorrelatedValuePropagation, 0); > + // Merge & remove BBs > + DEFAULT_MODULE_PASS(CFGSimplification, 0); > + // Combine silly seq's > + DEFAULT_MODULE_PASS(InstructionCombining, 0); > + // Eliminate tail calls > + DEFAULT_MODULE_PASS(TailCallElimination, 0); > + // Merge & remove BBs > + DEFAULT_MODULE_PASS(CFGSimplification, 0); > + // Reassociate expressions > + DEFAULT_MODULE_PASS(Reassociate, 0); > + // Rotate Loop > + DEFAULT_MODULE_PASS(LoopRotate, 0); > + // Hoist loop invariants > + DEFAULT_MODULE_PASS(LICM, 0); > + // Optimize for size if the optimzation level is 0-2 > + StandardPass::RegisterDefaultPass( > + PassInfo::NormalCtor_t(createSizeOptimizingLoopUnswitchPass), > + &DefaultStandardPasses::LoopUnswitchID, 0, > + StandardPass::Module, > + StandardPass::OptimizationFlags(0, 2)); > + // Optimize for size if the optimzation level is >2, and > OptimizeSize is > + // set > + StandardPass::RegisterDefaultPass( > + PassInfo::NormalCtor_t(createSizeOptimizingLoopUnswitchPass), > + &DefaultStandardPasses::LoopUnswitchID, 0, > + StandardPass::Module, > + StandardPass::OptimizationFlags(0, 3, > StandardPass::OptimizeSize)); > + // Don't optimize for size if optimisation level is >2 and > OptimizeSize > + // is not set > + StandardPass::RegisterDefaultPass( > + PassInfo::NormalCtor_t(createSizeOptimizingLoopUnswitchPass), > + &DefaultStandardPasses::LoopUnswitchID, 0, > + StandardPass::Module, > + StandardPass::OptimizationFlags(0, 3, 0, > StandardPass::OptimizeSize)); > + DEFAULT_MODULE_PASS(InstructionCombining, 0); > + // Canonicalize indvars > + DEFAULT_MODULE_PASS(IndVarSimplify, 0); > + // Recognize idioms like memset. > + DEFAULT_MODULE_PASS(LoopIdiom, 0); > + // Delete dead loops > + DEFAULT_MODULE_PASS(LoopDeletion, 0); > + // Unroll small loops > + DEFAULT_MODULE_PASS(LoopUnroll, StandardPass::UnrollLoops); > + // Remove redundancies > + DEFAULT_MODULE_PASS(GVN, 2); > + // Remove memcpy / form memset > + DEFAULT_MODULE_PASS(MemCpyOpt, 0); > + // Constant prop with SCCP > + DEFAULT_MODULE_PASS(SCCP, 0); > + > + // Run instcombine after redundancy elimination to exploit > opportunities > + // opened up by them. > + DEFAULT_MODULE_PASS(InstructionCombining, 0); > + // Thread jumps > + DEFAULT_MODULE_PASS(JumpThreading, 0); > + DEFAULT_MODULE_PASS(CorrelatedValuePropagation, 0); > + // Delete dead stores > + DEFAULT_MODULE_PASS(DeadStoreElimination, 0); > + // Delete dead instructions > + DEFAULT_MODULE_PASS(AggressiveDCE, 0); > + // Merge & remove BBs > + DEFAULT_MODULE_PASS(CFGSimplification, 0); > + // Clean up after everything. > + DEFAULT_MODULE_PASS(InstructionCombining, 0); > + > + // Get rid of dead prototypes > + DEFAULT_MODULE_PASS(StripDeadPrototypes, StandardPass::UnitAtATime); > + // Eliminate dead types > + DEFAULT_MODULE_PASS(DeadTypeElimination, StandardPass::UnitAtATime); > + > + // GlobalOpt already deletes dead functions and globals, at -O3 try > a > + // late pass of GlobalDCE. It is capable of deleting dead cycles. > + // Remove dead fns and globals. > + DEFAULT_MODULE_PASS(GlobalDCE, 3 | StandardPass::UnitAtATime); > + // Merge dup global constants > + DEFAULT_MODULE_PASS(ConstantMerge, 2 | StandardPass::UnitAtATime); > +#undef DEFAULT_MODULE_PASS > + > +#define DEFAULT_LTO_PASS(pass, flags)\ > + StandardPass::RegisterDefaultPass(\ > + PassInfo::NormalCtor_t(create ## pass ## Pass),\ > + &DefaultStandardPasses::pass ## ID, 0, StandardPass::LTO, flags) > + > + // LTO passes > + > + // Propagate constants at call sites into the functions they call. > This > + // opens opportunities for globalopt (and inlining) by substituting > + // function pointers passed as arguments to direct uses of > functions. > + DEFAULT_LTO_PASS(IPSCCP, 0); > + > + // Now that we internalized some globals, see if we can hack on > them! > + DEFAULT_LTO_PASS(GlobalOptimizer, 0); > + > + // Linking modules together can lead to duplicated global constants, > only > + // keep one copy of each constant... > + DEFAULT_LTO_PASS(ConstantMerge, 0); > + > + // Remove unused arguments from functions... > + DEFAULT_LTO_PASS(DeadArgElimination, 0); > + > + // Reduce the code after globalopt and ipsccp. Both can open up > + // significant simplification opportunities, and both can propagate > + // functions through function pointers. When this happens, we often > have > + // to resolve varargs calls, etc, so let instcombine do this. > + DEFAULT_LTO_PASS(InstructionCombining, 0); > + > + // Inline small functions > + DEFAULT_LTO_PASS(FunctionInlining, > + StandardPass::OptimizationFlags(0, 0xf, > StandardPass::RunInliner)); > + // Remove dead EH info. > + DEFAULT_LTO_PASS(PruneEH, 0); > + // Optimize globals again if we ran the inliner. > + DEFAULT_LTO_PASS(GlobalOptimizer, > + StandardPass::OptimizationFlags(0, 0xf, > StandardPass::RunInliner)); > + DEFAULT_LTO_PASS(GlobalDCE, 0); > + > + // If we didn't decide to inline a function, check to see if we can > + // transform it to pass arguments by value instead of by reference. > + DEFAULT_LTO_PASS(ArgumentPromotion, 0); > + > + // The IPO passes may leave cruft around. Clean up after them. > + DEFAULT_LTO_PASS(InstructionCombining, 0); > + DEFAULT_LTO_PASS(JumpThreading, 0); > + // Break up allocas > + DEFAULT_LTO_PASS(ScalarReplAggregates, 0); > + > + // Run a few AA driven optimizations here and now, to cleanup the > code. > + // Add nocapture. > + DEFAULT_LTO_PASS(FunctionAttrs, 0); > + // IP alias analysis. > + DEFAULT_LTO_PASS(GlobalsModRef, 0); > + > + // Hoist loop invariants. > + DEFAULT_LTO_PASS(LICM, 0); > + // Remove redundancies. > + DEFAULT_LTO_PASS(GVN, 0); > + // Remove dead memcpys. > + DEFAULT_LTO_PASS(MemCpyOpt, 0); > + // Nuke dead stores. > + DEFAULT_LTO_PASS(DeadStoreElimination, 0); > + > + // Cleanup and simplify the code after the scalar optimizations. > + DEFAULT_LTO_PASS(InstructionCombining, 0); > + > + DEFAULT_LTO_PASS(JumpThreading, 0); > + > + // Delete basic blocks, which optimization passes may have killed. > + DEFAULT_LTO_PASS(CFGSimplification, 0); > + > + // Now that we have optimized the program, discard unreachable > functions. > + DEFAULT_LTO_PASS(GlobalDCE, 0); > +#undef DEFAULT_LTO_PASS > + } > + }; > + static RegisterStandardPassLists AutoRegister; > + > + > static inline void createStandardAliasAnalysisPasses(PassManagerBase *PM) > { > - // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that > - // BasicAliasAnalysis wins if they disagree. This is intended to help > - // support "obvious" type-punning idioms. > - PM->add(createTypeBasedAliasAnalysisPass()); > - PM->add(createBasicAliasAnalysisPass()); > + StandardPass::AddPassesFromSet(PM, StandardPass::AliasAnalysis); > } > > /// createStandardFunctionPasses - Add the standard list of function > passes to > @@ -42,12 +290,7 @@ > /// -O1, etc. > static inline void createStandardFunctionPasses(PassManagerBase *PM, > unsigned > OptimizationLevel) { > - if (OptimizationLevel > 0) { > - createStandardAliasAnalysisPasses(PM); > - PM->add(createCFGSimplificationPass()); > - PM->add(createScalarReplAggregatesPass()); > - PM->add(createEarlyCSEPass()); > - } > + StandardPass::AddPassesFromSet(PM, StandardPass::Function, > OptimizationLevel); > } > > /// createStandardModulePasses - Add the standard list of module passes > to the > @@ -78,84 +321,16 @@ > PM->add(InliningPass); > return; > } > - > - if (UnitAtATime) { > - PM->add(createGlobalOptimizerPass()); // Optimize out global > vars > - > - PM->add(createIPSCCPPass()); // IP SCCP > - PM->add(createDeadArgEliminationPass()); // Dead argument > elimination > - > - PM->add(createInstructionCombiningPass());// Clean up after IPCP & > DAE > - PM->add(createCFGSimplificationPass()); // Clean up after IPCP & > DAE > - } > - > - // Start of CallGraph SCC passes. > - if (UnitAtATime && HaveExceptions) > - PM->add(createPruneEHPass()); // Remove dead EH info > - if (InliningPass) > - PM->add(InliningPass); > - if (UnitAtATime) > - PM->add(createFunctionAttrsPass()); // Set readonly/readnone > attrs > - if (OptimizationLevel > 2) > - PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn > args > - > - // Start of function pass. > - // Break up aggregate allocas, using SSAUpdater. > - PM->add(createScalarReplAggregatesPass(-1, false)); > - PM->add(createEarlyCSEPass()); // Catch trivial > redundancies > - if (SimplifyLibCalls) > - PM->add(createSimplifyLibCallsPass()); // Library Call > Optimizations > - PM->add(createJumpThreadingPass()); // Thread jumps. > - PM->add(createCorrelatedValuePropagationPass()); // Propagate > conditionals > - PM->add(createCFGSimplificationPass()); // Merge & remove BBs > - PM->add(createInstructionCombiningPass()); // Combine silly seq's > - > - PM->add(createTailCallEliminationPass()); // Eliminate tail calls > - PM->add(createCFGSimplificationPass()); // Merge & remove BBs > - PM->add(createReassociatePass()); // Reassociate expressions > - PM->add(createLoopRotatePass()); // Rotate Loop > - PM->add(createLICMPass()); // Hoist loop invariants > - PM->add(createLoopUnswitchPass(OptimizeSize || OptimizationLevel < > 3)); > - PM->add(createInstructionCombiningPass()); > - PM->add(createIndVarSimplifyPass()); // Canonicalize indvars > - PM->add(createLoopIdiomPass()); // Recognize idioms like > memset. > - PM->add(createLoopDeletionPass()); // Delete dead loops > - if (UnrollLoops) > - PM->add(createLoopUnrollPass()); // Unroll small loops > - if (OptimizationLevel > 1) > - PM->add(createGVNPass()); // Remove redundancies > - PM->add(createMemCpyOptPass()); // Remove memcpy / form > memset > - PM->add(createSCCPPass()); // Constant prop with SCCP > - > - // Run instcombine after redundancy elimination to exploit > opportunities > - // opened up by them. > - PM->add(createInstructionCombiningPass()); > - PM->add(createJumpThreadingPass()); // Thread jumps > - PM->add(createCorrelatedValuePropagationPass()); > - PM->add(createDeadStoreEliminationPass()); // Delete dead stores > - PM->add(createAggressiveDCEPass()); // Delete dead > instructions > - PM->add(createCFGSimplificationPass()); // Merge & remove BBs > - PM->add(createInstructionCombiningPass()); // Clean up after > everything. > - > - if (UnitAtATime) { > - PM->add(createStripDeadPrototypesPass()); // Get rid of dead > prototypes > - PM->add(createDeadTypeEliminationPass()); // Eliminate dead types > > - // GlobalOpt already deletes dead functions and globals, at -O3 try > a > - // late pass of GlobalDCE. It is capable of deleting dead cycles. > - if (OptimizationLevel > 2) > - PM->add(createGlobalDCEPass()); // Remove dead fns and > globals. > + StandardPass::AddPassesFromSet(PM, StandardPass::Module, > + StandardPass::OptimizationFlags(OptimizationLevel, > + (OptimizeSize ? StandardPass::OptimizeSize : 0) | > + (UnitAtATime ? StandardPass::UnitAtATime : 0) | > + (UnrollLoops ? StandardPass::UnrollLoops : 0) | > + (SimplifyLibCalls ? StandardPass::SimplifyLibCalls : 0) | > + (HaveExceptions ? StandardPass::HaveExceptions : 0)), > + InliningPass); > > - if (OptimizationLevel > 1) > - PM->add(createConstantMergePass()); // Merge dup global > constants > - } > - } > - > - static inline void addOnePass(PassManagerBase *PM, Pass *P, bool > AndVerify) { > - PM->add(P); > - > - if (AndVerify) > - PM->add(createVerifierPass()); > } > > /// createStandardLTOPasses - Add the standard list of module passes > suitable > @@ -174,70 +349,15 @@ > // Now that composite has been compiled, scan through the module, > looking > // for a main function. If main is defined, mark all other functions > // internal. > - if (Internalize) > - addOnePass(PM, createInternalizePass(true), VerifyEach); > - > - // Propagate constants at call sites into the functions they call. > This > - // opens opportunities for globalopt (and inlining) by substituting > function > - // pointers passed as arguments to direct uses of functions. > - addOnePass(PM, createIPSCCPPass(), VerifyEach); > - > - // Now that we internalized some globals, see if we can hack on them! > - addOnePass(PM, createGlobalOptimizerPass(), VerifyEach); > - > - // Linking modules together can lead to duplicated global constants, > only > - // keep one copy of each constant... > - addOnePass(PM, createConstantMergePass(), VerifyEach); > - > - // Remove unused arguments from functions... > - addOnePass(PM, createDeadArgEliminationPass(), VerifyEach); > - > - // Reduce the code after globalopt and ipsccp. Both can open up > significant > - // simplification opportunities, and both can propagate functions > through > - // function pointers. When this happens, we often have to resolve > varargs > - // calls, etc, so let instcombine do this. > - addOnePass(PM, createInstructionCombiningPass(), VerifyEach); > - > - // Inline small functions > - if (RunInliner) > - addOnePass(PM, createFunctionInliningPass(), VerifyEach); > - > - addOnePass(PM, createPruneEHPass(), VerifyEach); // Remove dead EH > info. > - // Optimize globals again if we ran the inliner. > - if (RunInliner) > - addOnePass(PM, createGlobalOptimizerPass(), VerifyEach); > - addOnePass(PM, createGlobalDCEPass(), VerifyEach); // Remove dead > functions. > - > - // If we didn't decide to inline a function, check to see if we can > - // transform it to pass arguments by value instead of by reference. > - addOnePass(PM, createArgumentPromotionPass(), VerifyEach); > - > - // The IPO passes may leave cruft around. Clean up after them. > - addOnePass(PM, createInstructionCombiningPass(), VerifyEach); > - addOnePass(PM, createJumpThreadingPass(), VerifyEach); > - // Break up allocas > - addOnePass(PM, createScalarReplAggregatesPass(), VerifyEach); > - > - // Run a few AA driven optimizations here and now, to cleanup the > code. > - addOnePass(PM, createFunctionAttrsPass(), VerifyEach); // Add > nocapture. > - addOnePass(PM, createGlobalsModRefPass(), VerifyEach); // IP alias > analysis. > - > - addOnePass(PM, createLICMPass(), VerifyEach); // Hoist loop > invariants. > - addOnePass(PM, createGVNPass(), VerifyEach); // Remove > redundancies. > - addOnePass(PM, createMemCpyOptPass(), VerifyEach); // Remove dead > memcpys. > - // Nuke dead stores. > - addOnePass(PM, createDeadStoreEliminationPass(), VerifyEach); > - > - // Cleanup and simplify the code after the scalar optimizations. > - addOnePass(PM, createInstructionCombiningPass(), VerifyEach); > - > - addOnePass(PM, createJumpThreadingPass(), VerifyEach); > - > - // Delete basic blocks, which optimization passes may have killed. > - addOnePass(PM, createCFGSimplificationPass(), VerifyEach); > + if (Internalize) { > + PM->add(createInternalizePass(true)); > + if (VerifyEach) > + PM->add(createVerifierPass()); > + } > > - // Now that we have optimized the program, discard unreachable > functions. > - addOnePass(PM, createGlobalDCEPass(), VerifyEach); > + StandardPass::AddPassesFromSet(PM, StandardPass::LTO, > + StandardPass::OptimizationFlags(0, 0, RunInliner ? > + StandardPass::RunInliner : 0), VerifyEach); > } > } > > > Added: llvm/trunk/lib/VMCore/StandardPasses.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/StandardPasses.cpp?rev=131155&view=auto > > ============================================================================== > --- llvm/trunk/lib/VMCore/StandardPasses.cpp (added) > +++ llvm/trunk/lib/VMCore/StandardPasses.cpp Tue May 10 16:36:48 2011 > @@ -0,0 +1,240 @@ > +//=========-- StandardPasses.cpp - Standard pass lists -----*- C++ > -*-=======// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > > +//===----------------------------------------------------------------------===// > +// > +// This file defines utility functions for creating a "standard" set of > +// optimization passes, so that compilers and tools which use optimization > +// passes use the same set of standard passes. > +// > > +//===----------------------------------------------------------------------===// > + > +#include "llvm/PassManager.h" > +#include "llvm/Analysis/Passes.h" > +#include "llvm/Analysis/Verifier.h" > +#include "llvm/Analysis/Verifier.h" > +#include "llvm/Support/ErrorHandling.h" > +#include "llvm/Support/ManagedStatic.h" > +#include "llvm/Support/Mutex.h" > +#include "llvm/Support/DynamicLibrary.h" > +#include "llvm/Transforms/Scalar.h" > +#include "llvm/Transforms/IPO.h" > + > + > +using namespace llvm::DefaultStandardPasses; > +using namespace llvm; > + > +namespace { > + > +/// Entry in the standard passes list. > +struct StandardPassEntry { > + /// Function called to create the pass > + PassInfo::NormalCtor_t createPass; > + /// Unique identifier for this pass > + unsigned char *passID; > + /// Flags specifying when this pass should be run > + unsigned flags; > + > + StandardPassEntry(PassInfo::NormalCtor_t constructor, unsigned char *ID, > + unsigned f) : createPass(constructor), passID(ID), flags(f) {}; > +}; > + > +/// Standard alias analysis passes > +static llvm::SmallVector AAPasses; > +/// Standard function passes > +static llvm::SmallVector FunctionPasses; > +/// Standard module passes > +static llvm::SmallVector ModulePasses; > +/// Standard link-time optimization passes > +static llvm::SmallVector LTOPasses; > + > +/// Entry in the unresolved standard pass list. IF a pass is inserted in > front > +/// of a pass that is not yet registered in the standard pass list then it > is > +/// stored in a separate list and resolved later. > +struct UnresolvedStandardPass : public StandardPassEntry { > + /// The set into which this is stored > + StandardPass::StandardSet set; > + /// The unique ID of the pass that should follow this one in the > sequence > + unsigned char *next; > + UnresolvedStandardPass(PassInfo::NormalCtor_t constructor, > + unsigned char *newPass, > + unsigned char *oldPass, > + StandardPass::StandardSet s, > + unsigned f) > + : StandardPassEntry(constructor, newPass, f), set(s), next(oldPass) {} > +}; > + > +/// The passes that can not be inserted into the correct lists yet because > of > +/// their place in the sequence. > +static llvm::SmallVector UnresolvedPasses; > + > +/// Returns a reference to the pass list for the corresponding set of > +/// optimisations. > +llvm::SmallVectorImpl& > +PassList(StandardPass::StandardSet set) { > + switch (set) { > + case StandardPass::AliasAnalysis: return AAPasses; > + case StandardPass::Function: return FunctionPasses; > + case StandardPass::Module: return ModulePasses; > + case StandardPass::LTO: return LTOPasses; > + } > + // We could use a map of standard pass lists to allow definition of new > + // default sets > + llvm_unreachable("Invalid standard optimization set requested"); > +} > + > +static ManagedStatic > Lock; > + > +/// Registers the default set of standard passes. This is called lazily > when > +/// an attempt is made to read or modify the standard pass list > +void RegisterDefaultStandardPasses(void(*doRegister)(void)) { > + // Only initialize the standard passes once > + static bool initialized = false; > + if (initialized) return; > + > + llvm::sys::SmartScopedLock Guard(*Lock); > + if (initialized) return; > + if (doRegister) { > + // We must set initialized to true before calling this function, > because > + // the doRegister() function will probably call > RegisterDefaultPasses(), > + // which will call this function, and we'd end up with infinite > recursion > + // and breakage if we didn't. > + initialized = true; > + doRegister(); > + } > +} > + > +} // Anonymous namespace > + > +void (*StandardPass::RegisterDefaultPasses)(void); > + > +void StandardPass::RegisterDefaultPass(PassInfo::NormalCtor_t constructor, > + unsigned char *newPass, > + unsigned char *oldPass, > + StandardPass::StandardSet set, > + unsigned flags) { > + // Make sure that the standard sets are already regstered > + RegisterDefaultStandardPasses(RegisterDefaultPasses); > + // Get the correct list to modify > + llvm::SmallVectorImpl &passList = PassList(set); > + > + // If there is no old pass specified, then we are adding a new final > pass, so > + // just push it onto the end. > + if (!oldPass) { > + StandardPassEntry pass(constructor, newPass, flags); > + passList.push_back(pass); > + return; > + } > + > + // Find the correct place to insert the pass. This is a linear search, > but > + // this shouldn't be too slow since the SmallVector will store the > values in > + // a contiguous block of memory. Each entry is just three words of > memory, so > + // in most cases we are only going to be looking in one or two cache > lines. > + // The extra memory accesses from a more complex search structure would > + // offset any performance gain (unless someone decides to > + for (SmallVectorImpl::iterator i = passList.begin(), > + e=passList.end(); i != e; ++i) { > + if (i->passID == oldPass) { > + StandardPassEntry pass(constructor, newPass, flags); > + passList.insert(i, pass); > + // If we've added a new pass, then there may have gained the ability > to > + // insert one of the previously unresolved ones. If so, insert the > new > + // one. > + for (SmallVectorImpl::iterator > + u = UnresolvedPasses.begin(), eu = UnresolvedPasses.end(); > + u!=eu; ++u){ > + if (u->next == newPass && u->set == set) { > + UnresolvedStandardPass p = *u; > + UnresolvedPasses.erase(u); > + RegisterDefaultPass(p.createPass, p.passID, p.next, p.set, > p.flags); > + } > + } > + return; > + } > + } > + // If we get to here, then we didn't find the correct place to insert > the new > + // pass > + UnresolvedStandardPass pass(constructor, newPass, oldPass, set, flags); > + UnresolvedPasses.push_back(pass); > +} > + > +void StandardPass::AddPassesFromSet(PassManagerBase *PM, > + StandardSet set, > + unsigned flags, > + bool VerifyEach, > + Pass *inliner) { > + RegisterDefaultStandardPasses(RegisterDefaultPasses); > + unsigned level = OptimizationLevel(flags); > + flags = RequiredFlags(flags); > + llvm::SmallVectorImpl& passList = PassList(set); > + // Add all of the passes from this set > + for (SmallVectorImpl::iterator i = passList.begin(), > + e=passList.end(); i != e ; ++i) { > + // Skip passes that don't have conditions that match the ones > specified > + // here. For a pass to match: > + // - Its minimum optimisation level must be less than or equal to the > + // specified level. > + // - Its maximum optimisation level must be greater than or equal to > the > + // specified level > + // - All of its required flags must be set > + // - None of its disallowed flags may be set > + if ((level >= OptimizationLevel(i->flags)) && > + ((level <= MaxOptimizationLevel(i->flags)) > + || MaxOptimizationLevel(i->flags) == 0) && > + ((RequiredFlags(i->flags) & flags) == RequiredFlags(i->flags)) && > + ((DisallowedFlags(i->flags) & flags) == 0)) { > + // This is quite an ugly way of allowing us to specify an inliner > pass to > + // insert. Ideally, we'd replace this with a general mechanism > allowing > + // callers to replace arbitrary passes in the list. > + Pass *p = inliner; > + if ((&InlinerPlaceholderID != i->passID) && i->createPass) > + p = i->createPass(); > + if (p) { > + PM->add(p); > + if (VerifyEach) > + PM->add(createVerifierPass()); > + } > + } > + } > +} > + > +unsigned char DefaultStandardPasses::AggressiveDCEID; > +unsigned char DefaultStandardPasses::ArgumentPromotionID; > +unsigned char DefaultStandardPasses::BasicAliasAnalysisID; > +unsigned char DefaultStandardPasses::CFGSimplificationID; > +unsigned char DefaultStandardPasses::ConstantMergeID; > +unsigned char DefaultStandardPasses::CorrelatedValuePropagationID; > +unsigned char DefaultStandardPasses::DeadArgEliminationID; > +unsigned char DefaultStandardPasses::DeadStoreEliminationID; > +unsigned char DefaultStandardPasses::DeadTypeEliminationID; > +unsigned char DefaultStandardPasses::EarlyCSEID; > +unsigned char DefaultStandardPasses::FunctionAttrsID; > +unsigned char DefaultStandardPasses::FunctionInliningID; > +unsigned char DefaultStandardPasses::GVNID; > +unsigned char DefaultStandardPasses::GlobalDCEID; > +unsigned char DefaultStandardPasses::GlobalOptimizerID; > +unsigned char DefaultStandardPasses::GlobalsModRefID; > +unsigned char DefaultStandardPasses::IPSCCPID; > +unsigned char DefaultStandardPasses::IndVarSimplifyID; > +unsigned char DefaultStandardPasses::InlinerPlaceholderID; > +unsigned char DefaultStandardPasses::InstructionCombiningID; > +unsigned char DefaultStandardPasses::JumpThreadingID; > +unsigned char DefaultStandardPasses::LICMID; > +unsigned char DefaultStandardPasses::LoopDeletionID; > +unsigned char DefaultStandardPasses::LoopIdiomID; > +unsigned char DefaultStandardPasses::LoopRotateID; > +unsigned char DefaultStandardPasses::LoopUnrollID; > +unsigned char DefaultStandardPasses::LoopUnswitchID; > +unsigned char DefaultStandardPasses::MemCpyOptID; > +unsigned char DefaultStandardPasses::PruneEHID; > +unsigned char DefaultStandardPasses::ReassociateID; > +unsigned char DefaultStandardPasses::SCCPID; > +unsigned char DefaultStandardPasses::ScalarReplAggregatesID; > +unsigned char DefaultStandardPasses::SimplifyLibCallsID; > +unsigned char DefaultStandardPasses::StripDeadPrototypesID; > +unsigned char DefaultStandardPasses::TailCallEliminationID; > +unsigned char DefaultStandardPasses::TypeBasedAliasAnalysisID; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110510/85f8afe5/attachment.html From rafael.espindola at gmail.com Tue May 10 17:28:36 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 22:28:36 -0000 Subject: [llvm-commits] [llvm] r131161 - /llvm/trunk/lib/MC/MCDwarf.cpp Message-ID: <20110510222836.0FD062A6C12C@llvm.org> Author: rafael Date: Tue May 10 17:28:35 2011 New Revision: 131161 URL: http://llvm.org/viewvc/llvm-project?rev=131161&view=rev Log: Avoid a gcc warning. Modified: llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=131161&r1=131160&r2=131161&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Tue May 10 17:28:35 2011 @@ -770,7 +770,8 @@ unsigned size = getSizeForEncoding(streamer, fdeEncoding); // PC Begin - unsigned PCBeginEncoding = IsEH ? fdeEncoding : dwarf::DW_EH_PE_absptr; + unsigned PCBeginEncoding = IsEH ? fdeEncoding : + (unsigned)dwarf::DW_EH_PE_absptr; unsigned PCBeginSize = getSizeForEncoding(streamer, PCBeginEncoding); EmitSymbol(streamer, *frame.Begin, PCBeginEncoding); From fvbommel at gmail.com Tue May 10 17:33:45 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Wed, 11 May 2011 00:33:45 +0200 Subject: [llvm-commits] [llvm] r131155 - in /llvm/trunk: include/llvm/PassSupport.h include/llvm/Support/StandardPasses.h lib/VMCore/StandardPasses.cpp In-Reply-To: <20110510213648.3D39B2A6C12C@llvm.org> References: <20110510213648.3D39B2A6C12C@llvm.org> Message-ID: Oops, forgot to CC the list. From: Frits van Bommel Date: Wed, May 11, 2011 at 12:32 AM Subject: Re: [llvm-commits] [llvm] r131155 - in /llvm/trunk: include/llvm/PassSupport.h include/llvm/Support/StandardPasses.h lib/VMCore/StandardPasses.cpp To: David Chisnall On Tue, May 10, 2011 at 11:36 PM, David Chisnall wrote: > + /// Returns the flags that must not be set for this to match > + static unsigned DisallowedFlags(unsigned flags) { > + return (flags & DisallowedFlagMask) >> RequiredFlagShift; I think you meant 'DisallowedFlagShift' here. > + } > +void StandardPass::RegisterDefaultPass(PassInfo::NormalCtor_t constructor, > + unsigned char *newPass, > + unsigned char *oldPass, > + StandardPass::StandardSet set, > + unsigned flags) { > + // Make sure that the standard sets are already regstered > + RegisterDefaultStandardPasses(RegisterDefaultPasses); > + // Get the correct list to modify > + llvm::SmallVectorImpl &passList = PassList(set); > + > + // If there is no old pass specified, then we are adding a new final pass, so > + // just push it onto the end. > + if (!oldPass) { > + StandardPassEntry pass(constructor, newPass, flags); > + passList.push_back(pass); > + return; > + } > + > + // Find the correct place to insert the pass. This is a linear search, but > + // this shouldn't be too slow since the SmallVector will store the values in > + // a contiguous block of memory. Each entry is just three words of memory, so > + // in most cases we are only going to be looking in one or two cache lines. > + // The extra memory accesses from a more complex search structure would > + // offset any performance gain (unless someone decides to Unfinished comment? > + for (SmallVectorImpl::iterator i = passList.begin(), > + e=passList.end(); i != e; ++i) { > + if (i->passID == oldPass) { > + StandardPassEntry pass(constructor, newPass, flags); > + passList.insert(i, pass); > + // If we've added a new pass, then there may have gained the ability to > + // insert one of the previously unresolved ones. If so, insert the new > + // one. > + for (SmallVectorImpl::iterator > + u = UnresolvedPasses.begin(), eu = UnresolvedPasses.end(); > + u!=eu; ++u){ > + if (u->next == newPass && u->set == set) { > + UnresolvedStandardPass p = *u; > + UnresolvedPasses.erase(u); > + RegisterDefaultPass(p.createPass, p.passID, p.next, p.set, p.flags); > + } > + } > + return; What if 'oldPass' refers to one of those passes that tends to be used multiple times in a pipeline such as -simplifycfg or -instcombine? Is the new pass then only inserted once, before the first instance of the old one? What if a new pass wants to run just before the *second* time that old pass runs? (for example, because it wants to run after the pass just before that) > + } > + } > + // If we get to here, then we didn't find the correct place to insert the new > + // pass > + UnresolvedStandardPass pass(constructor, newPass, oldPass, set, flags); > + UnresolvedPasses.push_back(pass); > +} It would be nice to have this interface documented somewhere other than in this code, preferably with an example of how to use it. Maybe a new section in docs/WritingAnLLVMPass.html? From nicholas at mxc.ca Tue May 10 17:38:17 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 10 May 2011 22:38:17 -0000 Subject: [llvm-commits] [llvm] r131162 - /llvm/trunk/lib/VMCore/StandardPasses.cpp Message-ID: <20110510223817.2E99B2A6C12E@llvm.org> Author: nicholas Date: Tue May 10 17:38:17 2011 New Revision: 131162 URL: http://llvm.org/viewvc/llvm-project?rev=131162&view=rev Log: Remove empty file. Removed: llvm/trunk/lib/VMCore/StandardPasses.cpp Removed: llvm/trunk/lib/VMCore/StandardPasses.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/StandardPasses.cpp?rev=131161&view=auto ============================================================================== (empty) From rafael.espindola at gmail.com Tue May 10 17:42:42 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 22:42:42 -0000 Subject: [llvm-commits] [llvm] r131164 - /llvm/trunk/lib/VMCore/CMakeLists.txt Message-ID: <20110510224242.12ACA2A6C130@llvm.org> Author: rafael Date: Tue May 10 17:42:41 2011 New Revision: 131164 URL: http://llvm.org/viewvc/llvm-project?rev=131164&view=rev Log: Fix cmake again. Modified: llvm/trunk/lib/VMCore/CMakeLists.txt Modified: llvm/trunk/lib/VMCore/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/CMakeLists.txt?rev=131164&r1=131163&r2=131164&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/CMakeLists.txt (original) +++ llvm/trunk/lib/VMCore/CMakeLists.txt Tue May 10 17:42:41 2011 @@ -28,7 +28,6 @@ PassManager.cpp PassRegistry.cpp PrintModulePass.cpp - StandardPasses.cpp Type.cpp TypeSymbolTable.cpp Use.cpp From aggarwa4 at illinois.edu Tue May 10 17:51:43 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 10 May 2011 22:51:43 -0000 Subject: [llvm-commits] [poolalloc] r131166 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Message-ID: <20110510225143.6F7622A6C12C@llvm.org> Author: aggarwa4 Date: Tue May 10 17:51:43 2011 New Revision: 131166 URL: http://llvm.org/viewvc/llvm-project?rev=131166&view=rev Log: Only instrument stores, if that location is used in an type unsafe manner. Only initialize type information for globals used in a type unsafe manner. Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=131166&r1=131165&r2=131166&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Tue May 10 17:51:43 2011 @@ -516,6 +516,11 @@ bool TypeChecks::visitGlobal(Module &M, GlobalVariable &GV, Constant *C, Instruction &I, unsigned offset) { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(&GV, I.getParent()->getParent())) { + return false; + } + } if(ConstantArray *CA = dyn_cast(C)) { const Type * ElementType = CA->getType()->getElementType(); unsigned int t = TD->getTypeStoreSize(ElementType); @@ -786,6 +791,11 @@ // Insert runtime checks before all store instructions. bool TypeChecks::visitStoreInst(Module &M, StoreInst &SI) { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(SI.getOperand(1), SI.getParent()->getParent())) { + return false; + } + } // Cast the pointer operand to i8* for the runtime function. CastInst *BCI = BitCastInst::CreatePointerCast(SI.getPointerOperand(), VoidPtrTy, "", &SI); @@ -805,6 +815,11 @@ // Insert runtime checks before copying store instructions. bool TypeChecks::visitCopyingStoreInst(Module &M, StoreInst &SI, Value *SS) { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(SI.getOperand(1), SI.getParent()->getParent())) { + return false; + } + } // Cast the pointer operand to i8* for the runtime function. CastInst *BCI_Dest = BitCastInst::CreatePointerCast(SI.getPointerOperand(), VoidPtrTy, "", &SI); CastInst *BCI_Src = BitCastInst::CreatePointerCast(SS, VoidPtrTy, "", &SI); From aggarwa4 at illinois.edu Tue May 10 17:56:03 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 10 May 2011 22:56:03 -0000 Subject: [llvm-commits] [poolalloc] r131167 - in /poolalloc/trunk/test: TEST.types.Makefile TEST.types.report Message-ID: <20110510225603.7B1B42A6C12C@llvm.org> Author: aggarwa4 Date: Tue May 10 17:56:03 2011 New Revision: 131167 URL: http://llvm.org/viewvc/llvm-project?rev=131167&view=rev Log: Added more stats for runtime of instrumented functions. This is cluttered makefile, which gives all the stats. Choose as per need. Modified: poolalloc/trunk/test/TEST.types.Makefile poolalloc/trunk/test/TEST.types.report Modified: poolalloc/trunk/test/TEST.types.Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/TEST.types.Makefile?rev=131167&r1=131166&r2=131167&view=diff ============================================================================== --- poolalloc/trunk/test/TEST.types.Makefile (original) +++ poolalloc/trunk/test/TEST.types.Makefile Tue May 10 17:56:03 2011 @@ -51,7 +51,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.opt.bc): \ Output/%.opt.bc: Output/%.llvm1.bc $(LOPT) $(ASSIST_SO) - -$(RUNOPT) -load $(ASSIST_SO) -disable-opt -info-output-file=$(CURDIR)/$@.info -instnamer -internalize -mem2reg -dce -basiccg -inline -dce -varargsfunc -indclone -funcspec -ipsccp -deadargelim -simplify-gep -die -die -mergearrgep -die -globaldce -simplifycfg -deadargelim -arg-simplify -die -varargsfunc -die -simplifycfg -globaldce -indclone -funcspec -deadargelim -globaldce -die -simplifycfg -gep-expr-arg -deadargelim -die -mergefunc -die -die -mergearrgep -die -globaldce -int2ptrcmp -die -dce -inline -mem2reg -dce -arg-cast -dce -struct-ret -deadargelim -simplify-ev -simplify-iv -dce -ld-args -gep-expr-arg -deadargelim -mergefunc -dce -stats -time-passes $< -f -o $@ + -$(RUNOPT) -load $(ASSIST_SO) -disable-opt -info-output-file=$(CURDIR)/$@.info -instnamer -internalize -mem2reg -dce -basiccg -inline -dce -varargsfunc -indclone -funcspec -ipsccp -deadargelim -simplify-gep -die -die -mergearrgep -die -globaldce -simplifycfg -deadargelim -arg-simplify -die -varargsfunc -die -simplifycfg -globaldce -indclone -funcspec -deadargelim -globaldce -die -simplifycfg -gep-expr-arg -deadargelim -die -mergefunc -die -die -mergearrgep -die -globaldce -int2ptrcmp -die -dce -inline -mem2reg -dce -arg-cast -dce -sretpromotion -struct-ret -deadargelim -simplify-ev -simplify-iv -dce -ld-args -gep-expr-arg -deadargelim -mergefunc -dce -stats -time-passes $< -f -o $@ $(PROGRAMS_TO_TEST:%=Output/%.count.bc): \ Output/%.count.bc: Output/%.opt.bc $(LOPT) $(ASSIST_SO) @@ -63,7 +63,11 @@ $(PROGRAMS_TO_TEST:%=Output/%.tc.bc): \ Output/%.tc.bc: Output/%.opt.bc $(LOPT) $(ASSIST_SO) - -$(RUNOPT) -load $(ASSIST_SO) -typechecks -dce -ipsccp -info-output-file=$(CURDIR)/$@.info $< -f -o $@ + -$(RUNOPT) -load $(ASSIST_SO) -typechecks -dce -ipsccp -stats -info-output-file=$(CURDIR)/$@.info $< -f -o $@ + +$(PROGRAMS_TO_TEST:%=Output/%.tco.bc): \ +Output/%.tco.bc: Output/%.opt.bc $(LOPT) $(ASSIST_SO) + -$(RUNOPT) -load $(ASSIST_SO) -typechecks -enable-type-safe-opt -dce -ipsccp -stats -info-output-file=$(CURDIR)/$@.info $< -f -o $@ $(PROGRAMS_TO_TEST:%=Output/%.count.s): \ Output/%.count.s: Output/%.count.bc $(LLC) @@ -80,6 +84,9 @@ $(PROGRAMS_TO_TEST:%=Output/%.tc.s): \ Output/%.tc.s: Output/%.tc.bc $(LLC) -$(LLC) -f $< -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.tco.s): \ +Output/%.tco.s: Output/%.tco.bc $(LLC) + -$(LLC) -f $< -o $@ $(PROGRAMS_TO_TEST:%=Output/%.opt): \ Output/%.opt: Output/%.opt.s @@ -87,6 +94,9 @@ $(PROGRAMS_TO_TEST:%=Output/%.tc): \ Output/%.tc: Output/%.tc.s $(TYPE_RT_O) -$(CC) $(CFLAGS) $< $(LLCLIBS) $(TYPE_RT_O) $(LDFLAGS) -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.tco): \ +Output/%.tco: Output/%.tco.s $(TYPE_RT_O) + -$(CC) $(CFLAGS) $< $(LLCLIBS) $(TYPE_RT_O) $(LDFLAGS) -o $@ $(PROGRAMS_TO_TEST:%=Output/%.llvm1): \ Output/%.llvm1: Output/%.llvm1.s -$(CC) $(CFLAGS) $< $(LLCLIBS) $(LDFLAGS) -o $@ @@ -116,6 +126,9 @@ $(PROGRAMS_TO_TEST:%=Output/%.tc.out): \ Output/%.tc.out: Output/%.tc -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) +$(PROGRAMS_TO_TEST:%=Output/%.tco.out): \ +Output/%.tco.out: Output/%.tco + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) else $(PROGRAMS_TO_TEST:%=Output/%.opt.out): \ @@ -139,6 +152,13 @@ ../../$< $(RUN_OPTIONS) -(cd Output/tc-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ -cp Output/tc-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time +$(PROGRAMS_TO_TEST:%=Output/%.tco.out): \ +Output/%.tco.out: Output/%.tco + -$(SPEC_SANDBOX) tco-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/tco-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/tco-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time $(PROGRAMS_TO_TEST:%=Output/%.count.out): \ Output/%.count.out: Output/%.count -$(SPEC_SANDBOX) count-$(RUN_TYPE) $@ $(REF_IN_DIR) \ @@ -167,6 +187,11 @@ @cp Output/$*.out-nat Output/$*.tc.out-nat -$(DIFFPROG) nat $*.tc $(HIDEDIFF) +$(PROGRAMS_TO_TEST:%=Output/%.tco.diff-nat): \ +Output/%.tco.diff-nat: Output/%.out-nat Output/%.tco.out + @cp Output/$*.out-nat Output/$*.tco.out-nat + -$(DIFFPROG) nat $*.tco $(HIDEDIFF) + $(PROGRAMS_TO_TEST:%=Output/%.llvm1.diff-nat): \ Output/%.llvm1.diff-nat: Output/%.out-nat Output/%.llvm1.out @cp Output/$*.out-nat Output/$*.llvm1.out-nat @@ -183,7 +208,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.$(TEST).report.txt): \ -Output/%.$(TEST).report.txt: Output/%.opt.bc Output/%.LOC.txt $(LOPT) Output/%.out-nat Output/%.opt.diff-nat Output/%.count.diff-nat Output/%.count1.diff-nat +Output/%.$(TEST).report.txt: Output/%.opt.bc Output/%.LOC.txt $(LOPT) Output/%.out-nat Output/%.opt.diff-nat Output/%.tc.diff-nat Output/%.count.diff-nat Output/%.count1.diff-nat Output/%.tco.diff-nat @# Gather data -($(RUNOPT) -dsa-$(PASS) -enable-type-inference-opts -dsa-stdlib-no-fold $(ANALYZE_OPTS) $<)> $@.time.1 2>&1 -($(RUNOPT) -dsa-$(PASS) $(ANALYZE_OPTS) $<)> $@.time.2 2>&1 @@ -242,6 +267,9 @@ @/bin/echo -n "IGN: " >> $@ - at grep 'Number of instructions ignored' $@.time.1 >> $@ @echo >> $@ + @/bin/echo -n "GEPI: " >> $@ + - at grep 'Number of gep instructions ignored' $@.time.1 >> $@ + @echo >> $@ @/bin/echo -n "ACCESSES I: " >> $@ - at grep 'Number of loads/stores which are on incomplete nodes' $@.time.1 >> $@ @echo >> $@ @@ -273,6 +301,19 @@ @/bin/echo -n "TIME: " >> $@ - at grep ' Top-down Data Structure' $@.time.1 >> $@ @echo >> $@ + @# Emit runtime data. + @-if test -f Output/$*.opt.diff-nat; then \ + printf "OPT-RUN_TIME: " >> $@;\ + grep 'program' Output/$*.opt.out.time >> $@;\ + fi + @-if test -f Output/$*.tc.diff-nat; then \ + printf "TC-RUN_TIME: " >> $@;\ + grep 'program' Output/$*.tc.out.time >> $@;\ + fi + @-if test -f Output/$*.tco.diff-nat; then \ + printf "TCO-RUN_TIME: " >> $@;\ + grep 'program' Output/$*.tco.out.time >> $@;\ + fi @# Emit AssistDS stats @/bin/echo -n "CLONED_FUNCSPEC: " >> $@ - at grep 'Number of Functions Cloned in FuncSpec' $<.info >> $@ @@ -316,7 +357,12 @@ @/bin/echo -n "DSAFE: " >> $@ - at grep 'Safe' lsstats1 >> $@ @echo >> $@ - + @/bin/echo -n "LCHK: " >> $@ + - at grep 'Number of Load Insts that need type checks' $<.info >> $@ + @echo >> $@ + @/bin/echo -n "SCHK: " >> $@ + - at grep 'Number of Store Insts that need type checks' $<.info >> $@ + @echo >> $@ $(PROGRAMS_TO_TEST:%=test.$(TEST).%): \ test.$(TEST).%: Output/%.$(TEST).report.txt Modified: poolalloc/trunk/test/TEST.types.report URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/TEST.types.report?rev=131167&r1=131166&r2=131167&view=diff ============================================================================== --- poolalloc/trunk/test/TEST.types.report (original) +++ poolalloc/trunk/test/TEST.types.report Tue May 10 17:56:03 2011 @@ -150,6 +150,7 @@ ["TS %" , sub { return TypeSafeRatio(@_); }], [], ["Ign", "IGN: *([0-9]+)"], + ["GEP-Ign", "GEPI: *([0-9]+)"], ["Type0", "ACCESSES TYPED0: *([0-9]+)"], ["Type1", "ACCESSES TYPED1: *([0-9]+)"], ["Type2", "ACCESSES TYPED2: *([0-9]+)"], @@ -182,4 +183,11 @@ ["DTotalO", "DTOTALO: *([0-9]+)"], ["DSafeO", "DSAFEO: *([0-9]+)"], ["DTS %" , sub { return Ratio(@_); }], + #[], + #["LoadChk", "LCHK: *([0-9]+)"], + #["StoreChk", "SCHK: *([0-9]+)"], + [], + ["OptTime", "OPT-RUN_TIME: program *([.0-9]+)"], + ["TcTime", "TC-RUN_TIME: program *([.0-9]+)"], + ["TcoTime", "TCO-RUN_TIME: program *([.0-9]+)"], ); From rafael.espindola at gmail.com Tue May 10 18:14:29 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 May 2011 23:14:29 -0000 Subject: [llvm-commits] [llvm] r131169 - /llvm/trunk/test/DebugInfo/debug_frame.ll Message-ID: <20110510231429.42D712A6C12C@llvm.org> Author: rafael Date: Tue May 10 18:14:29 2011 New Revision: 131169 URL: http://llvm.org/viewvc/llvm-project?rev=131169&view=rev Log: Add triple. Modified: llvm/trunk/test/DebugInfo/debug_frame.ll Modified: llvm/trunk/test/DebugInfo/debug_frame.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debug_frame.ll?rev=131169&r1=131168&r2=131169&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/debug_frame.ll (original) +++ llvm/trunk/test/DebugInfo/debug_frame.ll Tue May 10 18:14:29 2011 @@ -1,4 +1,4 @@ -; RUN: llc %s -o - | FileCheck %s +; RUN: llc %s -mtriple=i686-pc-linux-gnu -o - | FileCheck %s ; Test that we produce a .debug_frame, not an .eh_frame From rafael.espindola at gmail.com Tue May 10 18:56:45 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Tue, 10 May 2011 19:56:45 -0400 Subject: [llvm-commits] .cfi_* and ARM In-Reply-To: <4DC8552E.3030705@gmail.com> References: <4DC84EE9.8080402@gmail.com> <4DC8552E.3030705@gmail.com> Message-ID: <4DC9D0BD.8010004@gmail.com> On 11-05-09 04:57 PM, Rafael Avila de Espindola wrote: >> I should have a patch for 1 in a moment. Thoughts? > > The first patch is attached. OK, I think it is all implemented now. If the only reason for having the cfi instructions is that the user wants debug info, we will now also produce a .cfi_sections .debug_frame. Cheers, Rafael From echristo at apple.com Tue May 10 18:57:45 2011 From: echristo at apple.com (Eric Christopher) Date: Tue, 10 May 2011 23:57:45 -0000 Subject: [llvm-commits] [llvm] r131171 - in /llvm/trunk/lib/Target/X86: X86ISelDAGToDAG.cpp X86InstrCompiler.td Message-ID: <20110510235745.E1C512A6C12C@llvm.org> Author: echristo Date: Tue May 10 18:57:45 2011 New Revision: 131171 URL: http://llvm.org/viewvc/llvm-project?rev=131171&view=rev Log: Optimize atomic lock or that doesn't use the result value. Next up: xor and and. Part of rdar://8470697 Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86InstrCompiler.td Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=131171&r1=131170&r2=131171&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Tue May 10 18:57:45 2011 @@ -189,6 +189,7 @@ SDNode *Select(SDNode *N); SDNode *SelectAtomic64(SDNode *Node, unsigned Opc); SDNode *SelectAtomicLoadAdd(SDNode *Node, EVT NVT); + SDNode *SelectAtomicLoadOr(SDNode *Node, EVT NVT); bool MatchLoadInAddress(LoadSDNode *N, X86ISelAddressMode &AM); bool MatchWrapper(SDValue N, X86ISelAddressMode &AM); @@ -1329,6 +1330,8 @@ return ResNode; } +// FIXME: Figure out some way to unify this with the 'or' and other code +// below. SDNode *X86DAGToDAGISel::SelectAtomicLoadAdd(SDNode *Node, EVT NVT) { if (Node->hasAnyUseOfValue(0)) return 0; @@ -1479,6 +1482,78 @@ } } +SDNode *X86DAGToDAGISel::SelectAtomicLoadOr(SDNode *Node, EVT NVT) { + if (Node->hasAnyUseOfValue(0)) + return 0; + + // Optimize common patterns for __sync_or_and_fetch where the result + // is not used. This allows us to use the "lock" version of the or + // instruction. + // FIXME: Same as for 'add' and 'sub'. + SDValue Chain = Node->getOperand(0); + SDValue Ptr = Node->getOperand(1); + SDValue Val = Node->getOperand(2); + SDValue Tmp0, Tmp1, Tmp2, Tmp3, Tmp4; + if (!SelectAddr(Node, Ptr, Tmp0, Tmp1, Tmp2, Tmp3, Tmp4)) + return 0; + + bool isCN = false; + ConstantSDNode *CN = dyn_cast(Val); + if (CN) { + isCN = true; + Val = CurDAG->getTargetConstant(CN->getSExtValue(), NVT); + } + + unsigned Opc = 0; + switch (NVT.getSimpleVT().SimpleTy) { + default: return 0; + case MVT::i8: + if (isCN) + Opc = X86::LOCK_OR8mi; + else + Opc = X86::LOCK_OR8mr; + break; + case MVT::i16: + if (isCN) { + if (immSext8(Val.getNode())) + Opc = X86::LOCK_OR16mi8; + else + Opc = X86::LOCK_OR16mi; + } else + Opc = X86::LOCK_OR16mr; + break; + case MVT::i32: + if (isCN) { + if (immSext8(Val.getNode())) + Opc = X86::LOCK_OR32mi8; + else + Opc = X86::LOCK_OR32mi; + } else + Opc = X86::LOCK_OR32mr; + break; + case MVT::i64: + if (isCN) { + if (immSext8(Val.getNode())) + Opc = X86::LOCK_OR64mi8; + else if (i64immSExt32(Val.getNode())) + Opc = X86::LOCK_OR64mi32; + } else + Opc = X86::LOCK_OR64mr; + break; + } + + DebugLoc dl = Node->getDebugLoc(); + SDValue Undef = SDValue(CurDAG->getMachineNode(TargetOpcode::IMPLICIT_DEF, + dl, NVT), 0); + MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); + MemOp[0] = cast(Node)->getMemOperand(); + SDValue Ops[] = { Tmp0, Tmp1, Tmp2, Tmp3, Tmp4, Val, Chain }; + SDValue Ret = SDValue(CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops, 7), 0); + cast(Ret)->setMemRefs(MemOp, MemOp + 1); + SDValue RetVals[] = { Undef, Ret }; + return CurDAG->getMergeValues(RetVals, 2, dl).getNode(); +} + /// HasNoSignedComparisonUses - Test whether the given X86ISD::CMP node has /// any uses which require the SF or OF bits to be accurate. static bool HasNoSignedComparisonUses(SDNode *N) { @@ -1580,6 +1655,12 @@ return RetVal; break; } + case ISD::ATOMIC_LOAD_OR: { + SDNode *RetVal = SelectAtomicLoadOr(Node, NVT); + if (RetVal) + return RetVal; + break; + } case ISD::AND: case ISD::OR: case ISD::XOR: { Modified: llvm/trunk/lib/Target/X86/X86InstrCompiler.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrCompiler.td?rev=131171&r1=131170&r2=131171&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrCompiler.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrCompiler.td Tue May 10 18:57:45 2011 @@ -580,7 +580,7 @@ ImmOpc{3}, ImmOpc{2}, ImmOpc{1}, 0 }, ImmMod, (outs), (ins i8mem :$dst, i8imm :$src2), !strconcat("lock\n\t", mnemonic, "{b}\t", - "{$src2, $dst|$dst, $src2}"), + "{$src2, $dst|$dst, $src2}"), []>, LOCK; def #NAME#16mi : Ii16<{ImmOpc{7}, ImmOpc{6}, ImmOpc{5}, ImmOpc{4}, @@ -629,6 +629,7 @@ defm LOCK_ADD : LOCK_ArithBinOp<0x00, 0x80, 0x83, MRM0m, "add">; defm LOCK_SUB : LOCK_ArithBinOp<0x28, 0x80, 0x83, MRM5m, "sub">; +defm LOCK_OR : LOCK_ArithBinOp<0x08, 0x80, 0x83, MRM1m, "or">; // Optimized codegen when the non-memory output is not used. let Defs = [EFLAGS], mayLoad = 1, mayStore = 1, isCodeGenOnly = 1 in { From evan.cheng at apple.com Tue May 10 20:03:01 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 May 2011 01:03:01 -0000 Subject: [llvm-commits] [llvm] r131172 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp test/CodeGen/X86/hoist-common.ll Message-ID: <20110511010301.6D0BE2A6C12C@llvm.org> Author: evancheng Date: Tue May 10 20:03:01 2011 New Revision: 131172 URL: http://llvm.org/viewvc/llvm-project?rev=131172&view=rev Log: Add a late optimization to BranchFolding that hoist common instruction sequences at the start of basic blocks to their common predecessor. It's actually quite common (e.g. about 50 times in JM/lencod) and has shown to be a nice code size benefit. e.g. pushq %rax testl %edi, %edi jne LBB0_2 ## BB#1: xorb %al, %al popq %rdx ret LBB0_2: xorb %al, %al callq _foo popq %rdx ret => pushq %rax xorb %al, %al testl %edi, %edi je LBB0_2 ## BB#1: callq _foo LBB0_2: popq %rdx ret rdar://9145558 Added: llvm/trunk/test/CodeGen/X86/hoist-common.ll Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/CodeGen/BranchFolding.h llvm/trunk/lib/CodeGen/IfConversion.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131172&r1=131171&r2=131172&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Tue May 10 20:03:01 2011 @@ -41,6 +41,7 @@ STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); STATISTIC(NumBranchOpts, "Number of branches optimized"); STATISTIC(NumTailMerge , "Number of block tails merged"); +STATISTIC(NumHoist , "Number of times common instructions are hoisted"); static cl::opt FlagEnableTailMerge("enable-tail-merge", cl::init(cl::BOU_UNSET), cl::Hidden); @@ -65,7 +66,7 @@ public: static char ID; explicit BranchFolderPass(bool defaultEnableTailMerge) - : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge) {} + : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, true) {} virtual bool runOnMachineFunction(MachineFunction &MF); virtual const char *getPassName() const { return "Control Flow Optimizer"; } @@ -86,12 +87,14 @@ } -BranchFolder::BranchFolder(bool defaultEnableTailMerge) { +BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist) { switch (FlagEnableTailMerge) { case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; case cl::BOU_TRUE: EnableTailMerge = true; break; case cl::BOU_FALSE: EnableTailMerge = false; break; } + + EnableHoistCommonCode = CommonHoist; } /// RemoveDeadBlock - Remove the specified dead machine basic block from the @@ -186,9 +189,10 @@ bool MadeChangeThisIteration = true; while (MadeChangeThisIteration) { - MadeChangeThisIteration = false; - MadeChangeThisIteration |= TailMergeBlocks(MF); - MadeChangeThisIteration |= OptimizeBranches(MF); + MadeChangeThisIteration = TailMergeBlocks(MF); + MadeChangeThisIteration |= OptimizeBranches(MF); + if (EnableHoistCommonCode) + MadeChangeThisIteration |= HoistCommonCode(MF); MadeChange |= MadeChangeThisIteration; } @@ -910,7 +914,8 @@ // Make sure blocks are numbered in order MF.RenumberBlocks(); - for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { + for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); + I != E; ) { MachineBasicBlock *MBB = I++; MadeChange |= OptimizeBlock(MBB); @@ -1339,3 +1344,253 @@ return MadeChange; } + +//===----------------------------------------------------------------------===// +// Hoist Common Code +//===----------------------------------------------------------------------===// + +/// HoistCommonCode - Hoist common instruction sequences at the start of basic +/// blocks to their common predecessor. +/// NOTE: This optimization does not update live-in information so it must be +/// run after all passes that require correct liveness information. +bool BranchFolder::HoistCommonCode(MachineFunction &MF) { + bool MadeChange = false; + for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { + MachineBasicBlock *MBB = I++; + MadeChange |= HoistCommonCodeInSuccs(MBB); + } + + return MadeChange; +} + +/// findFalseBlock - BB has a fallthrough. Find its 'false' successor given +/// its 'true' successor. +static MachineBasicBlock *findFalseBlock(MachineBasicBlock *BB, + MachineBasicBlock *TrueBB) { + for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), + E = BB->succ_end(); SI != E; ++SI) { + MachineBasicBlock *SuccBB = *SI; + if (SuccBB != TrueBB) + return SuccBB; + } + return NULL; +} + +/// findHoistingInsertPosAndDeps - Find the location to move common instructions +/// in successors to. The location is ususally just before the terminator, +/// however if the terminator is a conditional branch and its previous +/// instruction is the flag setting instruction, the previous instruction is +/// the preferred location. This function also gathers uses and defs of the +/// instructions from the insertion point to the end of the block. The data is +/// used by HoistCommonCodeInSuccs to ensure safety. +static +MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB, + const TargetInstrInfo *TII, + const TargetRegisterInfo *TRI, + SmallSet &Uses, + SmallSet &Defs) { + MachineBasicBlock::iterator Loc = MBB->getFirstTerminator(); + if (!TII->isUnpredicatedTerminator(Loc)) + return MBB->end(); + + for (unsigned i = 0, e = Loc->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = Loc->getOperand(i); + if (!MO.isReg()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg) + continue; + if (MO.isUse()) { + Uses.insert(Reg); + for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) + Uses.insert(*AS); + } else if (!MO.isDead()) + // Don't try to hoist code in the rare case the terminator defines a + // register that is later used. + return MBB->end(); + } + + if (Uses.empty()) + return Loc; + if (Loc == MBB->begin()) + return MBB->end(); + + // The terminator is probably a conditional branch, try not to separate the + // branch from condition setting instruction. + MachineBasicBlock::iterator PI = Loc; + --PI; + while (PI != MBB->begin() && Loc->isDebugValue()) + --PI; + + bool IsDef = false; + for (unsigned i = 0, e = PI->getNumOperands(); !IsDef && i != e; ++i) { + const MachineOperand &MO = PI->getOperand(i); + if (!MO.isReg() || MO.isUse()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg) + continue; + if (Uses.count(Reg)) + IsDef = true; + } + if (!IsDef) + // The condition setting instruction is not just before the conditional + // branch. + return Loc; + + // Be conservative, don't insert instruction above something that may have + // side-effects. And since it's potentially bad to separate flag setting + // instruction from the conditional branch, just abort the optimization + // completely. + // Also avoid moving code above predicated instruction since it's hard to + // reason about register liveness with predicated instruction. + bool DontMoveAcrossStore = true; + if (!PI->isSafeToMove(TII, 0, DontMoveAcrossStore) || + TII->isPredicated(PI)) + return MBB->end(); + + + // Find out what registers are live. Note this routine is ignoring other live + // registers which are only used by instructions in successor blocks. + for (unsigned i = 0, e = PI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = PI->getOperand(i); + if (!MO.isReg()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg) + continue; + if (MO.isUse()) { + Uses.insert(Reg); + for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) + Uses.insert(*AS); + } else { + if (Uses.count(Reg)) { + Uses.erase(Reg); + for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) + Uses.erase(*SR); // Use getSubRegisters to be conservative + Defs.insert(Reg); + for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) + Defs.insert(*AS); + } + } + } + + return PI; +} + +/// HoistCommonCodeInSuccs - If the successors of MBB has common instruction +/// sequence at the start of the function, move the instructions before MBB +/// terminator if it's legal. +bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { + MachineBasicBlock *TBB = 0, *FBB = 0; + SmallVector Cond; + if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond, true) || !TBB || Cond.empty()) + return false; + + if (!FBB) FBB = findFalseBlock(MBB, TBB); + if (!FBB) + // Malformed bcc? True and false blocks are the same? + return false; + + // Restrict the optimization to cases where MBB is the only predecessor, + // it is an obvious win. + if (TBB->pred_size() > 1 || FBB->pred_size() > 1) + return false; + + // Find a suitable position to hoist the common instructions to. Also figure + // out which registers are used or defined by instructions from the insertion + // point to the end of the block. + SmallSet Uses, Defs; + MachineBasicBlock::iterator Loc = + findHoistingInsertPosAndDeps(MBB, TII, TRI, Uses, Defs); + if (Loc == MBB->end()) + return false; + + SmallSet LocalDefs; + unsigned NumDups = 0; + MachineBasicBlock::iterator TIB = TBB->begin(); + MachineBasicBlock::iterator FIB = FBB->begin(); + MachineBasicBlock::iterator TIE = TBB->end(); + MachineBasicBlock::iterator FIE = FBB->end(); + while (TIB != TIE && FIB != FIE) { + // Skip dbg_value instructions. These do not count. + if (TIB->isDebugValue()) { + while (TIB != TIE && TIB->isDebugValue()) + ++TIB; + if (TIB == TIE) + break; + } + if (FIB->isDebugValue()) { + while (FIB != FIE && FIB->isDebugValue()) + ++FIB; + if (FIB == FIE) + break; + } + if (!TIB->isIdenticalTo(FIB)) + break; + + if (TII->isPredicated(TIB)) + // Hard to reason about register liveness with predicated instruction. + break; + + bool IsSafe = true; + for (unsigned i = 0, e = TIB->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = TIB->getOperand(i); + if (!MO.isReg()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg) + continue; + if (MO.isDef()) { + if (Uses.count(Reg)) { + // Avoid clobbering a register that's used by the instruction at + // the point of insertion. + IsSafe = false; + break; + } + if (!MO.isDead() && Defs.count(Reg)) { + // Don't hoist the instruction if the def would be clobber by the + // instruction at the point insertion. FIXME: This is overly + // conservative. It should be possible to hoist the instructions + // in BB2 in the following example: + // BB1: + // r1, eflag = op1 r2, r3 + // brcc eflag + // + // BB2: + // r1 = op2, ... + // = op3, r1 + IsSafe = false; + break; + } + LocalDefs.insert(Reg); + for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) + LocalDefs.insert(*SR); + } else if (!LocalDefs.count(Reg)) { + if (Defs.count(Reg)) { + // Use is defined by the instruction at the point of insertion. + IsSafe = false; + break; + } + } + } + if (!IsSafe) + break; + + bool DontMoveAcrossStore = true; + if (!TIB->isSafeToMove(TII, 0, DontMoveAcrossStore)) + break; + + ++NumDups; + ++TIB; + ++FIB; + } + + if (!NumDups) + return false; + + MBB->splice(Loc, TBB, TBB->begin(), TIB); + FBB->erase(FBB->begin(), FIB); + ++NumHoist; + return true; +} Modified: llvm/trunk/lib/CodeGen/BranchFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=131172&r1=131171&r2=131172&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.h Tue May 10 20:03:01 2011 @@ -19,11 +19,10 @@ class RegScavenger; class TargetInstrInfo; class TargetRegisterInfo; - template class SmallVectorImpl; class BranchFolder { public: - explicit BranchFolder(bool defaultEnableTailMerge); + explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist); bool OptimizeFunction(MachineFunction &MF, const TargetInstrInfo *tii, @@ -85,6 +84,7 @@ std::vector SameTails; bool EnableTailMerge; + bool EnableHoistCommonCode; const TargetInstrInfo *TII; const TargetRegisterInfo *TRI; MachineModuleInfo *MMI; @@ -110,6 +110,9 @@ bool OptimizeBlock(MachineBasicBlock *MBB); void RemoveDeadBlock(MachineBasicBlock *MBB); bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); + + bool HoistCommonCode(MachineFunction &MF); + bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB); }; } Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=131172&r1=131171&r2=131172&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Tue May 10 20:03:01 2011 @@ -265,7 +265,7 @@ if (!TII) return false; // Tail merge tend to expose more if-conversion opportunities. - BranchFolder BF(true); + BranchFolder BF(true, false); bool BFChange = BF.OptimizeFunction(MF, TII, MF.getTarget().getRegisterInfo(), getAnalysisIfAvailable()); @@ -399,7 +399,7 @@ BBAnalysis.clear(); if (MadeChange && IfCvtBranchFold) { - BranchFolder BF(false); + BranchFolder BF(false, false); BF.OptimizeFunction(MF, TII, MF.getTarget().getRegisterInfo(), getAnalysisIfAvailable()); Added: llvm/trunk/test/CodeGen/X86/hoist-common.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hoist-common.ll?rev=131172&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/hoist-common.ll (added) +++ llvm/trunk/test/CodeGen/X86/hoist-common.ll Tue May 10 20:03:01 2011 @@ -0,0 +1,28 @@ +; RUN: llc < %s -march=x86-64 | FileCheck %s + +; Common "xorb al, al" instruction in the two successor blocks should be +; moved to the entry block above the test + je. + +; rdar://9145558 + +define zeroext i1 @t(i32 %c) nounwind ssp { +entry: +; CHECK: t: +; CHECK: xorb %al, %al +; CHECK: test +; CHECK: je + %tobool = icmp eq i32 %c, 0 + br i1 %tobool, label %return, label %if.then + +if.then: +; CHECK: callq + %call = tail call zeroext i1 (...)* @foo() nounwind + br label %return + +return: +; CHECK: ret + %retval.0 = phi i1 [ %call, %if.then ], [ false, %entry ] + ret i1 %retval.0 +} + +declare zeroext i1 @foo(...) From isanbard at gmail.com Tue May 10 20:08:39 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 May 2011 01:08:39 -0000 Subject: [llvm-commits] [llvm] r131173 - /llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h Message-ID: <20110511010839.BD3932A6C12C@llvm.org> Author: void Date: Tue May 10 20:08:39 2011 New Revision: 131173 URL: http://llvm.org/viewvc/llvm-project?rev=131173&view=rev Log: Fix comment. Modified: llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h Modified: llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h?rev=131173&r1=131172&r2=131173&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h Tue May 10 20:08:39 2011 @@ -107,11 +107,11 @@ // and returns an outchain. EH_SJLJ_LONGJMP, - // OUTCHAIN = EH_SJLJ_DISPATCHSETUP(INCHAIN, context) + // OUTCHAIN = EH_SJLJ_DISPATCHSETUP(INCHAIN, setjmpval) // This corresponds to the eh.sjlj.dispatchsetup intrinsic. It takes an - // input chain and a pointer to the sjlj function context as inputs and - // returns an outchain. By default, this does nothing. Targets can lower - // this to unwind setup code if needed. + // input chain and the value returning from setjmp as inputs and returns an + // outchain. By default, this does nothing. Targets can lower this to unwind + // setup code if needed. EH_SJLJ_DISPATCHSETUP, // TargetConstant* - Like Constant*, but the DAG does not do any folding, From isanbard at gmail.com Tue May 10 20:11:55 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 May 2011 01:11:55 -0000 Subject: [llvm-commits] [llvm] r131174 - in /llvm/trunk: include/llvm/Intrinsics.td lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp lib/CodeGen/SjLjEHPrepare.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td Message-ID: <20110511011155.704A32A6C12C@llvm.org> Author: void Date: Tue May 10 20:11:55 2011 New Revision: 131174 URL: http://llvm.org/viewvc/llvm-project?rev=131174&view=rev Log: Give the 'eh.sjlj.dispatchsetup' intrinsic call the value coming from the setjmp intrinsic call. This prevents it from being reordered so that it appears *before* the setjmp intrinsic (thus making it completely useless). Modified: llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=131174&r1=131173&r2=131174&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Tue May 10 20:11:55 2011 @@ -307,7 +307,7 @@ def int_eh_sjlj_lsda : Intrinsic<[llvm_ptr_ty]>; def int_eh_sjlj_callsite: Intrinsic<[], [llvm_i32_ty]>; } -def int_eh_sjlj_dispatch_setup : Intrinsic<[], []>; +def int_eh_sjlj_dispatch_setup : Intrinsic<[], [llvm_i32_ty], [IntrReadMem]>; def int_eh_sjlj_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>; def int_eh_sjlj_longjmp : Intrinsic<[], [llvm_ptr_ty]>; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=131174&r1=131173&r2=131174&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue May 10 20:11:55 2011 @@ -4403,7 +4403,7 @@ } case Intrinsic::eh_sjlj_dispatch_setup: { DAG.setRoot(DAG.getNode(ISD::EH_SJLJ_DISPATCHSETUP, dl, MVT::Other, - getRoot())); + getRoot(), getValue(I.getArgOperand(0)))); return 0; } Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=131174&r1=131173&r2=131174&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Tue May 10 20:11:55 2011 @@ -520,7 +520,7 @@ // Add a call to dispatch_setup after the setjmp call. This is expanded to any // target-specific setup that needs to be done. - CallInst::Create(DispatchSetupFn, "", EntryBB->getTerminator()); + CallInst::Create(DispatchSetupFn, DispatchVal, "", EntryBB->getTerminator()); // check the return value of the setjmp. non-zero goes to dispatcher. Value *IsNormal = new ICmpInst(EntryBB->getTerminator(), Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=131174&r1=131173&r2=131174&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue May 10 20:11:55 2011 @@ -2151,7 +2151,7 @@ const { DebugLoc dl = Op.getDebugLoc(); return DAG.getNode(ARMISD::EH_SJLJ_DISPATCHSETUP, dl, MVT::Other, - Op.getOperand(0)); + Op.getOperand(0), Op.getOperand(1)); } SDValue Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=131174&r1=131173&r2=131174&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue May 10 20:11:55 2011 @@ -58,7 +58,7 @@ SDTCisInt<2>]>; def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>; -def SDT_ARMEH_SJLJ_DispatchSetup: SDTypeProfile<0, 0, []>; +def SDT_ARMEH_SJLJ_DispatchSetup: SDTypeProfile<0, 1, [SDTCisInt<0>]>; def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>; @@ -3786,8 +3786,8 @@ // that need the instruction size). let isBarrier = 1, hasSideEffects = 1 in def Int_eh_sjlj_dispatchsetup : - PseudoInst<(outs), (ins), NoItinerary, - [(ARMeh_sjlj_dispatchsetup)]>, + PseudoInst<(outs), (ins GPR:$src), NoItinerary, + [(ARMeh_sjlj_dispatchsetup GPR:$src)]>, Requires<[IsDarwin]>; //===----------------------------------------------------------------------===// From rafael.espindola at gmail.com Tue May 10 22:27:17 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 11 May 2011 03:27:17 -0000 Subject: [llvm-commits] [llvm] r131176 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp test/CodeGen/X86/hoist-common.ll Message-ID: <20110511032717.8F2842A6C12C@llvm.org> Author: rafael Date: Tue May 10 22:27:17 2011 New Revision: 131176 URL: http://llvm.org/viewvc/llvm-project?rev=131176&view=rev Log: Revert 131172 as it is causing clang to miscompile itself. I will try to provide a reduced testcase. Removed: llvm/trunk/test/CodeGen/X86/hoist-common.ll Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/CodeGen/BranchFolding.h llvm/trunk/lib/CodeGen/IfConversion.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131176&r1=131175&r2=131176&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Tue May 10 22:27:17 2011 @@ -41,7 +41,6 @@ STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); STATISTIC(NumBranchOpts, "Number of branches optimized"); STATISTIC(NumTailMerge , "Number of block tails merged"); -STATISTIC(NumHoist , "Number of times common instructions are hoisted"); static cl::opt FlagEnableTailMerge("enable-tail-merge", cl::init(cl::BOU_UNSET), cl::Hidden); @@ -66,7 +65,7 @@ public: static char ID; explicit BranchFolderPass(bool defaultEnableTailMerge) - : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, true) {} + : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge) {} virtual bool runOnMachineFunction(MachineFunction &MF); virtual const char *getPassName() const { return "Control Flow Optimizer"; } @@ -87,14 +86,12 @@ } -BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist) { +BranchFolder::BranchFolder(bool defaultEnableTailMerge) { switch (FlagEnableTailMerge) { case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; case cl::BOU_TRUE: EnableTailMerge = true; break; case cl::BOU_FALSE: EnableTailMerge = false; break; } - - EnableHoistCommonCode = CommonHoist; } /// RemoveDeadBlock - Remove the specified dead machine basic block from the @@ -189,10 +186,9 @@ bool MadeChangeThisIteration = true; while (MadeChangeThisIteration) { - MadeChangeThisIteration = TailMergeBlocks(MF); - MadeChangeThisIteration |= OptimizeBranches(MF); - if (EnableHoistCommonCode) - MadeChangeThisIteration |= HoistCommonCode(MF); + MadeChangeThisIteration = false; + MadeChangeThisIteration |= TailMergeBlocks(MF); + MadeChangeThisIteration |= OptimizeBranches(MF); MadeChange |= MadeChangeThisIteration; } @@ -914,8 +910,7 @@ // Make sure blocks are numbered in order MF.RenumberBlocks(); - for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); - I != E; ) { + for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { MachineBasicBlock *MBB = I++; MadeChange |= OptimizeBlock(MBB); @@ -1344,253 +1339,3 @@ return MadeChange; } - -//===----------------------------------------------------------------------===// -// Hoist Common Code -//===----------------------------------------------------------------------===// - -/// HoistCommonCode - Hoist common instruction sequences at the start of basic -/// blocks to their common predecessor. -/// NOTE: This optimization does not update live-in information so it must be -/// run after all passes that require correct liveness information. -bool BranchFolder::HoistCommonCode(MachineFunction &MF) { - bool MadeChange = false; - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { - MachineBasicBlock *MBB = I++; - MadeChange |= HoistCommonCodeInSuccs(MBB); - } - - return MadeChange; -} - -/// findFalseBlock - BB has a fallthrough. Find its 'false' successor given -/// its 'true' successor. -static MachineBasicBlock *findFalseBlock(MachineBasicBlock *BB, - MachineBasicBlock *TrueBB) { - for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), - E = BB->succ_end(); SI != E; ++SI) { - MachineBasicBlock *SuccBB = *SI; - if (SuccBB != TrueBB) - return SuccBB; - } - return NULL; -} - -/// findHoistingInsertPosAndDeps - Find the location to move common instructions -/// in successors to. The location is ususally just before the terminator, -/// however if the terminator is a conditional branch and its previous -/// instruction is the flag setting instruction, the previous instruction is -/// the preferred location. This function also gathers uses and defs of the -/// instructions from the insertion point to the end of the block. The data is -/// used by HoistCommonCodeInSuccs to ensure safety. -static -MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB, - const TargetInstrInfo *TII, - const TargetRegisterInfo *TRI, - SmallSet &Uses, - SmallSet &Defs) { - MachineBasicBlock::iterator Loc = MBB->getFirstTerminator(); - if (!TII->isUnpredicatedTerminator(Loc)) - return MBB->end(); - - for (unsigned i = 0, e = Loc->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = Loc->getOperand(i); - if (!MO.isReg()) - continue; - unsigned Reg = MO.getReg(); - if (!Reg) - continue; - if (MO.isUse()) { - Uses.insert(Reg); - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) - Uses.insert(*AS); - } else if (!MO.isDead()) - // Don't try to hoist code in the rare case the terminator defines a - // register that is later used. - return MBB->end(); - } - - if (Uses.empty()) - return Loc; - if (Loc == MBB->begin()) - return MBB->end(); - - // The terminator is probably a conditional branch, try not to separate the - // branch from condition setting instruction. - MachineBasicBlock::iterator PI = Loc; - --PI; - while (PI != MBB->begin() && Loc->isDebugValue()) - --PI; - - bool IsDef = false; - for (unsigned i = 0, e = PI->getNumOperands(); !IsDef && i != e; ++i) { - const MachineOperand &MO = PI->getOperand(i); - if (!MO.isReg() || MO.isUse()) - continue; - unsigned Reg = MO.getReg(); - if (!Reg) - continue; - if (Uses.count(Reg)) - IsDef = true; - } - if (!IsDef) - // The condition setting instruction is not just before the conditional - // branch. - return Loc; - - // Be conservative, don't insert instruction above something that may have - // side-effects. And since it's potentially bad to separate flag setting - // instruction from the conditional branch, just abort the optimization - // completely. - // Also avoid moving code above predicated instruction since it's hard to - // reason about register liveness with predicated instruction. - bool DontMoveAcrossStore = true; - if (!PI->isSafeToMove(TII, 0, DontMoveAcrossStore) || - TII->isPredicated(PI)) - return MBB->end(); - - - // Find out what registers are live. Note this routine is ignoring other live - // registers which are only used by instructions in successor blocks. - for (unsigned i = 0, e = PI->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = PI->getOperand(i); - if (!MO.isReg()) - continue; - unsigned Reg = MO.getReg(); - if (!Reg) - continue; - if (MO.isUse()) { - Uses.insert(Reg); - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) - Uses.insert(*AS); - } else { - if (Uses.count(Reg)) { - Uses.erase(Reg); - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) - Uses.erase(*SR); // Use getSubRegisters to be conservative - Defs.insert(Reg); - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) - Defs.insert(*AS); - } - } - } - - return PI; -} - -/// HoistCommonCodeInSuccs - If the successors of MBB has common instruction -/// sequence at the start of the function, move the instructions before MBB -/// terminator if it's legal. -bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { - MachineBasicBlock *TBB = 0, *FBB = 0; - SmallVector Cond; - if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond, true) || !TBB || Cond.empty()) - return false; - - if (!FBB) FBB = findFalseBlock(MBB, TBB); - if (!FBB) - // Malformed bcc? True and false blocks are the same? - return false; - - // Restrict the optimization to cases where MBB is the only predecessor, - // it is an obvious win. - if (TBB->pred_size() > 1 || FBB->pred_size() > 1) - return false; - - // Find a suitable position to hoist the common instructions to. Also figure - // out which registers are used or defined by instructions from the insertion - // point to the end of the block. - SmallSet Uses, Defs; - MachineBasicBlock::iterator Loc = - findHoistingInsertPosAndDeps(MBB, TII, TRI, Uses, Defs); - if (Loc == MBB->end()) - return false; - - SmallSet LocalDefs; - unsigned NumDups = 0; - MachineBasicBlock::iterator TIB = TBB->begin(); - MachineBasicBlock::iterator FIB = FBB->begin(); - MachineBasicBlock::iterator TIE = TBB->end(); - MachineBasicBlock::iterator FIE = FBB->end(); - while (TIB != TIE && FIB != FIE) { - // Skip dbg_value instructions. These do not count. - if (TIB->isDebugValue()) { - while (TIB != TIE && TIB->isDebugValue()) - ++TIB; - if (TIB == TIE) - break; - } - if (FIB->isDebugValue()) { - while (FIB != FIE && FIB->isDebugValue()) - ++FIB; - if (FIB == FIE) - break; - } - if (!TIB->isIdenticalTo(FIB)) - break; - - if (TII->isPredicated(TIB)) - // Hard to reason about register liveness with predicated instruction. - break; - - bool IsSafe = true; - for (unsigned i = 0, e = TIB->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = TIB->getOperand(i); - if (!MO.isReg()) - continue; - unsigned Reg = MO.getReg(); - if (!Reg) - continue; - if (MO.isDef()) { - if (Uses.count(Reg)) { - // Avoid clobbering a register that's used by the instruction at - // the point of insertion. - IsSafe = false; - break; - } - if (!MO.isDead() && Defs.count(Reg)) { - // Don't hoist the instruction if the def would be clobber by the - // instruction at the point insertion. FIXME: This is overly - // conservative. It should be possible to hoist the instructions - // in BB2 in the following example: - // BB1: - // r1, eflag = op1 r2, r3 - // brcc eflag - // - // BB2: - // r1 = op2, ... - // = op3, r1 - IsSafe = false; - break; - } - LocalDefs.insert(Reg); - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) - LocalDefs.insert(*SR); - } else if (!LocalDefs.count(Reg)) { - if (Defs.count(Reg)) { - // Use is defined by the instruction at the point of insertion. - IsSafe = false; - break; - } - } - } - if (!IsSafe) - break; - - bool DontMoveAcrossStore = true; - if (!TIB->isSafeToMove(TII, 0, DontMoveAcrossStore)) - break; - - ++NumDups; - ++TIB; - ++FIB; - } - - if (!NumDups) - return false; - - MBB->splice(Loc, TBB, TBB->begin(), TIB); - FBB->erase(FBB->begin(), FIB); - ++NumHoist; - return true; -} Modified: llvm/trunk/lib/CodeGen/BranchFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=131176&r1=131175&r2=131176&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.h Tue May 10 22:27:17 2011 @@ -19,10 +19,11 @@ class RegScavenger; class TargetInstrInfo; class TargetRegisterInfo; + template class SmallVectorImpl; class BranchFolder { public: - explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist); + explicit BranchFolder(bool defaultEnableTailMerge); bool OptimizeFunction(MachineFunction &MF, const TargetInstrInfo *tii, @@ -84,7 +85,6 @@ std::vector SameTails; bool EnableTailMerge; - bool EnableHoistCommonCode; const TargetInstrInfo *TII; const TargetRegisterInfo *TRI; MachineModuleInfo *MMI; @@ -110,9 +110,6 @@ bool OptimizeBlock(MachineBasicBlock *MBB); void RemoveDeadBlock(MachineBasicBlock *MBB); bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); - - bool HoistCommonCode(MachineFunction &MF); - bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB); }; } Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=131176&r1=131175&r2=131176&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Tue May 10 22:27:17 2011 @@ -265,7 +265,7 @@ if (!TII) return false; // Tail merge tend to expose more if-conversion opportunities. - BranchFolder BF(true, false); + BranchFolder BF(true); bool BFChange = BF.OptimizeFunction(MF, TII, MF.getTarget().getRegisterInfo(), getAnalysisIfAvailable()); @@ -399,7 +399,7 @@ BBAnalysis.clear(); if (MadeChange && IfCvtBranchFold) { - BranchFolder BF(false, false); + BranchFolder BF(false); BF.OptimizeFunction(MF, TII, MF.getTarget().getRegisterInfo(), getAnalysisIfAvailable()); Removed: llvm/trunk/test/CodeGen/X86/hoist-common.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hoist-common.ll?rev=131175&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/hoist-common.ll (original) +++ llvm/trunk/test/CodeGen/X86/hoist-common.ll (removed) @@ -1,28 +0,0 @@ -; RUN: llc < %s -march=x86-64 | FileCheck %s - -; Common "xorb al, al" instruction in the two successor blocks should be -; moved to the entry block above the test + je. - -; rdar://9145558 - -define zeroext i1 @t(i32 %c) nounwind ssp { -entry: -; CHECK: t: -; CHECK: xorb %al, %al -; CHECK: test -; CHECK: je - %tobool = icmp eq i32 %c, 0 - br i1 %tobool, label %return, label %if.then - -if.then: -; CHECK: callq - %call = tail call zeroext i1 (...)* @foo() nounwind - br label %return - -return: -; CHECK: ret - %retval.0 = phi i1 [ %call, %if.then ], [ false, %entry ] - ret i1 %retval.0 -} - -declare zeroext i1 @foo(...) From nadav.rotem at intel.com Wed May 11 02:33:04 2011 From: nadav.rotem at intel.com (Rotem, Nadav) Date: Wed, 11 May 2011 10:33:04 +0300 Subject: [llvm-commits] [PATCH] - Fix a bug in DAGCombining of extract-load Message-ID: <6594DDFF12B03D4E89690887C2486994027D6A20A8@hasmsx504.ger.corp.intel.com> Hi, Please review the attached patch. This patch fixes a bug in the DAGCombiner. LoadSDNodes have two values (data, chain). If there is a store after the load node, then there is a chain, which means that there is another user. Thus, asking hasOneUser would fail. Instead we ask hasNUsesOfValue on the 'data' value. Thanks, Nadav --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110511/5a9785c8/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: LN0_uses.diff Type: application/octet-stream Size: 1091 bytes Desc: LN0_uses.diff Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110511/5a9785c8/attachment.obj From baldrick at free.fr Wed May 11 02:41:07 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 11 May 2011 09:41:07 +0200 Subject: [llvm-commits] [PATCH] - Fix a bug in DAGCombining of extract-load In-Reply-To: <6594DDFF12B03D4E89690887C2486994027D6A20A8@hasmsx504.ger.corp.intel.com> References: <6594DDFF12B03D4E89690887C2486994027D6A20A8@hasmsx504.ger.corp.intel.com> Message-ID: <4DCA3D93.6080004@free.fr> Hi Nadav, > This patch fixes a bug in the DAGCombiner. LoadSDNodes have two values (data, > chain). > > If there is a store after the load node, then there is a chain, which means that > there is another user. > > Thus, asking hasOneUser would fail. Instead we ask hasNUsesOfValue on the 'data' > value. this looks OK to me. Ciao, Duncan. From nadav.rotem at intel.com Wed May 11 03:12:10 2011 From: nadav.rotem at intel.com (Nadav Rotem) Date: Wed, 11 May 2011 08:12:10 -0000 Subject: [llvm-commits] [llvm] r131179 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h test/CodeGen/X86/x86-shifts.ll Message-ID: <20110511081210.4F4272A6C12D@llvm.org> Author: nadav Date: Wed May 11 03:12:09 2011 New Revision: 131179 URL: http://llvm.org/viewvc/llvm-project?rev=131179&view=rev Log: Add custom lowering of X86 vector SRA/SRL/SHL when the shift amount is a splat vector. Added: llvm/trunk/test/CodeGen/X86/x86-shifts.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=131179&r1=131178&r2=131179&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed May 11 03:12:09 2011 @@ -927,7 +927,6 @@ // Can turn SHL into an integer multiply. setOperationAction(ISD::SHL, MVT::v4i32, Custom); setOperationAction(ISD::SHL, MVT::v16i8, Custom); - setOperationAction(ISD::SRL, MVT::v4i32, Legal); // i8 and i16 vectors are custom , because the source register and source // source memory operand types are not the same width. f32 vectors are @@ -949,6 +948,19 @@ } } + if (Subtarget->hasSSE2()) { + setOperationAction(ISD::SRL, MVT::v2i64, Custom); + setOperationAction(ISD::SRL, MVT::v4i32, Custom); + setOperationAction(ISD::SRL, MVT::v16i8, Custom); + + setOperationAction(ISD::SHL, MVT::v2i64, Custom); + setOperationAction(ISD::SHL, MVT::v4i32, Custom); + setOperationAction(ISD::SHL, MVT::v8i16, Custom); + + setOperationAction(ISD::SRA, MVT::v4i32, Custom); + setOperationAction(ISD::SRA, MVT::v8i16, Custom); + } + if (Subtarget->hasSSE42()) setOperationAction(ISD::VSETCC, MVT::v2i64, Custom); @@ -6616,9 +6628,9 @@ } -/// LowerShift - Lower SRA_PARTS and friends, which return two i32 values and +/// LowerShiftParts - Lower SRA_PARTS and friends, which return two i32 values and /// take a 2 x i32 value to shift plus a shift amount. -SDValue X86TargetLowering::LowerShift(SDValue Op, SelectionDAG &DAG) const { +SDValue X86TargetLowering::LowerShiftParts(SDValue Op, SelectionDAG &DAG) const { assert(Op.getNumOperands() == 3 && "Not a double-shift!"); EVT VT = Op.getValueType(); unsigned VTBits = VT.getSizeInBits(); @@ -8778,16 +8790,71 @@ return Res; } -SDValue X86TargetLowering::LowerSHL(SDValue Op, SelectionDAG &DAG) const { +SDValue X86TargetLowering::LowerShift(SDValue Op, SelectionDAG &DAG) const { + EVT VT = Op.getValueType(); DebugLoc dl = Op.getDebugLoc(); SDValue R = Op.getOperand(0); + SDValue Amt = Op.getOperand(1); LLVMContext *Context = DAG.getContext(); - assert(Subtarget->hasSSE41() && "Cannot lower SHL without SSE4.1 or later"); + // Must have SSE2. + if (!Subtarget->hasSSE2()) return SDValue(); + + // Optimize shl/srl/sra with constant shift amount. + if (isSplatVector(Amt.getNode())) { + SDValue SclrAmt = Amt->getOperand(0); + if (ConstantSDNode *C = dyn_cast(SclrAmt)) { + uint64_t ShiftAmt = C->getZExtValue(); + + if (VT == MVT::v2i64 && Op.getOpcode() == ISD::SHL) + return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, + DAG.getConstant(Intrinsic::x86_sse2_pslli_q, MVT::i32), + R, DAG.getConstant(ShiftAmt, MVT::i32)); + + if (VT == MVT::v4i32 && Op.getOpcode() == ISD::SHL) + return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, + DAG.getConstant(Intrinsic::x86_sse2_pslli_d, MVT::i32), + R, DAG.getConstant(ShiftAmt, MVT::i32)); + + if (VT == MVT::v8i16 && Op.getOpcode() == ISD::SHL) + return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, + DAG.getConstant(Intrinsic::x86_sse2_pslli_w, MVT::i32), + R, DAG.getConstant(ShiftAmt, MVT::i32)); + + if (VT == MVT::v2i64 && Op.getOpcode() == ISD::SRL) + return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, + DAG.getConstant(Intrinsic::x86_sse2_psrli_q, MVT::i32), + R, DAG.getConstant(ShiftAmt, MVT::i32)); + + if (VT == MVT::v4i32 && Op.getOpcode() == ISD::SRL) + return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, + DAG.getConstant(Intrinsic::x86_sse2_psrli_d, MVT::i32), + R, DAG.getConstant(ShiftAmt, MVT::i32)); + + if (VT == MVT::v8i16 && Op.getOpcode() == ISD::SRL) + return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, + DAG.getConstant(Intrinsic::x86_sse2_psrli_w, MVT::i32), + R, DAG.getConstant(ShiftAmt, MVT::i32)); - if (VT == MVT::v4i32) { + if (VT == MVT::v4i32 && Op.getOpcode() == ISD::SRA) + return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, + DAG.getConstant(Intrinsic::x86_sse2_psrai_d, MVT::i32), + R, DAG.getConstant(ShiftAmt, MVT::i32)); + + if (VT == MVT::v8i16 && Op.getOpcode() == ISD::SRA) + return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, + DAG.getConstant(Intrinsic::x86_sse2_psrai_w, MVT::i32), + R, DAG.getConstant(ShiftAmt, MVT::i32)); + } + } + + // Lower SHL with variable shift amount. + // Cannot lower SHL without SSE4.1 or later. + if (!Subtarget->hasSSE41()) return SDValue(); + + if (VT == MVT::v4i32 && Op->getOpcode() == ISD::SHL) { Op = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, DAG.getConstant(Intrinsic::x86_sse2_pslli_d, MVT::i32), Op.getOperand(1), DAG.getConstant(23, MVT::i32)); @@ -8806,7 +8873,7 @@ Op = DAG.getNode(ISD::FP_TO_SINT, dl, VT, Op); return DAG.getNode(ISD::MUL, dl, VT, Op, R); } - if (VT == MVT::v16i8) { + if (VT == MVT::v16i8 && Op->getOpcode() == ISD::SHL) { // a = a << 5; Op = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, DAG.getConstant(Intrinsic::x86_sse2_pslli_w, MVT::i32), @@ -9111,7 +9178,7 @@ case ISD::BlockAddress: return LowerBlockAddress(Op, DAG); case ISD::SHL_PARTS: case ISD::SRA_PARTS: - case ISD::SRL_PARTS: return LowerShift(Op, DAG); + case ISD::SRL_PARTS: return LowerShiftParts(Op, DAG); case ISD::SINT_TO_FP: return LowerSINT_TO_FP(Op, DAG); case ISD::UINT_TO_FP: return LowerUINT_TO_FP(Op, DAG); case ISD::FP_TO_SINT: return LowerFP_TO_SINT(Op, DAG); @@ -9139,7 +9206,9 @@ case ISD::CTLZ: return LowerCTLZ(Op, DAG); case ISD::CTTZ: return LowerCTTZ(Op, DAG); case ISD::MUL: return LowerMUL_V2I64(Op, DAG); - case ISD::SHL: return LowerSHL(Op, DAG); + case ISD::SRA: + case ISD::SRL: + case ISD::SHL: return LowerShift(Op, DAG); case ISD::SADDO: case ISD::UADDO: case ISD::SSUBO: Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=131179&r1=131178&r2=131179&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Wed May 11 03:12:09 2011 @@ -770,7 +770,7 @@ SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const; SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const; - SDValue LowerShift(SDValue Op, SelectionDAG &DAG) const; + SDValue LowerShiftParts(SDValue Op, SelectionDAG &DAG) const; SDValue BuildFILD(SDValue Op, EVT SrcVT, SDValue Chain, SDValue StackSlot, SelectionDAG &DAG) const; SDValue LowerBITCAST(SDValue op, SelectionDAG &DAG) const; @@ -805,7 +805,7 @@ SDValue LowerCTLZ(SDValue Op, SelectionDAG &DAG) const; SDValue LowerCTTZ(SDValue Op, SelectionDAG &DAG) const; SDValue LowerMUL_V2I64(SDValue Op, SelectionDAG &DAG) const; - SDValue LowerSHL(SDValue Op, SelectionDAG &DAG) const; + SDValue LowerShift(SDValue Op, SelectionDAG &DAG) const; SDValue LowerXALUO(SDValue Op, SelectionDAG &DAG) const; SDValue LowerCMP_SWAP(SDValue Op, SelectionDAG &DAG) const; Added: llvm/trunk/test/CodeGen/X86/x86-shifts.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-shifts.ll?rev=131179&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/x86-shifts.ll (added) +++ llvm/trunk/test/CodeGen/X86/x86-shifts.ll Wed May 11 03:12:09 2011 @@ -0,0 +1,142 @@ +; RUN: llc < %s -march=x86-64 -mcpu=corei7 | FileCheck %s + +; Splat patterns below + + +define <4 x i32> @shl4(<4 x i32> %A) nounwind { +entry: +; CHECK: shl4 +; CHECK: pslld +; CHECK-NEXT: pslld + %B = shl <4 x i32> %A, < i32 2, i32 2, i32 2, i32 2> + %C = shl <4 x i32> %A, < i32 1, i32 1, i32 1, i32 1> + %K = xor <4 x i32> %B, %C + ret <4 x i32> %K +} + +define <4 x i32> @shr4(<4 x i32> %A) nounwind { +entry: +; CHECK: shr4 +; CHECK: psrld +; CHECK-NEXT: psrld + %B = lshr <4 x i32> %A, < i32 2, i32 2, i32 2, i32 2> + %C = lshr <4 x i32> %A, < i32 1, i32 1, i32 1, i32 1> + %K = xor <4 x i32> %B, %C + ret <4 x i32> %K +} + +define <4 x i32> @sra4(<4 x i32> %A) nounwind { +entry: +; CHECK: sra4 +; CHECK: psrad +; CHECK-NEXT: psrad + %B = ashr <4 x i32> %A, < i32 2, i32 2, i32 2, i32 2> + %C = ashr <4 x i32> %A, < i32 1, i32 1, i32 1, i32 1> + %K = xor <4 x i32> %B, %C + ret <4 x i32> %K +} + +define <2 x i64> @shl2(<2 x i64> %A) nounwind { +entry: +; CHECK: shl2 +; CHECK: psllq +; CHECK-NEXT: psllq + %B = shl <2 x i64> %A, < i64 2, i64 2> + %C = shl <2 x i64> %A, < i64 9, i64 9> + %K = xor <2 x i64> %B, %C + ret <2 x i64> %K +} + +define <2 x i64> @shr2(<2 x i64> %A) nounwind { +entry: +; CHECK: shr2 +; CHECK: psrlq +; CHECK-NEXT: psrlq + %B = lshr <2 x i64> %A, < i64 8, i64 8> + %C = lshr <2 x i64> %A, < i64 1, i64 1> + %K = xor <2 x i64> %B, %C + ret <2 x i64> %K +} + + +define <8 x i16> @shl8(<8 x i16> %A) nounwind { +entry: +; CHECK: shl8 +; CHECK: psllw +; CHECK-NEXT: psllw + %B = shl <8 x i16> %A, < i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2> + %C = shl <8 x i16> %A, < i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1> + %K = xor <8 x i16> %B, %C + ret <8 x i16> %K +} + +define <8 x i16> @shr8(<8 x i16> %A) nounwind { +entry: +; CHECK: shr8 +; CHECK: psrlw +; CHECK-NEXT: psrlw + %B = lshr <8 x i16> %A, < i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2> + %C = lshr <8 x i16> %A, < i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1> + %K = xor <8 x i16> %B, %C + ret <8 x i16> %K +} + +define <8 x i16> @sra8(<8 x i16> %A) nounwind { +entry: +; CHECK: sra8 +; CHECK: psraw +; CHECK-NEXT: psraw + %B = ashr <8 x i16> %A, < i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2> + %C = ashr <8 x i16> %A, < i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1> + %K = xor <8 x i16> %B, %C + ret <8 x i16> %K +} + +; non splat test + + +define <8 x i16> @sll8_nosplat(<8 x i16> %A) nounwind { +entry: +; CHECK: sll8_nosplat +; CHECK-NOT: psll +; CHECK-NOT: psll + %B = shl <8 x i16> %A, < i16 1, i16 2, i16 3, i16 6, i16 2, i16 2, i16 2, i16 2> + %C = shl <8 x i16> %A, < i16 9, i16 7, i16 5, i16 1, i16 4, i16 1, i16 1, i16 1> + %K = xor <8 x i16> %B, %C + ret <8 x i16> %K +} + + +define <2 x i64> @shr2_nosplat(<2 x i64> %A) nounwind { +entry: +; CHECK: shr2_nosplat +; CHECK-NOT: psrlq +; CHECK-NOT: psrlq + %B = lshr <2 x i64> %A, < i64 8, i64 1> + %C = lshr <2 x i64> %A, < i64 1, i64 0> + %K = xor <2 x i64> %B, %C + ret <2 x i64> %K +} + + +; Other shifts + +define <2 x i32> @shl2_other(<2 x i32> %A) nounwind { +entry: +; CHECK: shl2_other +; CHECK-not: psllq + %B = shl <2 x i32> %A, < i32 2, i32 2> + %C = shl <2 x i32> %A, < i32 9, i32 9> + %K = xor <2 x i32> %B, %C + ret <2 x i32> %K +} + +define <2 x i32> @shr2_other(<2 x i32> %A) nounwind { +entry: +; CHECK: shr2_other +; CHECK-NOT: psrlq + %B = lshr <2 x i32> %A, < i32 8, i32 8> + %C = lshr <2 x i32> %A, < i32 1, i32 1> + %K = xor <2 x i32> %B, %C + ret <2 x i32> %K +} From baldrick at free.fr Wed May 11 07:04:25 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 11 May 2011 12:04:25 -0000 Subject: [llvm-commits] [dragonegg] r131180 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp Message-ID: <20110511120425.1BA1B2A6C12C@llvm.org> Author: baldrick Date: Wed May 11 07:04:24 2011 New Revision: 131180 URL: http://llvm.org/viewvc/llvm-project?rev=131180&view=rev Log: Add support for VEC_UNPACK_HI_EXPR and VEC_UNPACK_LO_EXPR which the GCC tree vectorizer may produce when GCC optimizations are enabled. This fixes PR9714. Modified: dragonegg/trunk/include/dragonegg/Internals.h dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/include/dragonegg/Internals.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=131180&r1=131179&r2=131180&view=diff ============================================================================== --- dragonegg/trunk/include/dragonegg/Internals.h (original) +++ dragonegg/trunk/include/dragonegg/Internals.h Wed May 11 07:04:24 2011 @@ -723,6 +723,8 @@ Value *EmitReg_VEC_INTERLEAVE_LOW_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_VEC_PACK_TRUNC_EXPR(tree_node *type, tree_node *op0, tree_node *op1); + Value *EmitReg_VEC_UNPACK_HI_EXPR(tree_node *type, tree_node *op0); + Value *EmitReg_VEC_UNPACK_LO_EXPR(tree_node *type, tree_node *op0); Value *EmitLoadOfLValue(tree_node *exp); Value *EmitOBJ_TYPE_REF(tree_node *exp); Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131180&r1=131179&r2=131180&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Wed May 11 07:04:24 2011 @@ -7024,6 +7024,52 @@ return Builder.CreateShuffleVector(LHS, RHS, ConstantVector::get(Mask)); } +Value *TreeToLLVM::EmitReg_VEC_UNPACK_HI_EXPR(tree type, tree op0) { + // Eg: <2 x double> = VEC_UNPACK_HI_EXPR(<4 x float>) + Value *Op = EmitRegister(op0); + + // Extract the high elements, eg: <4 x float> -> <2 x float>. + unsigned Length = TYPE_VECTOR_SUBPARTS(type); + SmallVector Mask; + Mask.reserve(Length); + for (unsigned i = 0; i != Length; ++i) + Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), Length + i)); + Op = Builder.CreateShuffleVector(Op, UndefValue::get(Op->getType()), + ConstantVector::get(Mask)); + + // Extend the input elements to the output element type, eg: <2 x float> + // -> <2 x double>. + const Type *ExtTy = getRegType(type); + if (FLOAT_TYPE_P(TREE_TYPE(TREE_TYPE(op0)))) + return Builder.CreateFPExt(Op, ExtTy); + if (TYPE_UNSIGNED(TREE_TYPE(TREE_TYPE(op0)))) + return Builder.CreateZExt(Op, ExtTy); + return Builder.CreateSExt(Op, ExtTy); +} + +Value *TreeToLLVM::EmitReg_VEC_UNPACK_LO_EXPR(tree type, tree op0) { + // Eg: <2 x double> = VEC_UNPACK_LO_EXPR(<4 x float>) + Value *Op = EmitRegister(op0); + + // Extract the low elements, eg: <4 x float> -> <2 x float>. + unsigned Length = TYPE_VECTOR_SUBPARTS(type); + SmallVector Mask; + Mask.reserve(Length); + for (unsigned i = 0; i != Length; ++i) + Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), i)); + Op = Builder.CreateShuffleVector(Op, UndefValue::get(Op->getType()), + ConstantVector::get(Mask)); + + // Extend the input elements to the output element type, eg: <2 x float> + // -> <2 x double>. + const Type *ExtTy = getRegType(type); + if (FLOAT_TYPE_P(TREE_TYPE(TREE_TYPE(op0)))) + return Builder.CreateFPExt(Op, ExtTy); + if (TYPE_UNSIGNED(TREE_TYPE(TREE_TYPE(op0)))) + return Builder.CreateZExt(Op, ExtTy); + return Builder.CreateSExt(Op, ExtTy); +} + //===----------------------------------------------------------------------===// // ... Exception Handling ... @@ -7991,6 +8037,10 @@ RHS = EmitReg_VEC_INTERLEAVE_LOW_EXPR(rhs1, rhs2); break; case VEC_PACK_TRUNC_EXPR: RHS = EmitReg_VEC_PACK_TRUNC_EXPR(type, rhs1, rhs2); break; + case VEC_UNPACK_HI_EXPR: + RHS = EmitReg_VEC_UNPACK_HI_EXPR(type, rhs1); break; + case VEC_UNPACK_LO_EXPR: + RHS = EmitReg_VEC_UNPACK_LO_EXPR(type, rhs1); break; } assert(RHS->getType() == getRegType(type) && "RHS has wrong type!"); From ofv at wanadoo.es Wed May 11 08:53:08 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Wed, 11 May 2011 13:53:08 -0000 Subject: [llvm-commits] [llvm] r131181 - in /llvm/trunk: cmake/modules/HandleLLVMOptions.cmake cmake/modules/LLVMProcessSources.cmake unittests/CMakeLists.txt Message-ID: <20110511135308.7D9112A6C12C@llvm.org> Author: ofv Date: Wed May 11 08:53:08 2011 New Revision: 131181 URL: http://llvm.org/viewvc/llvm-project?rev=131181&view=rev Log: Handle gcc-compatible compilers (such as clang) the same way we handle gcc. Fixes PR9886. Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake llvm/trunk/cmake/modules/LLVMProcessSources.cmake llvm/trunk/unittests/CMakeLists.txt Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=131181&r1=131180&r2=131181&view=diff ============================================================================== --- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original) +++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Wed May 11 08:53:08 2011 @@ -1,5 +1,11 @@ include(AddLLVMDefinitions) +if( CMAKE_COMPILER_IS_GNUCXX ) + set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON) +elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) + set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON) +endif() + # Run-time build mode; It is used for unittests. if(MSVC_IDE) # Expect "$(Configuration)", "$(OutDir)", etc. @@ -167,7 +173,7 @@ if (LLVM_ENABLE_WERROR) add_llvm_definitions( /WX ) endif (LLVM_ENABLE_WERROR) -elseif( CMAKE_COMPILER_IS_GNUCXX ) +elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE ) if (LLVM_ENABLE_WARNINGS) add_llvm_definitions( -Wall -W -Wno-unused-parameter -Wwrite-strings ) if (LLVM_ENABLE_PEDANTIC) Modified: llvm/trunk/cmake/modules/LLVMProcessSources.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMProcessSources.cmake?rev=131181&r1=131180&r2=131181&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMProcessSources.cmake (original) +++ llvm/trunk/cmake/modules/LLVMProcessSources.cmake Wed May 11 08:53:08 2011 @@ -56,7 +56,7 @@ # Set common compiler options: if( NOT LLVM_REQUIRES_EH ) - if( CMAKE_COMPILER_IS_GNUCXX ) + if( LLVM_COMPILER_IS_GCC_COMPATIBLE ) add_definitions( -fno-exceptions ) elseif( MSVC ) llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/EHsc" "/EHs-c-") @@ -64,7 +64,7 @@ endif() endif() if( NOT LLVM_REQUIRES_RTTI ) - if( CMAKE_COMPILER_IS_GNUCXX ) + if( LLVM_COMPILER_IS_GCC_COMPATIBLE ) llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti") elseif( MSVC ) llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-") Modified: llvm/trunk/unittests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CMakeLists.txt?rev=131181&r1=131180&r2=131181&view=diff ============================================================================== --- llvm/trunk/unittests/CMakeLists.txt (original) +++ llvm/trunk/unittests/CMakeLists.txt Wed May 11 08:53:08 2011 @@ -20,7 +20,7 @@ include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include) add_definitions(-DGTEST_HAS_RTTI=0) -if( CMAKE_COMPILER_IS_GNUCXX ) +if( LLVM_COMPILER_IS_GCC_COMPATIBLE ) llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti") elseif( MSVC ) llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-") From nadav.rotem at intel.com Wed May 11 09:40:50 2011 From: nadav.rotem at intel.com (Nadav Rotem) Date: Wed, 11 May 2011 14:40:50 -0000 Subject: [llvm-commits] [llvm] r131183 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/ARM/vstlane.ll test/CodeGen/X86/2011-05-09-loaduse.ll test/CodeGen/X86/vec_extract-sse4.ll test/CodeGen/X86/vec_extract.ll Message-ID: <20110511144050.F3C112A6C12C@llvm.org> Author: nadav Date: Wed May 11 09:40:50 2011 New Revision: 131183 URL: http://llvm.org/viewvc/llvm-project?rev=131183&view=rev Log: Fixes a bug in the DAGCombiner. LoadSDNodes have two values (data, chain). If there is a store after the load node, then there is a chain, which means that there is another user. Thus, asking hasOneUser would fail. Instead we ask hasNUsesOfValue on the 'data' value. Added: llvm/trunk/test/CodeGen/X86/2011-05-09-loaduse.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/trunk/test/CodeGen/ARM/vstlane.ll llvm/trunk/test/CodeGen/X86/vec_extract-sse4.ll llvm/trunk/test/CodeGen/X86/vec_extract.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=131183&r1=131182&r2=131183&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed May 11 09:40:50 2011 @@ -6566,7 +6566,7 @@ } } - if (!LN0 || !LN0->hasOneUse() || LN0->isVolatile()) + if (!LN0 || !LN0->hasNUsesOfValue(1,0) || LN0->isVolatile()) return SDValue(); // If Idx was -1 above, Elt is going to be -1, so just return undef. Modified: llvm/trunk/test/CodeGen/ARM/vstlane.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vstlane.ll?rev=131183&r1=131182&r2=131183&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vstlane.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vstlane.ll Wed May 11 09:40:50 2011 @@ -54,7 +54,8 @@ define void @vst1laneQi8(i8* %A, <16 x i8>* %B) nounwind { ;CHECK: vst1laneQi8: -;CHECK: vst1.8 {d17[1]}, [r0] +; // Can use scalar load. No need to use vectors. +; // CHE-CK: vst1.8 {d17[1]}, [r0] %tmp1 = load <16 x i8>* %B %tmp2 = extractelement <16 x i8> %tmp1, i32 9 store i8 %tmp2, i8* %A, align 8 @@ -72,7 +73,8 @@ define void @vst1laneQi32(i32* %A, <4 x i32>* %B) nounwind { ;CHECK: vst1laneQi32: -;CHECK: vst1.32 {d17[1]}, [r0, :32] +; // Can use scalar load. No need to use vectors. +; // CHE-CK: vst1.32 {d17[1]}, [r0, :32] %tmp1 = load <4 x i32>* %B %tmp2 = extractelement <4 x i32> %tmp1, i32 3 store i32 %tmp2, i32* %A, align 8 @@ -82,7 +84,8 @@ ;Check for a post-increment updating store. define void @vst1laneQi32_update(i32** %ptr, <4 x i32>* %B) nounwind { ;CHECK: vst1laneQi32_update: -;CHECK: vst1.32 {d17[1]}, [r1, :32]! +; // Can use scalar load. No need to use vectors. +; // CHE-CK: vst1.32 {d17[1]}, [r1, :32]! %A = load i32** %ptr %tmp1 = load <4 x i32>* %B %tmp2 = extractelement <4 x i32> %tmp1, i32 3 @@ -94,7 +97,8 @@ define void @vst1laneQf(float* %A, <4 x float>* %B) nounwind { ;CHECK: vst1laneQf: -;CHECK: vst1.32 {d17[1]}, [r0] +; // Can use scalar load. No need to use vectors. +; // CHE-CK: vst1.32 {d17[1]}, [r0] %tmp1 = load <4 x float>* %B %tmp2 = extractelement <4 x float> %tmp1, i32 3 store float %tmp2, float* %A Added: llvm/trunk/test/CodeGen/X86/2011-05-09-loaduse.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2011-05-09-loaduse.ll?rev=131183&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2011-05-09-loaduse.ll (added) +++ llvm/trunk/test/CodeGen/X86/2011-05-09-loaduse.ll Wed May 11 09:40:50 2011 @@ -0,0 +1,13 @@ +; RUN: llc < %s -march=x86 -mcpu=corei7 | FileCheck %s + +;CHECK: test +;CHECK-not: pshufd +;CHECK: ret +define float @test(<4 x float>* %A) nounwind { +entry: + %T = load <4 x float>* %A + %R = extractelement <4 x float> %T, i32 3 + store <4 x float>, <4 x float>* %A + ret float %R +} + Modified: llvm/trunk/test/CodeGen/X86/vec_extract-sse4.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_extract-sse4.ll?rev=131183&r1=131182&r2=131183&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_extract-sse4.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_extract-sse4.ll Wed May 11 09:40:50 2011 @@ -1,8 +1,8 @@ -; RUN: llc < %s -march=x86 -mattr=+sse41 -o %t -; RUN: grep extractps %t | count 1 -; RUN: grep pextrd %t | count 1 +; RUN: llc < %s -mcpu=corei7 -march=x86 -mattr=+sse41 -o %t +; RUN: not grep extractps %t +; RUN: not grep pextrd %t ; RUN: not grep pshufd %t -; RUN: not grep movss %t +; RUN: grep movss %t | count 2 define void @t1(float* %R, <4 x float>* %P1) nounwind { %X = load <4 x float>* %P1 Modified: llvm/trunk/test/CodeGen/X86/vec_extract.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_extract.ll?rev=131183&r1=131182&r2=131183&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_extract.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_extract.ll Wed May 11 09:40:50 2011 @@ -1,7 +1,7 @@ -; RUN: llc < %s -march=x86 -mattr=+sse2,-sse41 -o %t -; RUN: grep movss %t | count 3 +; RUN: llc < %s -mcpu=corei7 -march=x86 -mattr=+sse2,-sse41 -o %t +; RUN: grep movss %t | count 4 ; RUN: grep movhlps %t | count 1 -; RUN: grep pshufd %t | count 1 +; RUN: not grep pshufd %t ; RUN: grep unpckhpd %t | count 1 define void @test1(<4 x float>* %F, float* %f) nounwind { From stuart at apple.com Wed May 11 11:00:21 2011 From: stuart at apple.com (Stuart Hastings) Date: Wed, 11 May 2011 16:00:21 -0000 Subject: [llvm-commits] [llvm] r131184 - /llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll Message-ID: <20110511160021.AEE622A6C12C@llvm.org> Author: stuart Date: Wed May 11 11:00:21 2011 New Revision: 131184 URL: http://llvm.org/viewvc/llvm-project?rev=131184&view=rev Log: And lo, I was given a testcase for 131152. rdar://problem/9416774 Added: llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll Added: llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll?rev=131184&view=auto ============================================================================== --- llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll (added) +++ llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll Wed May 11 11:00:21 2011 @@ -0,0 +1,60 @@ +; RUN: llc < %s +; rdar://problem/9416774 + +; ModuleID = 'reduced.ii' +target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32" +target triple = "thumbv7-apple-macosx10.6.6" + +%struct.GlAidRequest = type { [4 x %struct.GlOrbitInfoPerAidSource] } +%struct.GlOrbitInfoPerAidSource = type { [78 x i32] } + + at kCLLogGenericComponent = external constant i8* + at __PRETTY_FUNCTION__._ZN12CLGllRequest13logAssistDataERK12GlAidRequest = private unnamed_addr constant [62 x i8] c"static void CLGllRequest::logAssistData(const GlAidRequest &)\00" + at .str = private unnamed_addr constant [75 x i8] c"\09GlOrbitInfoPerAidSource:,BE:0x%08lx,ALM:0x%08lx,LTO:0x%08lx,CBEE:0x%08lx\0A\00" + +define void @_ZN12CLGllRequest13logAssistDataERK12GlAidRequest(%struct.GlAidRequest* %aidData) ssp align 2 { +entry: + %aidData.addr = alloca %struct.GlAidRequest*, align 4 + %agg.tmp = alloca %struct.GlOrbitInfoPerAidSource, align 4 + %agg.tmp4 = alloca %struct.GlOrbitInfoPerAidSource, align 4 + %agg.tmp10 = alloca %struct.GlOrbitInfoPerAidSource, align 4 + %agg.tmp16 = alloca %struct.GlOrbitInfoPerAidSource, align 4 + store %struct.GlAidRequest* %aidData, %struct.GlAidRequest** %aidData.addr, align 4 + br label %do.body + +do.body: ; preds = %entry + %tmp = load i8** @kCLLogGenericComponent, align 4 + %tmp1 = load %struct.GlAidRequest** %aidData.addr + %eph = getelementptr inbounds %struct.GlAidRequest* %tmp1, i32 0, i32 0 + %arrayidx = getelementptr inbounds [4 x %struct.GlOrbitInfoPerAidSource]* %eph, i32 0, i32 0 + %tmp2 = bitcast %struct.GlOrbitInfoPerAidSource* %agg.tmp to i8* + %tmp3 = bitcast %struct.GlOrbitInfoPerAidSource* %arrayidx to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* %tmp3, i32 312, i32 4, i1 false) + %tmp5 = load %struct.GlAidRequest** %aidData.addr + %eph6 = getelementptr inbounds %struct.GlAidRequest* %tmp5, i32 0, i32 0 + %arrayidx7 = getelementptr inbounds [4 x %struct.GlOrbitInfoPerAidSource]* %eph6, i32 0, i32 1 + %tmp8 = bitcast %struct.GlOrbitInfoPerAidSource* %agg.tmp4 to i8* + %tmp9 = bitcast %struct.GlOrbitInfoPerAidSource* %arrayidx7 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp8, i8* %tmp9, i32 312, i32 4, i1 false) + %tmp11 = load %struct.GlAidRequest** %aidData.addr + %eph12 = getelementptr inbounds %struct.GlAidRequest* %tmp11, i32 0, i32 0 + %arrayidx13 = getelementptr inbounds [4 x %struct.GlOrbitInfoPerAidSource]* %eph12, i32 0, i32 2 + %tmp14 = bitcast %struct.GlOrbitInfoPerAidSource* %agg.tmp10 to i8* + %tmp15 = bitcast %struct.GlOrbitInfoPerAidSource* %arrayidx13 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp14, i8* %tmp15, i32 312, i32 4, i1 false) + %tmp17 = load %struct.GlAidRequest** %aidData.addr + %eph18 = getelementptr inbounds %struct.GlAidRequest* %tmp17, i32 0, i32 0 + %arrayidx19 = getelementptr inbounds [4 x %struct.GlOrbitInfoPerAidSource]* %eph18, i32 0, i32 3 + %tmp20 = bitcast %struct.GlOrbitInfoPerAidSource* %agg.tmp16 to i8* + %tmp21 = bitcast %struct.GlOrbitInfoPerAidSource* %arrayidx19 to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp20, i8* %tmp21, i32 312, i32 4, i1 false) + call void (i8*, i32, i8*, i8*, ...)* @CLLoggingLog(i8* %tmp, i32 2, i8* getelementptr inbounds ([62 x i8]* @__PRETTY_FUNCTION__._ZN12CLGllRequest13logAssistDataERK12GlAidRequest, i32 0, i32 0), i8* getelementptr inbounds ([75 x i8]* @.str, i32 0, i32 0), %struct.GlOrbitInfoPerAidSource* byval %agg.tmp, %struct.GlOrbitInfoPerAidSource* byval %agg.tmp4, %struct.GlOrbitInfoPerAidSource* byval %agg.tmp10, %struct.GlOrbitInfoPerAidSource* byval %agg.tmp16) + br label %do.end + +do.end: ; preds = %do.body + ret void +} + +declare void @CLLoggingLog(i8*, i32, i8*, i8*, ...) + +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind From atrick at apple.com Wed May 11 11:31:24 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 11 May 2011 16:31:24 -0000 Subject: [llvm-commits] [llvm] r131186 - in /llvm/trunk: include/llvm/Support/Program.h lib/Support/Program.cpp lib/Support/Unix/Program.inc tools/bugpoint/ExecutionDriver.cpp tools/bugpoint/Miscompilation.cpp tools/bugpoint/ToolRunner.cpp Message-ID: <20110511163124.D83B82A6C12C@llvm.org> Author: atrick Date: Wed May 11 11:31:24 2011 New Revision: 131186 URL: http://llvm.org/viewvc/llvm-project?rev=131186&view=rev Log: Bugpoint support for miscompilations that result in a crash. This change allows bugpoint to pinpoint the "opt" pass and bitcode segment responsible for a crash caused by miscompilation. At least it works well for me now, without having to create any custom execution wrappers. Modified: llvm/trunk/include/llvm/Support/Program.h llvm/trunk/lib/Support/Program.cpp llvm/trunk/lib/Support/Unix/Program.inc llvm/trunk/tools/bugpoint/ExecutionDriver.cpp llvm/trunk/tools/bugpoint/Miscompilation.cpp llvm/trunk/tools/bugpoint/ToolRunner.cpp Modified: llvm/trunk/include/llvm/Support/Program.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Program.h?rev=131186&r1=131185&r2=131186&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Program.h (original) +++ llvm/trunk/include/llvm/Support/Program.h Wed May 11 11:31:24 2011 @@ -96,9 +96,11 @@ ///< expires, the child is killed and this call returns. If zero, ///< this function will wait until the child finishes or forever if ///< it doesn't. - std::string* ErrMsg ///< If non-zero, provides a pointer to a string + std::string* ErrMsg, ///< If non-zero, provides a pointer to a string ///< instance in which error messages will be returned. If the string ///< is non-empty upon return an error occurred while waiting. + const char *SignalPrefix ///< If non-zero, provides a prefix to be + ///< prepended to ErrMsg if the process is terminated abnormally. ); /// This function terminates the program. @@ -137,7 +139,8 @@ const sys::Path** redirects = 0, unsigned secondsToWait = 0, unsigned memoryLimit = 0, - std::string* ErrMsg = 0); + std::string* ErrMsg = 0, + const char *SignalPrefix = 0); /// A convenience function equivalent to Program prg; prg.Execute(..); /// @see Execute Modified: llvm/trunk/lib/Support/Program.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Program.cpp?rev=131186&r1=131185&r2=131186&view=diff ============================================================================== --- llvm/trunk/lib/Support/Program.cpp (original) +++ llvm/trunk/lib/Support/Program.cpp Wed May 11 11:31:24 2011 @@ -28,10 +28,11 @@ const Path** redirects, unsigned secondsToWait, unsigned memoryLimit, - std::string* ErrMsg) { + std::string* ErrMsg, + const char* SignalPrefix) { Program prg; if (prg.Execute(path, args, envp, redirects, memoryLimit, ErrMsg)) - return prg.Wait(path, secondsToWait, ErrMsg); + return prg.Wait(path, secondsToWait, ErrMsg, SignalPrefix); else return -1; } Modified: llvm/trunk/lib/Support/Unix/Program.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Program.inc?rev=131186&r1=131185&r2=131186&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/Program.inc (original) +++ llvm/trunk/lib/Support/Unix/Program.inc Wed May 11 11:31:24 2011 @@ -298,7 +298,8 @@ int Program::Wait(const sys::Path &path, unsigned secondsToWait, - std::string* ErrMsg) + std::string* ErrMsg, + const char* SignalPrefix) { #ifdef HAVE_SYS_WAIT_H struct sigaction Act, Old; @@ -376,7 +377,9 @@ } } else if (WIFSIGNALED(status)) { if (ErrMsg) { - *ErrMsg = strsignal(WTERMSIG(status)); + if (SignalPrefix) + *ErrMsg = SignalPrefix; + *ErrMsg += strsignal(WTERMSIG(status)); #ifdef WCOREDUMP if (WCOREDUMP(status)) *ErrMsg += " (core dumped)"; Modified: llvm/trunk/tools/bugpoint/ExecutionDriver.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExecutionDriver.cpp?rev=131186&r1=131185&r2=131186&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ExecutionDriver.cpp (original) +++ llvm/trunk/tools/bugpoint/ExecutionDriver.cpp Wed May 11 11:31:24 2011 @@ -475,7 +475,7 @@ /// diffProgram - This method executes the specified module and diffs the /// output against the file specified by ReferenceOutputFile. If the output /// is different, 1 is returned. If there is a problem with the code -/// generator (e.g., llc crashes), this will return -1 and set Error. +/// generator (e.g., llc crashes), this will set ErrMsg. /// bool BugDriver::diffProgram(const Module *Program, const std::string &BitcodeFile, Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=131186&r1=131185&r2=131186&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original) +++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Wed May 11 11:31:24 2011 @@ -624,9 +624,10 @@ if (!BugpointIsInterrupted) ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions, Error); - if (!Error.empty()) + if (!Error.empty()) { + errs() << "\n***Cannot reduce functions: "; return MiscompiledFunctions; - + } outs() << "\n*** The following function" << (MiscompiledFunctions.size() == 1 ? " is" : "s are") << " being miscompiled: "; Modified: llvm/trunk/tools/bugpoint/ToolRunner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.cpp?rev=131186&r1=131185&r2=131186&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ToolRunner.cpp (original) +++ llvm/trunk/tools/bugpoint/ToolRunner.cpp Wed May 11 11:31:24 2011 @@ -50,6 +50,11 @@ cl::desc("Remote execution (rsh/ssh) extra options")); } +// Add a prefix to ErrMsg if the program is terminated by a signal to +// distinguish compiled program crashes from other execution +// failures. Miscompilation likely to results in SIGSEGV. +static const char *SignalPrefix = "Signal - "; + /// RunProgramWithTimeout - This function provides an alternate interface /// to the sys::Program::ExecuteAndWait interface. /// @see sys::Program::ExecuteAndWait @@ -77,7 +82,7 @@ return sys::Program::ExecuteAndWait(ProgramPath, Args, 0, redirects, - NumSeconds, MemoryLimit, ErrMsg); + NumSeconds, MemoryLimit, ErrMsg, SignalPrefix); } /// RunProgramRemotelyWithTimeout - This function runs the given program @@ -854,9 +859,18 @@ if (RemoteClientPath.isEmpty()) { DEBUG(errs() << ""); - return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0], + int ExitCode = RunProgramWithTimeout(OutputBinary, &ProgramArgs[0], sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), Timeout, MemoryLimit, Error); + // Treat a signal (usually SIGSEGV) as part of the program output so that + // crash-causing miscompilation is handled seamlessly. + if (Error->find(SignalPrefix) == 0) { + std::ofstream outFile(OutputFile.c_str(), std::ios_base::app); + outFile << *Error << '\n'; + outFile.close(); + Error->clear(); + } + return ExitCode; } else { outs() << ""; outs().flush(); return RunProgramRemotelyWithTimeout(sys::Path(RemoteClientPath), From atrick at apple.com Wed May 11 11:44:08 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 11 May 2011 16:44:08 -0000 Subject: [llvm-commits] [llvm] r131187 - in /llvm/trunk: lib/Support/Windows/Program.inc tools/bugpoint/ToolRunner.cpp Message-ID: <20110511164408.9B3612A6C12C@llvm.org> Author: atrick Date: Wed May 11 11:44:08 2011 New Revision: 131187 URL: http://llvm.org/viewvc/llvm-project?rev=131187&view=rev Log: Typo and missing checkin from r131186. Modified: llvm/trunk/lib/Support/Windows/Program.inc llvm/trunk/tools/bugpoint/ToolRunner.cpp Modified: llvm/trunk/lib/Support/Windows/Program.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Program.inc?rev=131187&r1=131186&r2=131187&view=diff ============================================================================== --- llvm/trunk/lib/Support/Windows/Program.inc (original) +++ llvm/trunk/lib/Support/Windows/Program.inc Wed May 11 11:44:08 2011 @@ -332,7 +332,8 @@ int Program::Wait(const Path &path, unsigned secondsToWait, - std::string* ErrMsg) { + std::string* ErrMsg, + const char* /*SignalPrefix*/) { if (Data_ == 0) { MakeErrMsg(ErrMsg, "Process not started!"); return -1; Modified: llvm/trunk/tools/bugpoint/ToolRunner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.cpp?rev=131187&r1=131186&r2=131187&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ToolRunner.cpp (original) +++ llvm/trunk/tools/bugpoint/ToolRunner.cpp Wed May 11 11:44:08 2011 @@ -52,7 +52,7 @@ // Add a prefix to ErrMsg if the program is terminated by a signal to // distinguish compiled program crashes from other execution -// failures. Miscompilation likely to results in SIGSEGV. +// failures. Miscompilation likely results in SIGSEGV. static const char *SignalPrefix = "Signal - "; /// RunProgramWithTimeout - This function provides an alternate interface From eli.friedman at gmail.com Wed May 11 11:56:24 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 11 May 2011 09:56:24 -0700 Subject: [llvm-commits] [llvm] r131186 - in /llvm/trunk: include/llvm/Support/Program.h lib/Support/Program.cpp lib/Support/Unix/Program.inc tools/bugpoint/ExecutionDriver.cpp tools/bugpoint/Miscompilation.cpp tools/bugpoint/ToolRunner.cpp In-Reply-To: <20110511163124.D83B82A6C12C@llvm.org> References: <20110511163124.D83B82A6C12C@llvm.org> Message-ID: On Wed, May 11, 2011 at 9:31 AM, Andrew Trick wrote: > Author: atrick > Date: Wed May 11 11:31:24 2011 > New Revision: 131186 > > URL: http://llvm.org/viewvc/llvm-project?rev=131186&view=rev > Log: > Bugpoint support for miscompilations that result in a crash. > > This change allows bugpoint to pinpoint the "opt" pass and bitcode > segment responsible for a crash caused by miscompilation. At least it > works well for me now, without having to create any custom execution > wrappers. Thank you! I've been stuck with adding a call to signal() until now. -Eli From resistor at mac.com Wed May 11 12:00:48 2011 From: resistor at mac.com (Owen Anderson) Date: Wed, 11 May 2011 17:00:48 -0000 Subject: [llvm-commits] [llvm] r131189 - in /llvm/trunk: lib/Target/ARM/ARMInstrThumb.td test/MC/ARM/thumb.s Message-ID: <20110511170048.C1EC22A6C12C@llvm.org> Author: resistor Date: Wed May 11 12:00:48 2011 New Revision: 131189 URL: http://llvm.org/viewvc/llvm-project?rev=131189&view=rev Log: Fix encoding of Thumb BLX register instructions. Patch by Koan-Sin Tan. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/test/MC/ARM/thumb.s Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=131189&r1=131188&r2=131189&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Wed May 11 12:00:48 2011 @@ -457,7 +457,11 @@ "blx\t$func", [(ARMtcall GPR:$func)]>, Requires<[IsThumb, HasV5T, IsNotDarwin]>, - T1Special<{1,1,1,?}>; // A6.2.3 & A8.6.24; + T1Special<{1,1,1,?}> { // A6.2.3 & A8.6.24; + bits<4> func; + let Inst{6-3} = func; + let Inst{2-0} = 0b000; + } // ARMv4T // FIXME: Should be a pseudo. @@ -600,7 +604,7 @@ // The assembler uses 0xDEFE for a trap instruction. let isBarrier = 1, isTerminator = 1 in -def tTRAP : TI<(outs), (ins), IIC_Br, +def tTRAP : TI<(outs), (ins), IIC_Br, "trap", [(trap)]>, Encoding16 { let Inst = 0xdefe; } @@ -807,7 +811,7 @@ let mayStore = 1, hasExtraSrcRegAllocReq = 1 in defm tSTM : thumb_ldst_mult<"stm", IIC_iStore_m, IIC_iStore_mu, {1,1,0,0,0,?}, 0>; - + } // neverHasSideEffects let mayLoad = 1, Uses = [SP], Defs = [SP], hasExtraDefRegAllocReq = 1 in @@ -1451,7 +1455,7 @@ //===----------------------------------------------------------------------===// // SJLJ Exception handling intrinsics -// +// // eh_sjlj_setjmp() is an instruction sequence to store the return address and // save #0 in R0 for the non-longjmp case. Since by its nature we may be coming Modified: llvm/trunk/test/MC/ARM/thumb.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/thumb.s?rev=131189&r1=131188&r2=131189&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/thumb.s (original) +++ llvm/trunk/test/MC/ARM/thumb.s Wed May 11 12:00:48 2011 @@ -12,6 +12,8 @@ @ CHECK: blx r9 @ encoding: [0xc8,0x47] blx r9 +@ CHECK: blx r10 @ encoding: [0xd0,0x47] + blx r10 @ CHECK: rev r2, r3 @ encoding: [0x1a,0xba] @ CHECK: rev16 r3, r4 @ encoding: [0x63,0xba] From atrick at apple.com Wed May 11 12:15:18 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 11 May 2011 10:15:18 -0700 Subject: [llvm-commits] [llvm] r131186 - in /llvm/trunk: include/llvm/Support/Program.h lib/Support/Program.cpp lib/Support/Unix/Program.inc tools/bugpoint/ExecutionDriver.cpp tools/bugpoint/Miscompilation.cpp tools/bugpoint/ToolRunner.cpp In-Reply-To: References: <20110511163124.D83B82A6C12C@llvm.org> Message-ID: <424E22A1-9C41-4B13-8C17-664EEA0EF57E@apple.com> On May 11, 2011, at 9:56 AM, Eli Friedman wrote: > On Wed, May 11, 2011 at 9:31 AM, Andrew Trick wrote: >> Author: atrick >> Date: Wed May 11 11:31:24 2011 >> New Revision: 131186 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=131186&view=rev >> Log: >> Bugpoint support for miscompilations that result in a crash. >> >> This change allows bugpoint to pinpoint the "opt" pass and bitcode >> segment responsible for a crash caused by miscompilation. At least it >> works well for me now, without having to create any custom execution >> wrappers. > > Thank you! I've been stuck with adding a call to signal() until now. > > -Eli It's good to know I'm not the only person who wants the feature. BTW: it still needs Windows support, which should be trivial but I don't currently have access to Windows to test it. -Andy From stuart at apple.com Wed May 11 12:29:25 2011 From: stuart at apple.com (Stuart Hastings) Date: Wed, 11 May 2011 17:29:25 -0000 Subject: [llvm-commits] [llvm] r131191 - /llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll Message-ID: <20110511172925.EE1CA2A6C12C@llvm.org> Author: stuart Date: Wed May 11 12:29:25 2011 New Revision: 131191 URL: http://llvm.org/viewvc/llvm-project?rev=131191&view=rev Log: Reduced test case. rdar://problem/9416774 Modified: llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll Modified: llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll?rev=131191&r1=131190&r2=131191&view=diff ============================================================================== --- llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll (original) +++ llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll Wed May 11 12:29:25 2011 @@ -1,54 +1,54 @@ ; RUN: llc < %s ; rdar://problem/9416774 +; ModuleID = 'reduced.ll' -; ModuleID = 'reduced.ii' target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32" -target triple = "thumbv7-apple-macosx10.6.6" +target triple = "thumbv7-apple-ios" -%struct.GlAidRequest = type { [4 x %struct.GlOrbitInfoPerAidSource] } -%struct.GlOrbitInfoPerAidSource = type { [78 x i32] } +%struct.MMMMMMMMMMMM = type { [4 x %struct.RRRRRRRR] } +%struct.RRRRRRRR = type { [78 x i32] } - at kCLLogGenericComponent = external constant i8* - at __PRETTY_FUNCTION__._ZN12CLGllRequest13logAssistDataERK12GlAidRequest = private unnamed_addr constant [62 x i8] c"static void CLGllRequest::logAssistData(const GlAidRequest &)\00" - at .str = private unnamed_addr constant [75 x i8] c"\09GlOrbitInfoPerAidSource:,BE:0x%08lx,ALM:0x%08lx,LTO:0x%08lx,CBEE:0x%08lx\0A\00" + at kkkkkk = external constant i8* + at __PRETTY_FUNCTION__._ZN12CLGll = private unnamed_addr constant [62 x i8] c"static void tttttttttttt::lllllllllllll(const MMMMMMMMMMMM &)\00" + at .str = private unnamed_addr constant [75 x i8] c"\09GGGGGGGGGGGGGGGGGGGGGGG:,BE:0x%08lx,ALM:0x%08lx,LTO:0x%08lx,CBEE:0x%08lx\0A\00" -define void @_ZN12CLGllRequest13logAssistDataERK12GlAidRequest(%struct.GlAidRequest* %aidData) ssp align 2 { +define void @_ZN12CLGll(%struct.MMMMMMMMMMMM* %aidData) ssp align 2 { entry: - %aidData.addr = alloca %struct.GlAidRequest*, align 4 - %agg.tmp = alloca %struct.GlOrbitInfoPerAidSource, align 4 - %agg.tmp4 = alloca %struct.GlOrbitInfoPerAidSource, align 4 - %agg.tmp10 = alloca %struct.GlOrbitInfoPerAidSource, align 4 - %agg.tmp16 = alloca %struct.GlOrbitInfoPerAidSource, align 4 - store %struct.GlAidRequest* %aidData, %struct.GlAidRequest** %aidData.addr, align 4 + %aidData.addr = alloca %struct.MMMMMMMMMMMM*, align 4 + %agg.tmp = alloca %struct.RRRRRRRR, align 4 + %agg.tmp4 = alloca %struct.RRRRRRRR, align 4 + %agg.tmp10 = alloca %struct.RRRRRRRR, align 4 + %agg.tmp16 = alloca %struct.RRRRRRRR, align 4 + store %struct.MMMMMMMMMMMM* %aidData, %struct.MMMMMMMMMMMM** %aidData.addr, align 4 br label %do.body do.body: ; preds = %entry - %tmp = load i8** @kCLLogGenericComponent, align 4 - %tmp1 = load %struct.GlAidRequest** %aidData.addr - %eph = getelementptr inbounds %struct.GlAidRequest* %tmp1, i32 0, i32 0 - %arrayidx = getelementptr inbounds [4 x %struct.GlOrbitInfoPerAidSource]* %eph, i32 0, i32 0 - %tmp2 = bitcast %struct.GlOrbitInfoPerAidSource* %agg.tmp to i8* - %tmp3 = bitcast %struct.GlOrbitInfoPerAidSource* %arrayidx to i8* + %tmp = load i8** @kkkkkk, align 4 + %tmp1 = load %struct.MMMMMMMMMMMM** %aidData.addr + %eph = getelementptr inbounds %struct.MMMMMMMMMMMM* %tmp1, i32 0, i32 0 + %arrayidx = getelementptr inbounds [4 x %struct.RRRRRRRR]* %eph, i32 0, i32 0 + %tmp2 = bitcast %struct.RRRRRRRR* %agg.tmp to i8* + %tmp3 = bitcast %struct.RRRRRRRR* %arrayidx to i8* call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* %tmp3, i32 312, i32 4, i1 false) - %tmp5 = load %struct.GlAidRequest** %aidData.addr - %eph6 = getelementptr inbounds %struct.GlAidRequest* %tmp5, i32 0, i32 0 - %arrayidx7 = getelementptr inbounds [4 x %struct.GlOrbitInfoPerAidSource]* %eph6, i32 0, i32 1 - %tmp8 = bitcast %struct.GlOrbitInfoPerAidSource* %agg.tmp4 to i8* - %tmp9 = bitcast %struct.GlOrbitInfoPerAidSource* %arrayidx7 to i8* + %tmp5 = load %struct.MMMMMMMMMMMM** %aidData.addr + %eph6 = getelementptr inbounds %struct.MMMMMMMMMMMM* %tmp5, i32 0, i32 0 + %arrayidx7 = getelementptr inbounds [4 x %struct.RRRRRRRR]* %eph6, i32 0, i32 1 + %tmp8 = bitcast %struct.RRRRRRRR* %agg.tmp4 to i8* + %tmp9 = bitcast %struct.RRRRRRRR* %arrayidx7 to i8* call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp8, i8* %tmp9, i32 312, i32 4, i1 false) - %tmp11 = load %struct.GlAidRequest** %aidData.addr - %eph12 = getelementptr inbounds %struct.GlAidRequest* %tmp11, i32 0, i32 0 - %arrayidx13 = getelementptr inbounds [4 x %struct.GlOrbitInfoPerAidSource]* %eph12, i32 0, i32 2 - %tmp14 = bitcast %struct.GlOrbitInfoPerAidSource* %agg.tmp10 to i8* - %tmp15 = bitcast %struct.GlOrbitInfoPerAidSource* %arrayidx13 to i8* + %tmp11 = load %struct.MMMMMMMMMMMM** %aidData.addr + %eph12 = getelementptr inbounds %struct.MMMMMMMMMMMM* %tmp11, i32 0, i32 0 + %arrayidx13 = getelementptr inbounds [4 x %struct.RRRRRRRR]* %eph12, i32 0, i32 2 + %tmp14 = bitcast %struct.RRRRRRRR* %agg.tmp10 to i8* + %tmp15 = bitcast %struct.RRRRRRRR* %arrayidx13 to i8* call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp14, i8* %tmp15, i32 312, i32 4, i1 false) - %tmp17 = load %struct.GlAidRequest** %aidData.addr - %eph18 = getelementptr inbounds %struct.GlAidRequest* %tmp17, i32 0, i32 0 - %arrayidx19 = getelementptr inbounds [4 x %struct.GlOrbitInfoPerAidSource]* %eph18, i32 0, i32 3 - %tmp20 = bitcast %struct.GlOrbitInfoPerAidSource* %agg.tmp16 to i8* - %tmp21 = bitcast %struct.GlOrbitInfoPerAidSource* %arrayidx19 to i8* + %tmp17 = load %struct.MMMMMMMMMMMM** %aidData.addr + %eph18 = getelementptr inbounds %struct.MMMMMMMMMMMM* %tmp17, i32 0, i32 0 + %arrayidx19 = getelementptr inbounds [4 x %struct.RRRRRRRR]* %eph18, i32 0, i32 3 + %tmp20 = bitcast %struct.RRRRRRRR* %agg.tmp16 to i8* + %tmp21 = bitcast %struct.RRRRRRRR* %arrayidx19 to i8* call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp20, i8* %tmp21, i32 312, i32 4, i1 false) - call void (i8*, i32, i8*, i8*, ...)* @CLLoggingLog(i8* %tmp, i32 2, i8* getelementptr inbounds ([62 x i8]* @__PRETTY_FUNCTION__._ZN12CLGllRequest13logAssistDataERK12GlAidRequest, i32 0, i32 0), i8* getelementptr inbounds ([75 x i8]* @.str, i32 0, i32 0), %struct.GlOrbitInfoPerAidSource* byval %agg.tmp, %struct.GlOrbitInfoPerAidSource* byval %agg.tmp4, %struct.GlOrbitInfoPerAidSource* byval %agg.tmp10, %struct.GlOrbitInfoPerAidSource* byval %agg.tmp16) + call void (i8*, i32, i8*, i8*, ...)* @CLLoggingLog(i8* %tmp, i32 2, i8* getelementptr inbounds ([62 x i8]* @__PRETTY_FUNCTION__._ZN12CLGll, i32 0, i32 0), i8* getelementptr inbounds ([75 x i8]* @.str, i32 0, i32 0), %struct.RRRRRRRR* byval %agg.tmp, %struct.RRRRRRRR* byval %agg.tmp4, %struct.RRRRRRRR* byval %agg.tmp10, %struct.RRRRRRRR* byval %agg.tmp16) br label %do.end do.end: ; preds = %do.body From evan.cheng at apple.com Wed May 11 12:46:40 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 May 2011 10:46:40 -0700 Subject: [llvm-commits] [llvm] r131176 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp test/CodeGen/X86/hoist-common.ll In-Reply-To: <20110511032717.8F2842A6C12C@llvm.org> References: <20110511032717.8F2842A6C12C@llvm.org> Message-ID: <3017AEB5-ECC4-4AA8-A800-F222603BCBDD@apple.com> Sorry about it. I'll take a look as soon as I have some time. Evan On May 10, 2011, at 8:27 PM, Rafael Espindola wrote: > Author: rafael > Date: Tue May 10 22:27:17 2011 > New Revision: 131176 > > URL: http://llvm.org/viewvc/llvm-project?rev=131176&view=rev > Log: > Revert 131172 as it is causing clang to miscompile itself. I will try > to provide a reduced testcase. > > Removed: > llvm/trunk/test/CodeGen/X86/hoist-common.ll > Modified: > llvm/trunk/lib/CodeGen/BranchFolding.cpp > llvm/trunk/lib/CodeGen/BranchFolding.h > llvm/trunk/lib/CodeGen/IfConversion.cpp > > Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131176&r1=131175&r2=131176&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) > +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Tue May 10 22:27:17 2011 > @@ -41,7 +41,6 @@ > STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); > STATISTIC(NumBranchOpts, "Number of branches optimized"); > STATISTIC(NumTailMerge , "Number of block tails merged"); > -STATISTIC(NumHoist , "Number of times common instructions are hoisted"); > > static cl::opt FlagEnableTailMerge("enable-tail-merge", > cl::init(cl::BOU_UNSET), cl::Hidden); > @@ -66,7 +65,7 @@ > public: > static char ID; > explicit BranchFolderPass(bool defaultEnableTailMerge) > - : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, true) {} > + : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge) {} > > virtual bool runOnMachineFunction(MachineFunction &MF); > virtual const char *getPassName() const { return "Control Flow Optimizer"; } > @@ -87,14 +86,12 @@ > } > > > -BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist) { > +BranchFolder::BranchFolder(bool defaultEnableTailMerge) { > switch (FlagEnableTailMerge) { > case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; > case cl::BOU_TRUE: EnableTailMerge = true; break; > case cl::BOU_FALSE: EnableTailMerge = false; break; > } > - > - EnableHoistCommonCode = CommonHoist; > } > > /// RemoveDeadBlock - Remove the specified dead machine basic block from the > @@ -189,10 +186,9 @@ > > bool MadeChangeThisIteration = true; > while (MadeChangeThisIteration) { > - MadeChangeThisIteration = TailMergeBlocks(MF); > - MadeChangeThisIteration |= OptimizeBranches(MF); > - if (EnableHoistCommonCode) > - MadeChangeThisIteration |= HoistCommonCode(MF); > + MadeChangeThisIteration = false; > + MadeChangeThisIteration |= TailMergeBlocks(MF); > + MadeChangeThisIteration |= OptimizeBranches(MF); > MadeChange |= MadeChangeThisIteration; > } > > @@ -914,8 +910,7 @@ > // Make sure blocks are numbered in order > MF.RenumberBlocks(); > > - for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); > - I != E; ) { > + for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { > MachineBasicBlock *MBB = I++; > MadeChange |= OptimizeBlock(MBB); > > @@ -1344,253 +1339,3 @@ > > return MadeChange; > } > - > -//===----------------------------------------------------------------------===// > -// Hoist Common Code > -//===----------------------------------------------------------------------===// > - > -/// HoistCommonCode - Hoist common instruction sequences at the start of basic > -/// blocks to their common predecessor. > -/// NOTE: This optimization does not update live-in information so it must be > -/// run after all passes that require correct liveness information. > -bool BranchFolder::HoistCommonCode(MachineFunction &MF) { > - bool MadeChange = false; > - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { > - MachineBasicBlock *MBB = I++; > - MadeChange |= HoistCommonCodeInSuccs(MBB); > - } > - > - return MadeChange; > -} > - > -/// findFalseBlock - BB has a fallthrough. Find its 'false' successor given > -/// its 'true' successor. > -static MachineBasicBlock *findFalseBlock(MachineBasicBlock *BB, > - MachineBasicBlock *TrueBB) { > - for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), > - E = BB->succ_end(); SI != E; ++SI) { > - MachineBasicBlock *SuccBB = *SI; > - if (SuccBB != TrueBB) > - return SuccBB; > - } > - return NULL; > -} > - > -/// findHoistingInsertPosAndDeps - Find the location to move common instructions > -/// in successors to. The location is ususally just before the terminator, > -/// however if the terminator is a conditional branch and its previous > -/// instruction is the flag setting instruction, the previous instruction is > -/// the preferred location. This function also gathers uses and defs of the > -/// instructions from the insertion point to the end of the block. The data is > -/// used by HoistCommonCodeInSuccs to ensure safety. > -static > -MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB, > - const TargetInstrInfo *TII, > - const TargetRegisterInfo *TRI, > - SmallSet &Uses, > - SmallSet &Defs) { > - MachineBasicBlock::iterator Loc = MBB->getFirstTerminator(); > - if (!TII->isUnpredicatedTerminator(Loc)) > - return MBB->end(); > - > - for (unsigned i = 0, e = Loc->getNumOperands(); i != e; ++i) { > - const MachineOperand &MO = Loc->getOperand(i); > - if (!MO.isReg()) > - continue; > - unsigned Reg = MO.getReg(); > - if (!Reg) > - continue; > - if (MO.isUse()) { > - Uses.insert(Reg); > - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > - Uses.insert(*AS); > - } else if (!MO.isDead()) > - // Don't try to hoist code in the rare case the terminator defines a > - // register that is later used. > - return MBB->end(); > - } > - > - if (Uses.empty()) > - return Loc; > - if (Loc == MBB->begin()) > - return MBB->end(); > - > - // The terminator is probably a conditional branch, try not to separate the > - // branch from condition setting instruction. > - MachineBasicBlock::iterator PI = Loc; > - --PI; > - while (PI != MBB->begin() && Loc->isDebugValue()) > - --PI; > - > - bool IsDef = false; > - for (unsigned i = 0, e = PI->getNumOperands(); !IsDef && i != e; ++i) { > - const MachineOperand &MO = PI->getOperand(i); > - if (!MO.isReg() || MO.isUse()) > - continue; > - unsigned Reg = MO.getReg(); > - if (!Reg) > - continue; > - if (Uses.count(Reg)) > - IsDef = true; > - } > - if (!IsDef) > - // The condition setting instruction is not just before the conditional > - // branch. > - return Loc; > - > - // Be conservative, don't insert instruction above something that may have > - // side-effects. And since it's potentially bad to separate flag setting > - // instruction from the conditional branch, just abort the optimization > - // completely. > - // Also avoid moving code above predicated instruction since it's hard to > - // reason about register liveness with predicated instruction. > - bool DontMoveAcrossStore = true; > - if (!PI->isSafeToMove(TII, 0, DontMoveAcrossStore) || > - TII->isPredicated(PI)) > - return MBB->end(); > - > - > - // Find out what registers are live. Note this routine is ignoring other live > - // registers which are only used by instructions in successor blocks. > - for (unsigned i = 0, e = PI->getNumOperands(); i != e; ++i) { > - const MachineOperand &MO = PI->getOperand(i); > - if (!MO.isReg()) > - continue; > - unsigned Reg = MO.getReg(); > - if (!Reg) > - continue; > - if (MO.isUse()) { > - Uses.insert(Reg); > - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > - Uses.insert(*AS); > - } else { > - if (Uses.count(Reg)) { > - Uses.erase(Reg); > - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) > - Uses.erase(*SR); // Use getSubRegisters to be conservative > - Defs.insert(Reg); > - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > - Defs.insert(*AS); > - } > - } > - } > - > - return PI; > -} > - > -/// HoistCommonCodeInSuccs - If the successors of MBB has common instruction > -/// sequence at the start of the function, move the instructions before MBB > -/// terminator if it's legal. > -bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { > - MachineBasicBlock *TBB = 0, *FBB = 0; > - SmallVector Cond; > - if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond, true) || !TBB || Cond.empty()) > - return false; > - > - if (!FBB) FBB = findFalseBlock(MBB, TBB); > - if (!FBB) > - // Malformed bcc? True and false blocks are the same? > - return false; > - > - // Restrict the optimization to cases where MBB is the only predecessor, > - // it is an obvious win. > - if (TBB->pred_size() > 1 || FBB->pred_size() > 1) > - return false; > - > - // Find a suitable position to hoist the common instructions to. Also figure > - // out which registers are used or defined by instructions from the insertion > - // point to the end of the block. > - SmallSet Uses, Defs; > - MachineBasicBlock::iterator Loc = > - findHoistingInsertPosAndDeps(MBB, TII, TRI, Uses, Defs); > - if (Loc == MBB->end()) > - return false; > - > - SmallSet LocalDefs; > - unsigned NumDups = 0; > - MachineBasicBlock::iterator TIB = TBB->begin(); > - MachineBasicBlock::iterator FIB = FBB->begin(); > - MachineBasicBlock::iterator TIE = TBB->end(); > - MachineBasicBlock::iterator FIE = FBB->end(); > - while (TIB != TIE && FIB != FIE) { > - // Skip dbg_value instructions. These do not count. > - if (TIB->isDebugValue()) { > - while (TIB != TIE && TIB->isDebugValue()) > - ++TIB; > - if (TIB == TIE) > - break; > - } > - if (FIB->isDebugValue()) { > - while (FIB != FIE && FIB->isDebugValue()) > - ++FIB; > - if (FIB == FIE) > - break; > - } > - if (!TIB->isIdenticalTo(FIB)) > - break; > - > - if (TII->isPredicated(TIB)) > - // Hard to reason about register liveness with predicated instruction. > - break; > - > - bool IsSafe = true; > - for (unsigned i = 0, e = TIB->getNumOperands(); i != e; ++i) { > - const MachineOperand &MO = TIB->getOperand(i); > - if (!MO.isReg()) > - continue; > - unsigned Reg = MO.getReg(); > - if (!Reg) > - continue; > - if (MO.isDef()) { > - if (Uses.count(Reg)) { > - // Avoid clobbering a register that's used by the instruction at > - // the point of insertion. > - IsSafe = false; > - break; > - } > - if (!MO.isDead() && Defs.count(Reg)) { > - // Don't hoist the instruction if the def would be clobber by the > - // instruction at the point insertion. FIXME: This is overly > - // conservative. It should be possible to hoist the instructions > - // in BB2 in the following example: > - // BB1: > - // r1, eflag = op1 r2, r3 > - // brcc eflag > - // > - // BB2: > - // r1 = op2, ... > - // = op3, r1 > - IsSafe = false; > - break; > - } > - LocalDefs.insert(Reg); > - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) > - LocalDefs.insert(*SR); > - } else if (!LocalDefs.count(Reg)) { > - if (Defs.count(Reg)) { > - // Use is defined by the instruction at the point of insertion. > - IsSafe = false; > - break; > - } > - } > - } > - if (!IsSafe) > - break; > - > - bool DontMoveAcrossStore = true; > - if (!TIB->isSafeToMove(TII, 0, DontMoveAcrossStore)) > - break; > - > - ++NumDups; > - ++TIB; > - ++FIB; > - } > - > - if (!NumDups) > - return false; > - > - MBB->splice(Loc, TBB, TBB->begin(), TIB); > - FBB->erase(FBB->begin(), FIB); > - ++NumHoist; > - return true; > -} > > Modified: llvm/trunk/lib/CodeGen/BranchFolding.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=131176&r1=131175&r2=131176&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) > +++ llvm/trunk/lib/CodeGen/BranchFolding.h Tue May 10 22:27:17 2011 > @@ -19,10 +19,11 @@ > class RegScavenger; > class TargetInstrInfo; > class TargetRegisterInfo; > + template class SmallVectorImpl; > > class BranchFolder { > public: > - explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist); > + explicit BranchFolder(bool defaultEnableTailMerge); > > bool OptimizeFunction(MachineFunction &MF, > const TargetInstrInfo *tii, > @@ -84,7 +85,6 @@ > std::vector SameTails; > > bool EnableTailMerge; > - bool EnableHoistCommonCode; > const TargetInstrInfo *TII; > const TargetRegisterInfo *TRI; > MachineModuleInfo *MMI; > @@ -110,9 +110,6 @@ > bool OptimizeBlock(MachineBasicBlock *MBB); > void RemoveDeadBlock(MachineBasicBlock *MBB); > bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); > - > - bool HoistCommonCode(MachineFunction &MF); > - bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB); > }; > } > > > Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=131176&r1=131175&r2=131176&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) > +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Tue May 10 22:27:17 2011 > @@ -265,7 +265,7 @@ > if (!TII) return false; > > // Tail merge tend to expose more if-conversion opportunities. > - BranchFolder BF(true, false); > + BranchFolder BF(true); > bool BFChange = BF.OptimizeFunction(MF, TII, > MF.getTarget().getRegisterInfo(), > getAnalysisIfAvailable()); > @@ -399,7 +399,7 @@ > BBAnalysis.clear(); > > if (MadeChange && IfCvtBranchFold) { > - BranchFolder BF(false, false); > + BranchFolder BF(false); > BF.OptimizeFunction(MF, TII, > MF.getTarget().getRegisterInfo(), > getAnalysisIfAvailable()); > > Removed: llvm/trunk/test/CodeGen/X86/hoist-common.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hoist-common.ll?rev=131175&view=auto > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/hoist-common.ll (original) > +++ llvm/trunk/test/CodeGen/X86/hoist-common.ll (removed) > @@ -1,28 +0,0 @@ > -; RUN: llc < %s -march=x86-64 | FileCheck %s > - > -; Common "xorb al, al" instruction in the two successor blocks should be > -; moved to the entry block above the test + je. > - > -; rdar://9145558 > - > -define zeroext i1 @t(i32 %c) nounwind ssp { > -entry: > -; CHECK: t: > -; CHECK: xorb %al, %al > -; CHECK: test > -; CHECK: je > - %tobool = icmp eq i32 %c, 0 > - br i1 %tobool, label %return, label %if.then > - > -if.then: > -; CHECK: callq > - %call = tail call zeroext i1 (...)* @foo() nounwind > - br label %return > - > -return: > -; CHECK: ret > - %retval.0 = phi i1 [ %call, %if.then ], [ false, %entry ] > - ret i1 %retval.0 > -} > - > -declare zeroext i1 @foo(...) > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stoklund at 2pi.dk Wed May 11 13:25:10 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 11 May 2011 18:25:10 -0000 Subject: [llvm-commits] [llvm] r131192 - /llvm/trunk/lib/CodeGen/InlineSpiller.cpp Message-ID: <20110511182510.5750C2A6C12C@llvm.org> Author: stoklund Date: Wed May 11 13:25:10 2011 New Revision: 131192 URL: http://llvm.org/viewvc/llvm-project?rev=131192&view=rev Log: Avoid hoisting spills when looking at a copy from another register that is also about to be spilled. This can only happen when two extra snippet registers are included in the spill, and there is a copy between them. Hoisting the spill creates problems because the hoist will mark the copy for later dead code elimination, and spilling the second register will turn the copy into a spill. Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=131192&r1=131191&r2=131192&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original) +++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Wed May 11 13:25:10 2011 @@ -855,6 +855,7 @@ /// spillAroundUses - insert spill code around each use of Reg. void InlineSpiller::spillAroundUses(unsigned Reg) { + DEBUG(dbgs() << "spillAroundUses " << PrintReg(Reg) << '\n'); LiveInterval &OldLI = LIS.getInterval(Reg); // Iterate over instructions using Reg. @@ -902,6 +903,12 @@ // Check for a sibling copy. unsigned SibReg = isFullCopyOf(MI, Reg); if (SibReg && isSibling(SibReg)) { + // This may actually be a copy between snippets. + if (isRegToSpill(SibReg)) { + DEBUG(dbgs() << "Found new snippet copy: " << *MI); + SnippetCopies.insert(MI); + continue; + } if (Writes) { // Hoist the spill of a sib-reg copy. if (hoistSpill(OldLI, MI)) { @@ -983,13 +990,15 @@ } // Finally delete the SnippetCopies. - for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(Edit->getReg()); - MachineInstr *MI = RI.skipInstruction();) { - assert(SnippetCopies.count(MI) && "Remaining use wasn't a snippet copy"); - // FIXME: Do this with a LiveRangeEdit callback. - VRM.RemoveMachineInstrFromMaps(MI); - LIS.RemoveMachineInstrFromMaps(MI); - MI->eraseFromParent(); + for (unsigned i = 0, e = RegsToSpill.size(); i != e; ++i) { + for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(RegsToSpill[i]); + MachineInstr *MI = RI.skipInstruction();) { + assert(SnippetCopies.count(MI) && "Remaining use wasn't a snippet copy"); + // FIXME: Do this with a LiveRangeEdit callback. + VRM.RemoveMachineInstrFromMaps(MI); + LIS.RemoveMachineInstrFromMaps(MI); + MI->eraseFromParent(); + } } // Delete all spilled registers. From evan.cheng at apple.com Wed May 11 13:37:51 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 May 2011 11:37:51 -0700 Subject: [llvm-commits] [llvm] r131176 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp test/CodeGen/X86/hoist-common.ll In-Reply-To: <20110511032717.8F2842A6C12C@llvm.org> References: <20110511032717.8F2842A6C12C@llvm.org> Message-ID: <699A16F0-38E0-4B4D-B5B1-C4E2049AD8D0@apple.com> Rafael, can you provide more information? Which buildbot? What's the symptom? I noticed http://google1.osuosl.org:8011/builders/clang-x86_64-linux-fnt is still red. Evan On May 10, 2011, at 8:27 PM, Rafael Espindola wrote: > Author: rafael > Date: Tue May 10 22:27:17 2011 > New Revision: 131176 > > URL: http://llvm.org/viewvc/llvm-project?rev=131176&view=rev > Log: > Revert 131172 as it is causing clang to miscompile itself. I will try > to provide a reduced testcase. > > Removed: > llvm/trunk/test/CodeGen/X86/hoist-common.ll > Modified: > llvm/trunk/lib/CodeGen/BranchFolding.cpp > llvm/trunk/lib/CodeGen/BranchFolding.h > llvm/trunk/lib/CodeGen/IfConversion.cpp > > Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131176&r1=131175&r2=131176&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) > +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Tue May 10 22:27:17 2011 > @@ -41,7 +41,6 @@ > STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); > STATISTIC(NumBranchOpts, "Number of branches optimized"); > STATISTIC(NumTailMerge , "Number of block tails merged"); > -STATISTIC(NumHoist , "Number of times common instructions are hoisted"); > > static cl::opt FlagEnableTailMerge("enable-tail-merge", > cl::init(cl::BOU_UNSET), cl::Hidden); > @@ -66,7 +65,7 @@ > public: > static char ID; > explicit BranchFolderPass(bool defaultEnableTailMerge) > - : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, true) {} > + : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge) {} > > virtual bool runOnMachineFunction(MachineFunction &MF); > virtual const char *getPassName() const { return "Control Flow Optimizer"; } > @@ -87,14 +86,12 @@ > } > > > -BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist) { > +BranchFolder::BranchFolder(bool defaultEnableTailMerge) { > switch (FlagEnableTailMerge) { > case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; > case cl::BOU_TRUE: EnableTailMerge = true; break; > case cl::BOU_FALSE: EnableTailMerge = false; break; > } > - > - EnableHoistCommonCode = CommonHoist; > } > > /// RemoveDeadBlock - Remove the specified dead machine basic block from the > @@ -189,10 +186,9 @@ > > bool MadeChangeThisIteration = true; > while (MadeChangeThisIteration) { > - MadeChangeThisIteration = TailMergeBlocks(MF); > - MadeChangeThisIteration |= OptimizeBranches(MF); > - if (EnableHoistCommonCode) > - MadeChangeThisIteration |= HoistCommonCode(MF); > + MadeChangeThisIteration = false; > + MadeChangeThisIteration |= TailMergeBlocks(MF); > + MadeChangeThisIteration |= OptimizeBranches(MF); > MadeChange |= MadeChangeThisIteration; > } > > @@ -914,8 +910,7 @@ > // Make sure blocks are numbered in order > MF.RenumberBlocks(); > > - for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); > - I != E; ) { > + for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { > MachineBasicBlock *MBB = I++; > MadeChange |= OptimizeBlock(MBB); > > @@ -1344,253 +1339,3 @@ > > return MadeChange; > } > - > -//===----------------------------------------------------------------------===// > -// Hoist Common Code > -//===----------------------------------------------------------------------===// > - > -/// HoistCommonCode - Hoist common instruction sequences at the start of basic > -/// blocks to their common predecessor. > -/// NOTE: This optimization does not update live-in information so it must be > -/// run after all passes that require correct liveness information. > -bool BranchFolder::HoistCommonCode(MachineFunction &MF) { > - bool MadeChange = false; > - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { > - MachineBasicBlock *MBB = I++; > - MadeChange |= HoistCommonCodeInSuccs(MBB); > - } > - > - return MadeChange; > -} > - > -/// findFalseBlock - BB has a fallthrough. Find its 'false' successor given > -/// its 'true' successor. > -static MachineBasicBlock *findFalseBlock(MachineBasicBlock *BB, > - MachineBasicBlock *TrueBB) { > - for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), > - E = BB->succ_end(); SI != E; ++SI) { > - MachineBasicBlock *SuccBB = *SI; > - if (SuccBB != TrueBB) > - return SuccBB; > - } > - return NULL; > -} > - > -/// findHoistingInsertPosAndDeps - Find the location to move common instructions > -/// in successors to. The location is ususally just before the terminator, > -/// however if the terminator is a conditional branch and its previous > -/// instruction is the flag setting instruction, the previous instruction is > -/// the preferred location. This function also gathers uses and defs of the > -/// instructions from the insertion point to the end of the block. The data is > -/// used by HoistCommonCodeInSuccs to ensure safety. > -static > -MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB, > - const TargetInstrInfo *TII, > - const TargetRegisterInfo *TRI, > - SmallSet &Uses, > - SmallSet &Defs) { > - MachineBasicBlock::iterator Loc = MBB->getFirstTerminator(); > - if (!TII->isUnpredicatedTerminator(Loc)) > - return MBB->end(); > - > - for (unsigned i = 0, e = Loc->getNumOperands(); i != e; ++i) { > - const MachineOperand &MO = Loc->getOperand(i); > - if (!MO.isReg()) > - continue; > - unsigned Reg = MO.getReg(); > - if (!Reg) > - continue; > - if (MO.isUse()) { > - Uses.insert(Reg); > - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > - Uses.insert(*AS); > - } else if (!MO.isDead()) > - // Don't try to hoist code in the rare case the terminator defines a > - // register that is later used. > - return MBB->end(); > - } > - > - if (Uses.empty()) > - return Loc; > - if (Loc == MBB->begin()) > - return MBB->end(); > - > - // The terminator is probably a conditional branch, try not to separate the > - // branch from condition setting instruction. > - MachineBasicBlock::iterator PI = Loc; > - --PI; > - while (PI != MBB->begin() && Loc->isDebugValue()) > - --PI; > - > - bool IsDef = false; > - for (unsigned i = 0, e = PI->getNumOperands(); !IsDef && i != e; ++i) { > - const MachineOperand &MO = PI->getOperand(i); > - if (!MO.isReg() || MO.isUse()) > - continue; > - unsigned Reg = MO.getReg(); > - if (!Reg) > - continue; > - if (Uses.count(Reg)) > - IsDef = true; > - } > - if (!IsDef) > - // The condition setting instruction is not just before the conditional > - // branch. > - return Loc; > - > - // Be conservative, don't insert instruction above something that may have > - // side-effects. And since it's potentially bad to separate flag setting > - // instruction from the conditional branch, just abort the optimization > - // completely. > - // Also avoid moving code above predicated instruction since it's hard to > - // reason about register liveness with predicated instruction. > - bool DontMoveAcrossStore = true; > - if (!PI->isSafeToMove(TII, 0, DontMoveAcrossStore) || > - TII->isPredicated(PI)) > - return MBB->end(); > - > - > - // Find out what registers are live. Note this routine is ignoring other live > - // registers which are only used by instructions in successor blocks. > - for (unsigned i = 0, e = PI->getNumOperands(); i != e; ++i) { > - const MachineOperand &MO = PI->getOperand(i); > - if (!MO.isReg()) > - continue; > - unsigned Reg = MO.getReg(); > - if (!Reg) > - continue; > - if (MO.isUse()) { > - Uses.insert(Reg); > - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > - Uses.insert(*AS); > - } else { > - if (Uses.count(Reg)) { > - Uses.erase(Reg); > - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) > - Uses.erase(*SR); // Use getSubRegisters to be conservative > - Defs.insert(Reg); > - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > - Defs.insert(*AS); > - } > - } > - } > - > - return PI; > -} > - > -/// HoistCommonCodeInSuccs - If the successors of MBB has common instruction > -/// sequence at the start of the function, move the instructions before MBB > -/// terminator if it's legal. > -bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { > - MachineBasicBlock *TBB = 0, *FBB = 0; > - SmallVector Cond; > - if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond, true) || !TBB || Cond.empty()) > - return false; > - > - if (!FBB) FBB = findFalseBlock(MBB, TBB); > - if (!FBB) > - // Malformed bcc? True and false blocks are the same? > - return false; > - > - // Restrict the optimization to cases where MBB is the only predecessor, > - // it is an obvious win. > - if (TBB->pred_size() > 1 || FBB->pred_size() > 1) > - return false; > - > - // Find a suitable position to hoist the common instructions to. Also figure > - // out which registers are used or defined by instructions from the insertion > - // point to the end of the block. > - SmallSet Uses, Defs; > - MachineBasicBlock::iterator Loc = > - findHoistingInsertPosAndDeps(MBB, TII, TRI, Uses, Defs); > - if (Loc == MBB->end()) > - return false; > - > - SmallSet LocalDefs; > - unsigned NumDups = 0; > - MachineBasicBlock::iterator TIB = TBB->begin(); > - MachineBasicBlock::iterator FIB = FBB->begin(); > - MachineBasicBlock::iterator TIE = TBB->end(); > - MachineBasicBlock::iterator FIE = FBB->end(); > - while (TIB != TIE && FIB != FIE) { > - // Skip dbg_value instructions. These do not count. > - if (TIB->isDebugValue()) { > - while (TIB != TIE && TIB->isDebugValue()) > - ++TIB; > - if (TIB == TIE) > - break; > - } > - if (FIB->isDebugValue()) { > - while (FIB != FIE && FIB->isDebugValue()) > - ++FIB; > - if (FIB == FIE) > - break; > - } > - if (!TIB->isIdenticalTo(FIB)) > - break; > - > - if (TII->isPredicated(TIB)) > - // Hard to reason about register liveness with predicated instruction. > - break; > - > - bool IsSafe = true; > - for (unsigned i = 0, e = TIB->getNumOperands(); i != e; ++i) { > - const MachineOperand &MO = TIB->getOperand(i); > - if (!MO.isReg()) > - continue; > - unsigned Reg = MO.getReg(); > - if (!Reg) > - continue; > - if (MO.isDef()) { > - if (Uses.count(Reg)) { > - // Avoid clobbering a register that's used by the instruction at > - // the point of insertion. > - IsSafe = false; > - break; > - } > - if (!MO.isDead() && Defs.count(Reg)) { > - // Don't hoist the instruction if the def would be clobber by the > - // instruction at the point insertion. FIXME: This is overly > - // conservative. It should be possible to hoist the instructions > - // in BB2 in the following example: > - // BB1: > - // r1, eflag = op1 r2, r3 > - // brcc eflag > - // > - // BB2: > - // r1 = op2, ... > - // = op3, r1 > - IsSafe = false; > - break; > - } > - LocalDefs.insert(Reg); > - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) > - LocalDefs.insert(*SR); > - } else if (!LocalDefs.count(Reg)) { > - if (Defs.count(Reg)) { > - // Use is defined by the instruction at the point of insertion. > - IsSafe = false; > - break; > - } > - } > - } > - if (!IsSafe) > - break; > - > - bool DontMoveAcrossStore = true; > - if (!TIB->isSafeToMove(TII, 0, DontMoveAcrossStore)) > - break; > - > - ++NumDups; > - ++TIB; > - ++FIB; > - } > - > - if (!NumDups) > - return false; > - > - MBB->splice(Loc, TBB, TBB->begin(), TIB); > - FBB->erase(FBB->begin(), FIB); > - ++NumHoist; > - return true; > -} > > Modified: llvm/trunk/lib/CodeGen/BranchFolding.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=131176&r1=131175&r2=131176&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) > +++ llvm/trunk/lib/CodeGen/BranchFolding.h Tue May 10 22:27:17 2011 > @@ -19,10 +19,11 @@ > class RegScavenger; > class TargetInstrInfo; > class TargetRegisterInfo; > + template class SmallVectorImpl; > > class BranchFolder { > public: > - explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist); > + explicit BranchFolder(bool defaultEnableTailMerge); > > bool OptimizeFunction(MachineFunction &MF, > const TargetInstrInfo *tii, > @@ -84,7 +85,6 @@ > std::vector SameTails; > > bool EnableTailMerge; > - bool EnableHoistCommonCode; > const TargetInstrInfo *TII; > const TargetRegisterInfo *TRI; > MachineModuleInfo *MMI; > @@ -110,9 +110,6 @@ > bool OptimizeBlock(MachineBasicBlock *MBB); > void RemoveDeadBlock(MachineBasicBlock *MBB); > bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); > - > - bool HoistCommonCode(MachineFunction &MF); > - bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB); > }; > } > > > Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=131176&r1=131175&r2=131176&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) > +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Tue May 10 22:27:17 2011 > @@ -265,7 +265,7 @@ > if (!TII) return false; > > // Tail merge tend to expose more if-conversion opportunities. > - BranchFolder BF(true, false); > + BranchFolder BF(true); > bool BFChange = BF.OptimizeFunction(MF, TII, > MF.getTarget().getRegisterInfo(), > getAnalysisIfAvailable()); > @@ -399,7 +399,7 @@ > BBAnalysis.clear(); > > if (MadeChange && IfCvtBranchFold) { > - BranchFolder BF(false, false); > + BranchFolder BF(false); > BF.OptimizeFunction(MF, TII, > MF.getTarget().getRegisterInfo(), > getAnalysisIfAvailable()); > > Removed: llvm/trunk/test/CodeGen/X86/hoist-common.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hoist-common.ll?rev=131175&view=auto > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/hoist-common.ll (original) > +++ llvm/trunk/test/CodeGen/X86/hoist-common.ll (removed) > @@ -1,28 +0,0 @@ > -; RUN: llc < %s -march=x86-64 | FileCheck %s > - > -; Common "xorb al, al" instruction in the two successor blocks should be > -; moved to the entry block above the test + je. > - > -; rdar://9145558 > - > -define zeroext i1 @t(i32 %c) nounwind ssp { > -entry: > -; CHECK: t: > -; CHECK: xorb %al, %al > -; CHECK: test > -; CHECK: je > - %tobool = icmp eq i32 %c, 0 > - br i1 %tobool, label %return, label %if.then > - > -if.then: > -; CHECK: callq > - %call = tail call zeroext i1 (...)* @foo() nounwind > - br label %return > - > -return: > -; CHECK: ret > - %retval.0 = phi i1 [ %call, %if.then ], [ false, %entry ] > - ret i1 %retval.0 > -} > - > -declare zeroext i1 @foo(...) > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dpatel at apple.com Wed May 11 14:22:19 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 May 2011 19:22:19 -0000 Subject: [llvm-commits] [llvm] r131194 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h test/CodeGen/X86/dbg-prolog-end.ll Message-ID: <20110511192219.A7DBD2A6C12C@llvm.org> Author: dpatel Date: Wed May 11 14:22:19 2011 New Revision: 131194 URL: http://llvm.org/viewvc/llvm-project?rev=131194&view=rev Log: Identify end of prologue (and beginning of function body) using DW_LNS_set_prologue_end line table opcode. Added: llvm/trunk/test/CodeGen/X86/dbg-prolog-end.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=131194&r1=131193&r2=131194&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed May 11 14:22:19 2011 @@ -1483,12 +1483,17 @@ if (!MI->isDebugValue()) { DebugLoc DL = MI->getDebugLoc(); if (DL != PrevInstLoc && (!DL.isUnknown() || UnknownLocations)) { + unsigned Flags = DWARF2_FLAG_IS_STMT; PrevInstLoc = DL; + if (DL == PrologEndLoc) { + Flags |= DWARF2_FLAG_PROLOGUE_END; + PrologEndLoc = DebugLoc(); + } if (!DL.isUnknown()) { const MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext()); - recordSourceLine(DL.getLine(), DL.getCol(), Scope); + recordSourceLine(DL.getLine(), DL.getCol(), Scope, Flags); } else - recordSourceLine(0, 0, 0); + recordSourceLine(0, 0, 0, 0); } } @@ -1800,21 +1805,6 @@ } } -/// FindFirstDebugLoc - Find the first debug location in the function. This -/// is intended to be an approximation for the source position of the -/// beginning of the function. -static DebugLoc FindFirstDebugLoc(const MachineFunction *MF) { - for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); - I != E; ++I) - for (MachineBasicBlock::const_iterator MBBI = I->begin(), MBBE = I->end(); - MBBI != MBBE; ++MBBI) { - DebugLoc DL = MBBI->getDebugLoc(); - if (!DL.isUnknown()) - return DL; - } - return DebugLoc(); -} - /// getScopeNode - Get MDNode for DebugLoc's scope. static MDNode *getScopeNode(DebugLoc DL, const LLVMContext &Ctx) { if (MDNode *InlinedAt = DL.getInlinedAt(Ctx)) @@ -1822,6 +1812,16 @@ return DL.getScope(Ctx); } +/// getFnDebugLoc - Walk up the scope chain of given debug loc and find +/// line number info for the function. +static DebugLoc getFnDebugLoc(DebugLoc DL, const LLVMContext &Ctx) { + const MDNode *Scope = getScopeNode(DL, Ctx); + DISubprogram SP = getDISubprogram(Scope); + if (SP.Verify()) + return DebugLoc::get(SP.getLineNumber(), 0, SP); + return DebugLoc(); +} + /// beginFunction - Gather pre-function debug information. Assumes being /// emitted immediately after the function entry point. void DwarfDebug::beginFunction(const MachineFunction *MF) { @@ -1833,35 +1833,11 @@ // Assumes in correct section after the entry point. Asm->OutStreamer.EmitLabel(FunctionBeginSym); - // Emit label for the implicitly defined dbg.stoppoint at the start of the - // function. - DebugLoc FDL = FindFirstDebugLoc(MF); - if (FDL.isUnknown()) return; - - const MDNode *Scope = getScopeNode(FDL, MF->getFunction()->getContext()); - const MDNode *TheScope = 0; - - DISubprogram SP = getDISubprogram(Scope); - unsigned Line, Col; - if (SP.Verify()) { - Line = SP.getLineNumber(); - Col = 0; - TheScope = SP; - } else { - Line = FDL.getLine(); - Col = FDL.getCol(); - TheScope = Scope; - } - - recordSourceLine(Line, Col, TheScope); - assert(UserVariables.empty() && DbgValues.empty() && "Maps weren't cleaned"); /// ProcessedArgs - Collection of arguments already processed. SmallPtrSet ProcessedArgs; - const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); - /// LiveUserVar - Map physreg numbers to the MDNode they contain. std::vector LiveUserVar(TRI->getNumRegs()); @@ -1927,6 +1903,11 @@ if (!MI->isLabel()) AtBlockEntry = false; + // First known non DBG_VALUE location marks beginning of function + // body. + if (PrologEndLoc.isUnknown() && !MI->getDebugLoc().isUnknown()) + PrologEndLoc = MI->getDebugLoc(); + // Check if the instruction clobbers any registers with debug vars. for (MachineInstr::const_mop_iterator MOI = MI->operands_begin(), MOE = MI->operands_end(); MOI != MOE; ++MOI) { @@ -1995,6 +1976,15 @@ PrevInstLoc = DebugLoc(); PrevLabel = FunctionBeginSym; + + // Record beginning of function. + if (!PrologEndLoc.isUnknown()) { + DebugLoc FnStartDL = getFnDebugLoc(PrologEndLoc, + MF->getFunction()->getContext()); + recordSourceLine(FnStartDL.getLine(), FnStartDL.getCol(), + FnStartDL.getScope(MF->getFunction()->getContext()), + DWARF2_FLAG_IS_STMT); + } } /// endFunction - Gather and emit post-function debug information. @@ -2109,7 +2099,8 @@ /// recordSourceLine - Register a source line with debug info. Returns the /// unique label that was emitted and which provides correspondence to /// the source line list. -void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S){ +void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S, + unsigned Flags) { StringRef Fn; StringRef Dir; unsigned Src = 1; @@ -2137,7 +2128,7 @@ Src = GetOrCreateSourceID(Fn, Dir); } - Asm->OutStreamer.EmitDwarfLocDirective(Src, Line, Col, DWARF2_FLAG_IS_STMT, + Asm->OutStreamer.EmitDwarfLocDirective(Src, Line, Col, Flags, 0, 0, Fn); } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=131194&r1=131193&r2=131194&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed May 11 14:22:19 2011 @@ -253,6 +253,10 @@ DebugLoc PrevInstLoc; MCSymbol *PrevLabel; + /// PrologEndLoc - This location indicates end of function prologue and + /// beginning of function body. + DebugLoc PrologEndLoc; + struct FunctionDebugFrameInfo { unsigned Number; std::vector Moves; @@ -402,7 +406,8 @@ /// recordSourceLine - Register a source line with debug info. Returns the /// unique label that was emitted and which provides correspondence to /// the source line list. - void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope); + void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope, + unsigned Flags); /// recordVariableFrameIndex - Record a variable's index. void recordVariableFrameIndex(const DbgVariable *V, int Index); Added: llvm/trunk/test/CodeGen/X86/dbg-prolog-end.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dbg-prolog-end.ll?rev=131194&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/dbg-prolog-end.ll (added) +++ llvm/trunk/test/CodeGen/X86/dbg-prolog-end.ll Wed May 11 14:22:19 2011 @@ -0,0 +1,55 @@ +; RUN: llc -O0 < %s | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-macosx10.6.7" + +;CHECK: .loc 1 2 11 prologue_end +define i32 @foo(i32 %i) nounwind ssp { +entry: + %i.addr = alloca i32, align 4 + %j = alloca i32, align 4 + store i32 %i, i32* %i.addr, align 4 + call void @llvm.dbg.declare(metadata !{i32* %i.addr}, metadata !7), !dbg !8 + call void @llvm.dbg.declare(metadata !{i32* %j}, metadata !9), !dbg !11 + store i32 2, i32* %j, align 4, !dbg !12 + %tmp = load i32* %j, align 4, !dbg !13 + %inc = add nsw i32 %tmp, 1, !dbg !13 + store i32 %inc, i32* %j, align 4, !dbg !13 + %tmp1 = load i32* %j, align 4, !dbg !14 + %tmp2 = load i32* %i.addr, align 4, !dbg !14 + %add = add nsw i32 %tmp1, %tmp2, !dbg !14 + store i32 %add, i32* %j, align 4, !dbg !14 + %tmp3 = load i32* %j, align 4, !dbg !15 + ret i32 %tmp3, !dbg !15 +} + +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + +define i32 @main() nounwind ssp { +entry: + %retval = alloca i32, align 4 + store i32 0, i32* %retval + %call = call i32 @foo(i32 21), !dbg !16 + ret i32 %call, !dbg !16 +} + +!llvm.dbg.cu = !{!0} +!llvm.dbg.sp = !{!1, !6} + +!0 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/a.c", metadata !"/private/tmp", metadata !"clang version 3.0 (trunk 131100)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!1 = metadata !{i32 589870, i32 0, metadata !2, metadata !"foo", metadata !"foo", metadata !"", metadata !2, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 false, i32 (i32)* @foo, null, null} ; [ DW_TAG_subprogram ] +!2 = metadata !{i32 589865, metadata !"/tmp/a.c", metadata !"/private/tmp", metadata !0} ; [ DW_TAG_file_type ] +!3 = metadata !{i32 589845, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !0, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 589870, i32 0, metadata !2, metadata !"main", metadata !"main", metadata !"", metadata !2, i32 7, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 0, i1 false, i32 ()* @main, null, null} ; [ DW_TAG_subprogram ] +!7 = metadata !{i32 590081, metadata !1, metadata !"i", metadata !2, i32 16777217, metadata !5, i32 0} ; [ DW_TAG_arg_variable ] +!8 = metadata !{i32 1, i32 13, metadata !1, null} +!9 = metadata !{i32 590080, metadata !10, metadata !"j", metadata !2, i32 2, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!10 = metadata !{i32 589835, metadata !1, i32 1, i32 16, metadata !2, i32 0} ; [ DW_TAG_lexical_block ] +!11 = metadata !{i32 2, i32 6, metadata !10, null} +!12 = metadata !{i32 2, i32 11, metadata !10, null} +!13 = metadata !{i32 3, i32 2, metadata !10, null} +!14 = metadata !{i32 4, i32 2, metadata !10, null} +!15 = metadata !{i32 5, i32 2, metadata !10, null} +!16 = metadata !{i32 8, i32 2, metadata !17, null} +!17 = metadata !{i32 589835, metadata !6, i32 7, i32 12, metadata !2, i32 1} ; [ DW_TAG_lexical_block ] From baldrick at free.fr Wed May 11 14:40:30 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 11 May 2011 19:40:30 -0000 Subject: [llvm-commits] [dragonegg] r131195 - /dragonegg/trunk/src/Convert.cpp Message-ID: <20110511194030.3E7032A6C12C@llvm.org> Author: baldrick Date: Wed May 11 14:40:30 2011 New Revision: 131195 URL: http://llvm.org/viewvc/llvm-project?rev=131195&view=rev Log: Simplify handling of MAX_EXPR and MIN_EXPR: modern GCC is much more careful about types of operands and no longer needs all this heavy converting. Also, ensure vectors of float are handled, partially fixing PR9717. Modified: dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131195&r1=131194&r2=131195&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Wed May 11 14:40:30 2011 @@ -6445,25 +6445,12 @@ Value *TreeToLLVM::EmitReg_MinMaxExpr(tree type, tree op0, tree op1, unsigned UIPred, unsigned SIPred, unsigned FPPred, bool isMax) { - Value *LHS = EmitRegister(op0); - Value *RHS = EmitRegister(op1); - const Type *Ty = getRegType(type); - - // The LHS, RHS and Ty could be integer, floating or pointer typed. We need - // to convert the LHS and RHS into the destination type before doing the - // comparison. Use CastInst::getCastOpcode to get this right. - bool TyIsSigned = !TYPE_UNSIGNED(type); - bool LHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(op0)); - bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(op1)); - Instruction::CastOps opcode = - CastInst::getCastOpcode(LHS, LHSIsSigned, Ty, TyIsSigned); - LHS = Builder.CreateCast(opcode, LHS, Ty); - opcode = CastInst::getCastOpcode(RHS, RHSIsSigned, Ty, TyIsSigned); - RHS = Builder.CreateCast(opcode, RHS, Ty); + Value *LHS = UselesslyTypeConvert(EmitRegister(op0), Ty); + Value *RHS = UselesslyTypeConvert(EmitRegister(op1), Ty); Value *Compare; - if (LHS->getType()->isFloatingPointTy()) + if (FLOAT_TYPE_P(type)) Compare = Builder.CreateFCmp(FCmpInst::Predicate(FPPred), LHS, RHS); else if (TYPE_UNSIGNED(type)) Compare = Builder.CreateICmp(ICmpInst::Predicate(UIPred), LHS, RHS); From echristo at apple.com Wed May 11 14:45:47 2011 From: echristo at apple.com (Eric Christopher) Date: Wed, 11 May 2011 12:45:47 -0700 Subject: [llvm-commits] [PATCH] ExecutionEngine: fix ErrorStr handling In-Reply-To: References: Message-ID: <094EDE5D-E1D8-40FE-8426-4ADCD32A416C@apple.com> On May 10, 2011, at 11:35 AM, nobled wrote: >> Oops, I meant to paste this in the last message: >> >> When I tried this patch, it causes the test to fail all by itself, >> even though the "Engine.get() != NULL" assert doesn't trigger. It >> gives this output: >> >> Error building ExecutionEngine: Unable to find target for this triple >> (no targets are registered) >> >> Does that indicate a bug in the test? >> > > I found the actual bug; the ExecutionEngine code was still setting > ErrorStr in the case whenever using the JIT failed, even if the > fallback to the interpreter was successful. The attached patch fixes > that case, and now the first patch works fine. > > Okay to commit? Haven't looked a lot, but why not check to see if the engine is null and if so, print out the error string? -eric From stuart at apple.com Wed May 11 14:41:29 2011 From: stuart at apple.com (Stuart Hastings) Date: Wed, 11 May 2011 19:41:29 -0000 Subject: [llvm-commits] [llvm] r131196 - in /llvm/trunk/test: CodeGen/Thumb/2011-05-11-DAGLegalizer.ll Other/2011-05-11-DAGLegalizer.ll Message-ID: <20110511194129.13EC92A6C12C@llvm.org> Author: stuart Date: Wed May 11 14:41:28 2011 New Revision: 131196 URL: http://llvm.org/viewvc/llvm-project?rev=131196&view=rev Log: Move this test to CodeGen/Thumb. rdar://problem/9416774 Added: llvm/trunk/test/CodeGen/Thumb/2011-05-11-DAGLegalizer.ll - copied, changed from r131191, llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll Removed: llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll Copied: llvm/trunk/test/CodeGen/Thumb/2011-05-11-DAGLegalizer.ll (from r131191, llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/2011-05-11-DAGLegalizer.ll?p2=llvm/trunk/test/CodeGen/Thumb/2011-05-11-DAGLegalizer.ll&p1=llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll&r1=131191&r2=131196&rev=131196&view=diff ============================================================================== --- llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/2011-05-11-DAGLegalizer.ll Wed May 11 14:41:28 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s +; RUN: llc -mtriple=thumbv6-apple-darwin < %s ; rdar://problem/9416774 ; ModuleID = 'reduced.ll' Removed: llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll?rev=131195&view=auto ============================================================================== --- llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll (original) +++ llvm/trunk/test/Other/2011-05-11-DAGLegalizer.ll (removed) @@ -1,60 +0,0 @@ -; RUN: llc < %s -; rdar://problem/9416774 -; ModuleID = 'reduced.ll' - -target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32" -target triple = "thumbv7-apple-ios" - -%struct.MMMMMMMMMMMM = type { [4 x %struct.RRRRRRRR] } -%struct.RRRRRRRR = type { [78 x i32] } - - at kkkkkk = external constant i8* - at __PRETTY_FUNCTION__._ZN12CLGll = private unnamed_addr constant [62 x i8] c"static void tttttttttttt::lllllllllllll(const MMMMMMMMMMMM &)\00" - at .str = private unnamed_addr constant [75 x i8] c"\09GGGGGGGGGGGGGGGGGGGGGGG:,BE:0x%08lx,ALM:0x%08lx,LTO:0x%08lx,CBEE:0x%08lx\0A\00" - -define void @_ZN12CLGll(%struct.MMMMMMMMMMMM* %aidData) ssp align 2 { -entry: - %aidData.addr = alloca %struct.MMMMMMMMMMMM*, align 4 - %agg.tmp = alloca %struct.RRRRRRRR, align 4 - %agg.tmp4 = alloca %struct.RRRRRRRR, align 4 - %agg.tmp10 = alloca %struct.RRRRRRRR, align 4 - %agg.tmp16 = alloca %struct.RRRRRRRR, align 4 - store %struct.MMMMMMMMMMMM* %aidData, %struct.MMMMMMMMMMMM** %aidData.addr, align 4 - br label %do.body - -do.body: ; preds = %entry - %tmp = load i8** @kkkkkk, align 4 - %tmp1 = load %struct.MMMMMMMMMMMM** %aidData.addr - %eph = getelementptr inbounds %struct.MMMMMMMMMMMM* %tmp1, i32 0, i32 0 - %arrayidx = getelementptr inbounds [4 x %struct.RRRRRRRR]* %eph, i32 0, i32 0 - %tmp2 = bitcast %struct.RRRRRRRR* %agg.tmp to i8* - %tmp3 = bitcast %struct.RRRRRRRR* %arrayidx to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* %tmp3, i32 312, i32 4, i1 false) - %tmp5 = load %struct.MMMMMMMMMMMM** %aidData.addr - %eph6 = getelementptr inbounds %struct.MMMMMMMMMMMM* %tmp5, i32 0, i32 0 - %arrayidx7 = getelementptr inbounds [4 x %struct.RRRRRRRR]* %eph6, i32 0, i32 1 - %tmp8 = bitcast %struct.RRRRRRRR* %agg.tmp4 to i8* - %tmp9 = bitcast %struct.RRRRRRRR* %arrayidx7 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp8, i8* %tmp9, i32 312, i32 4, i1 false) - %tmp11 = load %struct.MMMMMMMMMMMM** %aidData.addr - %eph12 = getelementptr inbounds %struct.MMMMMMMMMMMM* %tmp11, i32 0, i32 0 - %arrayidx13 = getelementptr inbounds [4 x %struct.RRRRRRRR]* %eph12, i32 0, i32 2 - %tmp14 = bitcast %struct.RRRRRRRR* %agg.tmp10 to i8* - %tmp15 = bitcast %struct.RRRRRRRR* %arrayidx13 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp14, i8* %tmp15, i32 312, i32 4, i1 false) - %tmp17 = load %struct.MMMMMMMMMMMM** %aidData.addr - %eph18 = getelementptr inbounds %struct.MMMMMMMMMMMM* %tmp17, i32 0, i32 0 - %arrayidx19 = getelementptr inbounds [4 x %struct.RRRRRRRR]* %eph18, i32 0, i32 3 - %tmp20 = bitcast %struct.RRRRRRRR* %agg.tmp16 to i8* - %tmp21 = bitcast %struct.RRRRRRRR* %arrayidx19 to i8* - call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp20, i8* %tmp21, i32 312, i32 4, i1 false) - call void (i8*, i32, i8*, i8*, ...)* @CLLoggingLog(i8* %tmp, i32 2, i8* getelementptr inbounds ([62 x i8]* @__PRETTY_FUNCTION__._ZN12CLGll, i32 0, i32 0), i8* getelementptr inbounds ([75 x i8]* @.str, i32 0, i32 0), %struct.RRRRRRRR* byval %agg.tmp, %struct.RRRRRRRR* byval %agg.tmp4, %struct.RRRRRRRR* byval %agg.tmp10, %struct.RRRRRRRR* byval %agg.tmp16) - br label %do.end - -do.end: ; preds = %do.body - ret void -} - -declare void @CLLoggingLog(i8*, i32, i8*, i8*, ...) - -declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind From stoklund at 2pi.dk Wed May 11 15:09:05 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 11 May 2011 20:09:05 -0000 Subject: [llvm-commits] [zorg] r131197 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110511200905.9D6072A6C12C@llvm.org> Author: stoklund Date: Wed May 11 15:09:05 2011 New Revision: 131197 URL: http://llvm.org/viewvc/llvm-project?rev=131197&view=rev Log: Add a lnt runtest nt --build-threads option that runs a separate build step. This makes it possible to first build the tests with -j8 and then run them with -j1 for stable performance numbers. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=131197&r1=131196&r2=131197&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Wed May 11 15:09:05 2011 @@ -139,7 +139,7 @@ 'env DYLD_LIBRARY_PATH=%s' % os.path.dirname( opts.liblto_path)) - if opts.threads > 1: + if opts.threads > 1 or opts.build_threads > 1: make_variables['ENABLE_PARALLEL_REPORT'] = '1' # Select the test style to use. @@ -339,11 +339,29 @@ test_log_path = os.path.join(basedir, 'test.log') test_log = open(test_log_path, 'w') - args = ['make', '-k', '-j', str(opts.threads), - 'report', 'report.%s.csv' % opts.test_style] - args.extend('%s=%s' % (k,v) for k,v in make_variables.items()) + common_args = ['make', '-k'] + common_args.extend('%s=%s' % (k,v) for k,v in make_variables.items()) if opts.only_test is not None: - args.extend(['-C',opts.only_test]) + common_args.extend(['-C',opts.only_test]) + + # Run a separate 'make build' step if --build-threads was given. + if opts.build_threads > 0: + args = common_args + ['-j', str(opts.build_threads), 'build'] + print >>test_log, '%s: running: %s' % (timestamp(), + ' '.join('"%s"' % a + for a in args)) + test_log.flush() + + print >>sys.stderr, '%s: building -j%u...' % (timestamp(), + opts.build_threads) + p = subprocess.Popen(args=args, stdin=None, stdout=test_log, + stderr=subprocess.STDOUT, cwd=basedir, + env=os.environ) + res = p.wait() + + # Then 'make report'. + args = common_args + ['-j', str(opts.threads), + 'report', 'report.%s.csv' % opts.test_style] print >>test_log, '%s: running: %s' % (timestamp(), ' '.join('"%s"' % a for a in args)) @@ -352,7 +370,7 @@ # FIXME: We shouldn't need to set env=os.environ here, but if we don't # somehow MACOSX_DEPLOYMENT_TARGET gets injected into the environment on OS # X (which changes the driver behavior and causes generally weirdness). - print >>sys.stderr, '%s: testing...' % timestamp() + print >>sys.stderr, '%s: testing -j%u...' % (timestamp(), opts.threads) p = subprocess.Popen(args=args, stdin=None, stdout=test_log, stderr=subprocess.STDOUT, cwd=basedir, env=os.environ) @@ -762,6 +780,9 @@ group.add_option("-j", "--threads", dest="threads", help="Number of testing threads", type=int, default=1, metavar="N") + group.add_option("", "--build-threads", dest="build_threads", + help="Number of compilation threads", + type=int, default=0, metavar="N") group.add_option("", "--remote", dest="remote", help=("Execute remotely, see " From grosbach at apple.com Wed May 11 15:39:15 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 11 May 2011 13:39:15 -0700 Subject: [llvm-commits] [llvm] r131176 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp test/CodeGen/X86/hoist-common.ll In-Reply-To: <699A16F0-38E0-4B4D-B5B1-C4E2049AD8D0@apple.com> References: <20110511032717.8F2842A6C12C@llvm.org> <699A16F0-38E0-4B4D-B5B1-C4E2049AD8D0@apple.com> Message-ID: There's something odd going on with that buildbot. There are compile-time errors from the system host compiler on tramp3d, for example, as well as errors from the clang under test. On May 11, 2011, at 11:37 AM, Evan Cheng wrote: > Rafael, can you provide more information? Which buildbot? What's the symptom? I noticed http://google1.osuosl.org:8011/builders/clang-x86_64-linux-fnt is still red. > > Evan > > On May 10, 2011, at 8:27 PM, Rafael Espindola wrote: > >> Author: rafael >> Date: Tue May 10 22:27:17 2011 >> New Revision: 131176 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=131176&view=rev >> Log: >> Revert 131172 as it is causing clang to miscompile itself. I will try >> to provide a reduced testcase. >> >> Removed: >> llvm/trunk/test/CodeGen/X86/hoist-common.ll >> Modified: >> llvm/trunk/lib/CodeGen/BranchFolding.cpp >> llvm/trunk/lib/CodeGen/BranchFolding.h >> llvm/trunk/lib/CodeGen/IfConversion.cpp >> >> Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131176&r1=131175&r2=131176&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) >> +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Tue May 10 22:27:17 2011 >> @@ -41,7 +41,6 @@ >> STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); >> STATISTIC(NumBranchOpts, "Number of branches optimized"); >> STATISTIC(NumTailMerge , "Number of block tails merged"); >> -STATISTIC(NumHoist , "Number of times common instructions are hoisted"); >> >> static cl::opt FlagEnableTailMerge("enable-tail-merge", >> cl::init(cl::BOU_UNSET), cl::Hidden); >> @@ -66,7 +65,7 @@ >> public: >> static char ID; >> explicit BranchFolderPass(bool defaultEnableTailMerge) >> - : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, true) {} >> + : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge) {} >> >> virtual bool runOnMachineFunction(MachineFunction &MF); >> virtual const char *getPassName() const { return "Control Flow Optimizer"; } >> @@ -87,14 +86,12 @@ >> } >> >> >> -BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist) { >> +BranchFolder::BranchFolder(bool defaultEnableTailMerge) { >> switch (FlagEnableTailMerge) { >> case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; >> case cl::BOU_TRUE: EnableTailMerge = true; break; >> case cl::BOU_FALSE: EnableTailMerge = false; break; >> } >> - >> - EnableHoistCommonCode = CommonHoist; >> } >> >> /// RemoveDeadBlock - Remove the specified dead machine basic block from the >> @@ -189,10 +186,9 @@ >> >> bool MadeChangeThisIteration = true; >> while (MadeChangeThisIteration) { >> - MadeChangeThisIteration = TailMergeBlocks(MF); >> - MadeChangeThisIteration |= OptimizeBranches(MF); >> - if (EnableHoistCommonCode) >> - MadeChangeThisIteration |= HoistCommonCode(MF); >> + MadeChangeThisIteration = false; >> + MadeChangeThisIteration |= TailMergeBlocks(MF); >> + MadeChangeThisIteration |= OptimizeBranches(MF); >> MadeChange |= MadeChangeThisIteration; >> } >> >> @@ -914,8 +910,7 @@ >> // Make sure blocks are numbered in order >> MF.RenumberBlocks(); >> >> - for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); >> - I != E; ) { >> + for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { >> MachineBasicBlock *MBB = I++; >> MadeChange |= OptimizeBlock(MBB); >> >> @@ -1344,253 +1339,3 @@ >> >> return MadeChange; >> } >> - >> -//===----------------------------------------------------------------------===// >> -// Hoist Common Code >> -//===----------------------------------------------------------------------===// >> - >> -/// HoistCommonCode - Hoist common instruction sequences at the start of basic >> -/// blocks to their common predecessor. >> -/// NOTE: This optimization does not update live-in information so it must be >> -/// run after all passes that require correct liveness information. >> -bool BranchFolder::HoistCommonCode(MachineFunction &MF) { >> - bool MadeChange = false; >> - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { >> - MachineBasicBlock *MBB = I++; >> - MadeChange |= HoistCommonCodeInSuccs(MBB); >> - } >> - >> - return MadeChange; >> -} >> - >> -/// findFalseBlock - BB has a fallthrough. Find its 'false' successor given >> -/// its 'true' successor. >> -static MachineBasicBlock *findFalseBlock(MachineBasicBlock *BB, >> - MachineBasicBlock *TrueBB) { >> - for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), >> - E = BB->succ_end(); SI != E; ++SI) { >> - MachineBasicBlock *SuccBB = *SI; >> - if (SuccBB != TrueBB) >> - return SuccBB; >> - } >> - return NULL; >> -} >> - >> -/// findHoistingInsertPosAndDeps - Find the location to move common instructions >> -/// in successors to. The location is ususally just before the terminator, >> -/// however if the terminator is a conditional branch and its previous >> -/// instruction is the flag setting instruction, the previous instruction is >> -/// the preferred location. This function also gathers uses and defs of the >> -/// instructions from the insertion point to the end of the block. The data is >> -/// used by HoistCommonCodeInSuccs to ensure safety. >> -static >> -MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB, >> - const TargetInstrInfo *TII, >> - const TargetRegisterInfo *TRI, >> - SmallSet &Uses, >> - SmallSet &Defs) { >> - MachineBasicBlock::iterator Loc = MBB->getFirstTerminator(); >> - if (!TII->isUnpredicatedTerminator(Loc)) >> - return MBB->end(); >> - >> - for (unsigned i = 0, e = Loc->getNumOperands(); i != e; ++i) { >> - const MachineOperand &MO = Loc->getOperand(i); >> - if (!MO.isReg()) >> - continue; >> - unsigned Reg = MO.getReg(); >> - if (!Reg) >> - continue; >> - if (MO.isUse()) { >> - Uses.insert(Reg); >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) >> - Uses.insert(*AS); >> - } else if (!MO.isDead()) >> - // Don't try to hoist code in the rare case the terminator defines a >> - // register that is later used. >> - return MBB->end(); >> - } >> - >> - if (Uses.empty()) >> - return Loc; >> - if (Loc == MBB->begin()) >> - return MBB->end(); >> - >> - // The terminator is probably a conditional branch, try not to separate the >> - // branch from condition setting instruction. >> - MachineBasicBlock::iterator PI = Loc; >> - --PI; >> - while (PI != MBB->begin() && Loc->isDebugValue()) >> - --PI; >> - >> - bool IsDef = false; >> - for (unsigned i = 0, e = PI->getNumOperands(); !IsDef && i != e; ++i) { >> - const MachineOperand &MO = PI->getOperand(i); >> - if (!MO.isReg() || MO.isUse()) >> - continue; >> - unsigned Reg = MO.getReg(); >> - if (!Reg) >> - continue; >> - if (Uses.count(Reg)) >> - IsDef = true; >> - } >> - if (!IsDef) >> - // The condition setting instruction is not just before the conditional >> - // branch. >> - return Loc; >> - >> - // Be conservative, don't insert instruction above something that may have >> - // side-effects. And since it's potentially bad to separate flag setting >> - // instruction from the conditional branch, just abort the optimization >> - // completely. >> - // Also avoid moving code above predicated instruction since it's hard to >> - // reason about register liveness with predicated instruction. >> - bool DontMoveAcrossStore = true; >> - if (!PI->isSafeToMove(TII, 0, DontMoveAcrossStore) || >> - TII->isPredicated(PI)) >> - return MBB->end(); >> - >> - >> - // Find out what registers are live. Note this routine is ignoring other live >> - // registers which are only used by instructions in successor blocks. >> - for (unsigned i = 0, e = PI->getNumOperands(); i != e; ++i) { >> - const MachineOperand &MO = PI->getOperand(i); >> - if (!MO.isReg()) >> - continue; >> - unsigned Reg = MO.getReg(); >> - if (!Reg) >> - continue; >> - if (MO.isUse()) { >> - Uses.insert(Reg); >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) >> - Uses.insert(*AS); >> - } else { >> - if (Uses.count(Reg)) { >> - Uses.erase(Reg); >> - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) >> - Uses.erase(*SR); // Use getSubRegisters to be conservative >> - Defs.insert(Reg); >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) >> - Defs.insert(*AS); >> - } >> - } >> - } >> - >> - return PI; >> -} >> - >> -/// HoistCommonCodeInSuccs - If the successors of MBB has common instruction >> -/// sequence at the start of the function, move the instructions before MBB >> -/// terminator if it's legal. >> -bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { >> - MachineBasicBlock *TBB = 0, *FBB = 0; >> - SmallVector Cond; >> - if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond, true) || !TBB || Cond.empty()) >> - return false; >> - >> - if (!FBB) FBB = findFalseBlock(MBB, TBB); >> - if (!FBB) >> - // Malformed bcc? True and false blocks are the same? >> - return false; >> - >> - // Restrict the optimization to cases where MBB is the only predecessor, >> - // it is an obvious win. >> - if (TBB->pred_size() > 1 || FBB->pred_size() > 1) >> - return false; >> - >> - // Find a suitable position to hoist the common instructions to. Also figure >> - // out which registers are used or defined by instructions from the insertion >> - // point to the end of the block. >> - SmallSet Uses, Defs; >> - MachineBasicBlock::iterator Loc = >> - findHoistingInsertPosAndDeps(MBB, TII, TRI, Uses, Defs); >> - if (Loc == MBB->end()) >> - return false; >> - >> - SmallSet LocalDefs; >> - unsigned NumDups = 0; >> - MachineBasicBlock::iterator TIB = TBB->begin(); >> - MachineBasicBlock::iterator FIB = FBB->begin(); >> - MachineBasicBlock::iterator TIE = TBB->end(); >> - MachineBasicBlock::iterator FIE = FBB->end(); >> - while (TIB != TIE && FIB != FIE) { >> - // Skip dbg_value instructions. These do not count. >> - if (TIB->isDebugValue()) { >> - while (TIB != TIE && TIB->isDebugValue()) >> - ++TIB; >> - if (TIB == TIE) >> - break; >> - } >> - if (FIB->isDebugValue()) { >> - while (FIB != FIE && FIB->isDebugValue()) >> - ++FIB; >> - if (FIB == FIE) >> - break; >> - } >> - if (!TIB->isIdenticalTo(FIB)) >> - break; >> - >> - if (TII->isPredicated(TIB)) >> - // Hard to reason about register liveness with predicated instruction. >> - break; >> - >> - bool IsSafe = true; >> - for (unsigned i = 0, e = TIB->getNumOperands(); i != e; ++i) { >> - const MachineOperand &MO = TIB->getOperand(i); >> - if (!MO.isReg()) >> - continue; >> - unsigned Reg = MO.getReg(); >> - if (!Reg) >> - continue; >> - if (MO.isDef()) { >> - if (Uses.count(Reg)) { >> - // Avoid clobbering a register that's used by the instruction at >> - // the point of insertion. >> - IsSafe = false; >> - break; >> - } >> - if (!MO.isDead() && Defs.count(Reg)) { >> - // Don't hoist the instruction if the def would be clobber by the >> - // instruction at the point insertion. FIXME: This is overly >> - // conservative. It should be possible to hoist the instructions >> - // in BB2 in the following example: >> - // BB1: >> - // r1, eflag = op1 r2, r3 >> - // brcc eflag >> - // >> - // BB2: >> - // r1 = op2, ... >> - // = op3, r1 >> - IsSafe = false; >> - break; >> - } >> - LocalDefs.insert(Reg); >> - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) >> - LocalDefs.insert(*SR); >> - } else if (!LocalDefs.count(Reg)) { >> - if (Defs.count(Reg)) { >> - // Use is defined by the instruction at the point of insertion. >> - IsSafe = false; >> - break; >> - } >> - } >> - } >> - if (!IsSafe) >> - break; >> - >> - bool DontMoveAcrossStore = true; >> - if (!TIB->isSafeToMove(TII, 0, DontMoveAcrossStore)) >> - break; >> - >> - ++NumDups; >> - ++TIB; >> - ++FIB; >> - } >> - >> - if (!NumDups) >> - return false; >> - >> - MBB->splice(Loc, TBB, TBB->begin(), TIB); >> - FBB->erase(FBB->begin(), FIB); >> - ++NumHoist; >> - return true; >> -} >> >> Modified: llvm/trunk/lib/CodeGen/BranchFolding.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=131176&r1=131175&r2=131176&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) >> +++ llvm/trunk/lib/CodeGen/BranchFolding.h Tue May 10 22:27:17 2011 >> @@ -19,10 +19,11 @@ >> class RegScavenger; >> class TargetInstrInfo; >> class TargetRegisterInfo; >> + template class SmallVectorImpl; >> >> class BranchFolder { >> public: >> - explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist); >> + explicit BranchFolder(bool defaultEnableTailMerge); >> >> bool OptimizeFunction(MachineFunction &MF, >> const TargetInstrInfo *tii, >> @@ -84,7 +85,6 @@ >> std::vector SameTails; >> >> bool EnableTailMerge; >> - bool EnableHoistCommonCode; >> const TargetInstrInfo *TII; >> const TargetRegisterInfo *TRI; >> MachineModuleInfo *MMI; >> @@ -110,9 +110,6 @@ >> bool OptimizeBlock(MachineBasicBlock *MBB); >> void RemoveDeadBlock(MachineBasicBlock *MBB); >> bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); >> - >> - bool HoistCommonCode(MachineFunction &MF); >> - bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB); >> }; >> } >> >> >> Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=131176&r1=131175&r2=131176&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) >> +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Tue May 10 22:27:17 2011 >> @@ -265,7 +265,7 @@ >> if (!TII) return false; >> >> // Tail merge tend to expose more if-conversion opportunities. >> - BranchFolder BF(true, false); >> + BranchFolder BF(true); >> bool BFChange = BF.OptimizeFunction(MF, TII, >> MF.getTarget().getRegisterInfo(), >> getAnalysisIfAvailable()); >> @@ -399,7 +399,7 @@ >> BBAnalysis.clear(); >> >> if (MadeChange && IfCvtBranchFold) { >> - BranchFolder BF(false, false); >> + BranchFolder BF(false); >> BF.OptimizeFunction(MF, TII, >> MF.getTarget().getRegisterInfo(), >> getAnalysisIfAvailable()); >> >> Removed: llvm/trunk/test/CodeGen/X86/hoist-common.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hoist-common.ll?rev=131175&view=auto >> ============================================================================== >> --- llvm/trunk/test/CodeGen/X86/hoist-common.ll (original) >> +++ llvm/trunk/test/CodeGen/X86/hoist-common.ll (removed) >> @@ -1,28 +0,0 @@ >> -; RUN: llc < %s -march=x86-64 | FileCheck %s >> - >> -; Common "xorb al, al" instruction in the two successor blocks should be >> -; moved to the entry block above the test + je. >> - >> -; rdar://9145558 >> - >> -define zeroext i1 @t(i32 %c) nounwind ssp { >> -entry: >> -; CHECK: t: >> -; CHECK: xorb %al, %al >> -; CHECK: test >> -; CHECK: je >> - %tobool = icmp eq i32 %c, 0 >> - br i1 %tobool, label %return, label %if.then >> - >> -if.then: >> -; CHECK: callq >> - %call = tail call zeroext i1 (...)* @foo() nounwind >> - br label %return >> - >> -return: >> -; CHECK: ret >> - %retval.0 = phi i1 [ %call, %if.then ], [ false, %entry ] >> - ret i1 %retval.0 >> -} >> - >> -declare zeroext i1 @foo(...) >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dpatel at apple.com Wed May 11 15:46:37 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 May 2011 13:46:37 -0700 Subject: [llvm-commits] .cfi_* and ARM In-Reply-To: <4DC9D0BD.8010004@gmail.com> References: <4DC84EE9.8080402@gmail.com> <4DC8552E.3030705@gmail.com> <4DC9D0BD.8010004@gmail.com> Message-ID: <82E550F3-818C-4BF2-B11E-52ADF52823D2@apple.com> On May 10, 2011, at 4:56 PM, Rafael Avila de Espindola wrote: > On 11-05-09 04:57 PM, Rafael Avila de Espindola wrote: >>> I should have a patch for 1 in a moment. Thoughts? >> >> The first patch is attached. > > OK, I think it is all implemented now. If the only reason for having the cfi instructions is that the user wants debug info, we will now also produce a .cfi_sections .debug_frame. > > Cheers, Thanks! - Devang From nlewycky at google.com Wed May 11 16:27:47 2011 From: nlewycky at google.com (Nick Lewycky) Date: Wed, 11 May 2011 14:27:47 -0700 Subject: [llvm-commits] [llvm] r131176 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp test/CodeGen/X86/hoist-common.ll In-Reply-To: References: <20110511032717.8F2842A6C12C@llvm.org> <699A16F0-38E0-4B4D-B5B1-C4E2049AD8D0@apple.com> Message-ID: I recently upgraded that machine to gcc 4.6. We may need to fix the testsuite to build with newer GCCs. Nick On 11 May 2011 13:39, Jim Grosbach wrote: > There's something odd going on with that buildbot. There are compile-time > errors from the system host compiler on tramp3d, for example, as well as > errors from the clang under test. > > On May 11, 2011, at 11:37 AM, Evan Cheng wrote: > > > Rafael, can you provide more information? Which buildbot? What's the > symptom? I noticed > http://google1.osuosl.org:8011/builders/clang-x86_64-linux-fnt is still > red. > > > > Evan > > > > On May 10, 2011, at 8:27 PM, Rafael Espindola wrote: > > > >> Author: rafael > >> Date: Tue May 10 22:27:17 2011 > >> New Revision: 131176 > >> > >> URL: http://llvm.org/viewvc/llvm-project?rev=131176&view=rev > >> Log: > >> Revert 131172 as it is causing clang to miscompile itself. I will try > >> to provide a reduced testcase. > >> > >> Removed: > >> llvm/trunk/test/CodeGen/X86/hoist-common.ll > >> Modified: > >> llvm/trunk/lib/CodeGen/BranchFolding.cpp > >> llvm/trunk/lib/CodeGen/BranchFolding.h > >> llvm/trunk/lib/CodeGen/IfConversion.cpp > >> > >> Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp > >> URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131176&r1=131175&r2=131176&view=diff > >> > ============================================================================== > >> --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) > >> +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Tue May 10 22:27:17 2011 > >> @@ -41,7 +41,6 @@ > >> STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); > >> STATISTIC(NumBranchOpts, "Number of branches optimized"); > >> STATISTIC(NumTailMerge , "Number of block tails merged"); > >> -STATISTIC(NumHoist , "Number of times common instructions are > hoisted"); > >> > >> static cl::opt > FlagEnableTailMerge("enable-tail-merge", > >> cl::init(cl::BOU_UNSET), cl::Hidden); > >> @@ -66,7 +65,7 @@ > >> public: > >> static char ID; > >> explicit BranchFolderPass(bool defaultEnableTailMerge) > >> - : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, > true) {} > >> + : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge) > {} > >> > >> virtual bool runOnMachineFunction(MachineFunction &MF); > >> virtual const char *getPassName() const { return "Control Flow > Optimizer"; } > >> @@ -87,14 +86,12 @@ > >> } > >> > >> > >> -BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool > CommonHoist) { > >> +BranchFolder::BranchFolder(bool defaultEnableTailMerge) { > >> switch (FlagEnableTailMerge) { > >> case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; > >> case cl::BOU_TRUE: EnableTailMerge = true; break; > >> case cl::BOU_FALSE: EnableTailMerge = false; break; > >> } > >> - > >> - EnableHoistCommonCode = CommonHoist; > >> } > >> > >> /// RemoveDeadBlock - Remove the specified dead machine basic block from > the > >> @@ -189,10 +186,9 @@ > >> > >> bool MadeChangeThisIteration = true; > >> while (MadeChangeThisIteration) { > >> - MadeChangeThisIteration = TailMergeBlocks(MF); > >> - MadeChangeThisIteration |= OptimizeBranches(MF); > >> - if (EnableHoistCommonCode) > >> - MadeChangeThisIteration |= HoistCommonCode(MF); > >> + MadeChangeThisIteration = false; > >> + MadeChangeThisIteration |= TailMergeBlocks(MF); > >> + MadeChangeThisIteration |= OptimizeBranches(MF); > >> MadeChange |= MadeChangeThisIteration; > >> } > >> > >> @@ -914,8 +910,7 @@ > >> // Make sure blocks are numbered in order > >> MF.RenumberBlocks(); > >> > >> - for (MachineFunction::iterator I = llvm::next(MF.begin()), E = > MF.end(); > >> - I != E; ) { > >> + for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != > E; ) { > >> MachineBasicBlock *MBB = I++; > >> MadeChange |= OptimizeBlock(MBB); > >> > >> @@ -1344,253 +1339,3 @@ > >> > >> return MadeChange; > >> } > >> - > >> > -//===----------------------------------------------------------------------===// > >> -// Hoist Common Code > >> > -//===----------------------------------------------------------------------===// > >> - > >> -/// HoistCommonCode - Hoist common instruction sequences at the start > of basic > >> -/// blocks to their common predecessor. > >> -/// NOTE: This optimization does not update live-in information so it > must be > >> -/// run after all passes that require correct liveness information. > >> -bool BranchFolder::HoistCommonCode(MachineFunction &MF) { > >> - bool MadeChange = false; > >> - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; > ) { > >> - MachineBasicBlock *MBB = I++; > >> - MadeChange |= HoistCommonCodeInSuccs(MBB); > >> - } > >> - > >> - return MadeChange; > >> -} > >> - > >> -/// findFalseBlock - BB has a fallthrough. Find its 'false' successor > given > >> -/// its 'true' successor. > >> -static MachineBasicBlock *findFalseBlock(MachineBasicBlock *BB, > >> - MachineBasicBlock *TrueBB) { > >> - for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), > >> - E = BB->succ_end(); SI != E; ++SI) { > >> - MachineBasicBlock *SuccBB = *SI; > >> - if (SuccBB != TrueBB) > >> - return SuccBB; > >> - } > >> - return NULL; > >> -} > >> - > >> -/// findHoistingInsertPosAndDeps - Find the location to move common > instructions > >> -/// in successors to. The location is ususally just before the > terminator, > >> -/// however if the terminator is a conditional branch and its previous > >> -/// instruction is the flag setting instruction, the previous > instruction is > >> -/// the preferred location. This function also gathers uses and defs of > the > >> -/// instructions from the insertion point to the end of the block. The > data is > >> -/// used by HoistCommonCodeInSuccs to ensure safety. > >> -static > >> -MachineBasicBlock::iterator > findHoistingInsertPosAndDeps(MachineBasicBlock *MBB, > >> - const TargetInstrInfo > *TII, > >> - const > TargetRegisterInfo *TRI, > >> - SmallSet > &Uses, > >> - SmallSet > &Defs) { > >> - MachineBasicBlock::iterator Loc = MBB->getFirstTerminator(); > >> - if (!TII->isUnpredicatedTerminator(Loc)) > >> - return MBB->end(); > >> - > >> - for (unsigned i = 0, e = Loc->getNumOperands(); i != e; ++i) { > >> - const MachineOperand &MO = Loc->getOperand(i); > >> - if (!MO.isReg()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (MO.isUse()) { > >> - Uses.insert(Reg); > >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > >> - Uses.insert(*AS); > >> - } else if (!MO.isDead()) > >> - // Don't try to hoist code in the rare case the terminator > defines a > >> - // register that is later used. > >> - return MBB->end(); > >> - } > >> - > >> - if (Uses.empty()) > >> - return Loc; > >> - if (Loc == MBB->begin()) > >> - return MBB->end(); > >> - > >> - // The terminator is probably a conditional branch, try not to > separate the > >> - // branch from condition setting instruction. > >> - MachineBasicBlock::iterator PI = Loc; > >> - --PI; > >> - while (PI != MBB->begin() && Loc->isDebugValue()) > >> - --PI; > >> - > >> - bool IsDef = false; > >> - for (unsigned i = 0, e = PI->getNumOperands(); !IsDef && i != e; ++i) > { > >> - const MachineOperand &MO = PI->getOperand(i); > >> - if (!MO.isReg() || MO.isUse()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (Uses.count(Reg)) > >> - IsDef = true; > >> - } > >> - if (!IsDef) > >> - // The condition setting instruction is not just before the > conditional > >> - // branch. > >> - return Loc; > >> - > >> - // Be conservative, don't insert instruction above something that may > have > >> - // side-effects. And since it's potentially bad to separate flag > setting > >> - // instruction from the conditional branch, just abort the > optimization > >> - // completely. > >> - // Also avoid moving code above predicated instruction since it's > hard to > >> - // reason about register liveness with predicated instruction. > >> - bool DontMoveAcrossStore = true; > >> - if (!PI->isSafeToMove(TII, 0, DontMoveAcrossStore) || > >> - TII->isPredicated(PI)) > >> - return MBB->end(); > >> - > >> - > >> - // Find out what registers are live. Note this routine is ignoring > other live > >> - // registers which are only used by instructions in successor blocks. > >> - for (unsigned i = 0, e = PI->getNumOperands(); i != e; ++i) { > >> - const MachineOperand &MO = PI->getOperand(i); > >> - if (!MO.isReg()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (MO.isUse()) { > >> - Uses.insert(Reg); > >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > >> - Uses.insert(*AS); > >> - } else { > >> - if (Uses.count(Reg)) { > >> - Uses.erase(Reg); > >> - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) > >> - Uses.erase(*SR); // Use getSubRegisters to be conservative > >> - Defs.insert(Reg); > >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > >> - Defs.insert(*AS); > >> - } > >> - } > >> - } > >> - > >> - return PI; > >> -} > >> - > >> -/// HoistCommonCodeInSuccs - If the successors of MBB has common > instruction > >> -/// sequence at the start of the function, move the instructions before > MBB > >> -/// terminator if it's legal. > >> -bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { > >> - MachineBasicBlock *TBB = 0, *FBB = 0; > >> - SmallVector Cond; > >> - if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond, true) || !TBB || > Cond.empty()) > >> - return false; > >> - > >> - if (!FBB) FBB = findFalseBlock(MBB, TBB); > >> - if (!FBB) > >> - // Malformed bcc? True and false blocks are the same? > >> - return false; > >> - > >> - // Restrict the optimization to cases where MBB is the only > predecessor, > >> - // it is an obvious win. > >> - if (TBB->pred_size() > 1 || FBB->pred_size() > 1) > >> - return false; > >> - > >> - // Find a suitable position to hoist the common instructions to. Also > figure > >> - // out which registers are used or defined by instructions from the > insertion > >> - // point to the end of the block. > >> - SmallSet Uses, Defs; > >> - MachineBasicBlock::iterator Loc = > >> - findHoistingInsertPosAndDeps(MBB, TII, TRI, Uses, Defs); > >> - if (Loc == MBB->end()) > >> - return false; > >> - > >> - SmallSet LocalDefs; > >> - unsigned NumDups = 0; > >> - MachineBasicBlock::iterator TIB = TBB->begin(); > >> - MachineBasicBlock::iterator FIB = FBB->begin(); > >> - MachineBasicBlock::iterator TIE = TBB->end(); > >> - MachineBasicBlock::iterator FIE = FBB->end(); > >> - while (TIB != TIE && FIB != FIE) { > >> - // Skip dbg_value instructions. These do not count. > >> - if (TIB->isDebugValue()) { > >> - while (TIB != TIE && TIB->isDebugValue()) > >> - ++TIB; > >> - if (TIB == TIE) > >> - break; > >> - } > >> - if (FIB->isDebugValue()) { > >> - while (FIB != FIE && FIB->isDebugValue()) > >> - ++FIB; > >> - if (FIB == FIE) > >> - break; > >> - } > >> - if (!TIB->isIdenticalTo(FIB)) > >> - break; > >> - > >> - if (TII->isPredicated(TIB)) > >> - // Hard to reason about register liveness with predicated > instruction. > >> - break; > >> - > >> - bool IsSafe = true; > >> - for (unsigned i = 0, e = TIB->getNumOperands(); i != e; ++i) { > >> - const MachineOperand &MO = TIB->getOperand(i); > >> - if (!MO.isReg()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (MO.isDef()) { > >> - if (Uses.count(Reg)) { > >> - // Avoid clobbering a register that's used by the instruction > at > >> - // the point of insertion. > >> - IsSafe = false; > >> - break; > >> - } > >> - if (!MO.isDead() && Defs.count(Reg)) { > >> - // Don't hoist the instruction if the def would be clobber by > the > >> - // instruction at the point insertion. FIXME: This is overly > >> - // conservative. It should be possible to hoist the > instructions > >> - // in BB2 in the following example: > >> - // BB1: > >> - // r1, eflag = op1 r2, r3 > >> - // brcc eflag > >> - // > >> - // BB2: > >> - // r1 = op2, ... > >> - // = op3, r1 > >> - IsSafe = false; > >> - break; > >> - } > >> - LocalDefs.insert(Reg); > >> - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) > >> - LocalDefs.insert(*SR); > >> - } else if (!LocalDefs.count(Reg)) { > >> - if (Defs.count(Reg)) { > >> - // Use is defined by the instruction at the point of > insertion. > >> - IsSafe = false; > >> - break; > >> - } > >> - } > >> - } > >> - if (!IsSafe) > >> - break; > >> - > >> - bool DontMoveAcrossStore = true; > >> - if (!TIB->isSafeToMove(TII, 0, DontMoveAcrossStore)) > >> - break; > >> - > >> - ++NumDups; > >> - ++TIB; > >> - ++FIB; > >> - } > >> - > >> - if (!NumDups) > >> - return false; > >> - > >> - MBB->splice(Loc, TBB, TBB->begin(), TIB); > >> - FBB->erase(FBB->begin(), FIB); > >> - ++NumHoist; > >> - return true; > >> -} > >> > >> Modified: llvm/trunk/lib/CodeGen/BranchFolding.h > >> URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=131176&r1=131175&r2=131176&view=diff > >> > ============================================================================== > >> --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) > >> +++ llvm/trunk/lib/CodeGen/BranchFolding.h Tue May 10 22:27:17 2011 > >> @@ -19,10 +19,11 @@ > >> class RegScavenger; > >> class TargetInstrInfo; > >> class TargetRegisterInfo; > >> + template class SmallVectorImpl; > >> > >> class BranchFolder { > >> public: > >> - explicit BranchFolder(bool defaultEnableTailMerge, bool > CommonHoist); > >> + explicit BranchFolder(bool defaultEnableTailMerge); > >> > >> bool OptimizeFunction(MachineFunction &MF, > >> const TargetInstrInfo *tii, > >> @@ -84,7 +85,6 @@ > >> std::vector SameTails; > >> > >> bool EnableTailMerge; > >> - bool EnableHoistCommonCode; > >> const TargetInstrInfo *TII; > >> const TargetRegisterInfo *TRI; > >> MachineModuleInfo *MMI; > >> @@ -110,9 +110,6 @@ > >> bool OptimizeBlock(MachineBasicBlock *MBB); > >> void RemoveDeadBlock(MachineBasicBlock *MBB); > >> bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); > >> - > >> - bool HoistCommonCode(MachineFunction &MF); > >> - bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB); > >> }; > >> } > >> > >> > >> Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp > >> URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=131176&r1=131175&r2=131176&view=diff > >> > ============================================================================== > >> --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) > >> +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Tue May 10 22:27:17 2011 > >> @@ -265,7 +265,7 @@ > >> if (!TII) return false; > >> > >> // Tail merge tend to expose more if-conversion opportunities. > >> - BranchFolder BF(true, false); > >> + BranchFolder BF(true); > >> bool BFChange = BF.OptimizeFunction(MF, TII, > >> MF.getTarget().getRegisterInfo(), > >> > getAnalysisIfAvailable()); > >> @@ -399,7 +399,7 @@ > >> BBAnalysis.clear(); > >> > >> if (MadeChange && IfCvtBranchFold) { > >> - BranchFolder BF(false, false); > >> + BranchFolder BF(false); > >> BF.OptimizeFunction(MF, TII, > >> MF.getTarget().getRegisterInfo(), > >> getAnalysisIfAvailable()); > >> > >> Removed: llvm/trunk/test/CodeGen/X86/hoist-common.ll > >> URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hoist-common.ll?rev=131175&view=auto > >> > ============================================================================== > >> --- llvm/trunk/test/CodeGen/X86/hoist-common.ll (original) > >> +++ llvm/trunk/test/CodeGen/X86/hoist-common.ll (removed) > >> @@ -1,28 +0,0 @@ > >> -; RUN: llc < %s -march=x86-64 | FileCheck %s > >> - > >> -; Common "xorb al, al" instruction in the two successor blocks should > be > >> -; moved to the entry block above the test + je. > >> - > >> -; rdar://9145558 > >> - > >> -define zeroext i1 @t(i32 %c) nounwind ssp { > >> -entry: > >> -; CHECK: t: > >> -; CHECK: xorb %al, %al > >> -; CHECK: test > >> -; CHECK: je > >> - %tobool = icmp eq i32 %c, 0 > >> - br i1 %tobool, label %return, label %if.then > >> - > >> -if.then: > >> -; CHECK: callq > >> - %call = tail call zeroext i1 (...)* @foo() nounwind > >> - br label %return > >> - > >> -return: > >> -; CHECK: ret > >> - %retval.0 = phi i1 [ %call, %if.then ], [ false, %entry ] > >> - ret i1 %retval.0 > >> -} > >> - > >> -declare zeroext i1 @foo(...) > >> > >> > >> _______________________________________________ > >> llvm-commits mailing list > >> llvm-commits at cs.uiuc.edu > >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110511/f985b453/attachment.html From grosbach at apple.com Wed May 11 16:30:16 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 11 May 2011 14:30:16 -0700 Subject: [llvm-commits] [llvm] r131176 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp test/CodeGen/X86/hoist-common.ll In-Reply-To: References: <20110511032717.8F2842A6C12C@llvm.org> <699A16F0-38E0-4B4D-B5B1-C4E2049AD8D0@apple.com> Message-ID: <93B79100-4EFF-4919-AAF3-5471F652C48F@apple.com> That's likely what's going on, at least partly. Rafael pointed out that a self-hosted clang in the same environment passes the tests, so it looks like that GCC may also be miscompiling clang. -Jim On May 11, 2011, at 2:27 PM, Nick Lewycky wrote: > I recently upgraded that machine to gcc 4.6. We may need to fix the testsuite to build with newer GCCs. > > Nick > > On 11 May 2011 13:39, Jim Grosbach wrote: > There's something odd going on with that buildbot. There are compile-time errors from the system host compiler on tramp3d, for example, as well as errors from the clang under test. > > On May 11, 2011, at 11:37 AM, Evan Cheng wrote: > > > Rafael, can you provide more information? Which buildbot? What's the symptom? I noticed http://google1.osuosl.org:8011/builders/clang-x86_64-linux-fnt is still red. > > > > Evan > > > > On May 10, 2011, at 8:27 PM, Rafael Espindola wrote: > > > >> Author: rafael > >> Date: Tue May 10 22:27:17 2011 > >> New Revision: 131176 > >> > >> URL: http://llvm.org/viewvc/llvm-project?rev=131176&view=rev > >> Log: > >> Revert 131172 as it is causing clang to miscompile itself. I will try > >> to provide a reduced testcase. > >> > >> Removed: > >> llvm/trunk/test/CodeGen/X86/hoist-common.ll > >> Modified: > >> llvm/trunk/lib/CodeGen/BranchFolding.cpp > >> llvm/trunk/lib/CodeGen/BranchFolding.h > >> llvm/trunk/lib/CodeGen/IfConversion.cpp > >> > >> Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp > >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131176&r1=131175&r2=131176&view=diff > >> ============================================================================== > >> --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) > >> +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Tue May 10 22:27:17 2011 > >> @@ -41,7 +41,6 @@ > >> STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); > >> STATISTIC(NumBranchOpts, "Number of branches optimized"); > >> STATISTIC(NumTailMerge , "Number of block tails merged"); > >> -STATISTIC(NumHoist , "Number of times common instructions are hoisted"); > >> > >> static cl::opt FlagEnableTailMerge("enable-tail-merge", > >> cl::init(cl::BOU_UNSET), cl::Hidden); > >> @@ -66,7 +65,7 @@ > >> public: > >> static char ID; > >> explicit BranchFolderPass(bool defaultEnableTailMerge) > >> - : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, true) {} > >> + : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge) {} > >> > >> virtual bool runOnMachineFunction(MachineFunction &MF); > >> virtual const char *getPassName() const { return "Control Flow Optimizer"; } > >> @@ -87,14 +86,12 @@ > >> } > >> > >> > >> -BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist) { > >> +BranchFolder::BranchFolder(bool defaultEnableTailMerge) { > >> switch (FlagEnableTailMerge) { > >> case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; > >> case cl::BOU_TRUE: EnableTailMerge = true; break; > >> case cl::BOU_FALSE: EnableTailMerge = false; break; > >> } > >> - > >> - EnableHoistCommonCode = CommonHoist; > >> } > >> > >> /// RemoveDeadBlock - Remove the specified dead machine basic block from the > >> @@ -189,10 +186,9 @@ > >> > >> bool MadeChangeThisIteration = true; > >> while (MadeChangeThisIteration) { > >> - MadeChangeThisIteration = TailMergeBlocks(MF); > >> - MadeChangeThisIteration |= OptimizeBranches(MF); > >> - if (EnableHoistCommonCode) > >> - MadeChangeThisIteration |= HoistCommonCode(MF); > >> + MadeChangeThisIteration = false; > >> + MadeChangeThisIteration |= TailMergeBlocks(MF); > >> + MadeChangeThisIteration |= OptimizeBranches(MF); > >> MadeChange |= MadeChangeThisIteration; > >> } > >> > >> @@ -914,8 +910,7 @@ > >> // Make sure blocks are numbered in order > >> MF.RenumberBlocks(); > >> > >> - for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); > >> - I != E; ) { > >> + for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { > >> MachineBasicBlock *MBB = I++; > >> MadeChange |= OptimizeBlock(MBB); > >> > >> @@ -1344,253 +1339,3 @@ > >> > >> return MadeChange; > >> } > >> - > >> -//===----------------------------------------------------------------------===// > >> -// Hoist Common Code > >> -//===----------------------------------------------------------------------===// > >> - > >> -/// HoistCommonCode - Hoist common instruction sequences at the start of basic > >> -/// blocks to their common predecessor. > >> -/// NOTE: This optimization does not update live-in information so it must be > >> -/// run after all passes that require correct liveness information. > >> -bool BranchFolder::HoistCommonCode(MachineFunction &MF) { > >> - bool MadeChange = false; > >> - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { > >> - MachineBasicBlock *MBB = I++; > >> - MadeChange |= HoistCommonCodeInSuccs(MBB); > >> - } > >> - > >> - return MadeChange; > >> -} > >> - > >> -/// findFalseBlock - BB has a fallthrough. Find its 'false' successor given > >> -/// its 'true' successor. > >> -static MachineBasicBlock *findFalseBlock(MachineBasicBlock *BB, > >> - MachineBasicBlock *TrueBB) { > >> - for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), > >> - E = BB->succ_end(); SI != E; ++SI) { > >> - MachineBasicBlock *SuccBB = *SI; > >> - if (SuccBB != TrueBB) > >> - return SuccBB; > >> - } > >> - return NULL; > >> -} > >> - > >> -/// findHoistingInsertPosAndDeps - Find the location to move common instructions > >> -/// in successors to. The location is ususally just before the terminator, > >> -/// however if the terminator is a conditional branch and its previous > >> -/// instruction is the flag setting instruction, the previous instruction is > >> -/// the preferred location. This function also gathers uses and defs of the > >> -/// instructions from the insertion point to the end of the block. The data is > >> -/// used by HoistCommonCodeInSuccs to ensure safety. > >> -static > >> -MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB, > >> - const TargetInstrInfo *TII, > >> - const TargetRegisterInfo *TRI, > >> - SmallSet &Uses, > >> - SmallSet &Defs) { > >> - MachineBasicBlock::iterator Loc = MBB->getFirstTerminator(); > >> - if (!TII->isUnpredicatedTerminator(Loc)) > >> - return MBB->end(); > >> - > >> - for (unsigned i = 0, e = Loc->getNumOperands(); i != e; ++i) { > >> - const MachineOperand &MO = Loc->getOperand(i); > >> - if (!MO.isReg()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (MO.isUse()) { > >> - Uses.insert(Reg); > >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > >> - Uses.insert(*AS); > >> - } else if (!MO.isDead()) > >> - // Don't try to hoist code in the rare case the terminator defines a > >> - // register that is later used. > >> - return MBB->end(); > >> - } > >> - > >> - if (Uses.empty()) > >> - return Loc; > >> - if (Loc == MBB->begin()) > >> - return MBB->end(); > >> - > >> - // The terminator is probably a conditional branch, try not to separate the > >> - // branch from condition setting instruction. > >> - MachineBasicBlock::iterator PI = Loc; > >> - --PI; > >> - while (PI != MBB->begin() && Loc->isDebugValue()) > >> - --PI; > >> - > >> - bool IsDef = false; > >> - for (unsigned i = 0, e = PI->getNumOperands(); !IsDef && i != e; ++i) { > >> - const MachineOperand &MO = PI->getOperand(i); > >> - if (!MO.isReg() || MO.isUse()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (Uses.count(Reg)) > >> - IsDef = true; > >> - } > >> - if (!IsDef) > >> - // The condition setting instruction is not just before the conditional > >> - // branch. > >> - return Loc; > >> - > >> - // Be conservative, don't insert instruction above something that may have > >> - // side-effects. And since it's potentially bad to separate flag setting > >> - // instruction from the conditional branch, just abort the optimization > >> - // completely. > >> - // Also avoid moving code above predicated instruction since it's hard to > >> - // reason about register liveness with predicated instruction. > >> - bool DontMoveAcrossStore = true; > >> - if (!PI->isSafeToMove(TII, 0, DontMoveAcrossStore) || > >> - TII->isPredicated(PI)) > >> - return MBB->end(); > >> - > >> - > >> - // Find out what registers are live. Note this routine is ignoring other live > >> - // registers which are only used by instructions in successor blocks. > >> - for (unsigned i = 0, e = PI->getNumOperands(); i != e; ++i) { > >> - const MachineOperand &MO = PI->getOperand(i); > >> - if (!MO.isReg()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (MO.isUse()) { > >> - Uses.insert(Reg); > >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > >> - Uses.insert(*AS); > >> - } else { > >> - if (Uses.count(Reg)) { > >> - Uses.erase(Reg); > >> - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) > >> - Uses.erase(*SR); // Use getSubRegisters to be conservative > >> - Defs.insert(Reg); > >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > >> - Defs.insert(*AS); > >> - } > >> - } > >> - } > >> - > >> - return PI; > >> -} > >> - > >> -/// HoistCommonCodeInSuccs - If the successors of MBB has common instruction > >> -/// sequence at the start of the function, move the instructions before MBB > >> -/// terminator if it's legal. > >> -bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { > >> - MachineBasicBlock *TBB = 0, *FBB = 0; > >> - SmallVector Cond; > >> - if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond, true) || !TBB || Cond.empty()) > >> - return false; > >> - > >> - if (!FBB) FBB = findFalseBlock(MBB, TBB); > >> - if (!FBB) > >> - // Malformed bcc? True and false blocks are the same? > >> - return false; > >> - > >> - // Restrict the optimization to cases where MBB is the only predecessor, > >> - // it is an obvious win. > >> - if (TBB->pred_size() > 1 || FBB->pred_size() > 1) > >> - return false; > >> - > >> - // Find a suitable position to hoist the common instructions to. Also figure > >> - // out which registers are used or defined by instructions from the insertion > >> - // point to the end of the block. > >> - SmallSet Uses, Defs; > >> - MachineBasicBlock::iterator Loc = > >> - findHoistingInsertPosAndDeps(MBB, TII, TRI, Uses, Defs); > >> - if (Loc == MBB->end()) > >> - return false; > >> - > >> - SmallSet LocalDefs; > >> - unsigned NumDups = 0; > >> - MachineBasicBlock::iterator TIB = TBB->begin(); > >> - MachineBasicBlock::iterator FIB = FBB->begin(); > >> - MachineBasicBlock::iterator TIE = TBB->end(); > >> - MachineBasicBlock::iterator FIE = FBB->end(); > >> - while (TIB != TIE && FIB != FIE) { > >> - // Skip dbg_value instructions. These do not count. > >> - if (TIB->isDebugValue()) { > >> - while (TIB != TIE && TIB->isDebugValue()) > >> - ++TIB; > >> - if (TIB == TIE) > >> - break; > >> - } > >> - if (FIB->isDebugValue()) { > >> - while (FIB != FIE && FIB->isDebugValue()) > >> - ++FIB; > >> - if (FIB == FIE) > >> - break; > >> - } > >> - if (!TIB->isIdenticalTo(FIB)) > >> - break; > >> - > >> - if (TII->isPredicated(TIB)) > >> - // Hard to reason about register liveness with predicated instruction. > >> - break; > >> - > >> - bool IsSafe = true; > >> - for (unsigned i = 0, e = TIB->getNumOperands(); i != e; ++i) { > >> - const MachineOperand &MO = TIB->getOperand(i); > >> - if (!MO.isReg()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (MO.isDef()) { > >> - if (Uses.count(Reg)) { > >> - // Avoid clobbering a register that's used by the instruction at > >> - // the point of insertion. > >> - IsSafe = false; > >> - break; > >> - } > >> - if (!MO.isDead() && Defs.count(Reg)) { > >> - // Don't hoist the instruction if the def would be clobber by the > >> - // instruction at the point insertion. FIXME: This is overly > >> - // conservative. It should be possible to hoist the instructions > >> - // in BB2 in the following example: > >> - // BB1: > >> - // r1, eflag = op1 r2, r3 > >> - // brcc eflag > >> - // > >> - // BB2: > >> - // r1 = op2, ... > >> - // = op3, r1 > >> - IsSafe = false; > >> - break; > >> - } > >> - LocalDefs.insert(Reg); > >> - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) > >> - LocalDefs.insert(*SR); > >> - } else if (!LocalDefs.count(Reg)) { > >> - if (Defs.count(Reg)) { > >> - // Use is defined by the instruction at the point of insertion. > >> - IsSafe = false; > >> - break; > >> - } > >> - } > >> - } > >> - if (!IsSafe) > >> - break; > >> - > >> - bool DontMoveAcrossStore = true; > >> - if (!TIB->isSafeToMove(TII, 0, DontMoveAcrossStore)) > >> - break; > >> - > >> - ++NumDups; > >> - ++TIB; > >> - ++FIB; > >> - } > >> - > >> - if (!NumDups) > >> - return false; > >> - > >> - MBB->splice(Loc, TBB, TBB->begin(), TIB); > >> - FBB->erase(FBB->begin(), FIB); > >> - ++NumHoist; > >> - return true; > >> -} > >> > >> Modified: llvm/trunk/lib/CodeGen/BranchFolding.h > >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=131176&r1=131175&r2=131176&view=diff > >> ============================================================================== > >> --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) > >> +++ llvm/trunk/lib/CodeGen/BranchFolding.h Tue May 10 22:27:17 2011 > >> @@ -19,10 +19,11 @@ > >> class RegScavenger; > >> class TargetInstrInfo; > >> class TargetRegisterInfo; > >> + template class SmallVectorImpl; > >> > >> class BranchFolder { > >> public: > >> - explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist); > >> + explicit BranchFolder(bool defaultEnableTailMerge); > >> > >> bool OptimizeFunction(MachineFunction &MF, > >> const TargetInstrInfo *tii, > >> @@ -84,7 +85,6 @@ > >> std::vector SameTails; > >> > >> bool EnableTailMerge; > >> - bool EnableHoistCommonCode; > >> const TargetInstrInfo *TII; > >> const TargetRegisterInfo *TRI; > >> MachineModuleInfo *MMI; > >> @@ -110,9 +110,6 @@ > >> bool OptimizeBlock(MachineBasicBlock *MBB); > >> void RemoveDeadBlock(MachineBasicBlock *MBB); > >> bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); > >> - > >> - bool HoistCommonCode(MachineFunction &MF); > >> - bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB); > >> }; > >> } > >> > >> > >> Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp > >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=131176&r1=131175&r2=131176&view=diff > >> ============================================================================== > >> --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) > >> +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Tue May 10 22:27:17 2011 > >> @@ -265,7 +265,7 @@ > >> if (!TII) return false; > >> > >> // Tail merge tend to expose more if-conversion opportunities. > >> - BranchFolder BF(true, false); > >> + BranchFolder BF(true); > >> bool BFChange = BF.OptimizeFunction(MF, TII, > >> MF.getTarget().getRegisterInfo(), > >> getAnalysisIfAvailable()); > >> @@ -399,7 +399,7 @@ > >> BBAnalysis.clear(); > >> > >> if (MadeChange && IfCvtBranchFold) { > >> - BranchFolder BF(false, false); > >> + BranchFolder BF(false); > >> BF.OptimizeFunction(MF, TII, > >> MF.getTarget().getRegisterInfo(), > >> getAnalysisIfAvailable()); > >> > >> Removed: llvm/trunk/test/CodeGen/X86/hoist-common.ll > >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hoist-common.ll?rev=131175&view=auto > >> ============================================================================== > >> --- llvm/trunk/test/CodeGen/X86/hoist-common.ll (original) > >> +++ llvm/trunk/test/CodeGen/X86/hoist-common.ll (removed) > >> @@ -1,28 +0,0 @@ > >> -; RUN: llc < %s -march=x86-64 | FileCheck %s > >> - > >> -; Common "xorb al, al" instruction in the two successor blocks should be > >> -; moved to the entry block above the test + je. > >> - > >> -; rdar://9145558 > >> - > >> -define zeroext i1 @t(i32 %c) nounwind ssp { > >> -entry: > >> -; CHECK: t: > >> -; CHECK: xorb %al, %al > >> -; CHECK: test > >> -; CHECK: je > >> - %tobool = icmp eq i32 %c, 0 > >> - br i1 %tobool, label %return, label %if.then > >> - > >> -if.then: > >> -; CHECK: callq > >> - %call = tail call zeroext i1 (...)* @foo() nounwind > >> - br label %return > >> - > >> -return: > >> -; CHECK: ret > >> - %retval.0 = phi i1 [ %call, %if.then ], [ false, %entry ] > >> - ret i1 %retval.0 > >> -} > >> - > >> -declare zeroext i1 @foo(...) > >> > >> > >> _______________________________________________ > >> llvm-commits mailing list > >> llvm-commits at cs.uiuc.edu > >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From echristo at apple.com Wed May 11 16:44:58 2011 From: echristo at apple.com (Eric Christopher) Date: Wed, 11 May 2011 21:44:58 -0000 Subject: [llvm-commits] [llvm] r131200 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Message-ID: <20110511214458.651262A6C12C@llvm.org> Author: echristo Date: Wed May 11 16:44:58 2011 New Revision: 131200 URL: http://llvm.org/viewvc/llvm-project?rev=131200&view=rev Log: Turn this into a table, this will make more sense shortly. Part of rdar://8470697 Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=131200&r1=131199&r2=131200&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Wed May 11 16:44:58 2011 @@ -1482,6 +1482,22 @@ } } +static const unsigned int AtomicOpcTbl[1][11] = { + { + X86::LOCK_OR8mi, + X86::LOCK_OR8mr, + X86::LOCK_OR16mi8, + X86::LOCK_OR16mi, + X86::LOCK_OR16mr, + X86::LOCK_OR32mi8, + X86::LOCK_OR32mi, + X86::LOCK_OR32mr, + X86::LOCK_OR64mi8, + X86::LOCK_OR64mi32, + X86::LOCK_OR64mr + } +}; + SDNode *X86DAGToDAGISel::SelectAtomicLoadOr(SDNode *Node, EVT NVT) { if (Node->hasAnyUseOfValue(0)) return 0; @@ -1504,41 +1520,43 @@ Val = CurDAG->getTargetConstant(CN->getSExtValue(), NVT); } + // Which index into the table. + unsigned index = 0; unsigned Opc = 0; switch (NVT.getSimpleVT().SimpleTy) { default: return 0; case MVT::i8: if (isCN) - Opc = X86::LOCK_OR8mi; + Opc = AtomicOpcTbl[index][0]; else - Opc = X86::LOCK_OR8mr; + Opc = AtomicOpcTbl[index][1]; break; case MVT::i16: if (isCN) { if (immSext8(Val.getNode())) - Opc = X86::LOCK_OR16mi8; + Opc = AtomicOpcTbl[index][2]; else - Opc = X86::LOCK_OR16mi; + Opc = AtomicOpcTbl[index][3]; } else - Opc = X86::LOCK_OR16mr; + Opc = AtomicOpcTbl[index][4]; break; case MVT::i32: if (isCN) { if (immSext8(Val.getNode())) - Opc = X86::LOCK_OR32mi8; + Opc = AtomicOpcTbl[index][5]; else - Opc = X86::LOCK_OR32mi; + Opc = AtomicOpcTbl[index][6]; } else - Opc = X86::LOCK_OR32mr; + Opc = AtomicOpcTbl[index][7]; break; case MVT::i64: if (isCN) { if (immSext8(Val.getNode())) - Opc = X86::LOCK_OR64mi8; + Opc = AtomicOpcTbl[index][8]; else if (i64immSExt32(Val.getNode())) - Opc = X86::LOCK_OR64mi32; + Opc = AtomicOpcTbl[index][9]; } else - Opc = X86::LOCK_OR64mr; + Opc = AtomicOpcTbl[index][10]; break; } From rafael.espindola at gmail.com Wed May 11 16:55:47 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Wed, 11 May 2011 17:55:47 -0400 Subject: [llvm-commits] [llvm] r131176 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp test/CodeGen/X86/hoist-common.ll In-Reply-To: <699A16F0-38E0-4B4D-B5B1-C4E2049AD8D0@apple.com> References: <20110511032717.8F2842A6C12C@llvm.org> <699A16F0-38E0-4B4D-B5B1-C4E2049AD8D0@apple.com> Message-ID: <4DCB05E3.1090407@gmail.com> On 2011-05-11 14:37, Evan Cheng wrote: > Rafael, can you provide more information? Which buildbot? What's the > symptom? I noticed > http://google1.osuosl.org:8011/builders/clang-x86_64-linux-fnt is > still red. I noticed the problem while trying to reproduce that one. I reported PR9896 with the IL that gets miscompiled. A clang created by linking all object built by gcc except for CGVTables.o produced from the .ll in the bug would crash when running /home/espindola/llvm/clang/test/CodeGenCXX/vtable-key-function.cpp -triple=x86_64-apple-darwin10 -emit-llvm By reverting the patch, llc then produce a .o that does not cause clang to crash. > Evan > > Cheers, Rafael From jason.w.kim.2009 at gmail.com Wed May 11 17:53:06 2011 From: jason.w.kim.2009 at gmail.com (Jason W Kim) Date: Wed, 11 May 2011 22:53:06 -0000 Subject: [llvm-commits] [llvm] r131205 - in /llvm/trunk/lib/MC: ELFObjectWriter.cpp ELFObjectWriter.h Message-ID: <20110511225306.571622A6C12C@llvm.org> Author: jasonwkim Date: Wed May 11 17:53:06 2011 New Revision: 131205 URL: http://llvm.org/viewvc/llvm-project?rev=131205&view=rev Log: Address the last bit of relocation flag related divergence betweeen LLVM and binutils. With this patch, there are no functional differences between the .o produced directly from LLVM versus the .s to .o via GNU as, for relocation tags at least, for both PIC and non-PIC modes. Because some non-PIC reloc tags are used (legally) on PIC, so IsPCRel flag is necessary but not sufficient to determine whether the overall codegen mode is PIC or not. Why is this necessary? There is an incompatibility of how relocs are emitted in the .rodata section. Binutils PIC likes to emit certain relocs as section relative offsets. Non-PIC does not do this. So I added a hidden switch on the ELFObjectwriter "-arm-elf-force-pic" which forces the objectwriter to pretend that all relocs are for PIC mode. Todo: Activate ForceARMElfPIC to true if -relocation-model=pic is selected on llc. Todo: There are probably more issues for PIC mode on ARM/MC/ELF... Todo: Existing tests in MC/ARM/elf-reloc*.ll need to be converted over to .s tests as well as expanded to cover the gamut. Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp llvm/trunk/lib/MC/ELFObjectWriter.h Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=131205&r1=131204&r2=131205&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed May 11 17:53:06 2011 @@ -25,6 +25,8 @@ #include "llvm/Support/ELF.h" #include "llvm/Target/TargetAsmBackend.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/Statistic.h" #include "../Target/X86/X86FixupKinds.h" #include "../Target/ARM/ARMFixupKinds.h" @@ -32,6 +34,16 @@ #include using namespace llvm; +#undef DEBUG_TYPE +#define DEBUG_TYPE "reloc-info" + +// Emulate the wierd behavior of GNU-as for relocation types +namespace llvm { +cl::opt +ForceARMElfPIC("arm-elf-force-pic", cl::Hidden, cl::init(false), + cl::desc("Force ELF emitter to emit PIC style relocations")); +} + bool ELFObjectWriter::isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind) { const MCFixupKindInfo &FKI = Asm.getBackend().getFixupKindInfo((MCFixupKind) Kind); @@ -319,7 +331,9 @@ const MCSymbol *ELFObjectWriter::SymbolToReloc(const MCAssembler &Asm, const MCValue &Target, - const MCFragment &F) const { + const MCFragment &F, + const MCFixup &Fixup, + bool IsPCRel) const { const MCSymbol &Symbol = Target.getSymA()->getSymbol(); const MCSymbol &ASymbol = Symbol.AliasedSymbol(); const MCSymbol *Renamed = Renames.lookup(&Symbol); @@ -342,7 +356,7 @@ const SectionKind secKind = Section.getKind(); if (secKind.isBSS()) - return ExplicitRelSym(Asm, Target, F, true); + return ExplicitRelSym(Asm, Target, F, Fixup, IsPCRel); if (secKind.isThreadLocal()) { if (Renamed) @@ -365,13 +379,14 @@ if (Section.getFlags() & ELF::SHF_MERGE) { if (Target.getConstant() == 0) - return NULL; + return ExplicitRelSym(Asm, Target, F, Fixup, IsPCRel); if (Renamed) return Renamed; return &Symbol; } - return ExplicitRelSym(Asm, Target, F, false); + return ExplicitRelSym(Asm, Target, F, Fixup, IsPCRel); + } @@ -390,7 +405,7 @@ if (!Target.isAbsolute()) { const MCSymbol &Symbol = Target.getSymA()->getSymbol(); const MCSymbol &ASymbol = Symbol.AliasedSymbol(); - RelocSymbol = SymbolToReloc(Asm, Target, *Fragment); + RelocSymbol = SymbolToReloc(Asm, Target, *Fragment, Fixup, IsPCRel); if (const MCSymbolRefExpr *RefB = Target.getSymB()) { const MCSymbol &SymbolB = RefB->getSymbol(); @@ -1261,32 +1276,93 @@ // In ARM, _MergedGlobals and other most symbols get emitted directly. // I.e. not as an offset to a section symbol. -// This code is a first-cut approximation of what ARM/gcc does. +// This code is an approximation of what ARM/gcc does. + +STATISTIC(PCRelCount, "Total number of PIC Relocations"); +STATISTIC(NonPCRelCount, "Total number of non-PIC relocations"); const MCSymbol *ARMELFObjectWriter::ExplicitRelSym(const MCAssembler &Asm, const MCValue &Target, const MCFragment &F, - bool IsBSS) const { + const MCFixup &Fixup, + bool IsPCRel) const { const MCSymbol &Symbol = Target.getSymA()->getSymbol(); bool EmitThisSym = false; - if (IsBSS) { - EmitThisSym = StringSwitch(Symbol.getName()) - .Case("_MergedGlobals", true) - .Default(false); + const MCSectionELF &Section = + static_cast(Symbol.getSection()); + const SectionKind secKind = Section.getKind(); + const MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind(); + MCSymbolRefExpr::VariantKind Kind2; + Kind2 = Target.getSymB() ? Target.getSymB()->getKind() : + MCSymbolRefExpr::VK_None; + bool InNormalSection = true; + unsigned RelocType = 0; + RelocType = GetRelocTypeInner(Target, Fixup, IsPCRel); + + DEBUG(dbgs() << "considering symbol " + << Section.getSectionName() << "/" + << Symbol.getName() << "/" + << " Rel:" << (unsigned)RelocType + << " Kind: " << (int)Kind << "/" << (int)Kind2 + << " Tmp:" + << Symbol.isAbsolute() << "/" << Symbol.isDefined() << "/" + << Symbol.isVariable() << "/" << Symbol.isTemporary() + << " Counts:" << PCRelCount << "/" << NonPCRelCount << "\n"); + + if (IsPCRel || ForceARMElfPIC) { ++PCRelCount; + switch (RelocType) { + default: + // Most relocation types are emitted as explicit symbols + InNormalSection = + StringSwitch(Section.getSectionName()) + .Case(".data.rel.ro.local", false) + .Case(".data.rel", false) + .Case(".bss", false) + .Default(true); + EmitThisSym = true; + break; + case ELF::R_ARM_ABS32: + // But things get strange with R_ARM_ABS32 + // In this case, most things that go in .rodata show up + // as section relative relocations + InNormalSection = + StringSwitch(Section.getSectionName()) + .Case(".data.rel.ro.local", false) + .Case(".data.rel", false) + .Case(".rodata", false) + .Case(".bss", false) + .Default(true); + EmitThisSym = false; + break; + } } else { - EmitThisSym = StringSwitch(Symbol.getName()) - .Case("_MergedGlobals", true) - .StartsWith(".L.str", true) - .Default(false); + NonPCRelCount++; + InNormalSection = + StringSwitch(Section.getSectionName()) + .Case(".data.rel.ro.local", false) + .Case(".rodata", false) + .Case(".data.rel", false) + .Case(".bss", false) + .Default(true); + + switch (RelocType) { + default: EmitThisSym = true; break; + case ELF::R_ARM_ABS32: EmitThisSym = false; break; + } } + if (EmitThisSym) return &Symbol; - if (! Symbol.isTemporary()) + if (! Symbol.isTemporary() && InNormalSection) { return &Symbol; + } return NULL; } +// Need to examine the Fixup when determining whether to +// emit the relocation as an explicit symbol or as a section relative +// offset unsigned ARMELFObjectWriter::GetRelocType(const MCValue &Target, const MCFixup &Fixup, bool IsPCRel, @@ -1295,6 +1371,20 @@ MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ? MCSymbolRefExpr::VK_None : Target.getSymA()->getKind(); + unsigned Type = GetRelocTypeInner(Target, Fixup, IsPCRel); + + if (RelocNeedsGOT(Modifier)) + NeedsGOT = true; + + return Type; +} + +unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target, + const MCFixup &Fixup, + bool IsPCRel) const { + MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ? + MCSymbolRefExpr::VK_None : Target.getSymA()->getKind(); + unsigned Type = 0; if (IsPCRel) { switch ((unsigned)Fixup.getKind()) { @@ -1303,7 +1393,7 @@ switch (Modifier) { default: llvm_unreachable("Unsupported Modifier"); case MCSymbolRefExpr::VK_None: - Type = ELF::R_ARM_BASE_PREL; + Type = ELF::R_ARM_REL32; break; case MCSymbolRefExpr::VK_ARM_TLSGD: assert(0 && "unimplemented"); @@ -1399,9 +1489,6 @@ } } - if (RelocNeedsGOT(Modifier)) - NeedsGOT = true; - return Type; } Modified: llvm/trunk/lib/MC/ELFObjectWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.h?rev=131205&r1=131204&r2=131205&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.h (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.h Wed May 11 17:53:06 2011 @@ -140,15 +140,18 @@ unsigned ShstrtabIndex; - const MCSymbol *SymbolToReloc(const MCAssembler &Asm, - const MCValue &Target, - const MCFragment &F) const; + virtual const MCSymbol *SymbolToReloc(const MCAssembler &Asm, + const MCValue &Target, + const MCFragment &F, + const MCFixup &Fixup, + bool IsPCRel) const; // For arch-specific emission of explicit reloc symbol virtual const MCSymbol *ExplicitRelSym(const MCAssembler &Asm, const MCValue &Target, const MCFragment &F, - bool IsBSS) const { + const MCFixup &Fixup, + bool IsPCRel) const { return NULL; } @@ -380,11 +383,16 @@ virtual const MCSymbol *ExplicitRelSym(const MCAssembler &Asm, const MCValue &Target, const MCFragment &F, - bool IsBSS) const; + const MCFixup &Fixup, + bool IsPCRel) const; virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, bool IsPCRel, bool IsRelocWithSymbol, int64_t Addend); + private: + unsigned GetRelocTypeInner(const MCValue &Target, + const MCFixup &Fixup, bool IsPCRel) const; + }; //===- MBlazeELFObjectWriter -------------------------------------------===// From matthewbg at google.com Wed May 11 18:34:51 2011 From: matthewbg at google.com (Matt Beaumont-Gay) Date: Wed, 11 May 2011 23:34:51 -0000 Subject: [llvm-commits] [llvm] r131208 - /llvm/trunk/lib/MC/ELFObjectWriter.cpp Message-ID: <20110511233451.ACBA82A6C12C@llvm.org> Author: matthewbg Date: Wed May 11 18:34:51 2011 New Revision: 131208 URL: http://llvm.org/viewvc/llvm-project?rev=131208&view=rev Log: Remove an unused variable and move a couple others inside DEBUG. Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=131208&r1=131207&r2=131208&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed May 11 18:34:51 2011 @@ -1291,16 +1291,16 @@ const MCSectionELF &Section = static_cast(Symbol.getSection()); - const SectionKind secKind = Section.getKind(); - const MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind(); - MCSymbolRefExpr::VariantKind Kind2; - Kind2 = Target.getSymB() ? Target.getSymB()->getKind() : - MCSymbolRefExpr::VK_None; bool InNormalSection = true; unsigned RelocType = 0; RelocType = GetRelocTypeInner(Target, Fixup, IsPCRel); - DEBUG(dbgs() << "considering symbol " + DEBUG( + const MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind(); + MCSymbolRefExpr::VariantKind Kind2; + Kind2 = Target.getSymB() ? Target.getSymB()->getKind() : + MCSymbolRefExpr::VK_None; + dbgs() << "considering symbol " << Section.getSectionName() << "/" << Symbol.getName() << "/" << " Rel:" << (unsigned)RelocType From atrick at apple.com Wed May 11 19:04:28 2011 From: atrick at apple.com (Andrew Trick) Date: Thu, 12 May 2011 00:04:28 -0000 Subject: [llvm-commits] [llvm] r131210 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <20110512000428.83B2E2A6C12C@llvm.org> Author: atrick Date: Wed May 11 19:04:28 2011 New Revision: 131210 URL: http://llvm.org/viewvc/llvm-project?rev=131210&view=rev Log: indvars: Added SimplifyIVUsers. Interleave IV simplifications. Currently involves EliminateComparison and EliminateRemainder. Next I'll add EliminateExtend. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=131210&r1=131209&r2=131210&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Wed May 11 19:04:28 2011 @@ -109,8 +109,11 @@ private: bool isValidRewrite(Value *FromVal, Value *ToVal); - void EliminateIVComparisons(); - void EliminateIVRemainders(); + void SimplifyIVUsers(); + void EliminateIVComparison(ICmpInst *ICmp, Value *IVOperand); + void EliminateIVRemainder(BinaryOperator *Rem, + Value *IVOperand, + bool isSigned); void RewriteNonIntegerIVs(Loop *L); const Type *WidenIVs(Loop *L, SCEVExpander &Rewriter); @@ -451,96 +454,111 @@ SE->forgetLoop(L); } -void IndVarSimplify::EliminateIVComparisons() { - // Look for ICmp users. +/// SimplifyIVUsers - Iteratively perform simplification on IVUsers within this +/// loop. IVUsers is treated as a worklist. Each successive simplification may +/// push more users which may themselves be candidates for simplification. +void IndVarSimplify::SimplifyIVUsers() { for (IVUsers::iterator I = IU->begin(), E = IU->end(); I != E; ++I) { - IVStrideUse &UI = *I; - ICmpInst *ICmp = dyn_cast(UI.getUser()); - if (!ICmp) continue; - - bool Swapped = UI.getOperandValToReplace() == ICmp->getOperand(1); - ICmpInst::Predicate Pred = ICmp->getPredicate(); - if (Swapped) Pred = ICmpInst::getSwappedPredicate(Pred); - - // Get the SCEVs for the ICmp operands. - const SCEV *S = IU->getReplacementExpr(UI); - const SCEV *X = SE->getSCEV(ICmp->getOperand(!Swapped)); - - // Simplify unnecessary loops away. - const Loop *ICmpLoop = LI->getLoopFor(ICmp->getParent()); - S = SE->getSCEVAtScope(S, ICmpLoop); - X = SE->getSCEVAtScope(X, ICmpLoop); - - // If the condition is always true or always false, replace it with - // a constant value. - if (SE->isKnownPredicate(Pred, S, X)) - ICmp->replaceAllUsesWith(ConstantInt::getTrue(ICmp->getContext())); - else if (SE->isKnownPredicate(ICmpInst::getInversePredicate(Pred), S, X)) - ICmp->replaceAllUsesWith(ConstantInt::getFalse(ICmp->getContext())); - else + Instruction *UseInst = I->getUser(); + Value *IVOperand = I->getOperandValToReplace(); + + if (ICmpInst *ICmp = dyn_cast(UseInst)) { + EliminateIVComparison(ICmp, IVOperand); continue; + } - DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n'); - DeadInsts.push_back(ICmp); + if (BinaryOperator *Rem = dyn_cast(UseInst)) { + bool isSigned = Rem->getOpcode() == Instruction::SRem; + if (isSigned || Rem->getOpcode() == Instruction::URem) { + EliminateIVRemainder(Rem, IVOperand, isSigned); + continue; + } + } } } -void IndVarSimplify::EliminateIVRemainders() { - // Look for SRem and URem users. - for (IVUsers::iterator I = IU->begin(), E = IU->end(); I != E; ++I) { - IVStrideUse &UI = *I; - BinaryOperator *Rem = dyn_cast(UI.getUser()); - if (!Rem) continue; +void IndVarSimplify::EliminateIVComparison(ICmpInst *ICmp, Value *IVOperand) { + unsigned IVOperIdx = 0; + ICmpInst::Predicate Pred = ICmp->getPredicate(); + if (IVOperand != ICmp->getOperand(0)) { + // Swapped + assert(IVOperand == ICmp->getOperand(1) && "Can't find IVOperand"); + IVOperIdx = 1; + Pred = ICmpInst::getSwappedPredicate(Pred); + } + + // Get the SCEVs for the ICmp operands. + const SCEV *S = SE->getSCEV(ICmp->getOperand(IVOperIdx)); + const SCEV *X = SE->getSCEV(ICmp->getOperand(1 - IVOperIdx)); + + // Simplify unnecessary loops away. + const Loop *ICmpLoop = LI->getLoopFor(ICmp->getParent()); + S = SE->getSCEVAtScope(S, ICmpLoop); + X = SE->getSCEVAtScope(X, ICmpLoop); + + // If the condition is always true or always false, replace it with + // a constant value. + if (SE->isKnownPredicate(Pred, S, X)) + ICmp->replaceAllUsesWith(ConstantInt::getTrue(ICmp->getContext())); + else if (SE->isKnownPredicate(ICmpInst::getInversePredicate(Pred), S, X)) + ICmp->replaceAllUsesWith(ConstantInt::getFalse(ICmp->getContext())); + else + return; - bool isSigned = Rem->getOpcode() == Instruction::SRem; - if (!isSigned && Rem->getOpcode() != Instruction::URem) - continue; + DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n'); + DeadInsts.push_back(ICmp); +} - // We're only interested in the case where we know something about - // the numerator. - if (UI.getOperandValToReplace() != Rem->getOperand(0)) - continue; +void IndVarSimplify::EliminateIVRemainder(BinaryOperator *Rem, + Value *IVOperand, + bool isSigned) { + // We're only interested in the case where we know something about + // the numerator. + if (IVOperand != Rem->getOperand(0)) + return; - // Get the SCEVs for the ICmp operands. - const SCEV *S = SE->getSCEV(Rem->getOperand(0)); - const SCEV *X = SE->getSCEV(Rem->getOperand(1)); - - // Simplify unnecessary loops away. - const Loop *ICmpLoop = LI->getLoopFor(Rem->getParent()); - S = SE->getSCEVAtScope(S, ICmpLoop); - X = SE->getSCEVAtScope(X, ICmpLoop); - - // i % n --> i if i is in [0,n). - if ((!isSigned || SE->isKnownNonNegative(S)) && - SE->isKnownPredicate(isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, - S, X)) - Rem->replaceAllUsesWith(Rem->getOperand(0)); - else { - // (i+1) % n --> (i+1)==n?0:(i+1) if i is in [0,n). - const SCEV *LessOne = - SE->getMinusSCEV(S, SE->getConstant(S->getType(), 1)); - if ((!isSigned || SE->isKnownNonNegative(LessOne)) && - SE->isKnownPredicate(isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, - LessOne, X)) { - ICmpInst *ICmp = new ICmpInst(Rem, ICmpInst::ICMP_EQ, - Rem->getOperand(0), Rem->getOperand(1), - "tmp"); - SelectInst *Sel = - SelectInst::Create(ICmp, - ConstantInt::get(Rem->getType(), 0), - Rem->getOperand(0), "tmp", Rem); - Rem->replaceAllUsesWith(Sel); - } else - continue; - } + // Get the SCEVs for the ICmp operands. + const SCEV *S = SE->getSCEV(Rem->getOperand(0)); + const SCEV *X = SE->getSCEV(Rem->getOperand(1)); + + // Simplify unnecessary loops away. + const Loop *ICmpLoop = LI->getLoopFor(Rem->getParent()); + S = SE->getSCEVAtScope(S, ICmpLoop); + X = SE->getSCEVAtScope(X, ICmpLoop); + + // i % n --> i if i is in [0,n). + if ((!isSigned || SE->isKnownNonNegative(S)) && + SE->isKnownPredicate(isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, + S, X)) + Rem->replaceAllUsesWith(Rem->getOperand(0)); + else { + // (i+1) % n --> (i+1)==n?0:(i+1) if i is in [0,n). + const SCEV *LessOne = + SE->getMinusSCEV(S, SE->getConstant(S->getType(), 1)); + if (isSigned && !SE->isKnownNonNegative(LessOne)) + return; - // Inform IVUsers about the new users. - if (Instruction *I = dyn_cast(Rem->getOperand(0))) - IU->AddUsersIfInteresting(I); + if (!SE->isKnownPredicate(isSigned ? + ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, + LessOne, X)) + return; - DEBUG(dbgs() << "INDVARS: Simplified rem: " << *Rem << '\n'); - DeadInsts.push_back(Rem); - } + ICmpInst *ICmp = new ICmpInst(Rem, ICmpInst::ICMP_EQ, + Rem->getOperand(0), Rem->getOperand(1), + "tmp"); + SelectInst *Sel = + SelectInst::Create(ICmp, + ConstantInt::get(Rem->getType(), 0), + Rem->getOperand(0), "tmp", Rem); + Rem->replaceAllUsesWith(Sel); + } + + // Inform IVUsers about the new users. + if (Instruction *I = dyn_cast(Rem->getOperand(0))) + IU->AddUsersIfInteresting(I); + + DEBUG(dbgs() << "INDVARS: Simplified rem: " << *Rem << '\n'); + DeadInsts.push_back(Rem); } bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { @@ -589,11 +607,7 @@ if (!isa(BackedgeTakenCount)) RewriteLoopExitValues(L, Rewriter); - // Simplify ICmp IV users. - EliminateIVComparisons(); - - // Simplify SRem and URem IV users. - EliminateIVRemainders(); + SimplifyIVUsers(); // Compute the type of the largest recurrence expression, and decide whether // a canonical induction variable should be inserted. From evan.cheng at apple.com Wed May 11 19:56:58 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 May 2011 00:56:58 -0000 Subject: [llvm-commits] [llvm] r131214 - in /llvm/trunk: include/llvm/CodeGen/MachineInstr.h lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp lib/CodeGen/MachineInstr.cpp Message-ID: <20110512005658.768672A6C12C@llvm.org> Author: evancheng Date: Wed May 11 19:56:58 2011 New Revision: 131214 URL: http://llvm.org/viewvc/llvm-project?rev=131214&view=rev Log: Re-commit 131172 with fix. MachineInstr identity checks should check dead markers. In some cases a register def is dead on one path, but not on another. This is passing Clang self-hosting. Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/CodeGen/BranchFolding.h llvm/trunk/lib/CodeGen/IfConversion.cpp llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=131214&r1=131213&r2=131214&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Wed May 11 19:56:58 2011 @@ -229,6 +229,7 @@ enum MICheckType { CheckDefs, // Check all operands for equality + CheckKillDead, // Check all operands including kill / dead markers IgnoreDefs, // Ignore all definitions IgnoreVRegDefs // Ignore virtual register definitions }; Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131214&r1=131213&r2=131214&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed May 11 19:56:58 2011 @@ -41,6 +41,7 @@ STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); STATISTIC(NumBranchOpts, "Number of branches optimized"); STATISTIC(NumTailMerge , "Number of block tails merged"); +STATISTIC(NumHoist , "Number of times common instructions are hoisted"); static cl::opt FlagEnableTailMerge("enable-tail-merge", cl::init(cl::BOU_UNSET), cl::Hidden); @@ -65,7 +66,7 @@ public: static char ID; explicit BranchFolderPass(bool defaultEnableTailMerge) - : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge) {} + : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, true) {} virtual bool runOnMachineFunction(MachineFunction &MF); virtual const char *getPassName() const { return "Control Flow Optimizer"; } @@ -86,12 +87,14 @@ } -BranchFolder::BranchFolder(bool defaultEnableTailMerge) { +BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist) { switch (FlagEnableTailMerge) { case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; case cl::BOU_TRUE: EnableTailMerge = true; break; case cl::BOU_FALSE: EnableTailMerge = false; break; } + + EnableHoistCommonCode = CommonHoist; } /// RemoveDeadBlock - Remove the specified dead machine basic block from the @@ -186,9 +189,10 @@ bool MadeChangeThisIteration = true; while (MadeChangeThisIteration) { - MadeChangeThisIteration = false; - MadeChangeThisIteration |= TailMergeBlocks(MF); - MadeChangeThisIteration |= OptimizeBranches(MF); + MadeChangeThisIteration = TailMergeBlocks(MF); + MadeChangeThisIteration |= OptimizeBranches(MF); + if (EnableHoistCommonCode) + MadeChangeThisIteration |= HoistCommonCode(MF); MadeChange |= MadeChangeThisIteration; } @@ -910,7 +914,8 @@ // Make sure blocks are numbered in order MF.RenumberBlocks(); - for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { + for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); + I != E; ) { MachineBasicBlock *MBB = I++; MadeChange |= OptimizeBlock(MBB); @@ -1339,3 +1344,255 @@ return MadeChange; } + +//===----------------------------------------------------------------------===// +// Hoist Common Code +//===----------------------------------------------------------------------===// + +/// HoistCommonCode - Hoist common instruction sequences at the start of basic +/// blocks to their common predecessor. +/// NOTE: This optimization does not update live-in information so it must be +/// run after all passes that require correct liveness information. +bool BranchFolder::HoistCommonCode(MachineFunction &MF) { + bool MadeChange = false; + for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { + MachineBasicBlock *MBB = I++; + MadeChange |= HoistCommonCodeInSuccs(MBB); + } + + return MadeChange; +} + +/// findFalseBlock - BB has a fallthrough. Find its 'false' successor given +/// its 'true' successor. +static MachineBasicBlock *findFalseBlock(MachineBasicBlock *BB, + MachineBasicBlock *TrueBB) { + for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), + E = BB->succ_end(); SI != E; ++SI) { + MachineBasicBlock *SuccBB = *SI; + if (SuccBB != TrueBB) + return SuccBB; + } + return NULL; +} + +/// findHoistingInsertPosAndDeps - Find the location to move common instructions +/// in successors to. The location is ususally just before the terminator, +/// however if the terminator is a conditional branch and its previous +/// instruction is the flag setting instruction, the previous instruction is +/// the preferred location. This function also gathers uses and defs of the +/// instructions from the insertion point to the end of the block. The data is +/// used by HoistCommonCodeInSuccs to ensure safety. +static +MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB, + const TargetInstrInfo *TII, + const TargetRegisterInfo *TRI, + SmallSet &Uses, + SmallSet &Defs) { + MachineBasicBlock::iterator Loc = MBB->getFirstTerminator(); + if (!TII->isUnpredicatedTerminator(Loc)) + return MBB->end(); + + for (unsigned i = 0, e = Loc->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = Loc->getOperand(i); + if (!MO.isReg()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg) + continue; + if (MO.isUse()) { + Uses.insert(Reg); + for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) + Uses.insert(*AS); + } else if (!MO.isDead()) + // Don't try to hoist code in the rare case the terminator defines a + // register that is later used. + return MBB->end(); + } + + if (Uses.empty()) + return Loc; + if (Loc == MBB->begin()) + return MBB->end(); + + // The terminator is probably a conditional branch, try not to separate the + // branch from condition setting instruction. + MachineBasicBlock::iterator PI = Loc; + --PI; + while (PI != MBB->begin() && Loc->isDebugValue()) + --PI; + + bool IsDef = false; + for (unsigned i = 0, e = PI->getNumOperands(); !IsDef && i != e; ++i) { + const MachineOperand &MO = PI->getOperand(i); + if (!MO.isReg() || MO.isUse()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg) + continue; + if (Uses.count(Reg)) + IsDef = true; + } + if (!IsDef) + // The condition setting instruction is not just before the conditional + // branch. + return Loc; + + // Be conservative, don't insert instruction above something that may have + // side-effects. And since it's potentially bad to separate flag setting + // instruction from the conditional branch, just abort the optimization + // completely. + // Also avoid moving code above predicated instruction since it's hard to + // reason about register liveness with predicated instruction. + bool DontMoveAcrossStore = true; + if (!PI->isSafeToMove(TII, 0, DontMoveAcrossStore) || + TII->isPredicated(PI)) + return MBB->end(); + + + // Find out what registers are live. Note this routine is ignoring other live + // registers which are only used by instructions in successor blocks. + for (unsigned i = 0, e = PI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = PI->getOperand(i); + if (!MO.isReg()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg) + continue; + if (MO.isUse()) { + Uses.insert(Reg); + for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) + Uses.insert(*AS); + } else { + if (Uses.count(Reg)) { + Uses.erase(Reg); + for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) + Uses.erase(*SR); // Use getSubRegisters to be conservative + Defs.insert(Reg); + for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) + Defs.insert(*AS); + } + } + } + + return PI; +} + +/// HoistCommonCodeInSuccs - If the successors of MBB has common instruction +/// sequence at the start of the function, move the instructions before MBB +/// terminator if it's legal. +bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { + MachineBasicBlock *TBB = 0, *FBB = 0; + SmallVector Cond; + if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond, true) || !TBB || Cond.empty()) + return false; + + if (!FBB) FBB = findFalseBlock(MBB, TBB); + if (!FBB) + // Malformed bcc? True and false blocks are the same? + return false; + + // Restrict the optimization to cases where MBB is the only predecessor, + // it is an obvious win. + if (TBB->pred_size() > 1 || FBB->pred_size() > 1) + return false; + + // Find a suitable position to hoist the common instructions to. Also figure + // out which registers are used or defined by instructions from the insertion + // point to the end of the block. + SmallSet Uses, Defs; + MachineBasicBlock::iterator Loc = + findHoistingInsertPosAndDeps(MBB, TII, TRI, Uses, Defs); + if (Loc == MBB->end()) + return false; + + bool HasDups = false; + SmallSet LocalDefs; + MachineBasicBlock::iterator TIB = TBB->begin(); + MachineBasicBlock::iterator FIB = FBB->begin(); + MachineBasicBlock::iterator TIE = TBB->end(); + MachineBasicBlock::iterator FIE = FBB->end(); + while (TIB != TIE && FIB != FIE) { + // Skip dbg_value instructions. These do not count. + if (TIB->isDebugValue()) { + while (TIB != TIE && TIB->isDebugValue()) + ++TIB; + if (TIB == TIE) + break; + } + if (FIB->isDebugValue()) { + while (FIB != FIE && FIB->isDebugValue()) + ++FIB; + if (FIB == FIE) + break; + } + if (!TIB->isIdenticalTo(FIB, MachineInstr::CheckKillDead)) + break; + + if (TII->isPredicated(TIB)) + // Hard to reason about register liveness with predicated instruction. + break; + + bool IsSafe = true; + for (unsigned i = 0, e = TIB->getNumOperands(); i != e; ++i) { + MachineOperand &MO = TIB->getOperand(i); + if (!MO.isReg()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg) + continue; + if (MO.isDef()) { + if (Uses.count(Reg)) { + // Avoid clobbering a register that's used by the instruction at + // the point of insertion. + IsSafe = false; + break; + } + + if (Defs.count(Reg) && !MO.isDead()) { + // Don't hoist the instruction if the def would be clobber by the + // instruction at the point insertion. FIXME: This is overly + // conservative. It should be possible to hoist the instructions + // in BB2 in the following example: + // BB1: + // r1, eflag = op1 r2, r3 + // brcc eflag + // + // BB2: + // r1 = op2, ... + // = op3, r1 + IsSafe = false; + break; + } + + LocalDefs.insert(Reg); + for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) + LocalDefs.insert(*SR); + } else if (!LocalDefs.count(Reg)) { + if (Defs.count(Reg)) { + // Use is defined by the instruction at the point of insertion. + IsSafe = false; + break; + } + } + } + if (!IsSafe) + break; + + bool DontMoveAcrossStore = true; + if (!TIB->isSafeToMove(TII, 0, DontMoveAcrossStore)) + break; + + HasDups = true;; + ++TIB; + ++FIB; + } + + if (!HasDups) + return false; + + MBB->splice(Loc, TBB, TBB->begin(), TIB); + FBB->erase(FBB->begin(), FIB); + ++NumHoist; + return true; +} Modified: llvm/trunk/lib/CodeGen/BranchFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=131214&r1=131213&r2=131214&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.h Wed May 11 19:56:58 2011 @@ -19,11 +19,10 @@ class RegScavenger; class TargetInstrInfo; class TargetRegisterInfo; - template class SmallVectorImpl; class BranchFolder { public: - explicit BranchFolder(bool defaultEnableTailMerge); + explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist); bool OptimizeFunction(MachineFunction &MF, const TargetInstrInfo *tii, @@ -85,6 +84,7 @@ std::vector SameTails; bool EnableTailMerge; + bool EnableHoistCommonCode; const TargetInstrInfo *TII; const TargetRegisterInfo *TRI; MachineModuleInfo *MMI; @@ -110,6 +110,9 @@ bool OptimizeBlock(MachineBasicBlock *MBB); void RemoveDeadBlock(MachineBasicBlock *MBB); bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); + + bool HoistCommonCode(MachineFunction &MF); + bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB); }; } Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=131214&r1=131213&r2=131214&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Wed May 11 19:56:58 2011 @@ -265,7 +265,7 @@ if (!TII) return false; // Tail merge tend to expose more if-conversion opportunities. - BranchFolder BF(true); + BranchFolder BF(true, false); bool BFChange = BF.OptimizeFunction(MF, TII, MF.getTarget().getRegisterInfo(), getAnalysisIfAvailable()); @@ -399,7 +399,7 @@ BBAnalysis.clear(); if (MadeChange && IfCvtBranchFold) { - BranchFolder BF(false); + BranchFolder BF(false, false); BF.OptimizeFunction(MF, TII, MF.getTarget().getRegisterInfo(), getAnalysisIfAvailable()); Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=131214&r1=131213&r2=131214&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Wed May 11 19:56:58 2011 @@ -764,19 +764,35 @@ for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { const MachineOperand &MO = getOperand(i); const MachineOperand &OMO = Other->getOperand(i); + if (!MO.isReg()) { + if (!MO.isIdenticalTo(OMO)) + return false; + continue; + } + // Clients may or may not want to ignore defs when testing for equality. // For example, machine CSE pass only cares about finding common // subexpressions, so it's safe to ignore virtual register defs. - if (Check != CheckDefs && MO.isReg() && MO.isDef()) { + if (MO.isDef()) { if (Check == IgnoreDefs) continue; - // Check == IgnoreVRegDefs - if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()) || - TargetRegisterInfo::isPhysicalRegister(OMO.getReg())) - if (MO.getReg() != OMO.getReg()) + else if (Check == IgnoreVRegDefs) { + if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()) || + TargetRegisterInfo::isPhysicalRegister(OMO.getReg())) + if (MO.getReg() != OMO.getReg()) + return false; + } else { + if (!MO.isIdenticalTo(OMO)) return false; - } else if (!MO.isIdenticalTo(OMO)) - return false; + if (Check == CheckKillDead && MO.isDead() != OMO.isDead()) + return false; + } + } else { + if (!MO.isIdenticalTo(OMO)) + return false; + if (Check == CheckKillDead && MO.isKill() != OMO.isKill()) + return false; + } } return true; } From aggarwa4 at illinois.edu Wed May 11 20:06:30 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 12 May 2011 01:06:30 -0000 Subject: [llvm-commits] [poolalloc] r131216 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Message-ID: <20110512010630.F337A2A6C12C@llvm.org> Author: aggarwa4 Date: Wed May 11 20:06:30 2011 New Revision: 131216 URL: http://llvm.org/viewvc/llvm-project?rev=131216&view=rev Log: This seems to cause programs to break. Specifically 164.gzip. Revert till fixed. Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=131216&r1=131215&r2=131216&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Wed May 11 20:06:30 2011 @@ -516,11 +516,11 @@ bool TypeChecks::visitGlobal(Module &M, GlobalVariable &GV, Constant *C, Instruction &I, unsigned offset) { - if(EnableTypeSafeOpt) { + /*if(EnableTypeSafeOpt) { if(TS->isTypeSafe(&GV, I.getParent()->getParent())) { return false; } - } + }*/ if(ConstantArray *CA = dyn_cast(C)) { const Type * ElementType = CA->getType()->getElementType(); unsigned int t = TD->getTypeStoreSize(ElementType); From rafael.espindola at gmail.com Wed May 11 20:24:50 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Wed, 11 May 2011 21:24:50 -0400 Subject: [llvm-commits] .cfi_* and ARM In-Reply-To: <82E550F3-818C-4BF2-B11E-52ADF52823D2@apple.com> References: <4DC84EE9.8080402@gmail.com> <4DC8552E.3030705@gmail.com> <4DC9D0BD.8010004@gmail.com> <82E550F3-818C-4BF2-B11E-52ADF52823D2@apple.com> Message-ID: <4DCB36E2.4030202@gmail.com> I have added a small overview of what I did in: http://blog.mozilla.com/respindola/2011/05/12/cfi-directives/ Cheers, Rafael From rafael.espindola at gmail.com Wed May 11 21:11:05 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Wed, 11 May 2011 22:11:05 -0400 Subject: [llvm-commits] [llvm] r131214 - in /llvm/trunk: include/llvm/CodeGen/MachineInstr.h lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp lib/CodeGen/MachineInstr.cpp In-Reply-To: <20110512005658.768672A6C12C@llvm.org> References: <20110512005658.768672A6C12C@llvm.org> Message-ID: <4DCB41B9.4080507@gmail.com> On 2011-05-11 20:56, Evan Cheng wrote: > Author: evancheng > Date: Wed May 11 19:56:58 2011 > New Revision: 131214 > > URL: http://llvm.org/viewvc/llvm-project?rev=131214&view=rev > Log: > Re-commit 131172 with fix. MachineInstr identity checks should check dead > markers. In some cases a register def is dead on one path, but not on > another. > > This is passing Clang self-hosting. Thanks! Cheers, Rafael From aggarwa4 at illinois.edu Wed May 11 23:07:41 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 12 May 2011 04:07:41 -0000 Subject: [llvm-commits] [poolalloc] r131225 - in /poolalloc/trunk: include/assistDS/TypeChecks.h lib/AssistDS/TypeChecks.cpp Message-ID: <20110512040741.8278F2A6C12C@llvm.org> Author: aggarwa4 Date: Wed May 11 23:07:41 2011 New Revision: 131225 URL: http://llvm.org/viewvc/llvm-project?rev=131225&view=rev Log: 1. Visit all AllocaInst, and initialize all stack objects to Zero. Also initializie the metadata to zero/uninitialized. 2. Predicate the CallInst handling on the TypeSafety results too. Modified: poolalloc/trunk/include/assistDS/TypeChecks.h poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/include/assistDS/TypeChecks.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecks.h?rev=131225&r1=131224&r2=131225&view=diff ============================================================================== --- poolalloc/trunk/include/assistDS/TypeChecks.h (original) +++ poolalloc/trunk/include/assistDS/TypeChecks.h Wed May 11 23:07:41 2011 @@ -68,6 +68,7 @@ bool visitByValFunction(Module &M, Function &F); bool visitLoadInst(Module &M, LoadInst &LI); bool visitStoreInst(Module &M, StoreInst &SI); + bool visitAllocaInst(Module &M, AllocaInst &AI); bool visitGlobal(Module &M, GlobalVariable &GV, Constant *C, Instruction &I, unsigned offset); bool visitCopyingStoreInst(Module &M, StoreInst &SI, Value *SS); Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=131225&r1=131224&r2=131225&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Wed May 11 23:07:41 2011 @@ -158,6 +158,8 @@ modified |= visitCallInst(M, *CI); } else if (InvokeInst *II = dyn_cast(&I)) { modified |= visitInvokeInst(M, *II); + } else if (AllocaInst *AI = dyn_cast(&I)) { + modified |= visitAllocaInst(M, *AI); } } } @@ -181,8 +183,15 @@ bool hasByValArg = false; for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) { if (I->hasByValAttr()) { - hasByValArg = true; - break; + if(EnableTypeSafeOpt) { + if(!TS->isTypeSafe(cast(&I), &F)) { + hasByValArg = true; + break; + } + } else { + hasByValArg = true; + break; + } } } if(!hasByValArg) @@ -417,6 +426,7 @@ } return true; } + // Print the types found in the module. If the optional Module parameter is // passed in, then the types are printed symbolically if possible, using the // symbol table from the module. @@ -521,6 +531,7 @@ return false; } }*/ + if(ConstantArray *CA = dyn_cast(C)) { const Type * ElementType = CA->getType()->getElementType(); unsigned int t = TD->getTypeStoreSize(ElementType); @@ -610,6 +621,59 @@ return true; } + +// Insert code to initialize meta data to bottom +// Insert code to set objects to 0 +bool TypeChecks::visitAllocaInst(Module &M, AllocaInst &AI) { + + // Setting metadata to be 0(BOTTOM/Uninitialized) + const PointerType * PT = AI.getType(); + const Type * ET = PT->getElementType(); + Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET)); + CastInst *BCI = BitCastInst::CreatePointerCast(&AI, VoidPtrTy); + BCI->insertAfter(&AI); + std::vector Args; + Args.push_back(BCI); + Args.push_back(AllocSize); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + Constant *F = M.getOrInsertFunction("trackUnInitInst", VoidTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); + CallInst *CI = CallInst::Create(F, Args.begin(), Args.end()); + CI->insertAfter(BCI); + std::vector Args1; + Args1.push_back(BCI); + Args1.push_back(AllocSize); + Args1.push_back(AI.getArraySize()); + Args1.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + F = M.getOrInsertFunction("trackGlobalArray", VoidTy, VoidPtrTy, Int64Ty, AI.getArraySize()->getType(), Int32Ty, NULL); + CallInst *CI_Arr = CallInst::Create(F, Args1.begin(), Args1.end()); + CI_Arr->insertAfter(CI); + + // Set the object to be zero + // + // Add the memset function to the program. + Constant *memsetF = M.getOrInsertFunction ("llvm.memset.i64", VoidTy, + VoidPtrTy, + Int8Ty, + Int64Ty, + Int32Ty, + NULL); + + + CastInst *ArraySize = CastInst::CreateSExtOrBitCast(AI.getArraySize(), Int64Ty); + ArraySize->insertAfter(BCI); + BinaryOperator *Size = BinaryOperator::Create(Instruction::Mul, AllocSize, ArraySize); + Size->insertAfter(ArraySize); + std::vector Args2; + Args2.push_back(BCI); + Args2.push_back(ConstantInt::get(Int8Ty, 0)); + Args2.push_back(Size); + Args2.push_back(ConstantInt::get(Int32Ty, AI.getAlignment())); + CallInst *CI_Init = CallInst::Create(memsetF, Args2.begin(), Args2.end()); + CI_Init->insertAfter(CI_Arr); + + return true; +} + // Insert runtime checks for certain call instructions bool TypeChecks::visitCallInst(Module &M, CallInst &CI) { return visitCallSite(M, &CI); @@ -643,10 +707,15 @@ Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); Constant *F = M.getOrInsertFunction("copyTypeInfo", VoidTy, VoidPtrTy, VoidPtrTy, I->getOperand(3)->getType(), Int32Ty, NULL); CallInst::Create(F, Args.begin(), Args.end(), "", I); - break; + return true; } case Intrinsic::memset: + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(I->getOperand(1), I->getParent()->getParent())) { + return false; + } + } CastInst *BCI = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy, "", I); std::vector Args; Args.push_back(BCI); @@ -654,9 +723,14 @@ Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); CallInst::Create(F, Args.begin(), Args.end(), "", I); - break; + return true; } } else if(F->getNameStr() == std::string("ftime")) { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(I->getOperand(1), I->getParent()->getParent())) { + return false; + } + } CastInst *BCI = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy, "", I); const PointerType *PTy = cast(I->getOperand(1)->getType()); const Type * ElementType = PTy->getElementType(); @@ -667,7 +741,13 @@ Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); CallInst::Create(F, Args.begin(), Args.end(), "", I); + return true; } else if(F->getNameStr() == std::string("read")) { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(I->getOperand(2), I->getParent()->getParent())) { + return false; + } + } CastInst *BCI = BitCastInst::CreatePointerCast(I->getOperand(2), VoidPtrTy); BCI->insertAfter(I); std::vector Args; @@ -677,7 +757,13 @@ Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy, I->getType(), Int32Ty, NULL); CallInst *CI = CallInst::Create(F, Args.begin(), Args.end()); CI->insertAfter(BCI); + return true; } else if(F->getNameStr() == std::string("fread")) { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(I->getOperand(1), I->getParent()->getParent())) { + return false; + } + } CastInst *BCI = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy); BCI->insertAfter(I); std::vector Args; @@ -687,7 +773,13 @@ Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy, I->getType(), Int32Ty, NULL); CallInst *CI = CallInst::Create(F, Args.begin(), Args.end()); CI->insertAfter(BCI); + return true; } else if(F->getNameStr() == std::string("calloc")) { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(I, I->getParent()->getParent())) { + return false; + } + } CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy); BCI->insertAfter(I); std::vector Args; @@ -705,7 +797,13 @@ F = M.getOrInsertFunction("trackGlobalArray", VoidTy, VoidPtrTy, I->getOperand(2)->getType(), I->getOperand(1)->getType(), Int32Ty, NULL); CallInst *CI_Arr = CallInst::Create(F, Args1.begin(), Args1.end()); CI_Arr->insertAfter(CI); + return true; } else if(F->getNameStr() == std::string("realloc")) { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(I, I->getParent()->getParent())) { + return false; + } + } CastInst *BCI_Src = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy); CastInst *BCI_Dest = BitCastInst::CreatePointerCast(I, VoidPtrTy); BCI_Src->insertAfter(I); @@ -718,6 +816,7 @@ Constant *F = M.getOrInsertFunction("copyTypeInfo", VoidTy, VoidPtrTy, VoidPtrTy, I->getOperand(2)->getType(), Int32Ty, NULL); CallInst *CI = CallInst::Create(F, Args.begin(), Args.end()); CI->insertAfter(BCI_Dest); + return true; } else if(F->getNameStr() == std::string("fgets")) { CastInst *BCI = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy, "", I); std::vector Args; @@ -726,6 +825,7 @@ Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy, I->getOperand(2)->getType(), Int32Ty, NULL); CallInst::Create(F, Args.begin(), Args.end(), "", I); + return true; } else if(F->getNameStr() == std::string("sscanf")) { // FIXME: Need to look at the format string and check unsigned i = 3; @@ -741,10 +841,9 @@ } } } - - - return true; + return false; } + bool TypeChecks::visitInputFunctionValue(Module &M, Value *V, Instruction *CI) { // Cast the pointer operand to i8* for the runtime function. CastInst *BCI = BitCastInst::CreatePointerCast(V, VoidPtrTy, "", CI); From aggarwa4 at illinois.edu Wed May 11 23:35:44 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 12 May 2011 04:35:44 -0000 Subject: [llvm-commits] [poolalloc] r131226 - in /poolalloc/trunk/test: TEST.types.Makefile TEST.types.report Message-ID: <20110512043544.62D5E2A6C12C@llvm.org> Author: aggarwa4 Date: Wed May 11 23:35:44 2011 New Revision: 131226 URL: http://llvm.org/viewvc/llvm-project?rev=131226&view=rev Log: Adding tcoo version, uses TypeChecks, that uses TypeSafety pass(with DSA optimizations). Also, link in the runtime earlier, allow for optimizations. Modified: poolalloc/trunk/test/TEST.types.Makefile poolalloc/trunk/test/TEST.types.report Modified: poolalloc/trunk/test/TEST.types.Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/TEST.types.Makefile?rev=131226&r1=131225&r2=131226&view=diff ============================================================================== --- poolalloc/trunk/test/TEST.types.Makefile (original) +++ poolalloc/trunk/test/TEST.types.Makefile Wed May 11 23:35:44 2011 @@ -27,6 +27,7 @@ PASS := td TYPE_RT_O := $(PADIR)/$(CONFIGURATION)/lib/libtypechecks_rt.a +TYPE_RT_BC := $(PADIR)/$(CONFIGURATION)/lib/libtypechecks_rt.bca DYNCOUNT_RT_O := $(PADIR)/$(CONFIGURATION)/lib/libcount.a ANALYZE_OPTS := -stats -time-passes -disable-output -dsstats #ANALYZE_OPTS := -stats -time-passes -dsstats @@ -63,11 +64,22 @@ $(PROGRAMS_TO_TEST:%=Output/%.tc.bc): \ Output/%.tc.bc: Output/%.opt.bc $(LOPT) $(ASSIST_SO) - -$(RUNOPT) -load $(ASSIST_SO) -typechecks -dce -ipsccp -stats -info-output-file=$(CURDIR)/$@.info $< -f -o $@ + -$(RUNOPT) -load $(ASSIST_SO) -typechecks -dce -ipsccp -dce -stats -info-output-file=$(CURDIR)/$@.info $< -f -o $@.temp + -$(LLVMLD) -disable-opt -o $@.ld $@.temp $(TYPE_RT_BC) + -$(LOPT) $(SAFE_OPTS) $@.ld.bc -o $@ -f + $(PROGRAMS_TO_TEST:%=Output/%.tco.bc): \ Output/%.tco.bc: Output/%.opt.bc $(LOPT) $(ASSIST_SO) - -$(RUNOPT) -load $(ASSIST_SO) -typechecks -enable-type-safe-opt -dce -ipsccp -stats -info-output-file=$(CURDIR)/$@.info $< -f -o $@ + -$(RUNOPT) -load $(ASSIST_SO) -typechecks -enable-type-safe-opt -dce -ipsccp -dce -stats -info-output-file=$(CURDIR)/$@.info $< -f -o $@.temp + -$(LLVMLD) -disable-opt -o $@.ld $@.temp $(TYPE_RT_BC) + -$(LOPT) $(SAFE_OPTS) $@.ld.bc -o $@ -f + +$(PROGRAMS_TO_TEST:%=Output/%.tcoo.bc): \ +Output/%.tcoo.bc: Output/%.opt.bc $(LOPT) $(ASSIST_SO) + -$(RUNOPT) -load $(ASSIST_SO) -typechecks -enable-type-safe-opt -enable-type-inference-opts -dsa-stdlib-no-fold -dce -ipsccp -dce -stats -info-output-file=$(CURDIR)/$@.info $< -f -o $@.temp + -$(LLVMLD) -disable-opt -o $@.ld $@.temp $(TYPE_RT_BC) + -$(LOPT) $(SAFE_OPTS) $@.ld.bc -o $@ -f $(PROGRAMS_TO_TEST:%=Output/%.count.s): \ Output/%.count.s: Output/%.count.bc $(LLC) @@ -87,6 +99,9 @@ $(PROGRAMS_TO_TEST:%=Output/%.tco.s): \ Output/%.tco.s: Output/%.tco.bc $(LLC) -$(LLC) -f $< -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.tcoo.s): \ +Output/%.tcoo.s: Output/%.tcoo.bc $(LLC) + -$(LLC) -f $< -o $@ $(PROGRAMS_TO_TEST:%=Output/%.opt): \ Output/%.opt: Output/%.opt.s @@ -97,6 +112,9 @@ $(PROGRAMS_TO_TEST:%=Output/%.tco): \ Output/%.tco: Output/%.tco.s $(TYPE_RT_O) -$(CC) $(CFLAGS) $< $(LLCLIBS) $(TYPE_RT_O) $(LDFLAGS) -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.tcoo): \ +Output/%.tcoo: Output/%.tcoo.s $(TYPE_RT_O) + -$(CC) $(CFLAGS) $< $(LLCLIBS) $(TYPE_RT_O) $(LDFLAGS) -o $@ $(PROGRAMS_TO_TEST:%=Output/%.llvm1): \ Output/%.llvm1: Output/%.llvm1.s -$(CC) $(CFLAGS) $< $(LLCLIBS) $(LDFLAGS) -o $@ @@ -129,6 +147,9 @@ $(PROGRAMS_TO_TEST:%=Output/%.tco.out): \ Output/%.tco.out: Output/%.tco -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) +$(PROGRAMS_TO_TEST:%=Output/%.tcoo.out): \ +Output/%.tcoo.out: Output/%.tcoo + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) else $(PROGRAMS_TO_TEST:%=Output/%.opt.out): \ @@ -159,6 +180,13 @@ ../../$< $(RUN_OPTIONS) -(cd Output/tco-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ -cp Output/tco-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time +$(PROGRAMS_TO_TEST:%=Output/%.tcoo.out): \ +Output/%.tcoo.out: Output/%.tcoo + -$(SPEC_SANDBOX) tcoo-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/tcoo-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/tcoo-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time $(PROGRAMS_TO_TEST:%=Output/%.count.out): \ Output/%.count.out: Output/%.count -$(SPEC_SANDBOX) count-$(RUN_TYPE) $@ $(REF_IN_DIR) \ @@ -192,6 +220,11 @@ @cp Output/$*.out-nat Output/$*.tco.out-nat -$(DIFFPROG) nat $*.tco $(HIDEDIFF) +$(PROGRAMS_TO_TEST:%=Output/%.tcoo.diff-nat): \ +Output/%.tcoo.diff-nat: Output/%.out-nat Output/%.tcoo.out + @cp Output/$*.out-nat Output/$*.tcoo.out-nat + -$(DIFFPROG) nat $*.tcoo $(HIDEDIFF) + $(PROGRAMS_TO_TEST:%=Output/%.llvm1.diff-nat): \ Output/%.llvm1.diff-nat: Output/%.out-nat Output/%.llvm1.out @cp Output/$*.out-nat Output/$*.llvm1.out-nat @@ -208,7 +241,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.$(TEST).report.txt): \ -Output/%.$(TEST).report.txt: Output/%.opt.bc Output/%.LOC.txt $(LOPT) Output/%.out-nat Output/%.opt.diff-nat Output/%.tc.diff-nat Output/%.count.diff-nat Output/%.count1.diff-nat Output/%.tco.diff-nat +Output/%.$(TEST).report.txt: Output/%.opt.bc Output/%.LOC.txt $(LOPT) Output/%.out-nat Output/%.opt.diff-nat Output/%.tc.diff-nat Output/%.tco.diff-nat Output/%.tcoo.diff-nat @# Gather data -($(RUNOPT) -dsa-$(PASS) -enable-type-inference-opts -dsa-stdlib-no-fold $(ANALYZE_OPTS) $<)> $@.time.1 2>&1 -($(RUNOPT) -dsa-$(PASS) $(ANALYZE_OPTS) $<)> $@.time.2 2>&1 @@ -314,6 +347,10 @@ printf "TCO-RUN_TIME: " >> $@;\ grep 'program' Output/$*.tco.out.time >> $@;\ fi + @-if test -f Output/$*.tcoo.diff-nat; then \ + printf "TCOO-RUN_TIME: " >> $@;\ + grep 'program' Output/$*.tcoo.out.time >> $@;\ + fi @# Emit AssistDS stats @/bin/echo -n "CLONED_FUNCSPEC: " >> $@ - at grep 'Number of Functions Cloned in FuncSpec' $<.info >> $@ Modified: poolalloc/trunk/test/TEST.types.report URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/TEST.types.report?rev=131226&r1=131225&r2=131226&view=diff ============================================================================== --- poolalloc/trunk/test/TEST.types.report (original) +++ poolalloc/trunk/test/TEST.types.report Wed May 11 23:35:44 2011 @@ -190,4 +190,5 @@ ["OptTime", "OPT-RUN_TIME: program *([.0-9]+)"], ["TcTime", "TC-RUN_TIME: program *([.0-9]+)"], ["TcoTime", "TCO-RUN_TIME: program *([.0-9]+)"], + ["TcooTime", "TCOO-RUN_TIME: program *([.0-9]+)"], ); From aggarwa4 at illinois.edu Wed May 11 23:36:24 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 12 May 2011 04:36:24 -0000 Subject: [llvm-commits] [poolalloc] r131227 - /poolalloc/trunk/runtime/DynamicTypeChecks/Makefile Message-ID: <20110512043624.4DE532A6C12C@llvm.org> Author: aggarwa4 Date: Wed May 11 23:36:24 2011 New Revision: 131227 URL: http://llvm.org/viewvc/llvm-project?rev=131227&view=rev Log: Also build bytecode library. Modified: poolalloc/trunk/runtime/DynamicTypeChecks/Makefile Modified: poolalloc/trunk/runtime/DynamicTypeChecks/Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/Makefile?rev=131227&r1=131226&r2=131227&view=diff ============================================================================== --- poolalloc/trunk/runtime/DynamicTypeChecks/Makefile (original) +++ poolalloc/trunk/runtime/DynamicTypeChecks/Makefile Wed May 11 23:36:24 2011 @@ -1,5 +1,6 @@ LEVEL = ../.. LIBRARYNAME = typechecks_rt +BYTECODE_LIBRARY=1 ifneq ($(OS),Cygwin) ifneq ($(OS),MingW) From bob.wilson at apple.com Wed May 11 23:56:48 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 11 May 2011 21:56:48 -0700 Subject: [llvm-commits] [llvm] r131176 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp lib/CodeGen/BranchFolding.h lib/CodeGen/IfConversion.cpp test/CodeGen/X86/hoist-common.ll In-Reply-To: References: <20110511032717.8F2842A6C12C@llvm.org> <699A16F0-38E0-4B4D-B5B1-C4E2049AD8D0@apple.com> Message-ID: <0CCCB057-9E86-4817-9192-07581F70E98E@apple.com> I suspect that's also related to PR9858. Targetdata strings starting with "-", i.e., with no endianness specified, suddenly started causing assertion failures, and that buildbot is running on osu7. Nick, can you take a look at that PR? On May 11, 2011, at 2:27 PM, Nick Lewycky wrote: > I recently upgraded that machine to gcc 4.6. We may need to fix the testsuite to build with newer GCCs. > > Nick > > On 11 May 2011 13:39, Jim Grosbach wrote: > There's something odd going on with that buildbot. There are compile-time errors from the system host compiler on tramp3d, for example, as well as errors from the clang under test. > > On May 11, 2011, at 11:37 AM, Evan Cheng wrote: > > > Rafael, can you provide more information? Which buildbot? What's the symptom? I noticed http://google1.osuosl.org:8011/builders/clang-x86_64-linux-fnt is still red. > > > > Evan > > > > On May 10, 2011, at 8:27 PM, Rafael Espindola wrote: > > > >> Author: rafael > >> Date: Tue May 10 22:27:17 2011 > >> New Revision: 131176 > >> > >> URL: http://llvm.org/viewvc/llvm-project?rev=131176&view=rev > >> Log: > >> Revert 131172 as it is causing clang to miscompile itself. I will try > >> to provide a reduced testcase. > >> > >> Removed: > >> llvm/trunk/test/CodeGen/X86/hoist-common.ll > >> Modified: > >> llvm/trunk/lib/CodeGen/BranchFolding.cpp > >> llvm/trunk/lib/CodeGen/BranchFolding.h > >> llvm/trunk/lib/CodeGen/IfConversion.cpp > >> > >> Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp > >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131176&r1=131175&r2=131176&view=diff > >> ============================================================================== > >> --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) > >> +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Tue May 10 22:27:17 2011 > >> @@ -41,7 +41,6 @@ > >> STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); > >> STATISTIC(NumBranchOpts, "Number of branches optimized"); > >> STATISTIC(NumTailMerge , "Number of block tails merged"); > >> -STATISTIC(NumHoist , "Number of times common instructions are hoisted"); > >> > >> static cl::opt FlagEnableTailMerge("enable-tail-merge", > >> cl::init(cl::BOU_UNSET), cl::Hidden); > >> @@ -66,7 +65,7 @@ > >> public: > >> static char ID; > >> explicit BranchFolderPass(bool defaultEnableTailMerge) > >> - : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge, true) {} > >> + : MachineFunctionPass(ID), BranchFolder(defaultEnableTailMerge) {} > >> > >> virtual bool runOnMachineFunction(MachineFunction &MF); > >> virtual const char *getPassName() const { return "Control Flow Optimizer"; } > >> @@ -87,14 +86,12 @@ > >> } > >> > >> > >> -BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist) { > >> +BranchFolder::BranchFolder(bool defaultEnableTailMerge) { > >> switch (FlagEnableTailMerge) { > >> case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; > >> case cl::BOU_TRUE: EnableTailMerge = true; break; > >> case cl::BOU_FALSE: EnableTailMerge = false; break; > >> } > >> - > >> - EnableHoistCommonCode = CommonHoist; > >> } > >> > >> /// RemoveDeadBlock - Remove the specified dead machine basic block from the > >> @@ -189,10 +186,9 @@ > >> > >> bool MadeChangeThisIteration = true; > >> while (MadeChangeThisIteration) { > >> - MadeChangeThisIteration = TailMergeBlocks(MF); > >> - MadeChangeThisIteration |= OptimizeBranches(MF); > >> - if (EnableHoistCommonCode) > >> - MadeChangeThisIteration |= HoistCommonCode(MF); > >> + MadeChangeThisIteration = false; > >> + MadeChangeThisIteration |= TailMergeBlocks(MF); > >> + MadeChangeThisIteration |= OptimizeBranches(MF); > >> MadeChange |= MadeChangeThisIteration; > >> } > >> > >> @@ -914,8 +910,7 @@ > >> // Make sure blocks are numbered in order > >> MF.RenumberBlocks(); > >> > >> - for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); > >> - I != E; ) { > >> + for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { > >> MachineBasicBlock *MBB = I++; > >> MadeChange |= OptimizeBlock(MBB); > >> > >> @@ -1344,253 +1339,3 @@ > >> > >> return MadeChange; > >> } > >> - > >> -//===----------------------------------------------------------------------===// > >> -// Hoist Common Code > >> -//===----------------------------------------------------------------------===// > >> - > >> -/// HoistCommonCode - Hoist common instruction sequences at the start of basic > >> -/// blocks to their common predecessor. > >> -/// NOTE: This optimization does not update live-in information so it must be > >> -/// run after all passes that require correct liveness information. > >> -bool BranchFolder::HoistCommonCode(MachineFunction &MF) { > >> - bool MadeChange = false; > >> - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { > >> - MachineBasicBlock *MBB = I++; > >> - MadeChange |= HoistCommonCodeInSuccs(MBB); > >> - } > >> - > >> - return MadeChange; > >> -} > >> - > >> -/// findFalseBlock - BB has a fallthrough. Find its 'false' successor given > >> -/// its 'true' successor. > >> -static MachineBasicBlock *findFalseBlock(MachineBasicBlock *BB, > >> - MachineBasicBlock *TrueBB) { > >> - for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), > >> - E = BB->succ_end(); SI != E; ++SI) { > >> - MachineBasicBlock *SuccBB = *SI; > >> - if (SuccBB != TrueBB) > >> - return SuccBB; > >> - } > >> - return NULL; > >> -} > >> - > >> -/// findHoistingInsertPosAndDeps - Find the location to move common instructions > >> -/// in successors to. The location is ususally just before the terminator, > >> -/// however if the terminator is a conditional branch and its previous > >> -/// instruction is the flag setting instruction, the previous instruction is > >> -/// the preferred location. This function also gathers uses and defs of the > >> -/// instructions from the insertion point to the end of the block. The data is > >> -/// used by HoistCommonCodeInSuccs to ensure safety. > >> -static > >> -MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB, > >> - const TargetInstrInfo *TII, > >> - const TargetRegisterInfo *TRI, > >> - SmallSet &Uses, > >> - SmallSet &Defs) { > >> - MachineBasicBlock::iterator Loc = MBB->getFirstTerminator(); > >> - if (!TII->isUnpredicatedTerminator(Loc)) > >> - return MBB->end(); > >> - > >> - for (unsigned i = 0, e = Loc->getNumOperands(); i != e; ++i) { > >> - const MachineOperand &MO = Loc->getOperand(i); > >> - if (!MO.isReg()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (MO.isUse()) { > >> - Uses.insert(Reg); > >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > >> - Uses.insert(*AS); > >> - } else if (!MO.isDead()) > >> - // Don't try to hoist code in the rare case the terminator defines a > >> - // register that is later used. > >> - return MBB->end(); > >> - } > >> - > >> - if (Uses.empty()) > >> - return Loc; > >> - if (Loc == MBB->begin()) > >> - return MBB->end(); > >> - > >> - // The terminator is probably a conditional branch, try not to separate the > >> - // branch from condition setting instruction. > >> - MachineBasicBlock::iterator PI = Loc; > >> - --PI; > >> - while (PI != MBB->begin() && Loc->isDebugValue()) > >> - --PI; > >> - > >> - bool IsDef = false; > >> - for (unsigned i = 0, e = PI->getNumOperands(); !IsDef && i != e; ++i) { > >> - const MachineOperand &MO = PI->getOperand(i); > >> - if (!MO.isReg() || MO.isUse()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (Uses.count(Reg)) > >> - IsDef = true; > >> - } > >> - if (!IsDef) > >> - // The condition setting instruction is not just before the conditional > >> - // branch. > >> - return Loc; > >> - > >> - // Be conservative, don't insert instruction above something that may have > >> - // side-effects. And since it's potentially bad to separate flag setting > >> - // instruction from the conditional branch, just abort the optimization > >> - // completely. > >> - // Also avoid moving code above predicated instruction since it's hard to > >> - // reason about register liveness with predicated instruction. > >> - bool DontMoveAcrossStore = true; > >> - if (!PI->isSafeToMove(TII, 0, DontMoveAcrossStore) || > >> - TII->isPredicated(PI)) > >> - return MBB->end(); > >> - > >> - > >> - // Find out what registers are live. Note this routine is ignoring other live > >> - // registers which are only used by instructions in successor blocks. > >> - for (unsigned i = 0, e = PI->getNumOperands(); i != e; ++i) { > >> - const MachineOperand &MO = PI->getOperand(i); > >> - if (!MO.isReg()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (MO.isUse()) { > >> - Uses.insert(Reg); > >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > >> - Uses.insert(*AS); > >> - } else { > >> - if (Uses.count(Reg)) { > >> - Uses.erase(Reg); > >> - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) > >> - Uses.erase(*SR); // Use getSubRegisters to be conservative > >> - Defs.insert(Reg); > >> - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) > >> - Defs.insert(*AS); > >> - } > >> - } > >> - } > >> - > >> - return PI; > >> -} > >> - > >> -/// HoistCommonCodeInSuccs - If the successors of MBB has common instruction > >> -/// sequence at the start of the function, move the instructions before MBB > >> -/// terminator if it's legal. > >> -bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) { > >> - MachineBasicBlock *TBB = 0, *FBB = 0; > >> - SmallVector Cond; > >> - if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond, true) || !TBB || Cond.empty()) > >> - return false; > >> - > >> - if (!FBB) FBB = findFalseBlock(MBB, TBB); > >> - if (!FBB) > >> - // Malformed bcc? True and false blocks are the same? > >> - return false; > >> - > >> - // Restrict the optimization to cases where MBB is the only predecessor, > >> - // it is an obvious win. > >> - if (TBB->pred_size() > 1 || FBB->pred_size() > 1) > >> - return false; > >> - > >> - // Find a suitable position to hoist the common instructions to. Also figure > >> - // out which registers are used or defined by instructions from the insertion > >> - // point to the end of the block. > >> - SmallSet Uses, Defs; > >> - MachineBasicBlock::iterator Loc = > >> - findHoistingInsertPosAndDeps(MBB, TII, TRI, Uses, Defs); > >> - if (Loc == MBB->end()) > >> - return false; > >> - > >> - SmallSet LocalDefs; > >> - unsigned NumDups = 0; > >> - MachineBasicBlock::iterator TIB = TBB->begin(); > >> - MachineBasicBlock::iterator FIB = FBB->begin(); > >> - MachineBasicBlock::iterator TIE = TBB->end(); > >> - MachineBasicBlock::iterator FIE = FBB->end(); > >> - while (TIB != TIE && FIB != FIE) { > >> - // Skip dbg_value instructions. These do not count. > >> - if (TIB->isDebugValue()) { > >> - while (TIB != TIE && TIB->isDebugValue()) > >> - ++TIB; > >> - if (TIB == TIE) > >> - break; > >> - } > >> - if (FIB->isDebugValue()) { > >> - while (FIB != FIE && FIB->isDebugValue()) > >> - ++FIB; > >> - if (FIB == FIE) > >> - break; > >> - } > >> - if (!TIB->isIdenticalTo(FIB)) > >> - break; > >> - > >> - if (TII->isPredicated(TIB)) > >> - // Hard to reason about register liveness with predicated instruction. > >> - break; > >> - > >> - bool IsSafe = true; > >> - for (unsigned i = 0, e = TIB->getNumOperands(); i != e; ++i) { > >> - const MachineOperand &MO = TIB->getOperand(i); > >> - if (!MO.isReg()) > >> - continue; > >> - unsigned Reg = MO.getReg(); > >> - if (!Reg) > >> - continue; > >> - if (MO.isDef()) { > >> - if (Uses.count(Reg)) { > >> - // Avoid clobbering a register that's used by the instruction at > >> - // the point of insertion. > >> - IsSafe = false; > >> - break; > >> - } > >> - if (!MO.isDead() && Defs.count(Reg)) { > >> - // Don't hoist the instruction if the def would be clobber by the > >> - // instruction at the point insertion. FIXME: This is overly > >> - // conservative. It should be possible to hoist the instructions > >> - // in BB2 in the following example: > >> - // BB1: > >> - // r1, eflag = op1 r2, r3 > >> - // brcc eflag > >> - // > >> - // BB2: > >> - // r1 = op2, ... > >> - // = op3, r1 > >> - IsSafe = false; > >> - break; > >> - } > >> - LocalDefs.insert(Reg); > >> - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) > >> - LocalDefs.insert(*SR); > >> - } else if (!LocalDefs.count(Reg)) { > >> - if (Defs.count(Reg)) { > >> - // Use is defined by the instruction at the point of insertion. > >> - IsSafe = false; > >> - break; > >> - } > >> - } > >> - } > >> - if (!IsSafe) > >> - break; > >> - > >> - bool DontMoveAcrossStore = true; > >> - if (!TIB->isSafeToMove(TII, 0, DontMoveAcrossStore)) > >> - break; > >> - > >> - ++NumDups; > >> - ++TIB; > >> - ++FIB; > >> - } > >> - > >> - if (!NumDups) > >> - return false; > >> - > >> - MBB->splice(Loc, TBB, TBB->begin(), TIB); > >> - FBB->erase(FBB->begin(), FIB); > >> - ++NumHoist; > >> - return true; > >> -} > >> > >> Modified: llvm/trunk/lib/CodeGen/BranchFolding.h > >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.h?rev=131176&r1=131175&r2=131176&view=diff > >> ============================================================================== > >> --- llvm/trunk/lib/CodeGen/BranchFolding.h (original) > >> +++ llvm/trunk/lib/CodeGen/BranchFolding.h Tue May 10 22:27:17 2011 > >> @@ -19,10 +19,11 @@ > >> class RegScavenger; > >> class TargetInstrInfo; > >> class TargetRegisterInfo; > >> + template class SmallVectorImpl; > >> > >> class BranchFolder { > >> public: > >> - explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist); > >> + explicit BranchFolder(bool defaultEnableTailMerge); > >> > >> bool OptimizeFunction(MachineFunction &MF, > >> const TargetInstrInfo *tii, > >> @@ -84,7 +85,6 @@ > >> std::vector SameTails; > >> > >> bool EnableTailMerge; > >> - bool EnableHoistCommonCode; > >> const TargetInstrInfo *TII; > >> const TargetRegisterInfo *TRI; > >> MachineModuleInfo *MMI; > >> @@ -110,9 +110,6 @@ > >> bool OptimizeBlock(MachineBasicBlock *MBB); > >> void RemoveDeadBlock(MachineBasicBlock *MBB); > >> bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); > >> - > >> - bool HoistCommonCode(MachineFunction &MF); > >> - bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB); > >> }; > >> } > >> > >> > >> Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp > >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=131176&r1=131175&r2=131176&view=diff > >> ============================================================================== > >> --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) > >> +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Tue May 10 22:27:17 2011 > >> @@ -265,7 +265,7 @@ > >> if (!TII) return false; > >> > >> // Tail merge tend to expose more if-conversion opportunities. > >> - BranchFolder BF(true, false); > >> + BranchFolder BF(true); > >> bool BFChange = BF.OptimizeFunction(MF, TII, > >> MF.getTarget().getRegisterInfo(), > >> getAnalysisIfAvailable()); > >> @@ -399,7 +399,7 @@ > >> BBAnalysis.clear(); > >> > >> if (MadeChange && IfCvtBranchFold) { > >> - BranchFolder BF(false, false); > >> + BranchFolder BF(false); > >> BF.OptimizeFunction(MF, TII, > >> MF.getTarget().getRegisterInfo(), > >> getAnalysisIfAvailable()); > >> > >> Removed: llvm/trunk/test/CodeGen/X86/hoist-common.ll > >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hoist-common.ll?rev=131175&view=auto > >> ============================================================================== > >> --- llvm/trunk/test/CodeGen/X86/hoist-common.ll (original) > >> +++ llvm/trunk/test/CodeGen/X86/hoist-common.ll (removed) > >> @@ -1,28 +0,0 @@ > >> -; RUN: llc < %s -march=x86-64 | FileCheck %s > >> - > >> -; Common "xorb al, al" instruction in the two successor blocks should be > >> -; moved to the entry block above the test + je. > >> - > >> -; rdar://9145558 > >> - > >> -define zeroext i1 @t(i32 %c) nounwind ssp { > >> -entry: > >> -; CHECK: t: > >> -; CHECK: xorb %al, %al > >> -; CHECK: test > >> -; CHECK: je > >> - %tobool = icmp eq i32 %c, 0 > >> - br i1 %tobool, label %return, label %if.then > >> - > >> -if.then: > >> -; CHECK: callq > >> - %call = tail call zeroext i1 (...)* @foo() nounwind > >> - br label %return > >> - > >> -return: > >> -; CHECK: ret > >> - %retval.0 = phi i1 [ %call, %if.then ], [ false, %entry ] > >> - ret i1 %retval.0 > >> -} > >> - > >> -declare zeroext i1 @foo(...) > >> > >> > >> _______________________________________________ > >> llvm-commits mailing list > >> llvm-commits at cs.uiuc.edu > >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110511/2cabba2e/attachment-0001.html From clattner at apple.com Thu May 12 00:13:04 2011 From: clattner at apple.com (Chris Lattner) Date: Wed, 11 May 2011 22:13:04 -0700 Subject: [llvm-commits] [llvm] r131200 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp In-Reply-To: <20110511214458.651262A6C12C@llvm.org> References: <20110511214458.651262A6C12C@llvm.org> Message-ID: <47BD9F01-4096-4758-8F5D-0D5338E6CA8A@apple.com> On May 11, 2011, at 2:44 PM, Eric Christopher wrote: > Author: echristo > Date: Wed May 11 16:44:58 2011 > New Revision: 131200 > > URL: http://llvm.org/viewvc/llvm-project?rev=131200&view=rev > Log: > Turn this into a table, this will make more sense shortly. > > Part of rdar://8470697 Cool, please use an enum to index into the array though, instead of magic numbers like AtomicOpcTbl[index][7] -Chris > > Modified: > llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp > > Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=131200&r1=131199&r2=131200&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Wed May 11 16:44:58 2011 > @@ -1482,6 +1482,22 @@ > } > } > > +static const unsigned int AtomicOpcTbl[1][11] = { > + { > + X86::LOCK_OR8mi, > + X86::LOCK_OR8mr, > + X86::LOCK_OR16mi8, > + X86::LOCK_OR16mi, > + X86::LOCK_OR16mr, > + X86::LOCK_OR32mi8, > + X86::LOCK_OR32mi, > + X86::LOCK_OR32mr, > + X86::LOCK_OR64mi8, > + X86::LOCK_OR64mi32, > + X86::LOCK_OR64mr > + } > +}; > + > SDNode *X86DAGToDAGISel::SelectAtomicLoadOr(SDNode *Node, EVT NVT) { > if (Node->hasAnyUseOfValue(0)) > return 0; > @@ -1504,41 +1520,43 @@ > Val = CurDAG->getTargetConstant(CN->getSExtValue(), NVT); > } > > + // Which index into the table. > + unsigned index = 0; > unsigned Opc = 0; > switch (NVT.getSimpleVT().SimpleTy) { > default: return 0; > case MVT::i8: > if (isCN) > - Opc = X86::LOCK_OR8mi; > + Opc = AtomicOpcTbl[index][0]; > else > - Opc = X86::LOCK_OR8mr; > + Opc = AtomicOpcTbl[index][1]; > break; > case MVT::i16: > if (isCN) { > if (immSext8(Val.getNode())) > - Opc = X86::LOCK_OR16mi8; > + Opc = AtomicOpcTbl[index][2]; > else > - Opc = X86::LOCK_OR16mi; > + Opc = AtomicOpcTbl[index][3]; > } else > - Opc = X86::LOCK_OR16mr; > + Opc = AtomicOpcTbl[index][4]; > break; > case MVT::i32: > if (isCN) { > if (immSext8(Val.getNode())) > - Opc = X86::LOCK_OR32mi8; > + Opc = AtomicOpcTbl[index][5]; > else > - Opc = X86::LOCK_OR32mi; > + Opc = AtomicOpcTbl[index][6]; > } else > - Opc = X86::LOCK_OR32mr; > + Opc = AtomicOpcTbl[index][7]; > break; > case MVT::i64: > if (isCN) { > if (immSext8(Val.getNode())) > - Opc = X86::LOCK_OR64mi8; > + Opc = AtomicOpcTbl[index][8]; > else if (i64immSExt32(Val.getNode())) > - Opc = X86::LOCK_OR64mi32; > + Opc = AtomicOpcTbl[index][9]; > } else > - Opc = X86::LOCK_OR64mr; > + Opc = AtomicOpcTbl[index][10]; > break; > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From ofv at wanadoo.es Thu May 12 06:26:21 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Thu, 12 May 2011 11:26:21 -0000 Subject: [llvm-commits] [llvm] r131229 - /llvm/trunk/tools/gold/CMakeLists.txt Message-ID: <20110512112621.463F52A6C12C@llvm.org> Author: ofv Date: Thu May 12 06:26:21 2011 New Revision: 131229 URL: http://llvm.org/viewvc/llvm-project?rev=131229&view=rev Log: CMake builds gold by default since revision 127466. This is inconsistent with autoconf, which by default set BINUTILS_INCDIR to empty and exclude gold from target list. Based on a patch by Haitao Li! Modified: llvm/trunk/tools/gold/CMakeLists.txt Modified: llvm/trunk/tools/gold/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/CMakeLists.txt?rev=131229&r1=131228&r2=131229&view=diff ============================================================================== --- llvm/trunk/tools/gold/CMakeLists.txt (original) +++ llvm/trunk/tools/gold/CMakeLists.txt Thu May 12 06:26:21 2011 @@ -1,7 +1,9 @@ -set(LLVM_BINUTILS_INCDIR "/usr/include" CACHE PATH +set(LLVM_BINUTILS_INCDIR "" CACHE PATH "PATH to binutils/include containing plugin-api.h for gold plugin.") -if( NOT EXISTS "${LLVM_BINUTILS_INCDIR}/plugin-api.h" ) +if( NOT LLVM_BINUTILS_INCDIR ) + # Nothing to say. +elseif( NOT EXISTS "${LLVM_BINUTILS_INCDIR}/plugin-api.h" ) message(STATUS "plugin-api.h not found. gold plugin excluded from the build.") else() include_directories( ${LLVM_BINUTILS_INCDIR} ) From st at invia.fr Thu May 12 09:47:02 2011 From: st at invia.fr (Sylvere Teissier) Date: Thu, 12 May 2011 16:47:02 +0200 Subject: [llvm-commits] [llvm] r130339 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfCompileUnit.cpp DwarfCompileUnit.h DwarfDebug.cpp In-Reply-To: <20110427224524.47CEA2A6C12D@llvm.org> References: <20110427224524.47CEA2A6C12D@llvm.org> Message-ID: <4DCBF2E6.3030104@invia.fr> Le 28/04/2011 00:45, Devang Patel a ?crit : > Author: dpatel > Date: Wed Apr 27 17:45:24 2011 > New Revision: 130339 > > URL: http://llvm.org/viewvc/llvm-project?rev=130339&view=rev > Log: > Simplify handling of variables with complex address (i.e. blocks variables) > > Modified: > llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp > llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h > llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Hi, there is something that seems not clear for me here: > Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=130339&r1=130338&r2=130339&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) > +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Apr 27 17:45:24 2011 > @@ -699,11 +699,19 @@ > const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); > if (DVInsn->getOperand(1).isImm() && > TRI->getFrameRegister(*Asm->MF) == RegOp.getReg()) { > - VariableCU->addFrameVariableAddress(DV, VariableDie, > - DVInsn->getOperand(1).getImm()); > - updated = true; > - } else > - updated = VariableCU->addRegisterAddress(VariableDie, RegOp); > + unsigned FrameReg = 0; > + const TargetFrameLowering *TFI = Asm->TM.getFrameLowering(); My question is for this line: > + int Offset = > + TFI->getFrameIndexReference(*Asm->MF, > + DVInsn->getOperand(1).getImm(), > + FrameReg); During frame elimination the Target backend function "RegisterInfo::eliminateFrameIndex" has converted the DVInsn from something like this: DBG_VALUE to something like this: DBG_VALUE %SP,44 so here : DVInsn->getOperand(1).getImm() returns 44 but TFI->getFrameIndexReference FI argument require a frame index ( 12 in this example), not an offset in byte. Is there something wrong in this code or did I misunderstand something ? > + MachineLocation Location(FrameReg, Offset); > + VariableCU->addVariableAddress(DV, VariableDie, Location); > + > + } else if (RegOp.getReg()) > + VariableCU->addVariableAddress(DV, VariableDie, > + MachineLocation(RegOp.getReg())); > + updated = true; > } > else if (DVInsn->getOperand(0).isImm()) > > From rengolin at systemcall.org Thu May 12 11:38:30 2011 From: rengolin at systemcall.org (Renato Golin) Date: Thu, 12 May 2011 17:38:30 +0100 Subject: [llvm-commits] [llvm] r131205 - in /llvm/trunk/lib/MC: ELFObjectWriter.cpp ELFObjectWriter.h In-Reply-To: <20110511225306.571622A6C12C@llvm.org> References: <20110511225306.571622A6C12C@llvm.org> Message-ID: On 11 May 2011 23:53, Jason W Kim wrote: > ?const MCSymbol *ELFObjectWriter::SymbolToReloc(const MCAssembler &Asm, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const MCValue &Target, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const MCFragment &F) const { > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const MCFragment &F, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const MCFixup &Fixup, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool IsPCRel) const { Hi Jason, As a side note... since you're passing the relocation already, shouldn't isPcRel be a method on Fixup to define if that specific relocation is PC relative or not? Something like: virtual MCFixup::isPCRel() { return false; } and each architecture implement its own PC relative relocations as needed: virtual ARMMCFixup::isPCRel() { return Type == FOO_PC || Type == BAR_PC; } If that makes sense... cheers, --renato From jasonwkim at google.com Thu May 12 11:50:57 2011 From: jasonwkim at google.com (Jason Kim) Date: Thu, 12 May 2011 09:50:57 -0700 Subject: [llvm-commits] [llvm] r131205 - in /llvm/trunk/lib/MC: ELFObjectWriter.cpp ELFObjectWriter.h In-Reply-To: References: <20110511225306.571622A6C12C@llvm.org> Message-ID: On Thu, May 12, 2011 at 9:38 AM, Renato Golin wrote: > On 11 May 2011 23:53, Jason W Kim wrote: >> ?const MCSymbol *ELFObjectWriter::SymbolToReloc(const MCAssembler &Asm, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const MCValue &Target, >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const MCFragment &F) const { >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const MCFragment &F, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const MCFixup &Fixup, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool IsPCRel) const { > > Hi Jason, > > As a side note... since you're passing the relocation already, > shouldn't isPcRel be a method on Fixup to define if that specific > relocation is PC relative or not? > > Something like: Yah, we've gone back and forth on that. Currently it calls out to AsmBackend.getFixupKind() which is pretty much the same thing (i.e. arch specific and virtual). AsmBackend has a arch specific table with a flag that tells whether a relflag is pcrel or not. Thanks for review! -jason > > virtual MCFixup::isPCRel() { return false; } > > and each architecture implement its own PC relative relocations as needed: > > virtual ARMMCFixup::isPCRel() { return Type == FOO_PC || Type == BAR_PC; } > > If that makes sense... > > cheers, > --renato > From jasonwkim at google.com Thu May 12 11:51:50 2011 From: jasonwkim at google.com (Jason Kim) Date: Thu, 12 May 2011 09:51:50 -0700 Subject: [llvm-commits] [llvm] r131208 - /llvm/trunk/lib/MC/ELFObjectWriter.cpp In-Reply-To: <20110511233451.ACBA82A6C12C@llvm.org> References: <20110511233451.ACBA82A6C12C@llvm.org> Message-ID: On Wed, May 11, 2011 at 4:34 PM, Matt Beaumont-Gay wrote: > Author: matthewbg > Date: Wed May 11 18:34:51 2011 > New Revision: 131208 > > URL: http://llvm.org/viewvc/llvm-project?rev=131208&view=rev > Log: > Remove an unused variable and move a couple others inside DEBUG. Thanks! -jason > > Modified: > ? ?llvm/trunk/lib/MC/ELFObjectWriter.cpp > > Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=131208&r1=131207&r2=131208&view=diff > ============================================================================== > --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) > +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed May 11 18:34:51 2011 > @@ -1291,16 +1291,16 @@ > > ? const MCSectionELF &Section = > ? ? static_cast(Symbol.getSection()); > - ?const SectionKind secKind = Section.getKind(); > - ?const MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind(); > - ?MCSymbolRefExpr::VariantKind Kind2; > - ?Kind2 = Target.getSymB() ? ?Target.getSymB()->getKind() : > - ? ?MCSymbolRefExpr::VK_None; > ? bool InNormalSection = true; > ? unsigned RelocType = 0; > ? RelocType = GetRelocTypeInner(Target, Fixup, IsPCRel); > > - ?DEBUG(dbgs() << "considering symbol " > + ?DEBUG( > + ? ? ?const MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind(); > + ? ? ?MCSymbolRefExpr::VariantKind Kind2; > + ? ? ?Kind2 = Target.getSymB() ? ?Target.getSymB()->getKind() : > + ? ? ? ?MCSymbolRefExpr::VK_None; > + ? ? ?dbgs() << "considering symbol " > ? ? ? ? << Section.getSectionName() << "/" > ? ? ? ? << Symbol.getName() << "/" > ? ? ? ? << " Rel:" << (unsigned)RelocType > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From ahatanak at gmail.com Thu May 12 12:38:46 2011 From: ahatanak at gmail.com (Akira Hatanaka) Date: Thu, 12 May 2011 10:38:46 -0700 Subject: [llvm-commits] [PATCH] Mips, fix isCommutable. Message-ID: Fix setting of isCommutable flag. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110512/c524c5dd/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: iscomm.patch Type: text/x-patch Size: 5281 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110512/c524c5dd/attachment.bin From jason.w.kim.2009 at gmail.com Thu May 12 12:37:13 2011 From: jason.w.kim.2009 at gmail.com (Jason W Kim) Date: Thu, 12 May 2011 17:37:13 -0000 Subject: [llvm-commits] [llvm] r131231 - /llvm/trunk/README.txt Message-ID: <20110512173713.ED11D2A6C12C@llvm.org> Author: jasonwkim Date: Thu May 12 12:37:13 2011 New Revision: 131231 URL: http://llvm.org/viewvc/llvm-project?rev=131231&view=rev Log: Test commit from Mercurial Modified: llvm/trunk/README.txt Modified: llvm/trunk/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/README.txt?rev=131231&r1=131230&r2=131231&view=diff ============================================================================== --- llvm/trunk/README.txt (original) +++ llvm/trunk/README.txt Thu May 12 12:37:13 2011 @@ -14,3 +14,4 @@ If you're writing a package for LLVM, see docs/Packaging.html for our suggestions. + From jason.w.kim.2009 at gmail.com Thu May 12 12:38:08 2011 From: jason.w.kim.2009 at gmail.com (Jason W Kim) Date: Thu, 12 May 2011 17:38:08 -0000 Subject: [llvm-commits] [llvm] r131232 - /llvm/trunk/README.txt Message-ID: <20110512173808.A18262A6C12C@llvm.org> Author: jasonwkim Date: Thu May 12 12:38:08 2011 New Revision: 131232 URL: http://llvm.org/viewvc/llvm-project?rev=131232&view=rev Log: reverting test commit Modified: llvm/trunk/README.txt Modified: llvm/trunk/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/README.txt?rev=131232&r1=131231&r2=131232&view=diff ============================================================================== --- llvm/trunk/README.txt (original) +++ llvm/trunk/README.txt Thu May 12 12:38:08 2011 @@ -14,4 +14,3 @@ If you're writing a package for LLVM, see docs/Packaging.html for our suggestions. - From bruno.cardoso at gmail.com Thu May 12 12:45:00 2011 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Thu, 12 May 2011 14:45:00 -0300 Subject: [llvm-commits] [PATCH] Mips, fix isCommutable. In-Reply-To: References: Message-ID: Please apply! On Thu, May 12, 2011 at 2:38 PM, Akira Hatanaka wrote: > Fix setting of isCommutable flag. > -- Bruno Cardoso Lopes http://www.brunocardoso.cc From ahatanak at gmail.com Thu May 12 12:42:08 2011 From: ahatanak at gmail.com (Akira Hatanaka) Date: Thu, 12 May 2011 17:42:08 -0000 Subject: [llvm-commits] [llvm] r131233 - in /llvm/trunk/lib/Target/Mips: MipsInstrFPU.td MipsInstrInfo.td Message-ID: <20110512174208.EF4862A6C12C@llvm.org> Author: ahatanak Date: Thu May 12 12:42:08 2011 New Revision: 131233 URL: http://llvm.org/viewvc/llvm-project?rev=131233&view=rev Log: Fix setting of isCommutable flag. Modified: llvm/trunk/lib/Target/Mips/MipsInstrFPU.td llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Modified: llvm/trunk/lib/Target/Mips/MipsInstrFPU.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrFPU.td?rev=131233&r1=131232&r2=131233&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrFPU.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrFPU.td Thu May 12 12:42:08 2011 @@ -100,7 +100,8 @@ !strconcat(asmstr, " $fd, $fs"), []>; -multiclass FFR1_4 funct, string asmstr, SDNode FOp> { +multiclass FFR1_4 funct, string asmstr, SDNode FOp, bit isComm = 0> { + let isCommutable = isComm in { def _S32 : FFR<0x11, funct, 0x0, (outs FGR32:$fd), (ins FGR32:$fs, FGR32:$ft), !strconcat(asmstr, ".s $fd, $fs, $ft"), @@ -111,6 +112,7 @@ !strconcat(asmstr, ".d $fd, $fs, $ft"), [(set AFGR64:$fd, (FOp AFGR64:$fs, AFGR64:$ft))]>, Requires<[In32BitMode]>; + } } //===----------------------------------------------------------------------===// @@ -203,9 +205,9 @@ [(store FGR32:$ft, addr:$addr)]>; /// Floating-point Aritmetic -defm FADD : FFR1_4<0x10, "add", fadd>; +defm FADD : FFR1_4<0x10, "add", fadd, 1>; defm FDIV : FFR1_4<0x03, "div", fdiv>; -defm FMUL : FFR1_4<0x02, "mul", fmul>; +defm FMUL : FFR1_4<0x02, "mul", fmul, 1>; defm FSUB : FFR1_4<0x01, "sub", fsub>; //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=131233&r1=131232&r2=131233&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Thu May 12 12:42:08 2011 @@ -145,17 +145,19 @@ //===----------------------------------------------------------------------===// // Arithmetic 3 register operands -let isCommutable = 1 in class ArithR op, bits<6> func, string instr_asm, SDNode OpNode, - InstrItinClass itin>: + InstrItinClass itin, bit isComm = 0>: FR; + [(set CPURegs:$dst, (OpNode CPURegs:$b, CPURegs:$c))], itin> { + let isCommutable = isComm; +} -let isCommutable = 1 in -class ArithOverflowR op, bits<6> func, string instr_asm>: +class ArithOverflowR op, bits<6> func, string instr_asm, bit isComm = 0>: FR; + !strconcat(instr_asm, "\t$dst, $b, $c"), [], IIAlu> { + let isCommutable = isComm; +} // Arithmetic 2 register operands class ArithI op, string instr_asm, SDNode OpNode, @@ -171,12 +173,15 @@ // Arithmetic Multiply ADD/SUB let rd = 0, shamt = 0, Defs = [HI, LO], Uses = [HI, LO] in -class MArithR func, string instr_asm, SDNode op> : +class MArithR func, string instr_asm, SDNode op, bit isComm = 0> : FR<0x1c, func, (outs), (ins CPURegs:$rs, CPURegs:$rt), !strconcat(instr_asm, "\t$rs, $rt"), - [(op CPURegs:$rs, CPURegs:$rt, LO, HI)], IIImul>; + [(op CPURegs:$rs, CPURegs:$rt, LO, HI)], IIImul> { + let isCommutable = isComm; +} // Logical +let isCommutable = 1 in class LogicR func, string instr_asm, SDNode OpNode>: FR<0x00, func, (outs CPURegs:$dst), (ins CPURegs:$b, CPURegs:$c), !strconcat(instr_asm, "\t$dst, $b, $c"), @@ -187,6 +192,7 @@ !strconcat(instr_asm, "\t$dst, $b, $c"), [(set CPURegs:$dst, (OpNode CPURegs:$b, immZExt16:$c))], IIAlu>; +let isCommutable = 1 in class LogicNOR op, bits<6> func, string instr_asm>: FR func, string instr_asm, InstrItinClass itin>: FR<0x00, func, (outs), (ins CPURegs:$a, CPURegs:$b), !strconcat(instr_asm, "\t$a, $b"), [], itin>; @@ -394,9 +401,9 @@ def LUi : LoadUpper<0x0f, "lui">; /// Arithmetic Instructions (3-Operand, R-Type) -def ADDu : ArithR<0x00, 0x21, "addu", add, IIAlu>; +def ADDu : ArithR<0x00, 0x21, "addu", add, IIAlu, 1>; def SUBu : ArithR<0x00, 0x23, "subu", sub, IIAlu>; -def ADD : ArithOverflowR<0x00, 0x20, "add">; +def ADD : ArithOverflowR<0x00, 0x20, "add", 1>; def SUB : ArithOverflowR<0x00, 0x22, "sub">; def SLT : SetCC_R<0x00, 0x2a, "slt", setlt>; def SLTu : SetCC_R<0x00, 0x2b, "sltu", setult>; @@ -520,14 +527,14 @@ def LEA_ADDiu : EffectiveAddress<"addiu\t$dst, ${addr:stackloc}">; // MADD*/MSUB* -def MADD : MArithR<0, "madd", MipsMAdd>; -def MADDU : MArithR<1, "maddu", MipsMAddu>; +def MADD : MArithR<0, "madd", MipsMAdd, 1>; +def MADDU : MArithR<1, "maddu", MipsMAddu, 1>; def MSUB : MArithR<4, "msub", MipsMSub>; def MSUBU : MArithR<5, "msubu", MipsMSubu>; // MUL is a assembly macro in the current used ISAs. In recent ISA's // it is a real instruction. -def MUL : ArithR<0x1c, 0x02, "mul", mul, IIImul>, Requires<[IsMips32]>; +def MUL : ArithR<0x1c, 0x02, "mul", mul, IIImul, 1>, Requires<[IsMips32]>; //===----------------------------------------------------------------------===// // Arbitrary patterns that map to one or more instructions From dpatel at apple.com Thu May 12 12:52:02 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 12 May 2011 10:52:02 -0700 Subject: [llvm-commits] [llvm] r130339 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfCompileUnit.cpp DwarfCompileUnit.h DwarfDebug.cpp In-Reply-To: <4DCBF2E6.3030104@invia.fr> References: <20110427224524.47CEA2A6C12D@llvm.org> <4DCBF2E6.3030104@invia.fr> Message-ID: <5B58CF05-0745-4E9D-8994-BBAE610115F8@apple.com> On May 12, 2011, at 7:47 AM, Sylvere Teissier wrote: > Le 28/04/2011 00:45, Devang Patel a ?crit : >> Author: dpatel >> Date: Wed Apr 27 17:45:24 2011 >> New Revision: 130339 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=130339&view=rev >> Log: >> Simplify handling of variables with complex address (i.e. blocks variables) >> >> Modified: >> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp >> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h >> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp > > Hi, there is something that seems not clear for me here: > >> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=130339&r1=130338&r2=130339&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) >> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Apr 27 17:45:24 2011 >> @@ -699,11 +699,19 @@ >> const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); >> if (DVInsn->getOperand(1).isImm() && >> TRI->getFrameRegister(*Asm->MF) == RegOp.getReg()) { >> - VariableCU->addFrameVariableAddress(DV, VariableDie, >> - DVInsn->getOperand(1).getImm()); >> - updated = true; >> - } else >> - updated = VariableCU->addRegisterAddress(VariableDie, RegOp); >> + unsigned FrameReg = 0; >> + const TargetFrameLowering *TFI = Asm->TM.getFrameLowering(); > > > My question is for this line: > >> + int Offset = >> + TFI->getFrameIndexReference(*Asm->MF, >> + DVInsn->getOperand(1).getImm(), >> + FrameReg); > > During frame elimination the Target backend function > "RegisterInfo::eliminateFrameIndex" has converted the DVInsn > > from something like this: > > DBG_VALUE > > to something like this: > > DBG_VALUE %SP,44 > In that case DVInsn.getNumOperands() == 3 condition will fail. - Devang > so here : > > DVInsn->getOperand(1).getImm() > > returns 44 > > but TFI->getFrameIndexReference FI argument require a frame index ( 12 > in this example), not an offset in byte. > > Is there something wrong in this code or did I misunderstand something ? > From dpatel at apple.com Thu May 12 12:54:08 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 12 May 2011 10:54:08 -0700 Subject: [llvm-commits] .cfi_* and ARM In-Reply-To: <4DCB36E2.4030202@gmail.com> References: <4DC84EE9.8080402@gmail.com> <4DC8552E.3030705@gmail.com> <4DC9D0BD.8010004@gmail.com> <82E550F3-818C-4BF2-B11E-52ADF52823D2@apple.com> <4DCB36E2.4030202@gmail.com> Message-ID: <146C24D7-C2CB-43FE-8505-2825F2D3B836@apple.com> On May 11, 2011, at 6:24 PM, Rafael ?vila de Esp?ndola wrote: > I have added a small overview of what I did in: > > http://blog.mozilla.com/respindola/2011/05/12/cfi-directives/ > > Cheers, Thanks! A document like this is always a useful reference. - Devang From rengolin at systemcall.org Thu May 12 13:25:49 2011 From: rengolin at systemcall.org (Renato Golin) Date: Thu, 12 May 2011 19:25:49 +0100 Subject: [llvm-commits] [llvm] r131205 - in /llvm/trunk/lib/MC: ELFObjectWriter.cpp ELFObjectWriter.h In-Reply-To: References: <20110511225306.571622A6C12C@llvm.org> Message-ID: On 12 May 2011 17:50, Jason Kim wrote: > Yah, we've gone back and forth on that. I know the feeling, it's never good enough... ;) > Currently it calls out to AsmBackend.getFixupKind() which is pretty > much the same thing (i.e. arch specific and virtual). > AsmBackend has a arch specific table with a flag that tells whether a > relflag is pcrel or not. I see. I was just worried with the "isPCRel" being too specific to be a whole new argument for all those functions, as if the separation between pc-rel and non-pc-rel was the only possible/interesting among relocations kinds... But that's minor, since it's already target-specific. cheers! --renato From grosbach at apple.com Thu May 12 13:21:23 2011 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 12 May 2011 18:21:23 -0000 Subject: [llvm-commits] [llvm] r131234 - in /llvm/trunk/lib/ExecutionEngine/MCJIT: MCJIT.cpp MCJITMemoryManager.h Message-ID: <20110512182123.C5C682A6C12C@llvm.org> Author: grosbach Date: Thu May 12 13:21:23 2011 New Revision: 131234 URL: http://llvm.org/viewvc/llvm-project?rev=131234&view=rev Log: The MCJIT memory manager needs to initialize its Module member. Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp llvm/trunk/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=131234&r1=131233&r2=131234&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Thu May 12 13:21:23 2011 @@ -58,7 +58,7 @@ // If the target supports JIT code generation, create the JIT. if (TargetJITInfo *TJ = TM->getJITInfo()) - return new MCJIT(M, TM, *TJ, new MCJITMemoryManager(JMM), OptLevel, + return new MCJIT(M, TM, *TJ, new MCJITMemoryManager(JMM, M), OptLevel, GVsWithCode); if (ErrorStr) Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h?rev=131234&r1=131233&r2=131234&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h Thu May 12 13:21:23 2011 @@ -26,7 +26,7 @@ // FIXME: Multiple modules. Module *M; public: - MCJITMemoryManager(JITMemoryManager *jmm) : JMM(jmm) {} + MCJITMemoryManager(JITMemoryManager *jmm, Module *m) : JMM(jmm), M(m) {} // Allocate ActualSize bytes, or more, for the named function. Return // a pointer to the allocated memory and update Size to reflect how much From evan.cheng at apple.com Thu May 12 13:44:58 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 May 2011 18:44:58 -0000 Subject: [llvm-commits] [llvm] r131235 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <20110512184458.B166C2A6C12C@llvm.org> Author: evancheng Date: Thu May 12 13:44:58 2011 New Revision: 131235 URL: http://llvm.org/viewvc/llvm-project?rev=131235&view=rev Log: Temporarily disable the transformation. It's breaking 186.crafty in some configuration. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131235&r1=131234&r2=131235&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Thu May 12 13:44:58 2011 @@ -1354,6 +1354,10 @@ /// NOTE: This optimization does not update live-in information so it must be /// run after all passes that require correct liveness information. bool BranchFolder::HoistCommonCode(MachineFunction &MF) { +#if 1 + // FIXME: Temporarily disabled. + return false; +#endif bool MadeChange = false; for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { MachineBasicBlock *MBB = I++; From dpatel at apple.com Thu May 12 14:06:16 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 12 May 2011 19:06:16 -0000 Subject: [llvm-commits] [llvm] r131238 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/Support/Dwarf.h lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp lib/Support/Dwarf.cpp Message-ID: <20110512190617.0FC742A6C12C@llvm.org> Author: dpatel Date: Thu May 12 14:06:16 2011 New Revision: 131238 URL: http://llvm.org/viewvc/llvm-project?rev=131238&view=rev Log: Let Objective-C front-end identify class extension, in dwarf output, using an attribute DW_AT_APPLE_objc_class_extension. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/Support/Dwarf.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/trunk/lib/Support/Dwarf.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=131238&r1=131237&r2=131238&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Thu May 12 14:06:16 2011 @@ -49,15 +49,16 @@ class DIDescriptor { public: enum { - FlagPrivate = 1 << 0, - FlagProtected = 1 << 1, - FlagFwdDecl = 1 << 2, - FlagAppleBlock = 1 << 3, - FlagBlockByrefStruct = 1 << 4, - FlagVirtual = 1 << 5, - FlagArtificial = 1 << 6, - FlagExplicit = 1 << 7, - FlagPrototyped = 1 << 8 + FlagPrivate = 1 << 0, + FlagProtected = 1 << 1, + FlagFwdDecl = 1 << 2, + FlagAppleBlock = 1 << 3, + FlagBlockByrefStruct = 1 << 4, + FlagVirtual = 1 << 5, + FlagArtificial = 1 << 6, + FlagExplicit = 1 << 7, + FlagPrototyped = 1 << 8, + FlagObjcClassExtension = 1 << 9 }; protected: const MDNode *DbgNode; @@ -271,6 +272,9 @@ bool isArtificial() const { return (getFlags() & FlagArtificial) != 0; } + bool isObjcClassExtension() const { + return (getFlags() & FlagObjcClassExtension) != 0; + } bool isValid() const { return DbgNode && (isBasicType() || isDerivedType() || isCompositeType()); } Modified: llvm/trunk/include/llvm/Support/Dwarf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Dwarf.h?rev=131238&r1=131237&r2=131238&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Dwarf.h (original) +++ llvm/trunk/include/llvm/Support/Dwarf.h Thu May 12 14:06:16 2011 @@ -235,6 +235,7 @@ DW_AT_APPLE_property_getter = 0x3fe9, DW_AT_APPLE_property_setter = 0x3fea, DW_AT_APPLE_property_attribute = 0x3feb, + DW_AT_APPLE_objc_class_extension = 0x3fec, // Attribute form encodings DW_FORM_addr = 0x01, Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=131238&r1=131237&r2=131238&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Thu May 12 14:06:16 2011 @@ -766,6 +766,10 @@ addToContextOwner(&Buffer, Context); } + if (CTy.isObjcClassExtension()) + addUInt(&Buffer, dwarf::DW_AT_APPLE_objc_class_extension, + dwarf::DW_FORM_flag, 1); + if (Tag == dwarf::DW_TAG_class_type) addTemplateParams(Buffer, CTy.getTemplateParams()); Modified: llvm/trunk/lib/Support/Dwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Dwarf.cpp?rev=131238&r1=131237&r2=131238&view=diff ============================================================================== --- llvm/trunk/lib/Support/Dwarf.cpp (original) +++ llvm/trunk/lib/Support/Dwarf.cpp Thu May 12 14:06:16 2011 @@ -207,6 +207,7 @@ case DW_AT_APPLE_property_getter: return "DW_AT_APPLE_property_getter"; case DW_AT_APPLE_property_setter: return "DW_AT_APPLE_property_setter"; case DW_AT_APPLE_property_attribute: return "DW_AT_APPLE_property_attribute"; + case DW_AT_APPLE_objc_class_extension: return "DW_AT_APPLE_objc_class_extension"; } return 0; } From evan.cheng at apple.com Thu May 12 15:30:02 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 May 2011 20:30:02 -0000 Subject: [llvm-commits] [llvm] r131241 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp test/CodeGen/X86/hoist-common.ll Message-ID: <20110512203002.1A71B2A6C12C@llvm.org> Author: evancheng Date: Thu May 12 15:30:01 2011 New Revision: 131241 URL: http://llvm.org/viewvc/llvm-project?rev=131241&view=rev Log: Re-enable branchfolding common code hoisting optimization. Fixed a liveness test bug and also taught it to update liveins. Added: llvm/trunk/test/CodeGen/X86/hoist-common.ll Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131241&r1=131240&r2=131241&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Thu May 12 15:30:01 2011 @@ -1354,10 +1354,6 @@ /// NOTE: This optimization does not update live-in information so it must be /// run after all passes that require correct liveness information. bool BranchFolder::HoistCommonCode(MachineFunction &MF) { -#if 1 - // FIXME: Temporarily disabled. - return false; -#endif bool MadeChange = false; for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { MachineBasicBlock *MBB = I++; @@ -1472,10 +1468,10 @@ Uses.erase(Reg); for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) Uses.erase(*SR); // Use getSubRegisters to be conservative - Defs.insert(Reg); - for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) - Defs.insert(*AS); } + Defs.insert(Reg); + for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) + Defs.insert(*AS); } } @@ -1511,7 +1507,8 @@ return false; bool HasDups = false; - SmallSet LocalDefs; + SmallVector LocalDefs; + SmallSet LocalDefsSet; MachineBasicBlock::iterator TIB = TBB->begin(); MachineBasicBlock::iterator FIB = FBB->begin(); MachineBasicBlock::iterator TIE = TBB->end(); @@ -1568,11 +1565,7 @@ IsSafe = false; break; } - - LocalDefs.insert(Reg); - for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) - LocalDefs.insert(*SR); - } else if (!LocalDefs.count(Reg)) { + } else if (!LocalDefsSet.count(Reg)) { if (Defs.count(Reg)) { // Use is defined by the instruction at the point of insertion. IsSafe = false; @@ -1587,6 +1580,28 @@ if (!TIB->isSafeToMove(TII, 0, DontMoveAcrossStore)) break; + // Track local defs so we can update liveins. + for (unsigned i = 0, e = TIB->getNumOperands(); i != e; ++i) { + MachineOperand &MO = TIB->getOperand(i); + if (!MO.isReg()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg) + continue; + if (MO.isDef()) { + if (!MO.isDead()) { + LocalDefs.push_back(Reg); + LocalDefsSet.insert(Reg); + for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) + LocalDefsSet.insert(*SR); + } + } else if (MO.isKill() && LocalDefsSet.count(Reg)) { + LocalDefsSet.erase(Reg); + for (const unsigned *SR = TRI->getSubRegisters(Reg); *SR; ++SR) + LocalDefsSet.erase(*SR); + } + } + HasDups = true;; ++TIB; ++FIB; @@ -1597,6 +1612,16 @@ MBB->splice(Loc, TBB, TBB->begin(), TIB); FBB->erase(FBB->begin(), FIB); + + // Update livein's. + for (unsigned i = 0, e = LocalDefs.size(); i != e; ++i) { + unsigned Def = LocalDefs[i]; + if (LocalDefsSet.count(Def)) { + TBB->addLiveIn(Def); + FBB->addLiveIn(Def); + } + } + ++NumHoist; return true; } Added: llvm/trunk/test/CodeGen/X86/hoist-common.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hoist-common.ll?rev=131241&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/hoist-common.ll (added) +++ llvm/trunk/test/CodeGen/X86/hoist-common.ll Thu May 12 15:30:01 2011 @@ -0,0 +1,28 @@ +; RUN: llc < %s -march=x86-64 | FileCheck %s + +; Common "xorb al, al" instruction in the two successor blocks should be +; moved to the entry block above the test + je. + +; rdar://9145558 + +define zeroext i1 @t(i32 %c) nounwind ssp { +entry: +; CHECK: t: +; CHECK: xorb %al, %al +; CHECK: test +; CHECK: je + %tobool = icmp eq i32 %c, 0 + br i1 %tobool, label %return, label %if.then + +if.then: +; CHECK: callq + %call = tail call zeroext i1 (...)* @foo() nounwind + br label %return + +return: +; CHECK: ret + %retval.0 = phi i1 [ %call, %if.then ], [ false, %entry ] + ret i1 %retval.0 +} + +declare zeroext i1 @foo(...) From fvbommel at gmail.com Thu May 12 16:15:43 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Thu, 12 May 2011 23:15:43 +0200 Subject: [llvm-commits] [llvm] r131241 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp test/CodeGen/X86/hoist-common.ll In-Reply-To: <20110512203002.1A71B2A6C12C@llvm.org> References: <20110512203002.1A71B2A6C12C@llvm.org> Message-ID: On Thu, May 12, 2011 at 10:30 PM, Evan Cheng wrote: > Re-enable branchfolding common code hoisting optimization. Fixed a liveness test bug and also taught it to update liveins. Then the following comment is no longer correct and should be removed? > ?/// NOTE: This optimization does not update live-in information so it must be > ?/// run after all passes that require correct liveness information. > ?bool BranchFolder::HoistCommonCode(MachineFunction &MF) { From grosbach at apple.com Thu May 12 16:21:17 2011 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 12 May 2011 21:21:17 -0000 Subject: [llvm-commits] [llvm] r131243 - /llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Message-ID: <20110512212117.19A9B2A6C12E@llvm.org> Author: grosbach Date: Thu May 12 16:21:16 2011 New Revision: 131243 URL: http://llvm.org/viewvc/llvm-project?rev=131243&view=rev Log: MCJIT section loading should just skip non-text sections rather than erroring out completely. Some modules produce sections that aren't referenced, so it's friendlier to clients like LLDB to just skip them, at least for now. Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=131243&r1=131242&r2=131243&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Thu May 12 16:21:16 2011 @@ -268,9 +268,9 @@ if (!Sect) return Error("unable to load section: '" + Twine(SectNum) + "'"); - // FIXME: Improve check. + // FIXME: For the time being, we're only loading text segments. if (Sect->Flags != 0x80000400) - return Error("unsupported section type!"); + continue; // Address and names of symbols in the section. typedef std::pair SymbolEntry; @@ -403,9 +403,9 @@ if (!Sect) return Error("unable to load section: '" + Twine(SectNum) + "'"); - // FIXME: Improve check. + // FIXME: For the time being, we're only loading text segments. if (Sect->Flags != 0x80000400) - return Error("unsupported section type!"); + continue; // Address and names of symbols in the section. typedef std::pair SymbolEntry; From dpatel at apple.com Thu May 12 16:29:42 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 12 May 2011 21:29:42 -0000 Subject: [llvm-commits] [llvm] r131244 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h include/llvm/Support/Dwarf.h lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp lib/Support/Dwarf.cpp Message-ID: <20110512212942.5F4AB2A6C12E@llvm.org> Author: dpatel Date: Thu May 12 16:29:42 2011 New Revision: 131244 URL: http://llvm.org/viewvc/llvm-project?rev=131244&view=rev Log: Doug convinced me that DW_AT_APPLE_objc_complete_type is more appropriate name. s/DW_AT_APPLE_objc_class_extension/DW_AT_APPLE_objc_complete_type/g Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/Support/Dwarf.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/trunk/lib/Support/Dwarf.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=131244&r1=131243&r2=131244&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Thu May 12 16:29:42 2011 @@ -58,7 +58,7 @@ FlagArtificial = 1 << 6, FlagExplicit = 1 << 7, FlagPrototyped = 1 << 8, - FlagObjcClassExtension = 1 << 9 + FlagObjcClassComplete = 1 << 9 }; protected: const MDNode *DbgNode; @@ -272,8 +272,8 @@ bool isArtificial() const { return (getFlags() & FlagArtificial) != 0; } - bool isObjcClassExtension() const { - return (getFlags() & FlagObjcClassExtension) != 0; + bool isObjcClassComplete() const { + return (getFlags() & FlagObjcClassComplete) != 0; } bool isValid() const { return DbgNode && (isBasicType() || isDerivedType() || isCompositeType()); Modified: llvm/trunk/include/llvm/Support/Dwarf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Dwarf.h?rev=131244&r1=131243&r2=131244&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Dwarf.h (original) +++ llvm/trunk/include/llvm/Support/Dwarf.h Thu May 12 16:29:42 2011 @@ -235,7 +235,7 @@ DW_AT_APPLE_property_getter = 0x3fe9, DW_AT_APPLE_property_setter = 0x3fea, DW_AT_APPLE_property_attribute = 0x3feb, - DW_AT_APPLE_objc_class_extension = 0x3fec, + DW_AT_APPLE_objc_complete_type = 0x3fec, // Attribute form encodings DW_FORM_addr = 0x01, Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=131244&r1=131243&r2=131244&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Thu May 12 16:29:42 2011 @@ -766,8 +766,8 @@ addToContextOwner(&Buffer, Context); } - if (CTy.isObjcClassExtension()) - addUInt(&Buffer, dwarf::DW_AT_APPLE_objc_class_extension, + if (CTy.isObjcClassComplete()) + addUInt(&Buffer, dwarf::DW_AT_APPLE_objc_complete_type, dwarf::DW_FORM_flag, 1); if (Tag == dwarf::DW_TAG_class_type) Modified: llvm/trunk/lib/Support/Dwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Dwarf.cpp?rev=131244&r1=131243&r2=131244&view=diff ============================================================================== --- llvm/trunk/lib/Support/Dwarf.cpp (original) +++ llvm/trunk/lib/Support/Dwarf.cpp Thu May 12 16:29:42 2011 @@ -207,7 +207,7 @@ case DW_AT_APPLE_property_getter: return "DW_AT_APPLE_property_getter"; case DW_AT_APPLE_property_setter: return "DW_AT_APPLE_property_setter"; case DW_AT_APPLE_property_attribute: return "DW_AT_APPLE_property_attribute"; - case DW_AT_APPLE_objc_class_extension: return "DW_AT_APPLE_objc_class_extension"; + case DW_AT_APPLE_objc_complete_type: return "DW_AT_APPLE_objc_complete_type"; } return 0; } From grosser at fim.uni-passau.de Thu May 12 16:33:29 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 12 May 2011 21:33:29 -0000 Subject: [llvm-commits] [polly] r131246 - in /polly/trunk: include/polly/ScopDetection.h lib/Analysis/ScopDetection.cpp Message-ID: <20110512213329.285102A6C12E@llvm.org> Author: grosser Date: Thu May 12 16:33:28 2011 New Revision: 131246 URL: http://llvm.org/viewvc/llvm-project?rev=131246&view=rev Log: ScopDetection: Move implementation of function from header to .cpp file Modified: polly/trunk/include/polly/ScopDetection.h polly/trunk/lib/Analysis/ScopDetection.cpp Modified: polly/trunk/include/polly/ScopDetection.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetection.h?rev=131246&r1=131245&r2=131246&view=diff ============================================================================== --- polly/trunk/include/polly/ScopDetection.h (original) +++ polly/trunk/include/polly/ScopDetection.h Thu May 12 16:33:28 2011 @@ -247,10 +247,7 @@ /// @brief Remove a region and its children from valid region set. /// /// @param R The region to remove. - void forgetScop(const Region &R) { - assert(isMaxRegionInScop(R) && "R is not a Scop!"); - ValidRegions.erase(&R); - } + void forgetScop(const Region &R); /// @brief Mark the function as invalid so we will not extract any scop from /// the function. Modified: polly/trunk/lib/Analysis/ScopDetection.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=131246&r1=131245&r2=131246&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopDetection.cpp (original) +++ polly/trunk/lib/Analysis/ScopDetection.cpp Thu May 12 16:33:28 2011 @@ -624,6 +624,11 @@ verifyRegion(**I); } +void ScopDetection::forgetScop(const Region &R) { + assert(isMaxRegionInScop(R) && "R is not a Scop!"); + ValidRegions.erase(&R); +} + void ScopDetection::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.addRequired(); From grosser at fim.uni-passau.de Thu May 12 16:36:27 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 12 May 2011 21:36:27 -0000 Subject: [llvm-commits] [polly] r131247 - /polly/trunk/www/contributors.html Message-ID: <20110512213628.036DE2A6C12E@llvm.org> Author: grosser Date: Thu May 12 16:36:27 2011 New Revision: 131247 URL: http://llvm.org/viewvc/llvm-project?rev=131247&view=rev Log: www: Use german 'umlaut' in Simbuerger Modified: polly/trunk/www/contributors.html Modified: polly/trunk/www/contributors.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/contributors.html?rev=131247&r1=131246&r2=131247&view=diff ============================================================================== --- polly/trunk/www/contributors.html (original) +++ polly/trunk/www/contributors.html Thu May 12 16:36:27 2011 @@ -32,7 +32,7 @@

Website: www.grosser.es

-

Andreas Simbuerger

+

Andreas Simbürger

Andreas works on the profiling infrastructure during his PhD at University of Passau. From aggarwa4 at illinois.edu Thu May 12 16:46:57 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 12 May 2011 21:46:57 -0000 Subject: [llvm-commits] [poolalloc] r131248 - /poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Message-ID: <20110512214657.C87892A6C12E@llvm.org> Author: aggarwa4 Date: Thu May 12 16:46:57 2011 New Revision: 131248 URL: http://llvm.org/viewvc/llvm-project?rev=131248&view=rev Log: Add a function that given two type ids compares them. Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=131248&r1=131247&r2=131248&view=diff ============================================================================== --- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original) +++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Thu May 12 16:46:57 2011 @@ -95,6 +95,16 @@ #endif } +/** + * Check that the two types match + */ +void compareTypes(uint8_t typeNumberSrc, uint8_t typeNumberDest, uint32_t tag) { + //TODO:add size info + if(typeNumberSrc != typeNumberDest) { + printf("Type mismatch: detecting %u, expecting %u! %u \n", typeNumberDest, typeNumberSrc, tag); + } +} + /** * Check the loaded type against the type recorded in the shadow memory. */ From aggarwa4 at illinois.edu Thu May 12 16:47:15 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 12 May 2011 21:47:15 -0000 Subject: [llvm-commits] [poolalloc] r131249 - /poolalloc/trunk/include/assistDS/VarArgsFunc.h Message-ID: <20110512214715.977D92A6C12E@llvm.org> Author: aggarwa4 Date: Thu May 12 16:47:15 2011 New Revision: 131249 URL: http://llvm.org/viewvc/llvm-project?rev=131249&view=rev Log: Minor formatting. Modified: poolalloc/trunk/include/assistDS/VarArgsFunc.h Modified: poolalloc/trunk/include/assistDS/VarArgsFunc.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/VarArgsFunc.h?rev=131249&r1=131248&r2=131249&view=diff ============================================================================== --- poolalloc/trunk/include/assistDS/VarArgsFunc.h (original) +++ poolalloc/trunk/include/assistDS/VarArgsFunc.h Thu May 12 16:47:15 2011 @@ -1,4 +1,4 @@ -//===-- VarArgsFunc.cpp - Simplify calls to bitcasted const funcs --------===// +//===--- VarArgsFunc.cpp - Simplify calls to bitcasted const funcs --------===// // // The LLVM Compiler Infrastructure // @@ -21,7 +21,6 @@ // // Class: VarArgsFunc // - // class VarArgsFunc : public ModulePass { public: static char ID; From aggarwa4 at illinois.edu Thu May 12 16:49:36 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 12 May 2011 21:49:36 -0000 Subject: [llvm-commits] [poolalloc] r131250 - in /poolalloc/trunk: include/assistDS/TypeChecks.h lib/AssistDS/TypeChecks.cpp Message-ID: <20110512214936.222BA2A6C12E@llvm.org> Author: aggarwa4 Date: Thu May 12 16:49:35 2011 New Revision: 131250 URL: http://llvm.org/viewvc/llvm-project?rev=131250&view=rev Log: 1. Check static analysis results before instrumenting fgets/memmove/memcpy/allocaInst . 2. Initial support for va_arg intrinsic. Modified: poolalloc/trunk/include/assistDS/TypeChecks.h poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/include/assistDS/TypeChecks.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecks.h?rev=131250&r1=131249&r2=131250&view=diff ============================================================================== --- poolalloc/trunk/include/assistDS/TypeChecks.h (original) +++ poolalloc/trunk/include/assistDS/TypeChecks.h Thu May 12 16:49:35 2011 @@ -60,12 +60,14 @@ bool initShadow(Module &M); bool unmapShadow(Module &M, Instruction &I); + bool visitVAArgInst(Module &M, VAArgInst &VI); bool visitCallInst(Module &M, CallInst &CI); bool visitInvokeInst(Module &M, InvokeInst &CI); bool visitCallSite(Module &M, CallSite CS); bool visitInternalFunction(Module &M, Function &F); bool visitExternalFunction(Module &M, Function &F); bool visitByValFunction(Module &M, Function &F); + bool visitVarArgFunction(Module &M, Function &F); bool visitLoadInst(Module &M, LoadInst &LI); bool visitStoreInst(Module &M, StoreInst &SI); bool visitAllocaInst(Module &M, AllocaInst &AI); Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=131250&r1=131249&r2=131250&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Thu May 12 16:49:35 2011 @@ -88,7 +88,8 @@ TD = &getAnalysis(); TA = &getAnalysis(); - TS = &getAnalysis >(); + if(EnableTypeSafeOpt) + TS = &getAnalysis >(); VoidTy = IntegerType::getVoidTy(M.getContext()); Int8Ty = IntegerType::getInt8Ty(M.getContext()); @@ -108,8 +109,10 @@ } Function *MainF = M.getFunction("main"); - if (MainF == 0 || MainF->isDeclaration()) + if (MainF == 0 || MainF->isDeclaration()) { + assert(0 && "No main function found"); return false; + } // Insert the shadow initialization function. modified |= initShadow(M); @@ -160,6 +163,8 @@ modified |= visitInvokeInst(M, *II); } else if (AllocaInst *AI = dyn_cast(&I)) { modified |= visitAllocaInst(M, *AI); + } else if (VAArgInst *VI = dyn_cast(&I)) { + modified |= visitVAArgInst(M, *VI); } } } @@ -172,11 +177,49 @@ if(F->isDeclaration()) continue; modified |= visitByValFunction(M, *F); + modified |= visitVarArgFunction(M, *F); } return modified; } +// Transform Variable Argument functions, by also passing +// the relavant metadata info +bool +TypeChecks::visitVarArgFunction(Module &M, Function &F) { + if(!F.isVarArg()) + return false; + // FIXME:handle external functions + + // Find all uses of the function + for(Value::use_iterator ui = F.use_begin(), ue = F.use_end(); + ui != ue;) { + // Check for call sites + CallInst *CI = dyn_cast(ui++); + if(!CI) + continue; + if(CI->getNumOperands() - 1 <= F.arg_size()) + continue; + std::vector Args; + unsigned int i = F.arg_size() + 1; + for(i = 1 ;i < CI->getNumOperands(); i++) { + if(i > F.arg_size()) { + // For each vararg argument, also add its type information before it + Args.push_back(ConstantInt::get(Int8Ty, UsedTypes[CI->getOperand(i)->getType()])); + } + + // Add the original argument + Args.push_back(CI->getOperand(i)); + } + + // Create the new call + CallInst *CI_New = CallInst::Create(CI->getCalledValue(), Args.begin(), Args.end(), "", CI); + CI->replaceAllUsesWith(CI_New); + CI->eraseFromParent(); + } + return true; +} + bool TypeChecks::visitByValFunction(Module &M, Function &F) { @@ -526,11 +569,13 @@ bool TypeChecks::visitGlobal(Module &M, GlobalVariable &GV, Constant *C, Instruction &I, unsigned offset) { + // FIXME:This should maybe move into the global ctor. + /*if(EnableTypeSafeOpt) { if(TS->isTypeSafe(&GV, I.getParent()->getParent())) { - return false; + return false; } - }*/ + }*/ if(ConstantArray *CA = dyn_cast(C)) { const Type * ElementType = CA->getType()->getElementType(); @@ -626,12 +671,42 @@ // Insert code to set objects to 0 bool TypeChecks::visitAllocaInst(Module &M, AllocaInst &AI) { - // Setting metadata to be 0(BOTTOM/Uninitialized) + // Set the object to be zero + // + // Add the memset function to the program. + Constant *memsetF = M.getOrInsertFunction ("llvm.memset.i64", VoidTy, + VoidPtrTy, + Int8Ty, + Int64Ty, + Int32Ty, + NULL); + const PointerType * PT = AI.getType(); const Type * ET = PT->getElementType(); Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET)); CastInst *BCI = BitCastInst::CreatePointerCast(&AI, VoidPtrTy); BCI->insertAfter(&AI); + + CastInst *ArraySize = CastInst::CreateSExtOrBitCast(AI.getArraySize(), Int64Ty); + ArraySize->insertAfter(BCI); + BinaryOperator *Size = BinaryOperator::Create(Instruction::Mul, AllocSize, ArraySize); + Size->insertAfter(ArraySize); + std::vector Args2; + Args2.push_back(BCI); + Args2.push_back(ConstantInt::get(Int8Ty, 0)); + Args2.push_back(Size); + Args2.push_back(ConstantInt::get(Int32Ty, AI.getAlignment())); + CallInst *CI_Init = CallInst::Create(memsetF, Args2.begin(), Args2.end()); + CI_Init->insertAfter(Size); + + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(&AI, AI.getParent()->getParent())) { + return true; + } + } + + // Setting metadata to be 0(BOTTOM/Uninitialized) + std::vector Args; Args.push_back(BCI); Args.push_back(AllocSize); @@ -648,29 +723,24 @@ CallInst *CI_Arr = CallInst::Create(F, Args1.begin(), Args1.end()); CI_Arr->insertAfter(CI); - // Set the object to be zero - // - // Add the memset function to the program. - Constant *memsetF = M.getOrInsertFunction ("llvm.memset.i64", VoidTy, - VoidPtrTy, - Int8Ty, - Int64Ty, - Int32Ty, - NULL); + return true; +} +// Insert runtime check for va_arg instructions +bool TypeChecks::visitVAArgInst(Module &M, VAArgInst &VI) { - CastInst *ArraySize = CastInst::CreateSExtOrBitCast(AI.getArraySize(), Int64Ty); - ArraySize->insertAfter(BCI); - BinaryOperator *Size = BinaryOperator::Create(Instruction::Mul, AllocSize, ArraySize); - Size->insertAfter(ArraySize); - std::vector Args2; - Args2.push_back(BCI); - Args2.push_back(ConstantInt::get(Int8Ty, 0)); - Args2.push_back(Size); - Args2.push_back(ConstantInt::get(Int32Ty, AI.getAlignment())); - CallInst *CI_Init = CallInst::Create(memsetF, Args2.begin(), Args2.end()); - CI_Init->insertAfter(CI_Arr); - + // FIXME:handle external functions + // For every va_arg instruction, + // In a transformed function, we pass in the type metadata before the actual argument + // Read metadata from va_list + // And then add a compare in the runtime + VAArgInst *VI_Type = new VAArgInst(VI.getOperand(0), Int8Ty, "", &VI); + std::vector Args; + Args.push_back(VI_Type); + Args.push_back(ConstantInt::get(Int8Ty, UsedTypes[VI.getType()])); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + Constant *F = M.getOrInsertFunction("compareTypes", VoidTy, Int8Ty, Int8Ty,Int32Ty, NULL); + CallInst::Create(F, Args.begin(), Args.end(), "", &VI); return true; } @@ -698,6 +768,11 @@ case Intrinsic::memcpy: case Intrinsic::memmove: { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(I->getOperand(2), I->getParent()->getParent())) { + return false; + } + } CastInst *BCI_Src = BitCastInst::CreatePointerCast(I->getOperand(2), VoidPtrTy, "", I); CastInst *BCI_Dest = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy, "", I); std::vector Args; @@ -818,6 +893,11 @@ CI->insertAfter(BCI_Dest); return true; } else if(F->getNameStr() == std::string("fgets")) { + if(EnableTypeSafeOpt) { + if(TS->isTypeSafe(I->getOperand(1), I->getParent()->getParent())) { + return true; + } + } CastInst *BCI = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy, "", I); std::vector Args; Args.push_back(BCI); @@ -880,7 +960,6 @@ Args.push_back(ConstantInt::get(Int64Ty, TD->getTypeStoreSize(LI.getType()))); Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); - // Create the call to the runtime check and place it before the load instruction. Constant *F = M.getOrInsertFunction("trackLoadInst", VoidTy, VoidPtrTy, Int8Ty, Int64Ty, Int32Ty, NULL); CallInst::Create(F, Args.begin(), Args.end(), "", &LI); From aggarwa4 at illinois.edu Thu May 12 16:53:19 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 12 May 2011 21:53:19 -0000 Subject: [llvm-commits] [poolalloc] r131251 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <20110512215319.5C4E52A6C12D@llvm.org> Author: aggarwa4 Date: Thu May 12 16:53:19 2011 New Revision: 131251 URL: http://llvm.org/viewvc/llvm-project?rev=131251&view=rev Log: Added support for handling va_arg in x86_64. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=131251&r1=131250&r2=131251&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Thu May 12 16:53:19 2011 @@ -415,20 +415,48 @@ } void GraphBuilder::visitVAArgInst(VAArgInst &I) { - assert(0 && "What frontend generates this?"); - //FIXME: also updates the argument - DSNodeHandle Ptr = getValueDest(I.getOperand(0)); - if (Ptr.isNull()) return; + Module *M = FB->getParent(); + Triple TargetTriple(M->getTargetTriple()); + Triple::ArchType Arch = TargetTriple.getArch(); + switch(Arch) { + case Triple::x86_64: { + // On x86_64, we have va_list as a struct {i32, i32, i8*, i8* } + // The first i8* is where arguments generally go, but the second i8* can + // be used also to pass arguments by register. + // We model this by having both the i8*'s point to an array of pointers + // to the arguments. + DSNodeHandle Ptr = G.getVANodeFor(*FB); + DSNodeHandle Dest = getValueDest(&I); + if (Ptr.isNull()) return; + + // Make that the node is read and written + Ptr.getNode()->setReadMarker()->setModifiedMarker(); + + // Not updating type info, as it is already a collapsed node + + if (isa(I.getType())) + Dest.mergeWith(Ptr); + return; + } - // Make that the node is read and written - Ptr.getNode()->setReadMarker()->setModifiedMarker(); + default: { + assert(0 && "What frontend generates this?"); + DSNodeHandle Ptr = getValueDest(I.getOperand(0)); - // Ensure a type record exists. - DSNode *PtrN = Ptr.getNode(); - PtrN->mergeTypeInfo(I.getType(), Ptr.getOffset()); + //FIXME: also updates the argument + if (Ptr.isNull()) return; - if (isa(I.getType())) - setDestTo(I, getLink(Ptr)); + // Make that the node is read and written + Ptr.getNode()->setReadMarker()->setModifiedMarker(); + + // Ensure a type record exists. + DSNode *PtrN = Ptr.getNode(); + PtrN->mergeTypeInfo(I.getType(), Ptr.getOffset()); + + if (isa(I.getType())) + setDestTo(I, getLink(Ptr)); + } + } } void GraphBuilder::visitIntToPtrInst(IntToPtrInst &I) { From gkistanova at gmail.com Thu May 12 16:55:35 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Thu, 12 May 2011 21:55:35 -0000 Subject: [llvm-commits] [llvm] r131252 - /llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll Message-ID: <20110512215535.1FC0B2A6C12C@llvm.org> Author: gkistanova Date: Thu May 12 16:55:34 2011 New Revision: 131252 URL: http://llvm.org/viewvc/llvm-project?rev=131252&view=rev Log: Correction. Use explicit target triple in the test. Modified: llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll Modified: llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll?rev=131252&r1=131251&r2=131252&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll Thu May 12 16:55:34 2011 @@ -1,4 +1,4 @@ -; RUN: llc -O1 -march=arm -mattr=+vfp2 -float-abi=hard < %s | FileCheck %s +; RUN: llc -O1 -march=arm -mattr=+vfp2 -mtriple=arm-linux-gnueabi < %s | FileCheck %s ; pr4939 define void @test(double* %x, double* %y) nounwind { From mcinally at cray.com Thu May 12 16:47:16 2011 From: mcinally at cray.com (Cameron McInally) Date: Thu, 12 May 2011 16:47:16 -0500 Subject: [llvm-commits] [PATCH] Error cannot be reached Message-ID: <4DCC5564.2060406@cray.com> A silly little patch for unreachable code. It's self-explanatory: mcinally/llvm> svn diff Index: utils/TableGen/CodeGenDAGPatterns.cpp =================================================================== --- utils/TableGen/CodeGenDAGPatterns.cpp (revision 131245) +++ utils/TableGen/CodeGenDAGPatterns.cpp (working copy) @@ -1732,7 +1732,7 @@ // Input argument? TreePatternNode *Res = new TreePatternNode(DI, 1); - if (R->getName() == "node" && !OpName.empty()) { + if (R->getName() == "node") { if (OpName.empty()) error("'node' argument requires a name to match with operand list"); Args.push_back(OpName); mcinally/llvm> svn info Path: . URL: http://llvm.org/svn/llvm-project/llvm/trunk Repository Root: http://llvm.org/svn/llvm-project Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8 Revision: 131241 Node Kind: directory Schedule: normal Last Changed Author: evancheng Last Changed Rev: 131241 Last Changed Date: 2011-05-12 15:30:01 -0500 (Thu, 12 May 2011) Thanks, Cameron From aggarwa4 at illinois.edu Thu May 12 17:35:15 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 12 May 2011 22:35:15 -0000 Subject: [llvm-commits] [poolalloc] r131257 - /poolalloc/trunk/test/dsa/var_arg/basic.ll Message-ID: <20110512223515.484CC2A6C12C@llvm.org> Author: aggarwa4 Date: Thu May 12 17:35:15 2011 New Revision: 131257 URL: http://llvm.org/viewvc/llvm-project?rev=131257&view=rev Log: Added an example with a va_arg instruction. I had to force the front end to generate it. Added: poolalloc/trunk/test/dsa/var_arg/basic.ll Added: poolalloc/trunk/test/dsa/var_arg/basic.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/var_arg/basic.ll?rev=131257&view=auto ============================================================================== --- poolalloc/trunk/test/dsa/var_arg/basic.ll (added) +++ poolalloc/trunk/test/dsa/var_arg/basic.ll Thu May 12 17:35:15 2011 @@ -0,0 +1,68 @@ +;XFAIL: * +; ModuleID = 'basic.o' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-unknown-linux-gnu" + +%struct.__va_list_tag = type { i32, i32, i8*, i8* } + +define internal i32 @get(i32 %unused, ...) nounwind { +entry: + %unused_addr = alloca i32 ; [#uses=1] + %retval = alloca i32 ; [#uses=2] + %0 = alloca i32 ; [#uses=2] + %ap = alloca [1 x %struct.__va_list_tag] ; <[1 x %struct.__va_list_tag]*> [#uses=4] + %val = alloca i32* ; [#uses=2] + %val1 = alloca i8* ; [#uses=1] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store i32 %unused, i32* %unused_addr + %ap1 = bitcast [1 x %struct.__va_list_tag]* %ap to %struct.__va_list_tag* ; <%struct.__va_list_tag*> [#uses=1] + %ap12 = bitcast %struct.__va_list_tag* %ap1 to i8* ; [#uses=1] + call void @llvm.va_start(i8* %ap12) + %ap3 = bitcast [1 x %struct.__va_list_tag]* %ap to %struct.__va_list_tag* ; <%struct.__va_list_tag*> [#uses=1] + %1 = va_arg %struct.__va_list_tag* %ap3, i32* ; [#uses=1] + store i32* %1, i32** %val, align 8 + %ap4 = bitcast [1 x %struct.__va_list_tag]* %ap to %struct.__va_list_tag* ; <%struct.__va_list_tag*> [#uses=1] + %2 = va_arg %struct.__va_list_tag* %ap4, i8* ; [#uses=1] + store i8* %2, i8** %val1, align 8 + %ap5 = bitcast [1 x %struct.__va_list_tag]* %ap to %struct.__va_list_tag* ; <%struct.__va_list_tag*> [#uses=1] + %ap56 = bitcast %struct.__va_list_tag* %ap5 to i8* ; [#uses=1] + call void @llvm.va_end(i8* %ap56) + %3 = load i32** %val, align 8 ; [#uses=1] + %4 = load i32* %3, align 4 ; [#uses=1] + store i32 %4, i32* %0, align 4 + %5 = load i32* %0, align 4 ; [#uses=1] + store i32 %5, i32* %retval, align 4 + br label %return + +return: ; preds = %entry + %retval7 = load i32* %retval ; [#uses=1] + ret i32 %retval7 +} + +declare void @llvm.va_start(i8*) nounwind + +declare void @llvm.va_end(i8*) nounwind + +define i32 @main() nounwind { +entry: + %retval = alloca i32 ; [#uses=2] + %0 = alloca i32 ; [#uses=2] + %stack_val = alloca i32 ; [#uses=2] + %stack_val1 = alloca i8 ; [#uses=2] + %ret = alloca i32 ; [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store i32 5, i32* %stack_val, align 4 + store i8 97, i8* %stack_val1, align 1 + %1 = call i32 (i32, ...)* @get(i32 0, i32* %stack_val, i8* %stack_val1) nounwind ; [#uses=1] + store i32 %1, i32* %ret, align 4 + %2 = load i32* %ret, align 4 ; [#uses=1] + %3 = sub nsw i32 %2, 5 ; [#uses=1] + store i32 %3, i32* %0, align 4 + %4 = load i32* %0, align 4 ; [#uses=1] + store i32 %4, i32* %retval, align 4 + br label %return + +return: ; preds = %entry + %retval1 = load i32* %retval ; [#uses=1] + ret i32 %retval1 +} From evan.cheng at apple.com Thu May 12 17:35:48 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 May 2011 22:35:48 -0000 Subject: [llvm-commits] [llvm] r131258 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp Message-ID: <20110512223548.A92102A6C12C@llvm.org> Author: evancheng Date: Thu May 12 17:35:48 2011 New Revision: 131258 URL: http://llvm.org/viewvc/llvm-project?rev=131258&view=rev Log: Update comment. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=131258&r1=131257&r2=131258&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Thu May 12 17:35:48 2011 @@ -1351,8 +1351,6 @@ /// HoistCommonCode - Hoist common instruction sequences at the start of basic /// blocks to their common predecessor. -/// NOTE: This optimization does not update live-in information so it must be -/// run after all passes that require correct liveness information. bool BranchFolder::HoistCommonCode(MachineFunction &MF) { bool MadeChange = false; for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ) { From stuart at apple.com Thu May 12 18:36:41 2011 From: stuart at apple.com (Stuart Hastings) Date: Thu, 12 May 2011 23:36:41 -0000 Subject: [llvm-commits] [llvm] r131261 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll Message-ID: <20110512233641.91FF32A6C12C@llvm.org> Author: stuart Date: Thu May 12 18:36:41 2011 New Revision: 131261 URL: http://llvm.org/viewvc/llvm-project?rev=131261&view=rev Log: Non-fast-isel followup to 129634; correctly handle branches controlled by non-CMP expressions. The executable test case (129821) would test this as well, if we had an "-O0 -disable-arm-fast-isel" LLVM-GCC tester. Alas, the ARM assembly would be very difficult to check with FileCheck. The thumb2-cbnz.ll test is affected; it generates larger code (tst.w vs. cmp #0), but I believe the new version is correct. rdar://problem/9298790 Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=131261&r1=131260&r2=131261&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu May 12 18:36:41 2011 @@ -3535,9 +3535,16 @@ Tmp2.getOperand(0), Tmp2.getOperand(1), Node->getOperand(2)); } else { + // We test only the i1 bit. Skip the AND if UNDEF. + Tmp3 = (Tmp2.getOpcode() == ISD::UNDEF || + (Tmp2.getOpcode() == ISD::AND && + Tmp2.getConstantOperandVal(1) == 1)) ? + Tmp2 : + DAG.getNode(ISD::AND, dl, Tmp2.getValueType(), Tmp2, + DAG.getConstant(1, Tmp2.getValueType())); Tmp1 = DAG.getNode(ISD::BR_CC, dl, MVT::Other, Tmp1, - DAG.getCondCode(ISD::SETNE), Tmp2, - DAG.getConstant(0, Tmp2.getValueType()), + DAG.getCondCode(ISD::SETNE), Tmp3, + DAG.getConstant(0, Tmp3.getValueType()), Node->getOperand(2)); } Results.push_back(Tmp1); Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll?rev=131261&r1=131260&r2=131261&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Thu May 12 18:36:41 2011 @@ -20,9 +20,10 @@ br i1 %a, label %bb11, label %bb9 bb9: ; preds = %bb7 -; CHECK: cmp r0, #0 -; CHECK: cmp r0, #0 -; CHECK-NEXT: cbnz +; CHECK: tst.w r0, #1 +; CHECK: tst.w r0, #1 +; CHECK: tst.w r0, #1 +; CHECK: bne %0 = tail call double @floor(double %b) nounwind readnone ; [#uses=0] br label %bb11 From aggarwa4 at illinois.edu Thu May 12 18:39:30 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 12 May 2011 23:39:30 -0000 Subject: [llvm-commits] [poolalloc] r131262 - in /poolalloc/trunk: lib/AssistDS/TypeChecks.cpp runtime/DynamicTypeChecks/TypeRuntime.c Message-ID: <20110512233930.C4B3F2A6C12C@llvm.org> Author: aggarwa4 Date: Thu May 12 18:39:30 2011 New Revision: 131262 URL: http://llvm.org/viewvc/llvm-project?rev=131262&view=rev Log: 1. We can ignore size in the runtime,because matching types ensures that. 2. Ensure that we only transform internal varargs functions Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=131262&r1=131261&r2=131262&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Thu May 12 18:39:30 2011 @@ -189,6 +189,8 @@ TypeChecks::visitVarArgFunction(Module &M, Function &F) { if(!F.isVarArg()) return false; + if(!F.hasInternalLinkage()) + return false; // FIXME:handle external functions // Find all uses of the function @@ -728,6 +730,9 @@ // Insert runtime check for va_arg instructions bool TypeChecks::visitVAArgInst(Module &M, VAArgInst &VI) { + Function *Func = VI.getParent()->getParent(); + if(!Func->hasInternalLinkage()) + return false; // FIXME:handle external functions // For every va_arg instruction, Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=131262&r1=131261&r2=131262&view=diff ============================================================================== --- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original) +++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Thu May 12 18:39:30 2011 @@ -99,7 +99,6 @@ * Check that the two types match */ void compareTypes(uint8_t typeNumberSrc, uint8_t typeNumberDest, uint32_t tag) { - //TODO:add size info if(typeNumberSrc != typeNumberDest) { printf("Type mismatch: detecting %u, expecting %u! %u \n", typeNumberDest, typeNumberSrc, tag); } From stuart at apple.com Thu May 12 19:10:03 2011 From: stuart at apple.com (Stuart Hastings) Date: Fri, 13 May 2011 00:10:03 -0000 Subject: [llvm-commits] [llvm] r131266 - /llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Message-ID: <20110513001003.860632A6C12C@llvm.org> Author: stuart Date: Thu May 12 19:10:03 2011 New Revision: 131266 URL: http://llvm.org/viewvc/llvm-project?rev=131266&view=rev Log: Tweak 131261 (thumb2-cbnz.ll) to generate the intended cbnz. rdar://problem/9298790 Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll?rev=131266&r1=131265&r2=131266&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Thu May 12 19:10:03 2011 @@ -3,27 +3,29 @@ declare double @floor(double) nounwind readnone -define void @t(i1 %a, double %b) { +define void @t(i32 %c, double %b) { entry: - br i1 %a, label %bb3, label %bb1 + %cmp1 = icmp ne i32 %c, 0 + br i1 %cmp1, label %bb3, label %bb1 bb1: ; preds = %entry unreachable bb3: ; preds = %entry - br i1 %a, label %bb7, label %bb5 + %cmp2 = icmp ne i32 %c, 0 + br i1 %cmp2, label %bb7, label %bb5 bb5: ; preds = %bb3 unreachable bb7: ; preds = %bb3 - br i1 %a, label %bb11, label %bb9 + %cmp3 = icmp ne i32 %c, 0 + br i1 %cmp3, label %bb11, label %bb9 bb9: ; preds = %bb7 -; CHECK: tst.w r0, #1 -; CHECK: tst.w r0, #1 -; CHECK: tst.w r0, #1 -; CHECK: bne +; CHECK: cmp r0, #0 +; CHECK: cmp r0, #0 +; CHECK-NEXT: cbnz %0 = tail call double @floor(double %b) nounwind readnone ; [#uses=0] br label %bb11 From stuart at apple.com Thu May 12 19:15:17 2011 From: stuart at apple.com (Stuart Hastings) Date: Fri, 13 May 2011 00:15:17 -0000 Subject: [llvm-commits] [llvm] r131269 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll Message-ID: <20110513001517.5B4BC2A6C12C@llvm.org> Author: stuart Date: Thu May 12 19:15:17 2011 New Revision: 131269 URL: http://llvm.org/viewvc/llvm-project?rev=131269&view=rev Log: Revert 131266 and 131261 due to buildbot complaints. rdar://problem/9298790 Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=131269&r1=131268&r2=131269&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu May 12 19:15:17 2011 @@ -3535,16 +3535,9 @@ Tmp2.getOperand(0), Tmp2.getOperand(1), Node->getOperand(2)); } else { - // We test only the i1 bit. Skip the AND if UNDEF. - Tmp3 = (Tmp2.getOpcode() == ISD::UNDEF || - (Tmp2.getOpcode() == ISD::AND && - Tmp2.getConstantOperandVal(1) == 1)) ? - Tmp2 : - DAG.getNode(ISD::AND, dl, Tmp2.getValueType(), Tmp2, - DAG.getConstant(1, Tmp2.getValueType())); Tmp1 = DAG.getNode(ISD::BR_CC, dl, MVT::Other, Tmp1, - DAG.getCondCode(ISD::SETNE), Tmp3, - DAG.getConstant(0, Tmp3.getValueType()), + DAG.getCondCode(ISD::SETNE), Tmp2, + DAG.getConstant(0, Tmp2.getValueType()), Node->getOperand(2)); } Results.push_back(Tmp1); Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll?rev=131269&r1=131268&r2=131269&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Thu May 12 19:15:17 2011 @@ -3,29 +3,26 @@ declare double @floor(double) nounwind readnone -define void @t(i32 %c, double %b) { +define void @t(i1 %a, double %b) { entry: - %cmp1 = icmp ne i32 %c, 0 - br i1 %cmp1, label %bb3, label %bb1 + br i1 %a, label %bb3, label %bb1 bb1: ; preds = %entry unreachable bb3: ; preds = %entry - %cmp2 = icmp ne i32 %c, 0 - br i1 %cmp2, label %bb7, label %bb5 + br i1 %a, label %bb7, label %bb5 bb5: ; preds = %bb3 unreachable bb7: ; preds = %bb3 - %cmp3 = icmp ne i32 %c, 0 - br i1 %cmp3, label %bb11, label %bb9 + br i1 %a, label %bb11, label %bb9 bb9: ; preds = %bb7 -; CHECK: cmp r0, #0 -; CHECK: cmp r0, #0 -; CHECK-NEXT: cbnz +; CHECK: cmp r0, #0 +; CHECK: cmp r0, #0 +; CHECK-NEXT: cbnz %0 = tail call double @floor(double %b) nounwind readnone ; [#uses=0] br label %bb11 From stuart at apple.com Thu May 12 19:51:54 2011 From: stuart at apple.com (Stuart Hastings) Date: Fri, 13 May 2011 00:51:54 -0000 Subject: [llvm-commits] [llvm] r131274 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll Message-ID: <20110513005154.F34E32A6C12C@llvm.org> Author: stuart Date: Thu May 12 19:51:54 2011 New Revision: 131274 URL: http://llvm.org/viewvc/llvm-project?rev=131274&view=rev Log: Since I can't reproduce the failures from 131261, re-trying with a simplified version. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=131274&r1=131273&r2=131274&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu May 12 19:51:54 2011 @@ -3535,9 +3535,13 @@ Tmp2.getOperand(0), Tmp2.getOperand(1), Node->getOperand(2)); } else { + // We test only the i1 bit. Skip the AND if UNDEF. + Tmp3 = (Tmp2.getOpcode() == ISD::UNDEF) ? Tmp2 : + DAG.getNode(ISD::AND, dl, Tmp2.getValueType(), Tmp2, + DAG.getConstant(1, Tmp2.getValueType())); Tmp1 = DAG.getNode(ISD::BR_CC, dl, MVT::Other, Tmp1, - DAG.getCondCode(ISD::SETNE), Tmp2, - DAG.getConstant(0, Tmp2.getValueType()), + DAG.getCondCode(ISD::SETNE), Tmp3, + DAG.getConstant(0, Tmp3.getValueType()), Node->getOperand(2)); } Results.push_back(Tmp1); Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll?rev=131274&r1=131273&r2=131274&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Thu May 12 19:51:54 2011 @@ -3,26 +3,29 @@ declare double @floor(double) nounwind readnone -define void @t(i1 %a, double %b) { +define void @t(i32 %c, double %b) { entry: - br i1 %a, label %bb3, label %bb1 + %cmp1 = icmp ne i32 %c, 0 + br i1 %cmp1, label %bb3, label %bb1 bb1: ; preds = %entry unreachable bb3: ; preds = %entry - br i1 %a, label %bb7, label %bb5 + %cmp2 = icmp ne i32 %c, 0 + br i1 %cmp2, label %bb7, label %bb5 bb5: ; preds = %bb3 unreachable bb7: ; preds = %bb3 - br i1 %a, label %bb11, label %bb9 + %cmp3 = icmp ne i32 %c, 0 + br i1 %cmp3, label %bb11, label %bb9 bb9: ; preds = %bb7 -; CHECK: cmp r0, #0 -; CHECK: cmp r0, #0 -; CHECK-NEXT: cbnz +; CHECK: cmp r0, #0 +; CHECK: cmp r0, #0 +; CHECK-NEXT: cbnz %0 = tail call double @floor(double %b) nounwind readnone ; [#uses=0] br label %bb11 From rafael.espindola at gmail.com Thu May 12 20:13:42 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Thu, 12 May 2011 21:13:42 -0400 Subject: [llvm-commits] [llvm] r131205 - in /llvm/trunk/lib/MC: ELFObjectWriter.cpp ELFObjectWriter.h In-Reply-To: <20110511225306.571622A6C12C@llvm.org> References: <20110511225306.571622A6C12C@llvm.org> Message-ID: <4DCC85C6.4070106@gmail.com> On 11-05-11 6:53 PM, Jason W Kim wrote: > Author: jasonwkim > Date: Wed May 11 17:53:06 2011 > New Revision: 131205 > > URL: http://llvm.org/viewvc/llvm-project?rev=131205&view=rev > Log: > Address the last bit of relocation flag related divergence betweeen > LLVM and binutils. > > With this patch, there are no functional differences between the .o > produced directly from LLVM versus the .s to .o via GNU as, for relocation tags > at least, for both PIC and non-PIC modes. > > Because some non-PIC reloc tags are used (legally) on PIC, so IsPCRel flag is > necessary but not sufficient to determine whether the overall codegen mode is > PIC or not. Why is this necessary? There is an incompatibility of how relocs > are emitted in the .rodata section. Binutils PIC likes to emit certain relocs > as section relative offsets. Non-PIC does not do this. > > So I added a hidden switch on the ELFObjectwriter "-arm-elf-force-pic" which > forces the objectwriter to pretend that all relocs are for PIC mode. > > > Todo: Activate ForceARMElfPIC to true if -relocation-model=pic is selected > on llc. > Is this ARM only? On X86 at least no flag is passed to the assembler indicating that a given file is PIC or not. Since the MC interface is isomorphic with the assembler, llc should not pass any flags to mc. Cheers, Rafael From atrick at apple.com Thu May 12 20:12:21 2011 From: atrick at apple.com (Andrew Trick) Date: Fri, 13 May 2011 01:12:21 -0000 Subject: [llvm-commits] [llvm] r131277 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <20110513011221.431A72A6C12C@llvm.org> Author: atrick Date: Thu May 12 20:12:21 2011 New Revision: 131277 URL: http://llvm.org/viewvc/llvm-project?rev=131277&view=rev Log: Convert SimplifyIVUsers into a worklist instead of a single pass over the users. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=131277&r1=131276&r2=131277&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Thu May 12 20:12:21 2011 @@ -458,7 +458,7 @@ /// loop. IVUsers is treated as a worklist. Each successive simplification may /// push more users which may themselves be candidates for simplification. void IndVarSimplify::SimplifyIVUsers() { - for (IVUsers::iterator I = IU->begin(), E = IU->end(); I != E; ++I) { + for (IVUsers::iterator I = IU->begin(); I != IU->end(); ++I) { Instruction *UseInst = I->getUser(); Value *IVOperand = I->getOperandValToReplace(); From peter at pcc.me.uk Thu May 12 22:27:56 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 13 May 2011 03:27:56 -0000 Subject: [llvm-commits] [llvm] r131279 - in /llvm/trunk: autoconf/configure.ac configure Message-ID: <20110513032756.BE84B2A6C12C@llvm.org> Author: pcc Date: Thu May 12 22:27:56 2011 New Revision: 131279 URL: http://llvm.org/viewvc/llvm-project?rev=131279&view=rev Log: Re-add the autoconf rule for the docs/doxygen.cfg file. For some reason this was not reverted when r103213 was. At the same time, add an optional rule for clang's doxygen.cfg. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/configure Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=131279&r1=131278&r2=131279&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Thu May 12 22:27:56 2011 @@ -1723,6 +1723,12 @@ dnl Configure the RPM spec file for LLVM AC_CONFIG_FILES([llvm.spec]) +dnl Configure doxygen's configuration file +AC_CONFIG_FILES([docs/doxygen.cfg]) +if test -f ${srcdir}/tools/clang/README.txt; then + AC_CONFIG_FILES([tools/clang/docs/doxygen.cfg]) +fi + dnl Configure llvmc's Base plugin AC_CONFIG_FILES([tools/llvmc/src/Base.td]) Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=131279&r1=131278&r2=131279&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Thu May 12 22:27:56 2011 @@ -22574,6 +22574,13 @@ ac_config_files="$ac_config_files llvm.spec" +ac_config_files="$ac_config_files docs/doxygen.cfg" + +if test -f ${srcdir}/tools/clang/README.txt; then + ac_config_files="$ac_config_files tools/clang/docs/doxygen.cfg" + +fi + ac_config_files="$ac_config_files tools/llvmc/src/Base.td" @@ -23194,6 +23201,8 @@ "include/llvm/Support/DataTypes.h") CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/Support/DataTypes.h" ;; "Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;; "llvm.spec") CONFIG_FILES="$CONFIG_FILES llvm.spec" ;; + "docs/doxygen.cfg") CONFIG_FILES="$CONFIG_FILES docs/doxygen.cfg" ;; + "tools/clang/docs/doxygen.cfg") CONFIG_FILES="$CONFIG_FILES tools/clang/docs/doxygen.cfg" ;; "tools/llvmc/src/Base.td") CONFIG_FILES="$CONFIG_FILES tools/llvmc/src/Base.td" ;; "tools/llvm-config/llvm-config.in") CONFIG_FILES="$CONFIG_FILES tools/llvm-config/llvm-config.in" ;; "setup") CONFIG_COMMANDS="$CONFIG_COMMANDS setup" ;; From clattner at apple.com Thu May 12 23:18:06 2011 From: clattner at apple.com (Chris Lattner) Date: Thu, 12 May 2011 21:18:06 -0700 Subject: [llvm-commits] [PATCH] Error cannot be reached In-Reply-To: <4DCC5564.2060406@cray.com> References: <4DCC5564.2060406@cray.com> Message-ID: <61B8F381-0482-4745-A404-29EEDF5C5A23@apple.com> On May 12, 2011, at 2:47 PM, Cameron McInally wrote: > A silly little patch for unreachable code. It's self-explanatory: How is that unreachable? OpName != R->getName() -Chris > > mcinally/llvm> svn diff > Index: utils/TableGen/CodeGenDAGPatterns.cpp > =================================================================== > --- utils/TableGen/CodeGenDAGPatterns.cpp (revision 131245) > +++ utils/TableGen/CodeGenDAGPatterns.cpp (working copy) > @@ -1732,7 +1732,7 @@ > > // Input argument? > TreePatternNode *Res = new TreePatternNode(DI, 1); > - if (R->getName() == "node" && !OpName.empty()) { > + if (R->getName() == "node") { > if (OpName.empty()) > error("'node' argument requires a name to match with operand > list"); > Args.push_back(OpName); > > mcinally/llvm> svn info > Path: . > URL: http://llvm.org/svn/llvm-project/llvm/trunk > Repository Root: http://llvm.org/svn/llvm-project > Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8 > Revision: 131241 > Node Kind: directory > Schedule: normal > Last Changed Author: evancheng > Last Changed Rev: 131241 > Last Changed Date: 2011-05-12 15:30:01 -0500 (Thu, 12 May 2011) > > Thanks, > Cameron > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From cdavis at mymail.mines.edu Thu May 12 23:21:10 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Thu, 12 May 2011 22:21:10 -0600 Subject: [llvm-commits] [PATCH] Error cannot be reached In-Reply-To: <61B8F381-0482-4745-A404-29EEDF5C5A23@apple.com> References: <4DCC5564.2060406@cray.com> <61B8F381-0482-4745-A404-29EEDF5C5A23@apple.com> Message-ID: <4DCCB1B6.2080206@mymail.mines.edu> On 5/12/11 10:18 PM, Chris Lattner wrote: > > On May 12, 2011, at 2:47 PM, Cameron McInally wrote: > >> A silly little patch for unreachable code. It's self-explanatory: > > How is that unreachable? OpName != R->getName() You may want to read the subject again: >> - if (R->getName() == "node" && !OpName.empty()) { >> + if (R->getName() == "node") { >> if (OpName.empty()) >> error("'node' argument requires a name to match with operand Chip From mcinally at cray.com Fri May 13 00:10:46 2011 From: mcinally at cray.com (Cameron McInally) Date: Fri, 13 May 2011 00:10:46 -0500 Subject: [llvm-commits] [PATCH] Error cannot be reached In-Reply-To: <61B8F381-0482-4745-A404-29EEDF5C5A23@apple.com> References: <4DCC5564.2060406@cray.com>, <61B8F381-0482-4745-A404-29EEDF5C5A23@apple.com> Message-ID: <455CB75527BC764BA1E62B31CE4D937C09B67887EE@CFEXMBX.americas.cray.com> Hey Chris, The code in trunk looks like this: if (R->getName() == "node" && !OpName.empty()) { //Let's call this (1) if (OpName.empty()) //Let's call this (2) error("'node' argument requires a name to match with operand list"); Args.push_back(OpName); } Unless the expression OpName.empty() has side-effects, which I am fairly confident that it does not, the call cannot evaluate to false at (1) and true at (2). I'm assuming that '==' has a higher precedence than '&&' in C++, but maybe I'm mistaken. Is that not correct? Essentially, this code sequence is: bool b = true; if(b) { if(!b) { printf("unreachable\n"); } } Cameron ________________________________________ From: Chris Lattner [clattner at apple.com] Sent: Thursday, May 12, 2011 11:18 PM To: Cameron McInally Cc: llvm-commits at cs.uiuc.edu Subject: Re: [llvm-commits] [PATCH] Error cannot be reached On May 12, 2011, at 2:47 PM, Cameron McInally wrote: > A silly little patch for unreachable code. It's self-explanatory: How is that unreachable? OpName != R->getName() -Chris > > mcinally/llvm> svn diff > Index: utils/TableGen/CodeGenDAGPatterns.cpp > =================================================================== > --- utils/TableGen/CodeGenDAGPatterns.cpp (revision 131245) > +++ utils/TableGen/CodeGenDAGPatterns.cpp (working copy) > @@ -1732,7 +1732,7 @@ > > // Input argument? > TreePatternNode *Res = new TreePatternNode(DI, 1); > - if (R->getName() == "node" && !OpName.empty()) { > + if (R->getName() == "node") { > if (OpName.empty()) > error("'node' argument requires a name to match with operand > list"); > Args.push_back(OpName); > > mcinally/llvm> svn info > Path: . > URL: http://llvm.org/svn/llvm-project/llvm/trunk > Repository Root: http://llvm.org/svn/llvm-project > Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8 > Revision: 131241 > Node Kind: directory > Schedule: normal > Last Changed Author: evancheng > Last Changed Rev: 131241 > Last Changed Date: 2011-05-12 15:30:01 -0500 (Thu, 12 May 2011) > > Thanks, > Cameron > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From jlerouge at apple.com Fri May 13 00:20:42 2011 From: jlerouge at apple.com (Julien Lerouge) Date: Fri, 13 May 2011 05:20:42 -0000 Subject: [llvm-commits] [llvm] r131283 - in /llvm/trunk: include/llvm/Analysis/FindUsedTypes.h lib/Analysis/IPA/FindUsedTypes.cpp lib/Target/CBackend/CBackend.cpp lib/Transforms/IPO/DeadTypeElimination.cpp Message-ID: <20110513052042.8992E2A6C12C@llvm.org> Author: jlerouge Date: Fri May 13 00:20:42 2011 New Revision: 131283 URL: http://llvm.org/viewvc/llvm-project?rev=131283&view=rev Log: Fix a source of non determinism in FindUsedTypes, use a SetVector instead of a set. rdar://9423996 Modified: llvm/trunk/include/llvm/Analysis/FindUsedTypes.h llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Transforms/IPO/DeadTypeElimination.cpp Modified: llvm/trunk/include/llvm/Analysis/FindUsedTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/FindUsedTypes.h?rev=131283&r1=131282&r2=131283&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/FindUsedTypes.h (original) +++ llvm/trunk/include/llvm/Analysis/FindUsedTypes.h Fri May 13 00:20:42 2011 @@ -14,8 +14,8 @@ #ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H #define LLVM_ANALYSIS_FINDUSEDTYPES_H +#include "llvm/ADT/SetVector.h" #include "llvm/Pass.h" -#include namespace llvm { @@ -23,7 +23,7 @@ class Value; class FindUsedTypes : public ModulePass { - std::set UsedTypes; + SetVector UsedTypes; public: static char ID; // Pass identification, replacement for typeid FindUsedTypes() : ModulePass(ID) { @@ -33,7 +33,7 @@ /// getTypes - After the pass has been run, return the set containing all of /// the types used in the module. /// - const std::set &getTypes() const { return UsedTypes; } + const SetVector &getTypes() const { return UsedTypes; } /// Print the types found in the module. If the optional Module parameter is /// passed in, then the types are printed symbolically if possible, using the Modified: llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp?rev=131283&r1=131282&r2=131283&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/FindUsedTypes.cpp Fri May 13 00:20:42 2011 @@ -32,7 +32,7 @@ void FindUsedTypes::IncorporateType(const Type *Ty) { // If ty doesn't already exist in the used types map, add it now, otherwise // return. - if (!UsedTypes.insert(Ty).second) return; // Already contain Ty. + if (!UsedTypes.insert(Ty)) return; // Already contain Ty. // Make sure to add any types this type references now. // @@ -94,7 +94,7 @@ // void FindUsedTypes::print(raw_ostream &OS, const Module *M) const { OS << "Types in use by this module:\n"; - for (std::set::const_iterator I = UsedTypes.begin(), + for (SetVector::const_iterator I = UsedTypes.begin(), E = UsedTypes.end(); I != E; ++I) { OS << " "; WriteTypeSymbolic(OS, *I, M); Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=131283&r1=131282&r2=131283&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Fri May 13 00:20:42 2011 @@ -373,7 +373,7 @@ /// bool CBackendNameAllUsedStructsAndMergeFunctions::runOnModule(Module &M) { // Get a set of types that are used by the program... - std::set UT = getAnalysis().getTypes(); + SetVector UT = getAnalysis().getTypes(); // Loop over the module symbol table, removing types from UT that are // already named, and removing names for types that are not used. @@ -390,11 +390,10 @@ TST.remove(I); } else { // If this is not used, remove it from the symbol table. - std::set::iterator UTI = UT.find(I->second); - if (UTI == UT.end()) + if (!UT.count(I->second)) TST.remove(I); else - UT.erase(UTI); // Only keep one name for this type. + UT.remove(I->second); // Only keep one name for this type. } } @@ -403,7 +402,7 @@ // bool Changed = false; unsigned RenameCounter = 0; - for (std::set::const_iterator I = UT.begin(), E = UT.end(); + for (SetVector::const_iterator I = UT.begin(), E = UT.end(); I != E; ++I) if ((*I)->isStructTy() || (*I)->isArrayTy()) { while (M.addTypeName("unnamed"+utostr(RenameCounter), *I)) Modified: llvm/trunk/lib/Transforms/IPO/DeadTypeElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadTypeElimination.cpp?rev=131283&r1=131282&r2=131283&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadTypeElimination.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/DeadTypeElimination.cpp Fri May 13 00:20:42 2011 @@ -83,7 +83,8 @@ bool Changed = false; TypeSymbolTable &ST = M.getTypeSymbolTable(); - std::set UsedTypes = getAnalysis().getTypes(); + const SetVector &T = getAnalysis().getTypes(); + std::set UsedTypes(T.begin(), T.end()); // Check the symbol table for superfluous type entries... // From baldrick at free.fr Fri May 13 02:57:05 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 13 May 2011 07:57:05 -0000 Subject: [llvm-commits] [dragonegg] r131288 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp Message-ID: <20110513075705.C1C682A6C12D@llvm.org> Author: baldrick Date: Fri May 13 02:57:05 2011 New Revision: 131288 URL: http://llvm.org/viewvc/llvm-project?rev=131288&view=rev Log: Rename UselesslyTypeConvert to TriviallyTypeConvert, and tighten it up: it should do nothing except for pointer types, because except for pointer types equivalent GCC middle-end scalar types map to the same LLVM type. Stop using this method when we know we are dealing with pointer types (just bitcast directly in that case). Modified: dragonegg/trunk/include/dragonegg/Internals.h dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/include/dragonegg/Internals.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=131288&r1=131287&r2=131288&view=diff ============================================================================== --- dragonegg/trunk/include/dragonegg/Internals.h (original) +++ dragonegg/trunk/include/dragonegg/Internals.h Fri May 13 02:57:05 2011 @@ -654,15 +654,16 @@ //===---------- EmitReg* - Convert register expression to LLVM ----------===// - /// UselesslyTypeConvert - The useless_type_conversion_p predicate implicitly - /// defines the GCC middle-end type system. For scalar GCC types inner_type - /// and outer_type, if 'useless_type_conversion_p(outer_type, inner_type)' is - /// true then the corresponding LLVM inner and outer types (see getRegType) - /// are equal except possibly if they are both pointer types (casts to 'void*' - /// are considered useless for example) or types derived from pointer types - /// (vector types with pointer element type are the only possibility here). - /// This method converts LLVM values of the inner type to the outer type. - Value *UselesslyTypeConvert(Value *V, const Type *Ty) { + /// TriviallyTypeConvert - Convert the given value to the given type, assuming + /// that the original and target types are LLVM register types that correspond + /// to GCC scalar types t1 and t2 satisfying useless_type_conversion_p(t1, t2) + /// or useless_type_conversion_p(t2, t1). + Value *TriviallyTypeConvert(Value *V, const Type *Ty) { + // If useless_type_conversion_p(t1, t2) holds then the corresponding LLVM + // register types are either equal or are both pointer types. + if (V->getType() == Ty) + return V; + assert(V->getType()->isPointerTy() && Ty->isPointerTy() && "Not trivial!"); return Builder.CreateBitCast(V, Ty); } Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131288&r1=131287&r2=131288&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Fri May 13 02:57:05 2011 @@ -5754,10 +5754,10 @@ LValue TreeToLLVM::EmitLV_INDIRECT_REF(tree exp) { // The lvalue is just the address. LValue LV = LValue(EmitRegister(TREE_OPERAND(exp, 0)), expr_align(exp) / 8); - // May need a useless type conversion (useless_type_conversion_p), for example - // when INDIRECT_REF is applied to a void*, resulting in a non-void type. - LV.Ptr = UselesslyTypeConvert(LV.Ptr, - ConvertType(TREE_TYPE(exp))->getPointerTo()); + // May need to change pointer type, for example when INDIRECT_REF is applied + // to a void*, resulting in a non-void type. + LV.Ptr = Builder.CreateBitCast(LV.Ptr, + ConvertType(TREE_TYPE(exp))->getPointerTo()); return LV; } @@ -5770,10 +5770,10 @@ if (!Alignment) Alignment = 8; assert(!(Alignment & 7) && "Alignment not in octets!"); LValue LV = LValue(EmitRegister(TREE_OPERAND(exp, 0)), Alignment / 8); - // May need a useless type conversion (useless_type_conversion_p), for example - // when INDIRECT_REF is applied to a void*, resulting in a non-void type. - LV.Ptr = UselesslyTypeConvert(LV.Ptr, - ConvertType(TREE_TYPE(exp))->getPointerTo()); + // May need to change pointer type, for example when MISALIGNED_INDIRECT_REF + // is applied to a void*, resulting in a non-void type. + LV.Ptr = Builder.CreateBitCast(LV.Ptr, + ConvertType(TREE_TYPE(exp))->getPointerTo()); return LV; } @@ -5854,8 +5854,8 @@ } // The result can be of a different pointer type even if we didn't advance it. - Ref.Ptr = UselesslyTypeConvert(Ref.Ptr, - ConvertType(TREE_TYPE(exp))->getPointerTo()); + Ref.Ptr = Builder.CreateBitCast(Ref.Ptr, + ConvertType(TREE_TYPE(exp))->getPointerTo()); return Ref; } @@ -6361,7 +6361,7 @@ /// The result is an i1 boolean. Value *TreeToLLVM::EmitCompare(tree lhs, tree rhs, unsigned code) { Value *LHS = EmitRegister(lhs); - Value *RHS = UselesslyTypeConvert(EmitRegister(rhs), LHS->getType()); + Value *RHS = TriviallyTypeConvert(EmitRegister(rhs), LHS->getType()); // Compute the LLVM opcodes corresponding to the GCC comparison. CmpInst::Predicate UIPred = CmpInst::BAD_ICMP_PREDICATE; @@ -6446,8 +6446,8 @@ unsigned UIPred, unsigned SIPred, unsigned FPPred, bool isMax) { const Type *Ty = getRegType(type); - Value *LHS = UselesslyTypeConvert(EmitRegister(op0), Ty); - Value *RHS = UselesslyTypeConvert(EmitRegister(op1), Ty); + Value *LHS = TriviallyTypeConvert(EmitRegister(op0), Ty); + Value *RHS = TriviallyTypeConvert(EmitRegister(op1), Ty); Value *Compare; if (FLOAT_TYPE_P(type)) @@ -6763,7 +6763,7 @@ Builder.CreateInBoundsGEP(Ptr, Idx) : Builder.CreateGEP(Ptr, Idx); // The result may be of a different pointer type. - return UselesslyTypeConvert(GEP, getRegType(type)); + return Builder.CreateBitCast(GEP, getRegType(type)); } Value *TreeToLLVM::EmitReg_RDIV_EXPR(tree op0, tree op1) { @@ -8128,8 +8128,8 @@ /// WriteScalarToLHS - Store RHS, a non-aggregate value, into the given LHS. void TreeToLLVM::WriteScalarToLHS(tree lhs, Value *RHS) { - // Perform a useless type conversion (useless_type_conversion_p). - RHS = UselesslyTypeConvert(RHS, getRegType(TREE_TYPE(lhs))); + // May need a useless type conversion (useless_type_conversion_p). + RHS = TriviallyTypeConvert(RHS, getRegType(TREE_TYPE(lhs))); // If this is the definition of an ssa name, record it in the SSANames map. if (TREE_CODE(lhs) == SSA_NAME) { From baldrick at free.fr Fri May 13 07:33:32 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 13 May 2011 12:33:32 -0000 Subject: [llvm-commits] [dragonegg] r131289 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp Message-ID: <20110513123332.EE8F92A6C12C@llvm.org> Author: baldrick Date: Fri May 13 07:33:32 2011 New Revision: 131289 URL: http://llvm.org/viewvc/llvm-project?rev=131289&view=rev Log: A bunch of places did not really need to be passed the return type. Modified: dragonegg/trunk/include/dragonegg/Internals.h dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/include/dragonegg/Internals.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=131289&r1=131288&r2=131289&view=diff ============================================================================== --- dragonegg/trunk/include/dragonegg/Internals.h (original) +++ dragonegg/trunk/include/dragonegg/Internals.h Fri May 13 07:33:32 2011 @@ -691,9 +691,8 @@ Value *EmitCompare(tree_node *lhs, tree_node *rhs, unsigned code); // Binary expressions. - Value *EmitReg_MinMaxExpr(tree_node *type, tree_node *op0, tree_node *op1, - unsigned UIPred, unsigned SIPred, unsigned Opc, - bool isMax); + Value *EmitReg_MinMaxExpr(tree_node *op0, tree_node *op1, unsigned UIPred, + unsigned SIPred, unsigned Opc); Value *EmitReg_RotateOp(tree_node *type, tree_node *op0, tree_node *op1, unsigned Opc1, unsigned Opc2); Value *EmitReg_ShiftOp(tree_node *op0, tree_node *op1, unsigned Opc); @@ -702,20 +701,16 @@ Value *EmitReg_BIT_AND_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_BIT_IOR_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_BIT_XOR_EXPR(tree_node *op0, tree_node *op1); - Value *EmitReg_CEIL_DIV_EXPR(tree_node *type, tree_node *op0, tree_node *op1); + Value *EmitReg_CEIL_DIV_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_COMPLEX_EXPR(tree_node *op0, tree_node *op1); - Value *EmitReg_FLOOR_DIV_EXPR(tree_node *type, tree_node *op0, - tree_node *op1); - Value *EmitReg_FLOOR_MOD_EXPR(tree_node *type, tree_node *op0, - tree_node *op1); + Value *EmitReg_FLOOR_DIV_EXPR(tree_node *op0, tree_node *op1); + Value *EmitReg_FLOOR_MOD_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_MINUS_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_MULT_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_PLUS_EXPR(tree_node *op0, tree_node *op1); - Value *EmitReg_POINTER_PLUS_EXPR(tree_node *type, tree_node *op0, - tree_node *op1); + Value *EmitReg_POINTER_PLUS_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_RDIV_EXPR(tree_node *op0, tree_node *op1); - Value *EmitReg_ROUND_DIV_EXPR(tree_node *type, tree_node *op0, - tree_node *op1); + Value *EmitReg_ROUND_DIV_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_TRUNC_DIV_EXPR(tree_node *op0, tree_node *op1, bool isExact); Value *EmitReg_TRUNC_MOD_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_VEC_EXTRACT_EVEN_EXPR(tree_node *op0, tree_node *op1); Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131289&r1=131288&r2=131289&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Fri May 13 07:33:32 2011 @@ -6442,22 +6442,20 @@ return Builder.CreateICmp(pred, LHS, RHS); } -Value *TreeToLLVM::EmitReg_MinMaxExpr(tree type, tree op0, tree op1, - unsigned UIPred, unsigned SIPred, - unsigned FPPred, bool isMax) { - const Type *Ty = getRegType(type); - Value *LHS = TriviallyTypeConvert(EmitRegister(op0), Ty); - Value *RHS = TriviallyTypeConvert(EmitRegister(op1), Ty); +Value *TreeToLLVM::EmitReg_MinMaxExpr(tree op0, tree op1, unsigned UIPred, + unsigned SIPred, unsigned FPPred) { + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); Value *Compare; - if (FLOAT_TYPE_P(type)) + if (FLOAT_TYPE_P(TREE_TYPE(op0))) Compare = Builder.CreateFCmp(FCmpInst::Predicate(FPPred), LHS, RHS); - else if (TYPE_UNSIGNED(type)) + else if (TYPE_UNSIGNED(TREE_TYPE(op1))) Compare = Builder.CreateICmp(ICmpInst::Predicate(UIPred), LHS, RHS); else Compare = Builder.CreateICmp(ICmpInst::Predicate(SIPred), LHS, RHS); - return Builder.CreateSelect(Compare, LHS, RHS, isMax ? "max" : "min"); + return Builder.CreateSelect(Compare, LHS, RHS); } Value *TreeToLLVM::EmitReg_RotateOp(tree type, tree op0, tree op1, @@ -6510,7 +6508,7 @@ return Builder.CreateZExt(Res, getRegType(type)); } -Value *TreeToLLVM::EmitReg_CEIL_DIV_EXPR(tree type, tree op0, tree op1) { +Value *TreeToLLVM::EmitReg_CEIL_DIV_EXPR(tree op0, tree op1) { // Notation: CEIL_DIV_EXPR <-> CDiv, TRUNC_DIV_EXPR <-> Div. // CDiv calculates LHS/RHS by rounding up to the nearest integer. In terms @@ -6519,7 +6517,7 @@ // LHS CDiv RHS = (LHS - Sign(RHS)) Div RHS + 1 // otherwise. - const Type *Ty = getRegType(type); + const Type *Ty = getRegType(TREE_TYPE(op0)); Constant *Zero = ConstantInt::get(Ty, 0); Constant *One = ConstantInt::get(Ty, 1); Constant *MinusOne = Constant::getAllOnesValue(Ty); @@ -6527,7 +6525,7 @@ Value *LHS = EmitRegister(op0); Value *RHS = EmitRegister(op1); - if (!TYPE_UNSIGNED(type)) { + if (!TYPE_UNSIGNED(TREE_TYPE(op0))) { // In the case of signed arithmetic, we calculate CDiv as follows: // LHS CDiv RHS = (LHS - Sign(RHS) * Offset) Div RHS + Offset, // where Offset is 1 if LHS and RHS have the same sign and LHS is @@ -6591,7 +6589,7 @@ return CreateComplex(EmitRegister(op0), EmitRegister(op1)); } -Value *TreeToLLVM::EmitReg_FLOOR_DIV_EXPR(tree type, tree op0, tree op1) { +Value *TreeToLLVM::EmitReg_FLOOR_DIV_EXPR(tree op0, tree op1) { // Notation: FLOOR_DIV_EXPR <-> FDiv, TRUNC_DIV_EXPR <-> Div. Value *LHS = EmitRegister(op0); Value *RHS = EmitRegister(op1); @@ -6602,12 +6600,12 @@ // LHS FDiv RHS = (LHS + Sign(RHS)) Div RHS - 1 // otherwise. - if (TYPE_UNSIGNED(type)) + if (TYPE_UNSIGNED(TREE_TYPE(op0))) // In the case of unsigned arithmetic, LHS and RHS necessarily have the // same sign, so FDiv is the same as Div. return Builder.CreateUDiv(LHS, RHS, "fdiv"); - const Type *Ty = getRegType(type); + const Type *Ty = getRegType(TREE_TYPE(op0)); Constant *Zero = ConstantInt::get(Ty, 0); Constant *One = ConstantInt::get(Ty, 1); Constant *MinusOne = Constant::getAllOnesValue(Ty); @@ -6640,7 +6638,7 @@ return Builder.CreateSub(FDiv, Offset, "fdiv"); } -Value *TreeToLLVM::EmitReg_FLOOR_MOD_EXPR(tree type, tree op0, tree op1) { +Value *TreeToLLVM::EmitReg_FLOOR_MOD_EXPR(tree op0, tree op1) { // Notation: FLOOR_MOD_EXPR <-> Mod, TRUNC_MOD_EXPR <-> Rem. Value *LHS = EmitRegister(op0); @@ -6650,11 +6648,11 @@ // or the values of LHS and RHS have the same sign, then Mod equals Rem. // Otherwise Mod equals Rem + RHS. This means that LHS Mod RHS traps iff // LHS Rem RHS traps. - if (TYPE_UNSIGNED(type)) + if (TYPE_UNSIGNED(TREE_TYPE(op0))) // LHS and RHS values must have the same sign if their type is unsigned. return Builder.CreateURem(LHS, RHS); - const Type *Ty = getRegType(type); + const Type *Ty = getRegType(TREE_TYPE(op0)); Constant *Zero = ConstantInt::get(Ty, 0); // The two possible values for Mod. @@ -6753,17 +6751,14 @@ return CreateAnyAdd(LHS, RHS, type); } -Value *TreeToLLVM::EmitReg_POINTER_PLUS_EXPR(tree type, tree op0, tree op1) { +Value *TreeToLLVM::EmitReg_POINTER_PLUS_EXPR(tree op0, tree op1) { Value *Ptr = EmitRegister(op0); // The pointer. Value *Idx = EmitRegister(op1); // The offset in units. // Convert the pointer into an i8* and add the offset to it. Ptr = Builder.CreateBitCast(Ptr, GetUnitPointerType(Context)); - Value *GEP = POINTER_TYPE_OVERFLOW_UNDEFINED ? + return POINTER_TYPE_OVERFLOW_UNDEFINED ? Builder.CreateInBoundsGEP(Ptr, Idx) : Builder.CreateGEP(Ptr, Idx); - - // The result may be of a different pointer type. - return Builder.CreateBitCast(GEP, getRegType(type)); } Value *TreeToLLVM::EmitReg_RDIV_EXPR(tree op0, tree op1) { @@ -6800,7 +6795,7 @@ return Builder.CreateFDiv(LHS, RHS); } -Value *TreeToLLVM::EmitReg_ROUND_DIV_EXPR(tree type, tree op0, tree op1) { +Value *TreeToLLVM::EmitReg_ROUND_DIV_EXPR(tree op0, tree op1) { // Notation: ROUND_DIV_EXPR <-> RDiv, TRUNC_DIV_EXPR <-> Div. // RDiv calculates LHS/RHS by rounding to the nearest integer. Ties @@ -6813,14 +6808,14 @@ // required to ensure correct results. The details depend on whether // we are doing signed or unsigned arithmetic. - const Type *Ty = getRegType(type); + const Type *Ty = getRegType(TREE_TYPE(op0)); Constant *Zero = ConstantInt::get(Ty, 0); Constant *Two = ConstantInt::get(Ty, 2); Value *LHS = EmitRegister(op0); Value *RHS = EmitRegister(op1); - if (!TYPE_UNSIGNED(type)) { + if (!TYPE_UNSIGNED(TREE_TYPE(op0))) { // In the case of signed arithmetic, we calculate RDiv as follows: // LHS RDiv RHS = (sign) ( (|LHS| + (|RHS| UDiv 2)) UDiv |RHS| ), // where sign is +1 if LHS and RHS have the same sign, -1 if their @@ -7961,15 +7956,15 @@ case BIT_XOR_EXPR: RHS = EmitReg_BIT_XOR_EXPR(rhs1, rhs2); break; case CEIL_DIV_EXPR: - RHS = EmitReg_CEIL_DIV_EXPR(type, rhs1, rhs2); break; + RHS = EmitReg_CEIL_DIV_EXPR(rhs1, rhs2); break; case COMPLEX_EXPR: RHS = EmitReg_COMPLEX_EXPR(rhs1, rhs2); break; case EXACT_DIV_EXPR: RHS = EmitReg_TRUNC_DIV_EXPR(rhs1, rhs2, /*isExact*/true); break; case FLOOR_DIV_EXPR: - RHS = EmitReg_FLOOR_DIV_EXPR(type, rhs1, rhs2); break; + RHS = EmitReg_FLOOR_DIV_EXPR(rhs1, rhs2); break; case FLOOR_MOD_EXPR: - RHS = EmitReg_FLOOR_MOD_EXPR(type, rhs1, rhs2); break; + RHS = EmitReg_FLOOR_MOD_EXPR(rhs1, rhs2); break; case LROTATE_EXPR: RHS = EmitReg_RotateOp(type, rhs1, rhs2, Instruction::Shl, Instruction::LShr); @@ -7977,12 +7972,12 @@ case LSHIFT_EXPR: RHS = EmitReg_ShiftOp(rhs1, rhs2, Instruction::Shl); break; case MAX_EXPR: - RHS = EmitReg_MinMaxExpr(type, rhs1, rhs2, ICmpInst::ICMP_UGE, - ICmpInst::ICMP_SGE, FCmpInst::FCMP_OGE, true); + RHS = EmitReg_MinMaxExpr(rhs1, rhs2, ICmpInst::ICMP_UGE, ICmpInst::ICMP_SGE, + FCmpInst::FCMP_OGE); break; case MIN_EXPR: - RHS = EmitReg_MinMaxExpr(type, rhs1, rhs2, ICmpInst::ICMP_ULE, - ICmpInst::ICMP_SLE, FCmpInst::FCMP_OLE, false); + RHS = EmitReg_MinMaxExpr(rhs1, rhs2, ICmpInst::ICMP_ULE, ICmpInst::ICMP_SLE, + FCmpInst::FCMP_OLE); break; case MINUS_EXPR: RHS = EmitReg_MINUS_EXPR(rhs1, rhs2); break; @@ -7991,11 +7986,11 @@ case PLUS_EXPR: RHS = EmitReg_PLUS_EXPR(rhs1, rhs2); break; case POINTER_PLUS_EXPR: - RHS = EmitReg_POINTER_PLUS_EXPR(type, rhs1, rhs2); break; + RHS = EmitReg_POINTER_PLUS_EXPR(rhs1, rhs2); break; case RDIV_EXPR: RHS = EmitReg_RDIV_EXPR(rhs1, rhs2); break; case ROUND_DIV_EXPR: - RHS = EmitReg_ROUND_DIV_EXPR(type, rhs1, rhs2); break; + RHS = EmitReg_ROUND_DIV_EXPR(rhs1, rhs2); break; case RROTATE_EXPR: RHS = EmitReg_RotateOp(type, rhs1, rhs2, Instruction::LShr, Instruction::Shl); @@ -8030,8 +8025,7 @@ RHS = EmitReg_VEC_UNPACK_LO_EXPR(type, rhs1); break; } - assert(RHS->getType() == getRegType(type) && "RHS has wrong type!"); - return RHS; + return TriviallyTypeConvert(RHS, getRegType(type)); } /// EmitAssignSingleRHS - Helper for EmitAssignRHS. Handles those RHS that are From baldrick at free.fr Fri May 13 10:04:04 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 13 May 2011 15:04:04 -0000 Subject: [llvm-commits] [dragonegg] r131293 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp Message-ID: <20110513150404.9C8DD2A6C12C@llvm.org> Author: baldrick Date: Fri May 13 10:04:04 2011 New Revision: 131293 URL: http://llvm.org/viewvc/llvm-project?rev=131293&view=rev Log: Add support for REDUC_MAX_EXPR and REDUC_MIN_EXPR which may be formed by the GCC tree vectorizer. Modified: dragonegg/trunk/include/dragonegg/Internals.h dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/include/dragonegg/Internals.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=131293&r1=131292&r2=131293&view=diff ============================================================================== --- dragonegg/trunk/include/dragonegg/Internals.h (original) +++ dragonegg/trunk/include/dragonegg/Internals.h Fri May 13 10:04:04 2011 @@ -693,6 +693,8 @@ // Binary expressions. Value *EmitReg_MinMaxExpr(tree_node *op0, tree_node *op1, unsigned UIPred, unsigned SIPred, unsigned Opc); + Value *EmitReg_ReducMinMaxExpr(tree_node *op, unsigned UIPred, + unsigned SIPred, unsigned Opc); Value *EmitReg_RotateOp(tree_node *type, tree_node *op0, tree_node *op1, unsigned Opc1, unsigned Opc2); Value *EmitReg_ShiftOp(tree_node *op0, tree_node *op1, unsigned Opc); @@ -876,6 +878,18 @@ void StoreRegisterToMemory(Value *V, MemRef Loc, tree_node *type, LLVMBuilder &Builder); + /// VectorHighElements - Return a vector of half the length, consisting of the + /// elements of the given vector with indices in the top half. + Value *VectorHighElements(Value *Vec); + + /// VectorLowElements - Return a vector of half the length, consisting of the + /// elements of the given vector with indices in the bottom half. + Value *VectorLowElements(Value *Vec); + + /// ReducMinMaxExprHelper - Split the given vector in two and form the max/min + /// of the two pieces; repeat recursively on the result until scalar. + Value *ReducMinMaxExprHelper(Value *Op, CmpInst::Predicate Pred); + private: // Optional target defined builtin intrinsic expanding function. bool TargetIntrinsicLower(gimple_statement_d *stmt, Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131293&r1=131292&r2=131293&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Fri May 13 10:04:04 2011 @@ -6200,6 +6200,36 @@ SI->setAlignment(Loc.getAlignment()); } +/// VectorHighElements - Return a vector of half the length, consisting of the +/// elements of the given vector with indices in the top half. +Value *TreeToLLVM::VectorHighElements(Value *Vec) { + const VectorType *Ty = cast(Vec->getType()); + assert(!(Ty->getNumElements() & 1) && "Vector has odd number of elements!"); + unsigned NumElts = Ty->getNumElements() / 2; + SmallVector Mask; + Mask.reserve(NumElts); + const Type *Int32Ty = Type::getInt32Ty(Context); + for (unsigned i = 0; i != NumElts; ++i) + Mask.push_back(ConstantInt::get(Int32Ty, NumElts + i)); + return Builder.CreateShuffleVector(Vec, UndefValue::get(Ty), + ConstantVector::get(Mask)); +} + +/// VectorLowElements - Return a vector of half the length, consisting of the +/// elements of the given vector with indices in the bottom half. +Value *TreeToLLVM::VectorLowElements(Value *Vec) { + const VectorType *Ty = cast(Vec->getType()); + assert(!(Ty->getNumElements() & 1) && "Vector has odd number of elements!"); + unsigned NumElts = Ty->getNumElements() / 2; + SmallVector Mask; + Mask.reserve(NumElts); + const Type *Int32Ty = Type::getInt32Ty(Context); + for (unsigned i = 0; i != NumElts; ++i) + Mask.push_back(ConstantInt::get(Int32Ty, i)); + return Builder.CreateShuffleVector(Vec, UndefValue::get(Ty), + ConstantVector::get(Mask)); +} + //===----------------------------------------------------------------------===// // ... EmitReg* - Convert register expression to LLVM... @@ -6458,6 +6488,58 @@ return Builder.CreateSelect(Compare, LHS, RHS); } +/// ReducMinMaxExprHelper - Split the given vector in two and form the max/min +/// of the two pieces; repeat recursively on the result until scalar. +Value *TreeToLLVM::ReducMinMaxExprHelper(Value *Op, CmpInst::Predicate Pred) { + const VectorType *Ty = cast(Op->getType()); + unsigned NumElts = Ty->getNumElements(); + assert(NumElts > 1 && !(NumElts & (NumElts - 1)) && + "Number of vector elements is not a power of 2!"); + + if (NumElts == 2) { + // Extract each of the two elements and return the max/min of them. + const Type *Int32Ty = Type::getInt32Ty(Context); + Value *LHS = Builder.CreateExtractElement(Op, ConstantInt::get(Int32Ty, 0)); + Value *RHS = Builder.CreateExtractElement(Op, ConstantInt::get(Int32Ty, 1)); + Value *Compare = CmpInst::isFPPredicate(Pred) ? + Builder.CreateFCmp(Pred, LHS, RHS) : Builder.CreateICmp(Pred, LHS, RHS); + return Builder.CreateSelect(Compare, LHS, RHS); + } + + // Recursively extract the high and low halves of the vector and take the + // max/min of them. Using vector select like this results in better code + // if the target supports it for at least one of the resulting vector sizes. + Value *LHS = VectorLowElements(Op), *RHS = VectorHighElements(Op); + Value *Compare = CmpInst::isFPPredicate(Pred) ? + Builder.CreateFCmp(Pred, LHS, RHS) : Builder.CreateICmp(Pred, LHS, RHS); + Op = Builder.CreateSelect(Compare, LHS, RHS); + return ReducMinMaxExprHelper(Op, Pred); +} + +Value *TreeToLLVM::EmitReg_ReducMinMaxExpr(tree op, unsigned UIPred, + unsigned SIPred, unsigned FPPred) { + // Use a divide and conquer scheme that results in the same code as the simple + // scalar implementation on targets that don't support vector select but gives + // better code if vector select is present. + // For example, reduc-max becomes + // v = max , <- vector select + // m = max float v0, float v1 <- scalar select; v = + // The final result, m, equals max(max(x0,x2),max(x1,x3)) = max(x0,x1,x2,x3). + Value *Val = EmitRegister(op); + Value *Res; + if (FLOAT_TYPE_P(TREE_TYPE(op))) + Res = ReducMinMaxExprHelper(Val, CmpInst::Predicate(FPPred)); + else if (TYPE_UNSIGNED(TREE_TYPE(op))) + Res = ReducMinMaxExprHelper(Val, CmpInst::Predicate(UIPred)); + else + Res = ReducMinMaxExprHelper(Val, CmpInst::Predicate(SIPred)); + + // The result is vector with the max/min as first element. + return Builder.CreateInsertElement(UndefValue::get(Val->getType()), Res, + ConstantInt::get(Type::getInt32Ty(Context), + 0)); +} + Value *TreeToLLVM::EmitReg_RotateOp(tree type, tree op0, tree op1, unsigned Opc1, unsigned Opc2) { Value *In = EmitRegister(op0); @@ -7011,13 +7093,7 @@ Value *Op = EmitRegister(op0); // Extract the high elements, eg: <4 x float> -> <2 x float>. - unsigned Length = TYPE_VECTOR_SUBPARTS(type); - SmallVector Mask; - Mask.reserve(Length); - for (unsigned i = 0; i != Length; ++i) - Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), Length + i)); - Op = Builder.CreateShuffleVector(Op, UndefValue::get(Op->getType()), - ConstantVector::get(Mask)); + Op = VectorHighElements(Op); // Extend the input elements to the output element type, eg: <2 x float> // -> <2 x double>. @@ -7034,13 +7110,7 @@ Value *Op = EmitRegister(op0); // Extract the low elements, eg: <4 x float> -> <2 x float>. - unsigned Length = TYPE_VECTOR_SUBPARTS(type); - SmallVector Mask; - Mask.reserve(Length); - for (unsigned i = 0; i != Length; ++i) - Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), i)); - Op = Builder.CreateShuffleVector(Op, UndefValue::get(Op->getType()), - ConstantVector::get(Mask)); + Op = VectorLowElements(Op); // Extend the input elements to the output element type, eg: <2 x float> // -> <2 x double>. @@ -7989,6 +8059,14 @@ RHS = EmitReg_POINTER_PLUS_EXPR(rhs1, rhs2); break; case RDIV_EXPR: RHS = EmitReg_RDIV_EXPR(rhs1, rhs2); break; + case REDUC_MAX_EXPR: + RHS = EmitReg_ReducMinMaxExpr(rhs1, ICmpInst::ICMP_UGE, ICmpInst::ICMP_SGE, + FCmpInst::FCMP_OGE); + break; + case REDUC_MIN_EXPR: + RHS = EmitReg_ReducMinMaxExpr(rhs1, ICmpInst::ICMP_ULE, ICmpInst::ICMP_SLE, + FCmpInst::FCMP_OLE); + break; case ROUND_DIV_EXPR: RHS = EmitReg_ROUND_DIV_EXPR(rhs1, rhs2); break; case RROTATE_EXPR: From rafael.espindola at gmail.com Fri May 13 10:18:06 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 13 May 2011 15:18:06 -0000 Subject: [llvm-commits] [llvm] r131294 - in /llvm/trunk: include/llvm/Type.h lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp lib/VMCore/Type.cpp test/CodeGen/Generic/zero-sized-array.ll Message-ID: <20110513151806.9B19E2A6C12D@llvm.org> Author: rafael Date: Fri May 13 10:18:06 2011 New Revision: 131294 URL: http://llvm.org/viewvc/llvm-project?rev=131294&view=rev Log: Make codegen able to handle values of empty types. This is one way to fix PR9900. I will keep it open until sable is able to comment on it. Added: llvm/trunk/test/CodeGen/Generic/zero-sized-array.ll Modified: llvm/trunk/include/llvm/Type.h llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/include/llvm/Type.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Type.h?rev=131294&r1=131293&r2=131294&view=diff ============================================================================== --- llvm/trunk/include/llvm/Type.h (original) +++ llvm/trunk/include/llvm/Type.h Fri May 13 10:18:06 2011 @@ -273,6 +273,9 @@ /// @brief Determine if this type could be losslessly bitcast to Ty bool canLosslesslyBitCastTo(const Type *Ty) const; + /// isEmptyTy - Return true if this type is empty, that is, it has no + /// elements or all its elements are empty. + bool isEmptyTy() const; /// Here are some useful little methods to query what type derived types are /// Note that all other types can just compare to see if this == Type::xxxTy; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=131294&r1=131293&r2=131294&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Fri May 13 10:18:06 2011 @@ -155,6 +155,10 @@ const PHINode *PN = dyn_cast(I); ++I) { if (PN->use_empty()) continue; + // Skip empty types + if (PN->getType()->isEmptyTy()) + continue; + DebugLoc DL = PN->getDebugLoc(); unsigned PHIReg = ValueMap[PN]; assert(PHIReg && "PHI node does not have an assigned virtual register!"); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=131294&r1=131293&r2=131294&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri May 13 10:18:06 2011 @@ -1175,6 +1175,10 @@ /// created for it, emit nodes to copy the value into the virtual /// registers. void SelectionDAGBuilder::CopyToExportRegsIfNeeded(const Value *V) { + // Skip empty types + if (V->getType()->isEmptyTy()) + return; + DenseMap::iterator VMI = FuncInfo.ValueMap.find(V); if (VMI != FuncInfo.ValueMap.end()) { assert(!V->use_empty() && "Unused value assigned virtual registers!"); @@ -2810,16 +2814,18 @@ SmallVector Values(NumAggValues); SDValue Agg = getValue(Op0); - SDValue Val = getValue(Op1); unsigned i = 0; // Copy the beginning value(s) from the original aggregate. for (; i != LinearIndex; ++i) Values[i] = IntoUndef ? DAG.getUNDEF(AggValueVTs[i]) : SDValue(Agg.getNode(), Agg.getResNo() + i); // Copy values from the inserted value(s). - for (; i != LinearIndex + NumValValues; ++i) - Values[i] = FromUndef ? DAG.getUNDEF(AggValueVTs[i]) : - SDValue(Val.getNode(), Val.getResNo() + i - LinearIndex); + if (NumValValues) { + SDValue Val = getValue(Op1); + for (; i != LinearIndex + NumValValues; ++i) + Values[i] = FromUndef ? DAG.getUNDEF(AggValueVTs[i]) : + SDValue(Val.getNode(), Val.getResNo() + i - LinearIndex); + } // Copy remaining value(s) from the original aggregate. for (; i != NumAggValues; ++i) Values[i] = IntoUndef ? DAG.getUNDEF(AggValueVTs[i]) : @@ -2842,6 +2848,13 @@ ComputeValueVTs(TLI, ValTy, ValValueVTs); unsigned NumValValues = ValValueVTs.size(); + + // Ignore a extractvalue that produces an empty object + if (!NumValValues) { + setValue(&I, DAG.getUNDEF(MVT(MVT::Other))); + return; + } + SmallVector Values(NumValValues); SDValue Agg = getValue(Op0); @@ -4827,8 +4840,14 @@ for (ImmutableCallSite::arg_iterator i = CS.arg_begin(), e = CS.arg_end(); i != e; ++i) { - SDValue ArgNode = getValue(*i); - Entry.Node = ArgNode; Entry.Ty = (*i)->getType(); + const Value *V = *i; + + // Skip empty types + if (V->getType()->isEmptyTy()) + continue; + + SDValue ArgNode = getValue(V); + Entry.Node = ArgNode; Entry.Ty = V->getType(); unsigned attrInd = i - CS.arg_begin() + 1; Entry.isSExt = CS.paramHasAttr(attrInd, Attribute::SExt); @@ -6498,6 +6517,10 @@ // Ignore dead phi's. if (PN->use_empty()) continue; + // Skip empty types + if (PN->getType()->isEmptyTy()) + continue; + unsigned Reg; const Value *PHIOp = PN->getIncomingValueForBlock(LLVMBB); Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=131294&r1=131293&r2=131294&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Fri May 13 10:18:06 2011 @@ -197,6 +197,25 @@ return false; // Other types have no identity values } +bool Type::isEmptyTy() const { + const ArrayType *ATy = dyn_cast(this); + if (ATy) { + unsigned NumElements = ATy->getNumElements(); + return NumElements == 0 || ATy->getElementType()->isEmptyTy(); + } + + const StructType *STy = dyn_cast(this); + if (STy) { + unsigned NumElements = STy->getNumElements(); + for (unsigned i = 0; i < NumElements; ++i) + if (!STy->getElementType(i)->isEmptyTy()) + return false; + return true; + } + + return false; +} + unsigned Type::getPrimitiveSizeInBits() const { switch (getTypeID()) { case Type::FloatTyID: return 32; Added: llvm/trunk/test/CodeGen/Generic/zero-sized-array.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/zero-sized-array.ll?rev=131294&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Generic/zero-sized-array.ll (added) +++ llvm/trunk/test/CodeGen/Generic/zero-sized-array.ll Fri May 13 10:18:06 2011 @@ -0,0 +1,81 @@ +; RUN: llc < %s +; PR9900 + +%zero = type [0 x i8] +%foobar = type { i32, %zero } + +define void @f(%foobar %arg) { + %arg1 = extractvalue %foobar %arg, 0 + %arg2 = extractvalue %foobar %arg, 1 + call i32 @f2(%zero %arg2, i32 5, i32 42) + ret void +} + +define i32 @f2(%zero %x, i32 %y, i32 %z) { + ret i32 %y +} + +define void @f3(%zero %x, i32 %y) { + call i32 @f2(%zero %x, i32 5, i32 %y) + ret void +} + +define void @f4(%zero %z) { + insertvalue %foobar undef, %zero %z, 1 + ret void +} + +define void @f5(%foobar %x) { +allocas: + %y = extractvalue %foobar %x, 1 + br label %b1 + +b1: + %insert120 = insertvalue %foobar undef, %zero %y, 1 + ret void +} + +define void @f6(%zero %x, %zero %y) { +b1: + br i1 undef, label %end, label %b2 + +b2: + br label %end + +end: + %z = phi %zero [ %y, %b1 ], [ %x, %b2 ] + call void @f4(%zero %z) + ret void +} + +%zero2 = type {} + +define i32 @g1(%zero2 %x, i32 %y, i32 %z) { + ret i32 %y +} + +define void @g2(%zero2 %x, i32 %y) { + call i32 @g1(%zero2 %x, i32 5, i32 %y) + ret void +} + +%zero2r = type {%zero2} + +define i32 @h1(%zero2r %x, i32 %y, i32 %z) { + ret i32 %y +} + +define void @h2(%zero2r %x, i32 %y) { + call i32 @h1(%zero2r %x, i32 5, i32 %y) + ret void +} + +%foobar2 = type { i32, %zero2r } + +define void @h3(%foobar2 %arg) { + %arg1 = extractvalue %foobar2 %arg, 0 + %arg2 = extractvalue %foobar2 %arg, 1 + %arg21 = extractvalue %zero2r %arg2, 0 + call void @g2(%zero2 %arg21, i32 5) + ret void +} From gkistanova at gmail.com Fri May 13 13:24:46 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Fri, 13 May 2011 11:24:46 -0700 Subject: [llvm-commits] [llvm] r130875 - /llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll In-Reply-To: References: <20110504215745.2F6B42A6C12C@llvm.org> Message-ID: Corrected in 131252. Thanks Galina On Wed, May 4, 2011 at 3:13 PM, Anton Korobeynikov wrote: > Hi Galina, > >> This test fails on ARM. The test shouldn't explicitly specify alignment (and alignment 4 is wrong) and requires hard-float. > In fact it doesn't. The difference is just APCS vs AAPCS, so, explicit > target triplet would be fine :) > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University > From gkistanova at gmail.com Fri May 13 14:27:33 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Fri, 13 May 2011 12:27:33 -0700 Subject: [llvm-commits] [llvm] r131169 - /llvm/trunk/test/DebugInfo/debug_frame.ll In-Reply-To: <20110510231429.42D712A6C12C@llvm.org> References: <20110510231429.42D712A6C12C@llvm.org> Message-ID: Hello Rafael, Would you move this test in to X86 foulder, since it's platform-dependent. Thanks Galina On Tue, May 10, 2011 at 4:14 PM, Rafael Espindola wrote: > Author: rafael > Date: Tue May 10 18:14:29 2011 > New Revision: 131169 > > URL: http://llvm.org/viewvc/llvm-project?rev=131169&view=rev > Log: > Add triple. > > Modified: > ? ?llvm/trunk/test/DebugInfo/debug_frame.ll > > Modified: llvm/trunk/test/DebugInfo/debug_frame.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debug_frame.ll?rev=131169&r1=131168&r2=131169&view=diff > ============================================================================== > --- llvm/trunk/test/DebugInfo/debug_frame.ll (original) > +++ llvm/trunk/test/DebugInfo/debug_frame.ll Tue May 10 18:14:29 2011 > @@ -1,4 +1,4 @@ > -; RUN: llc %s -o - | FileCheck %s > +; RUN: llc %s -mtriple=i686-pc-linux-gnu -o - | FileCheck %s > > ?; Test that we produce a .debug_frame, not an .eh_frame > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From gkistanova at gmail.com Fri May 13 14:29:59 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Fri, 13 May 2011 12:29:59 -0700 Subject: [llvm-commits] [llvm] r131146 - in /llvm/trunk: lib/MC/MCDwarf.cpp test/DebugInfo/eh_symbol.ll In-Reply-To: <20110510195153.8C9B92A6C12C@llvm.org> References: <20110510195153.8C9B92A6C12C@llvm.org> Message-ID: Hello Rafael, Would you move llvm/trunk/test/DebugInfo/eh_symbol.ll test in to the X86 foulder, please? It is platform-dependent now. Thanks Galina On Tue, May 10, 2011 at 12:51 PM, Rafael Espindola wrote: > Author: rafael > Date: Tue May 10 14:51:53 2011 > New Revision: 131146 > > URL: http://llvm.org/viewvc/llvm-project?rev=131146&view=rev > Log: > The EH symbols are only needed in eh_frame, not debug_frame. > > Added: > ? ?llvm/trunk/test/DebugInfo/eh_symbol.ll > Modified: > ? ?llvm/trunk/lib/MC/MCDwarf.cpp > > Modified: llvm/trunk/lib/MC/MCDwarf.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=131146&r1=131145&r2=131146&view=diff > ============================================================================== > --- llvm/trunk/lib/MC/MCDwarf.cpp (original) > +++ llvm/trunk/lib/MC/MCDwarf.cpp Tue May 10 14:51:53 2011 > @@ -633,7 +633,7 @@ > ? const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); > > ? MCSymbol *sectionStart; > - ?if (asmInfo.isFunctionEHFrameSymbolPrivate()) > + ?if (asmInfo.isFunctionEHFrameSymbolPrivate() || !IsEH) > ? ? sectionStart = context.CreateTempSymbol(); > ? else > ? ? sectionStart = context.GetOrCreateSymbol(Twine("EH_frame") + Twine(CIENum)); > @@ -739,7 +739,7 @@ > ? MCSymbol *fdeEnd = context.CreateTempSymbol(); > ? const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); > > - ?if (!asmInfo.isFunctionEHFrameSymbolPrivate()) { > + ?if (!asmInfo.isFunctionEHFrameSymbolPrivate() && IsEH) { > ? ? MCSymbol *EHSym = context.GetOrCreateSymbol( > ? ? ? frame.Function->getName() + Twine(".eh")); > ? ? streamer.EmitEHSymAttributes(frame.Function, EHSym); > > Added: llvm/trunk/test/DebugInfo/eh_symbol.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/eh_symbol.ll?rev=131146&view=auto > ============================================================================== > --- llvm/trunk/test/DebugInfo/eh_symbol.ll (added) > +++ llvm/trunk/test/DebugInfo/eh_symbol.ll Tue May 10 14:51:53 2011 > @@ -0,0 +1,18 @@ > +; RUN: llc -mtriple=i386-apple-macosx -disable-cfi %s -o - | FileCheck %s > + > +; test that we don't produce foo.eh symbols is a debug_frame section. > +; CHECK-NOT: .globl ? ?_f.eh > + > +define i32 @f() nounwind readnone optsize { > +entry: > + ?ret i32 42 > +} > + > +!llvm.dbg.sp = !{!0} > + > +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"f", metadata !"f", metadata !"", metadata !1, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i32 ()* @f, null, null} ; [ DW_TAG_subprogram ] > +!1 = metadata !{i32 589865, metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/tmpfs/build", metadata !2} ; [ DW_TAG_file_type ] > +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/tmpfs/build", metadata !"clang version 3.0 ()", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] > +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] > +!4 = metadata !{metadata !5} > +!5 = metadata !{i32 589860, metadata !2, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From gkistanova at gmail.com Fri May 13 14:45:05 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Fri, 13 May 2011 19:45:05 -0000 Subject: [llvm-commits] [llvm] r131302 - in /llvm/trunk/test/Other: X86/ X86/dg.exp X86/inline-asm-newline-terminator.ll inline-asm-newline-terminator.ll Message-ID: <20110513194505.478992A6C12C@llvm.org> Author: gkistanova Date: Fri May 13 14:45:05 2011 New Revision: 131302 URL: http://llvm.org/viewvc/llvm-project?rev=131302&view=rev Log: Move platform-dependent test to appropriate directory. Added: llvm/trunk/test/Other/X86/ llvm/trunk/test/Other/X86/dg.exp llvm/trunk/test/Other/X86/inline-asm-newline-terminator.ll Removed: llvm/trunk/test/Other/inline-asm-newline-terminator.ll Added: llvm/trunk/test/Other/X86/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/X86/dg.exp?rev=131302&view=auto ============================================================================== --- llvm/trunk/test/Other/X86/dg.exp (added) +++ llvm/trunk/test/Other/X86/dg.exp Fri May 13 14:45:05 2011 @@ -0,0 +1,5 @@ +load_lib llvm.exp + +if { [llvm_supports_target X86] } { + RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll}]] +} Added: llvm/trunk/test/Other/X86/inline-asm-newline-terminator.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/X86/inline-asm-newline-terminator.ll?rev=131302&view=auto ============================================================================== --- llvm/trunk/test/Other/X86/inline-asm-newline-terminator.ll (added) +++ llvm/trunk/test/Other/X86/inline-asm-newline-terminator.ll Fri May 13 14:45:05 2011 @@ -0,0 +1,6 @@ +; RUN: llc -filetype=obj -o - < %s + +; ModuleID = 't.c' +target triple = "x86_64-apple-darwin10.0.0" + +module asm ".desc _f0, 0x10" Removed: llvm/trunk/test/Other/inline-asm-newline-terminator.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/inline-asm-newline-terminator.ll?rev=131301&view=auto ============================================================================== --- llvm/trunk/test/Other/inline-asm-newline-terminator.ll (original) +++ llvm/trunk/test/Other/inline-asm-newline-terminator.ll (removed) @@ -1,6 +0,0 @@ -; RUN: llc -filetype=obj -o - < %s - -; ModuleID = 't.c' -target triple = "x86_64-apple-darwin10.0.0" - -module asm ".desc _f0, 0x10" From grosbach at apple.com Fri May 13 15:12:14 2011 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 13 May 2011 20:12:14 -0000 Subject: [llvm-commits] [llvm] r131305 - /llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Message-ID: <20110513201214.AD2982A6C12C@llvm.org> Author: grosbach Date: Fri May 13 15:12:14 2011 New Revision: 131305 URL: http://llvm.org/viewvc/llvm-project?rev=131305&view=rev Log: Teach the RtDyld to tell the memory manager about how much space a function actually takes rather than how much memory was allocated for it. This is more accurate and should help the manager pack things more effectively. Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=131305&r1=131304&r2=131305&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Fri May 13 15:12:14 2011 @@ -129,18 +129,19 @@ uint8_t *EndAddress) { // Allocate memory for the function via the memory manager. uintptr_t Size = EndAddress - StartAddress + 1; - uint8_t *Mem = MemMgr->startFunctionBody(Name.data(), Size); + uintptr_t AllocSize = Size; + uint8_t *Mem = MemMgr->startFunctionBody(Name.data(), AllocSize); assert(Size >= (uint64_t)(EndAddress - StartAddress + 1) && "Memory manager failed to allocate enough memory!"); // Copy the function payload into the memory block. - memcpy(Mem, StartAddress, EndAddress - StartAddress + 1); + memcpy(Mem, StartAddress, Size); MemMgr->endFunctionBody(Name.data(), Mem, Mem + Size); // Remember where we put it. Functions[Name] = sys::MemoryBlock(Mem, Size); // Default the assigned address for this symbol to wherever this // allocated it. SymbolTable[Name] = Mem; - DEBUG(dbgs() << " allocated to " << Mem << "\n"); + DEBUG(dbgs() << " allocated to [" << Mem << ", " << Mem + Size << "]\n"); } bool RuntimeDyldImpl:: From nobled at dreamwidth.org Fri May 13 15:24:16 2011 From: nobled at dreamwidth.org (nobled) Date: Fri, 13 May 2011 16:24:16 -0400 Subject: [llvm-commits] [PATCH v2] unittests/ExecutionEngine: use EngineBuilder::setErrorStr() In-Reply-To: References: Message-ID: If create() returned NULL, this prints the reason why before exiting. --- unittests/ExecutionEngine/ExecutionEngineTest.cpp | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/unittests/ExecutionEngine/ExecutionEngineTest.cpp index 904ee2b..57668a3 100644 --- a/unittests/ExecutionEngine/ExecutionEngineTest.cpp +++ b/unittests/ExecutionEngine/ExecutionEngineTest.cpp @@ -22,12 +22,13 @@ namespace { class ExecutionEngineTest : public testing::Test { protected: ExecutionEngineTest() - : M(new Module("

", getGlobalContext())), - Engine(EngineBuilder(M).create()) { + : M(new Module("
", getGlobalContext())), Error(""), + Engine(EngineBuilder(M).setErrorStr(&Error).create()) { } virtual void SetUp() { - ASSERT_TRUE(Engine.get() != NULL); + ASSERT_TRUE(Engine.get() != NULL) + << "Error building ExecutionEngine: " << Error; } GlobalVariable *NewExtGlobal(const Type *T, const Twine &Name) { @@ -36,6 +37,7 @@ protected: } Module *const M; + std::string Error; const OwningPtr Engine; }; -- 1.7.0.4 -------------- next part -------------- A non-text attachment was scrubbed... Name: 0003-unittests-ExecutionEngine-use-EngineBuilder-setError.patch Type: text/x-patch Size: 1396 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110513/a2370c90/attachment.bin From nobled at dreamwidth.org Fri May 13 15:41:01 2011 From: nobled at dreamwidth.org (nobled) Date: Fri, 13 May 2011 16:41:01 -0400 Subject: [llvm-commits] [PATCH] ExecutionEngine: fix ErrorStr handling In-Reply-To: <094EDE5D-E1D8-40FE-8426-4ADCD32A416C@apple.com> References: <094EDE5D-E1D8-40FE-8426-4ADCD32A416C@apple.com> Message-ID: On Wed, May 11, 2011 at 3:45 PM, Eric Christopher wrote: > > On May 10, 2011, at 11:35 AM, nobled wrote: > >>> Oops, I meant to paste this in the last message: >>> >>> When I tried this patch, it causes the test to fail all by itself, >>> even though the "Engine.get() != NULL" assert doesn't trigger. It >>> gives this output: >>> >>> Error building ExecutionEngine: Unable to find target for this triple >>> (no targets are registered) >>> >>> Does that indicate a bug in the test? >>> >> >> I found the actual bug; the ExecutionEngine code was still setting >> ErrorStr in the case whenever using the JIT failed, even if the >> fallback to the interpreter was successful. The attached patch fixes >> that case, and now the first patch works fine. >> >> Okay to commit? > > Haven't looked a lot, but why not check to see if the engine is null > and if so, print out the error string? You're right, that's definitely better for the first patch. In the general case, though, is EngineBuilder's current behavior of giving an error on a successful fallback the right thing to do? > > -eric > > From grosser at fim.uni-passau.de Fri May 13 15:51:45 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Fri, 13 May 2011 20:51:45 -0000 Subject: [llvm-commits] [polly] r131307 - /polly/trunk/www/todo.html Message-ID: <20110513205145.7CEAE2A6C12C@llvm.org> Author: grosser Date: Fri May 13 15:51:45 2011 New Revision: 131307 URL: http://llvm.org/viewvc/llvm-project?rev=131307&view=rev Log: www: Update status of our move to the LLVM infrastructure Modified: polly/trunk/www/todo.html Modified: polly/trunk/www/todo.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/todo.html?rev=131307&r1=131306&r2=131307&view=diff ============================================================================== --- polly/trunk/www/todo.html (original) +++ polly/trunk/www/todo.html Fri May 13 15:51:45 2011 @@ -17,41 +17,58 @@ - - - - - + - - - From rafael.espindola at gmail.com Fri May 13 16:33:32 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 13 May 2011 21:33:32 -0000 Subject: [llvm-commits] [llvm] r131314 - in /llvm/trunk/test/DebugInfo: X86/eh_symbol.ll eh_symbol.ll Message-ID: <20110513213332.9699B2A6C12C@llvm.org> Author: rafael Date: Fri May 13 16:33:32 2011 New Revision: 131314 URL: http://llvm.org/viewvc/llvm-project?rev=131314&view=rev Log: Move test. Added: llvm/trunk/test/DebugInfo/X86/eh_symbol.ll - copied, changed from r131305, llvm/trunk/test/DebugInfo/eh_symbol.ll Removed: llvm/trunk/test/DebugInfo/eh_symbol.ll Copied: llvm/trunk/test/DebugInfo/X86/eh_symbol.ll (from r131305, llvm/trunk/test/DebugInfo/eh_symbol.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/eh_symbol.ll?p2=llvm/trunk/test/DebugInfo/X86/eh_symbol.ll&p1=llvm/trunk/test/DebugInfo/eh_symbol.ll&r1=131305&r2=131314&rev=131314&view=diff ============================================================================== (empty) Removed: llvm/trunk/test/DebugInfo/eh_symbol.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/eh_symbol.ll?rev=131313&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/eh_symbol.ll (original) +++ llvm/trunk/test/DebugInfo/eh_symbol.ll (removed) @@ -1,18 +0,0 @@ -; RUN: llc -mtriple=i386-apple-macosx -disable-cfi %s -o - | FileCheck %s - -; test that we don't produce foo.eh symbols is a debug_frame section. -; CHECK-NOT: .globl _f.eh - -define i32 @f() nounwind readnone optsize { -entry: - ret i32 42 -} - -!llvm.dbg.sp = !{!0} - -!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"f", metadata !"f", metadata !"", metadata !1, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i32 ()* @f, null, null} ; [ DW_TAG_subprogram ] -!1 = metadata !{i32 589865, metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/tmpfs/build", metadata !2} ; [ DW_TAG_file_type ] -!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/tmpfs/build", metadata !"clang version 3.0 ()", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] -!4 = metadata !{metadata !5} -!5 = metadata !{i32 589860, metadata !2, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] From rafael.espindola at gmail.com Fri May 13 16:35:18 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 13 May 2011 21:35:18 -0000 Subject: [llvm-commits] [llvm] r131315 - in /llvm/trunk/test/DebugInfo: X86/debug_frame.ll debug_frame.ll Message-ID: <20110513213518.25F1B2A6C12C@llvm.org> Author: rafael Date: Fri May 13 16:35:17 2011 New Revision: 131315 URL: http://llvm.org/viewvc/llvm-project?rev=131315&view=rev Log: Move test. Added: llvm/trunk/test/DebugInfo/X86/debug_frame.ll - copied, changed from r131314, llvm/trunk/test/DebugInfo/debug_frame.ll Removed: llvm/trunk/test/DebugInfo/debug_frame.ll Copied: llvm/trunk/test/DebugInfo/X86/debug_frame.ll (from r131314, llvm/trunk/test/DebugInfo/debug_frame.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug_frame.ll?p2=llvm/trunk/test/DebugInfo/X86/debug_frame.ll&p1=llvm/trunk/test/DebugInfo/debug_frame.ll&r1=131314&r2=131315&rev=131315&view=diff ============================================================================== (empty) Removed: llvm/trunk/test/DebugInfo/debug_frame.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debug_frame.ll?rev=131314&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/debug_frame.ll (original) +++ llvm/trunk/test/DebugInfo/debug_frame.ll (removed) @@ -1,18 +0,0 @@ -; RUN: llc %s -mtriple=i686-pc-linux-gnu -o - | FileCheck %s - -; Test that we produce a .debug_frame, not an .eh_frame - -; CHECK: .cfi_sections .debug_frame - -define void @f() nounwind { -entry: - ret void -} - -!llvm.dbg.sp = !{!0} - -!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"f", metadata !"f", metadata !"", metadata !1, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, void ()* @f, null, null} ; [ DW_TAG_subprogram ] -!1 = metadata !{i32 589865, metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/llvm/build", metadata !2} ; [ DW_TAG_file_type ] -!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/llvm/build", metadata !"clang version 3.0 ()", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] -!4 = metadata !{null} From nobled at dreamwidth.org Fri May 13 16:36:16 2011 From: nobled at dreamwidth.org (Dylan Noblesmith) Date: Fri, 13 May 2011 21:36:16 -0000 Subject: [llvm-commits] [llvm] r131316 - in /llvm/trunk: include/llvm/ExecutionEngine/ExecutionEngine.h lib/ExecutionEngine/CMakeLists.txt lib/ExecutionEngine/JIT/CMakeLists.txt lib/ExecutionEngine/JIT/JIT.cpp lib/ExecutionEngine/JIT/JIT.h lib/ExecutionEngine/JIT/TargetSelect.cpp lib/ExecutionEngine/MCJIT/CMakeLists.txt lib/ExecutionEngine/MCJIT/MCJIT.cpp lib/ExecutionEngine/MCJIT/MCJIT.h lib/ExecutionEngine/MCJIT/TargetSelect.cpp lib/ExecutionEngine/TargetSelect.cpp Message-ID: <20110513213616.BEA702A6C12C@llvm.org> Author: nobled Date: Fri May 13 16:36:16 2011 New Revision: 131316 URL: http://llvm.org/viewvc/llvm-project?rev=131316&view=rev Log: ExecutionEngine: fix JIT/MCJIT selectTarget() duplication (v2) This prepares for making JITCtor/MCJITCtor take a TargetMachine* directly from clients like EngineBuilder. Added: llvm/trunk/lib/ExecutionEngine/TargetSelect.cpp Removed: llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp llvm/trunk/lib/ExecutionEngine/MCJIT/TargetSelect.cpp Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h llvm/trunk/lib/ExecutionEngine/CMakeLists.txt llvm/trunk/lib/ExecutionEngine/JIT/CMakeLists.txt llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp llvm/trunk/lib/ExecutionEngine/JIT/JIT.h llvm/trunk/lib/ExecutionEngine/MCJIT/CMakeLists.txt llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=131316&r1=131315&r2=131316&view=diff ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original) +++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Fri May 13 16:36:16 2011 @@ -569,6 +569,14 @@ return *this; } + /// selectTarget - Pick a target either via -march or by guessing the native + /// arch. Add any CPU features specified via -mcpu or -mattr. + static TargetMachine *selectTarget(Module *M, + StringRef MArch, + StringRef MCPU, + const SmallVectorImpl& MAttrs, + std::string *Err); + ExecutionEngine *create(); }; Modified: llvm/trunk/lib/ExecutionEngine/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/CMakeLists.txt?rev=131316&r1=131315&r2=131316&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/CMakeLists.txt (original) +++ llvm/trunk/lib/ExecutionEngine/CMakeLists.txt Fri May 13 16:36:16 2011 @@ -1,6 +1,7 @@ add_llvm_library(LLVMExecutionEngine ExecutionEngine.cpp ExecutionEngineBindings.cpp + TargetSelect.cpp ) add_subdirectory(Interpreter) Modified: llvm/trunk/lib/ExecutionEngine/JIT/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/CMakeLists.txt?rev=131316&r1=131315&r2=131316&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/CMakeLists.txt (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/CMakeLists.txt Fri May 13 16:36:16 2011 @@ -9,5 +9,4 @@ JITEmitter.cpp JITMemoryManager.cpp OProfileJITEventListener.cpp - TargetSelect.cpp ) Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=131316&r1=131315&r2=131316&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Fri May 13 16:36:16 2011 @@ -228,14 +228,21 @@ StringRef MCPU, const SmallVectorImpl& MAttrs) { // Try to register the program as a source of symbols to resolve against. + // + // FIXME: Don't do this here. sys::DynamicLibrary::LoadLibraryPermanently(0, NULL); // Pick a target either via -march or by guessing the native arch. - TargetMachine *TM = JIT::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr); + // + // FIXME: This should be lifted out of here, it isn't something which should + // be part of the JIT policy, rather the burden for this selection should be + // pushed to clients. + TargetMachine *TM = + EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr); if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; TM->setCodeModel(CMM); - // If the target supports JIT code generation, create a the JIT. + // If the target supports JIT code generation, create the JIT. if (TargetJITInfo *TJ = TM->getJITInfo()) { return new JIT(M, *TM, *TJ, JMM, OptLevel, GVsWithCode); } else { Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.h?rev=131316&r1=131315&r2=131316&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.h (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.h Fri May 13 16:36:16 2011 @@ -181,14 +181,6 @@ /// JITCodeEmitter *getCodeEmitter() const { return JCE; } - /// selectTarget - Pick a target either via -march or by guessing the native - /// arch. Add any CPU features specified via -mcpu or -mattr. - static TargetMachine *selectTarget(Module *M, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs, - std::string *Err); - static ExecutionEngine *createJIT(Module *M, std::string *ErrorStr, JITMemoryManager *JMM, Removed: llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp?rev=131315&view=auto ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp (removed) @@ -1,91 +0,0 @@ -//===-- TargetSelect.cpp - Target Chooser Code ----------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This just asks the TargetRegistry for the appropriate JIT to use, and allows -// the user to specify a specific one on the commandline with -march=x. Clients -// should initialize targets prior to calling createJIT. -// -//===----------------------------------------------------------------------===// - -#include "JIT.h" -#include "llvm/Module.h" -#include "llvm/ADT/Triple.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Host.h" -#include "llvm/Target/SubtargetFeature.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetRegistry.h" -using namespace llvm; - -/// selectTarget - Pick a target either via -march or by guessing the native -/// arch. Add any CPU features specified via -mcpu or -mattr. -TargetMachine *JIT::selectTarget(Module *Mod, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs, - std::string *ErrorStr) { - Triple TheTriple(Mod->getTargetTriple()); - if (TheTriple.getTriple().empty()) - TheTriple.setTriple(sys::getHostTriple()); - - // Adjust the triple to match what the user requested. - const Target *TheTarget = 0; - if (!MArch.empty()) { - for (TargetRegistry::iterator it = TargetRegistry::begin(), - ie = TargetRegistry::end(); it != ie; ++it) { - if (MArch == it->getName()) { - TheTarget = &*it; - break; - } - } - - if (!TheTarget) { - *ErrorStr = "No available targets are compatible with this -march, " - "see -version for the available targets.\n"; - return 0; - } - - // Adjust the triple to match (if known), otherwise stick with the - // module/host triple. - Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch); - if (Type != Triple::UnknownArch) - TheTriple.setArch(Type); - } else { - std::string Error; - TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error); - if (TheTarget == 0) { - if (ErrorStr) - *ErrorStr = Error; - return 0; - } - } - - if (!TheTarget->hasJIT()) { - errs() << "WARNING: This target JIT is not designed for the host you are" - << " running. If bad things happen, please choose a different " - << "-march switch.\n"; - } - - // Package up features to be passed to target/subtarget - std::string FeaturesStr; - if (!MCPU.empty() || !MAttrs.empty()) { - SubtargetFeatures Features; - Features.setCPU(MCPU); - for (unsigned i = 0; i != MAttrs.size(); ++i) - Features.AddFeature(MAttrs[i]); - FeaturesStr = Features.getString(); - } - - // Allocate a target... - TargetMachine *Target = - TheTarget->createTargetMachine(TheTriple.getTriple(), FeaturesStr); - assert(Target && "Could not allocate target machine!"); - return Target; -} Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/CMakeLists.txt?rev=131316&r1=131315&r2=131316&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/CMakeLists.txt (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/CMakeLists.txt Fri May 13 16:36:16 2011 @@ -1,5 +1,4 @@ add_llvm_library(LLVMMCJIT MCJIT.cpp - TargetSelect.cpp Intercept.cpp ) Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=131316&r1=131315&r2=131316&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Fri May 13 16:36:16 2011 @@ -52,7 +52,8 @@ // FIXME: This should be lifted out of here, it isn't something which should // be part of the JIT policy, rather the burden for this selection should be // pushed to clients. - TargetMachine *TM = MCJIT::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr); + TargetMachine *TM = + EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr); if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; TM->setCodeModel(CMM); Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h?rev=131316&r1=131315&r2=131316&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Fri May 13 16:36:16 2011 @@ -76,13 +76,6 @@ MCJITCtor = createJIT; } - // FIXME: This routine is scheduled for termination. Do not use it. - static TargetMachine *selectTarget(Module *M, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs, - std::string *Err); - static ExecutionEngine *createJIT(Module *M, std::string *ErrorStr, JITMemoryManager *JMM, Removed: llvm/trunk/lib/ExecutionEngine/MCJIT/TargetSelect.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/TargetSelect.cpp?rev=131315&view=auto ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/TargetSelect.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/TargetSelect.cpp (removed) @@ -1,91 +0,0 @@ -//===-- TargetSelect.cpp - Target Chooser Code ----------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This just asks the TargetRegistry for the appropriate JIT to use, and allows -// the user to specify a specific one on the commandline with -march=x. Clients -// should initialize targets prior to calling createJIT. -// -//===----------------------------------------------------------------------===// - -#include "MCJIT.h" -#include "llvm/Module.h" -#include "llvm/ADT/Triple.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Host.h" -#include "llvm/Target/SubtargetFeature.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetRegistry.h" -using namespace llvm; - -/// selectTarget - Pick a target either via -march or by guessing the native -/// arch. Add any CPU features specified via -mcpu or -mattr. -TargetMachine *MCJIT::selectTarget(Module *Mod, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs, - std::string *ErrorStr) { - Triple TheTriple(Mod->getTargetTriple()); - if (TheTriple.getTriple().empty()) - TheTriple.setTriple(sys::getHostTriple()); - - // Adjust the triple to match what the user requested. - const Target *TheTarget = 0; - if (!MArch.empty()) { - for (TargetRegistry::iterator it = TargetRegistry::begin(), - ie = TargetRegistry::end(); it != ie; ++it) { - if (MArch == it->getName()) { - TheTarget = &*it; - break; - } - } - - if (!TheTarget) { - *ErrorStr = "No available targets are compatible with this -march, " - "see -version for the available targets.\n"; - return 0; - } - - // Adjust the triple to match (if known), otherwise stick with the - // module/host triple. - Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch); - if (Type != Triple::UnknownArch) - TheTriple.setArch(Type); - } else { - std::string Error; - TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error); - if (TheTarget == 0) { - if (ErrorStr) - *ErrorStr = Error; - return 0; - } - } - - if (!TheTarget->hasJIT()) { - errs() << "WARNING: This target JIT is not designed for the host you are" - << " running. If bad things happen, please choose a different " - << "-march switch.\n"; - } - - // Package up features to be passed to target/subtarget - std::string FeaturesStr; - if (!MCPU.empty() || !MAttrs.empty()) { - SubtargetFeatures Features; - Features.setCPU(MCPU); - for (unsigned i = 0; i != MAttrs.size(); ++i) - Features.AddFeature(MAttrs[i]); - FeaturesStr = Features.getString(); - } - - // Allocate a target... - TargetMachine *Target = - TheTarget->createTargetMachine(TheTriple.getTriple(), FeaturesStr); - assert(Target && "Could not allocate target machine!"); - return Target; -} Added: llvm/trunk/lib/ExecutionEngine/TargetSelect.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/TargetSelect.cpp?rev=131316&view=auto ============================================================================== --- llvm/trunk/lib/ExecutionEngine/TargetSelect.cpp (added) +++ llvm/trunk/lib/ExecutionEngine/TargetSelect.cpp Fri May 13 16:36:16 2011 @@ -0,0 +1,91 @@ +//===-- TargetSelect.cpp - Target Chooser Code ----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This just asks the TargetRegistry for the appropriate JIT to use, and allows +// the user to specify a specific one on the commandline with -march=x. Clients +// should initialize targets prior to calling createJIT. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ExecutionEngine/ExecutionEngine.h" +#include "llvm/Module.h" +#include "llvm/ADT/Triple.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Host.h" +#include "llvm/Target/SubtargetFeature.h" +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetRegistry.h" +using namespace llvm; + +/// selectTarget - Pick a target either via -march or by guessing the native +/// arch. Add any CPU features specified via -mcpu or -mattr. +TargetMachine *EngineBuilder::selectTarget(Module *Mod, + StringRef MArch, + StringRef MCPU, + const SmallVectorImpl& MAttrs, + std::string *ErrorStr) { + Triple TheTriple(Mod->getTargetTriple()); + if (TheTriple.getTriple().empty()) + TheTriple.setTriple(sys::getHostTriple()); + + // Adjust the triple to match what the user requested. + const Target *TheTarget = 0; + if (!MArch.empty()) { + for (TargetRegistry::iterator it = TargetRegistry::begin(), + ie = TargetRegistry::end(); it != ie; ++it) { + if (MArch == it->getName()) { + TheTarget = &*it; + break; + } + } + + if (!TheTarget) { + *ErrorStr = "No available targets are compatible with this -march, " + "see -version for the available targets.\n"; + return 0; + } + + // Adjust the triple to match (if known), otherwise stick with the + // module/host triple. + Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch); + if (Type != Triple::UnknownArch) + TheTriple.setArch(Type); + } else { + std::string Error; + TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error); + if (TheTarget == 0) { + if (ErrorStr) + *ErrorStr = Error; + return 0; + } + } + + if (!TheTarget->hasJIT()) { + errs() << "WARNING: This target JIT is not designed for the host you are" + << " running. If bad things happen, please choose a different " + << "-march switch.\n"; + } + + // Package up features to be passed to target/subtarget + std::string FeaturesStr; + if (!MCPU.empty() || !MAttrs.empty()) { + SubtargetFeatures Features; + Features.setCPU(MCPU); + for (unsigned i = 0; i != MAttrs.size(); ++i) + Features.AddFeature(MAttrs[i]); + FeaturesStr = Features.getString(); + } + + // Allocate a target... + TargetMachine *Target = + TheTarget->createTargetMachine(TheTriple.getTriple(), FeaturesStr); + assert(Target && "Could not allocate target machine!"); + return Target; +} From jasonwkim at google.com Fri May 13 16:50:05 2011 From: jasonwkim at google.com (Jason Kim) Date: Fri, 13 May 2011 14:50:05 -0700 Subject: [llvm-commits] [llvm] r131205 - in /llvm/trunk/lib/MC: ELFObjectWriter.cpp ELFObjectWriter.h In-Reply-To: <4DCC85C6.4070106@gmail.com> References: <20110511225306.571622A6C12C@llvm.org> <4DCC85C6.4070106@gmail.com> Message-ID: On Thu, May 12, 2011 at 6:13 PM, Rafael ?vila de Esp?ndola wrote: > On 11-05-11 6:53 PM, Jason W Kim wrote: >> Author: jasonwkim >> Date: Wed May 11 17:53:06 2011 >> New Revision: 131205 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=131205&view=rev >> Log: >> Address the last bit of relocation flag related divergence betweeen >> LLVM and binutils. >> >> With this patch, there are no functional differences between the .o >> produced directly from LLVM versus the .s to .o via GNU as, for relocation tags >> at least, for both PIC and non-PIC modes. >> >> Because some non-PIC reloc tags are used (legally) on PIC, so IsPCRel flag is >> necessary but not sufficient to determine whether the overall codegen mode is >> PIC or not. Why is this necessary? There is an incompatibility of how relocs >> are emitted in the .rodata section. ?Binutils PIC likes to emit certain relocs >> as section relative offsets. ?Non-PIC does not do this. >> >> So I added a hidden switch on the ELFObjectwriter "-arm-elf-force-pic" which >> forces the objectwriter to pretend that all relocs are for PIC mode. >> >> >> Todo: Activate ForceARMElfPIC to true if -relocation-model=pic is selected >> on llc. >> > > Is this ARM only? On X86 at least no flag is passed to the assembler Yes.. > indicating that a given file is PIC or not. Since the MC interface is > isomorphic with the assembler, llc should not pass any flags to mc. That switch is necessary for producing code that is identical to gas. This is a tough call. Either we live with a hidden switch or make it "nicer" by linking the two switches, or give MC access to upstream codegen internals. Linking the cmdline switches is the solution of least work, but I'm punting on it for now > > Cheers, > Rafael > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From nobled at dreamwidth.org Fri May 13 16:51:29 2011 From: nobled at dreamwidth.org (Dylan Noblesmith) Date: Fri, 13 May 2011 21:51:29 -0000 Subject: [llvm-commits] [llvm] r131317 - in /llvm/trunk: include/llvm/ExecutionEngine/ExecutionEngine.h lib/ExecutionEngine/ExecutionEngine.cpp lib/ExecutionEngine/JIT/JIT.cpp lib/ExecutionEngine/JIT/JIT.h lib/ExecutionEngine/MCJIT/MCJIT.cpp lib/ExecutionEngine/MCJIT/MCJIT.h Message-ID: <20110513215129.4CFEE2A6C12C@llvm.org> Author: nobled Date: Fri May 13 16:51:29 2011 New Revision: 131317 URL: http://llvm.org/viewvc/llvm-project?rev=131317&view=rev Log: ExecutionEngine: push TargetMachine creation into clients (v2) In particular, into EngineBuilder. This should only impact the private API between the EE and EB classes, not external clients, since JITCtor and MCJITCtor are both protected members. Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp llvm/trunk/lib/ExecutionEngine/JIT/JIT.h llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=131317&r1=131316&r2=131317&view=diff ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original) +++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Fri May 13 16:51:29 2011 @@ -135,20 +135,14 @@ JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode, - CodeModel::Model CMM, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs); + TargetMachine *TM); static ExecutionEngine *(*MCJITCtor)( Module *M, std::string *ErrorStr, JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode, - CodeModel::Model CMM, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs); + TargetMachine *TM); static ExecutionEngine *(*InterpCtor)(Module *M, std::string *ErrorStr); Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=131317&r1=131316&r2=131317&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Fri May 13 16:51:29 2011 @@ -29,6 +29,7 @@ #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Host.h" #include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetMachine.h" #include #include using namespace llvm; @@ -42,20 +43,14 @@ JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode, - CodeModel::Model CMM, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs) = 0; + TargetMachine *TM) = 0; ExecutionEngine *(*ExecutionEngine::MCJITCtor)( Module *M, std::string *ErrorStr, JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode, - CodeModel::Model CMM, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs) = 0; + TargetMachine *TM) = 0; ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M, std::string *ErrorStr) = 0; @@ -441,18 +436,21 @@ // Unless the interpreter was explicitly selected or the JIT is not linked, // try making a JIT. if (WhichEngine & EngineKind::JIT) { - if (UseMCJIT && ExecutionEngine::MCJITCtor) { - ExecutionEngine *EE = - ExecutionEngine::MCJITCtor(M, ErrorStr, JMM, OptLevel, - AllocateGVsWithCode, CMModel, - MArch, MCPU, MAttrs); - if (EE) return EE; - } else if (ExecutionEngine::JITCtor) { - ExecutionEngine *EE = - ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel, - AllocateGVsWithCode, CMModel, - MArch, MCPU, MAttrs); - if (EE) return EE; + if (TargetMachine *TM = + EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr)) { + TM->setCodeModel(CMModel); + + if (UseMCJIT && ExecutionEngine::MCJITCtor) { + ExecutionEngine *EE = + ExecutionEngine::MCJITCtor(M, ErrorStr, JMM, OptLevel, + AllocateGVsWithCode, TM); + if (EE) return EE; + } else if (ExecutionEngine::JITCtor) { + ExecutionEngine *EE = + ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel, + AllocateGVsWithCode, TM); + if (EE) return EE; + } } } Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=131317&r1=131316&r2=131317&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Fri May 13 16:51:29 2011 @@ -214,8 +214,12 @@ StringRef MArch = ""; StringRef MCPU = ""; SmallVector MAttrs; - return JIT::createJIT(M, ErrorStr, JMM, OptLevel, GVsWithCode, CMM, - MArch, MCPU, MAttrs); + TargetMachine *TM = + EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr); + if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; + TM->setCodeModel(CMM); + + return JIT::createJIT(M, ErrorStr, JMM, OptLevel, GVsWithCode, TM); } ExecutionEngine *JIT::createJIT(Module *M, @@ -223,25 +227,12 @@ JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode, - CodeModel::Model CMM, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs) { + TargetMachine *TM) { // Try to register the program as a source of symbols to resolve against. // // FIXME: Don't do this here. sys::DynamicLibrary::LoadLibraryPermanently(0, NULL); - // Pick a target either via -march or by guessing the native arch. - // - // FIXME: This should be lifted out of here, it isn't something which should - // be part of the JIT policy, rather the burden for this selection should be - // pushed to clients. - TargetMachine *TM = - EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr); - if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; - TM->setCodeModel(CMM); - // If the target supports JIT code generation, create the JIT. if (TargetJITInfo *TJ = TM->getJITInfo()) { return new JIT(M, *TM, *TJ, JMM, OptLevel, GVsWithCode); Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.h?rev=131317&r1=131316&r2=131317&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.h (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.h Fri May 13 16:51:29 2011 @@ -186,10 +186,7 @@ JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode, - CodeModel::Model CMM, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs); + TargetMachine *TM); // Run the JIT on F and return information about the generated code void runJITOnFunction(Function *F, MachineCodeInfo *MCI = 0); Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=131317&r1=131316&r2=131317&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Fri May 13 16:51:29 2011 @@ -38,25 +38,12 @@ JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode, - CodeModel::Model CMM, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs) { + TargetMachine *TM) { // Try to register the program as a source of symbols to resolve against. // // FIXME: Don't do this here. sys::DynamicLibrary::LoadLibraryPermanently(0, NULL); - // Pick a target either via -march or by guessing the native arch. - // - // FIXME: This should be lifted out of here, it isn't something which should - // be part of the JIT policy, rather the burden for this selection should be - // pushed to clients. - TargetMachine *TM = - EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr); - if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; - TM->setCodeModel(CMM); - // If the target supports JIT code generation, create the JIT. if (TargetJITInfo *TJ = TM->getJITInfo()) return new MCJIT(M, TM, *TJ, new MCJITMemoryManager(JMM, M), OptLevel, Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h?rev=131317&r1=131316&r2=131317&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Fri May 13 16:51:29 2011 @@ -81,10 +81,7 @@ JITMemoryManager *JMM, CodeGenOpt::Level OptLevel, bool GVsWithCode, - CodeModel::Model CMM, - StringRef MArch, - StringRef MCPU, - const SmallVectorImpl& MAttrs); + TargetMachine *TM); // @} }; From rafael.espindola at gmail.com Fri May 13 17:02:32 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Fri, 13 May 2011 18:02:32 -0400 Subject: [llvm-commits] [llvm] r131205 - in /llvm/trunk/lib/MC: ELFObjectWriter.cpp ELFObjectWriter.h In-Reply-To: References: <20110511225306.571622A6C12C@llvm.org> <4DCC85C6.4070106@gmail.com> Message-ID: <4DCDAA78.1030101@gmail.com> >> indicating that a given file is PIC or not. Since the MC interface is >> isomorphic with the assembler, llc should not pass any flags to mc. > > That switch is necessary for producing code that is identical to gas. > > This is a tough call. > > Either we live with a hidden switch or make it "nicer" by linking the > two switches, or give MC access to upstream codegen internals. > Linking the cmdline switches is the solution of least work, but I'm > punting on it for now The option is *not* needed. When building for ARM I get: $ gcc -c test.c -v ... as -march=armv5te -mfloat-abi=soft -mfpu=vfp -meabi=4 -o test.o test.s $ gcc -fPIC -c test.c -v ... as -march=armv5te -mfloat-abi=soft -mfpu=vfp -meabi=4 -o test.o test.s Note that the command line to as is the same in both cases. All the information gas needs is in the .s file, so all the information MC needs is also there. Please remove the option and figure out what logic gas is using. Cheers, Rafael From nobled at dreamwidth.org Fri May 13 17:02:53 2011 From: nobled at dreamwidth.org (Dylan Noblesmith) Date: Fri, 13 May 2011 22:02:53 -0000 Subject: [llvm-commits] [llvm] r131320 - in /llvm/trunk/lib/ExecutionEngine: ExecutionEngine.cpp JIT/JIT.cpp Message-ID: <20110513220253.59A0A2A6C12C@llvm.org> Author: nobled Date: Fri May 13 17:02:53 2011 New Revision: 131320 URL: http://llvm.org/viewvc/llvm-project?rev=131320&view=rev Log: ExecutionEngine: move createJIT() definition (v2) As an ExecutionEngine class function, its definition really belongs in ExecutionEngine.cpp, not JIT.cpp. Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=131320&r1=131319&r2=131320&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Fri May 13 17:02:53 2011 @@ -414,6 +414,35 @@ .create(); } +/// createJIT - This is the factory method for creating a JIT for the current +/// machine, it does not fall back to the interpreter. This takes ownership +/// of the module. +ExecutionEngine *ExecutionEngine::createJIT(Module *M, + std::string *ErrorStr, + JITMemoryManager *JMM, + CodeGenOpt::Level OptLevel, + bool GVsWithCode, + CodeModel::Model CMM) { + if (ExecutionEngine::JITCtor == 0) { + if (ErrorStr) + *ErrorStr = "JIT has not been linked in."; + return 0; + } + + // Use the defaults for extra parameters. Users can use EngineBuilder to + // set them. + StringRef MArch = ""; + StringRef MCPU = ""; + SmallVector MAttrs; + + TargetMachine *TM = + EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr); + if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; + TM->setCodeModel(CMM); + + return ExecutionEngine::JITCtor(M, ErrorStr, JMM, OptLevel, GVsWithCode, TM); +} + ExecutionEngine *EngineBuilder::create() { // Make sure we can resolve symbols in the program as well. The zero arg // to the function tells DynamicLibrary to load the program, not a library. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=131320&r1=131319&r2=131320&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Fri May 13 17:02:53 2011 @@ -203,25 +203,6 @@ /// createJIT - This is the factory method for creating a JIT for the current /// machine, it does not fall back to the interpreter. This takes ownership /// of the module. -ExecutionEngine *ExecutionEngine::createJIT(Module *M, - std::string *ErrorStr, - JITMemoryManager *JMM, - CodeGenOpt::Level OptLevel, - bool GVsWithCode, - CodeModel::Model CMM) { - // Use the defaults for extra parameters. Users can use EngineBuilder to - // set them. - StringRef MArch = ""; - StringRef MCPU = ""; - SmallVector MAttrs; - TargetMachine *TM = - EngineBuilder::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr); - if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; - TM->setCodeModel(CMM); - - return JIT::createJIT(M, ErrorStr, JMM, OptLevel, GVsWithCode, TM); -} - ExecutionEngine *JIT::createJIT(Module *M, std::string *ErrorStr, JITMemoryManager *JMM, From grosbach at apple.com Fri May 13 18:11:30 2011 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 13 May 2011 23:11:30 -0000 Subject: [llvm-commits] [llvm] r131322 - /llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Message-ID: <20110513231130.7B0892A6C12C@llvm.org> Author: grosbach Date: Fri May 13 18:11:30 2011 New Revision: 131322 URL: http://llvm.org/viewvc/llvm-project?rev=131322&view=rev Log: Be a bit more permissive about symbols we don't understand. Just skip them rather than throwing an error. Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=131322&r1=131321&r2=131322&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Fri May 13 18:11:30 2011 @@ -296,11 +296,11 @@ // FIXME: Check the symbol type and flags. if (STE->Type != 0xF) // external, defined in this section. - return Error("unexpected symbol type!"); + continue; // Flags == 0x8 marks a thumb function for ARM, which is fine as it // doesn't require any special handling here. if (STE->Flags != 0x0 && STE->Flags != 0x8) - return Error("unexpected symbol type!"); + continue; // Remember the symbol. Symbols.push_back(SymbolEntry(STE->Value, Name)); @@ -311,6 +311,10 @@ // Sort the symbols by address, just in case they didn't come in that way. array_pod_sort(Symbols.begin(), Symbols.end()); + // If there weren't any functions (odd, but just in case...) + if (!Symbols.size()) + continue; + // Extract the function data. uint8_t *Base = (uint8_t*)Obj->getData(SegmentLC->FileOffset, SegmentLC->FileSize).data(); @@ -431,9 +435,9 @@ // FIXME: Check the symbol type and flags. if (STE->Type != 0xF) // external, defined in this section. - return Error("unexpected symbol type!"); + continue; if (STE->Flags != 0x0) - return Error("unexpected symbol type!"); + continue; // Remember the symbol. Symbols.push_back(SymbolEntry(STE->Value, Name)); @@ -444,6 +448,10 @@ // Sort the symbols by address, just in case they didn't come in that way. array_pod_sort(Symbols.begin(), Symbols.end()); + // If there weren't any functions (odd, but just in case...) + if (!Symbols.size()) + continue; + // Extract the function data. uint8_t *Base = (uint8_t*)Obj->getData(Segment64LC->FileOffset, Segment64LC->FileSize).data(); From rjmccall at apple.com Fri May 13 18:58:45 2011 From: rjmccall at apple.com (John McCall) Date: Fri, 13 May 2011 23:58:45 -0000 Subject: [llvm-commits] [llvm] r131325 - /llvm/trunk/include/llvm/ADT/StringRef.h Message-ID: <20110513235845.D79D02A6C12C@llvm.org> Author: rjmccall Date: Fri May 13 18:58:45 2011 New Revision: 131325 URL: http://llvm.org/viewvc/llvm-project?rev=131325&view=rev Log: Add an operator+= for appending StringRefs onto std::strings. Previously this pattern would be compiled using an implicit conversion to std::string. Modified: llvm/trunk/include/llvm/ADT/StringRef.h Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=131325&r1=131324&r2=131325&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Fri May 13 18:58:45 2011 @@ -447,6 +447,10 @@ return LHS.compare(RHS) != -1; } + inline std::string &operator+=(std::string &buffer, llvm::StringRef string) { + return buffer.append(string.data(), string.size()); + } + /// @} // StringRefs can be treated like a POD type. From eli.friedman at gmail.com Fri May 13 19:19:33 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Sat, 14 May 2011 00:19:33 -0000 Subject: [llvm-commits] [llvm] r131329 - /llvm/trunk/lib/Target/X86/X86FastISel.cpp Message-ID: <20110514001933.0C0B32A6C12C@llvm.org> Author: efriedma Date: Fri May 13 19:19:32 2011 New Revision: 131329 URL: http://llvm.org/viewvc/llvm-project?rev=131329&view=rev Log: Zap useless code; this hasn't done anything useful since fast-isel switched to being bottom-up (a very long time ago). Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=131329&r1=131328&r2=131329&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Fri May 13 19:19:32 2011 @@ -108,8 +108,6 @@ bool X86SelectFPExt(const Instruction *I); bool X86SelectFPTrunc(const Instruction *I); - bool X86SelectExtractValue(const Instruction *I); - bool X86VisitIntrinsicCall(const IntrinsicInst &I); bool X86SelectCall(const Instruction *I); @@ -1303,31 +1301,6 @@ return true; } -bool X86FastISel::X86SelectExtractValue(const Instruction *I) { - const ExtractValueInst *EI = cast(I); - const Value *Agg = EI->getAggregateOperand(); - - if (const IntrinsicInst *CI = dyn_cast(Agg)) { - switch (CI->getIntrinsicID()) { - default: break; - case Intrinsic::sadd_with_overflow: - case Intrinsic::uadd_with_overflow: { - // Cheat a little. We know that the registers for "add" and "seto" are - // allocated sequentially. However, we only keep track of the register - // for "add" in the value map. Use extractvalue's index to get the - // correct register for "seto". - unsigned OpReg = getRegForValue(Agg); - if (OpReg == 0) - return false; - UpdateValueMap(I, OpReg + *EI->idx_begin()); - return true; - } - } - } - - return false; -} - bool X86FastISel::TryEmitSmallMemcpy(X86AddressMode DestAM, X86AddressMode SrcAM, uint64_t Len) { // Make sure we don't bloat code by inlining very large memcpy's. @@ -1911,8 +1884,6 @@ return X86SelectFPExt(I); case Instruction::FPTrunc: return X86SelectFPTrunc(I); - case Instruction::ExtractValue: - return X86SelectExtractValue(I); case Instruction::IntToPtr: // Deliberate fall-through. case Instruction::PtrToInt: { EVT SrcVT = TLI.getValueType(I->getOperand(0)->getType()); From rafael.espindola at gmail.com Fri May 13 19:30:01 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sat, 14 May 2011 00:30:01 -0000 Subject: [llvm-commits] [llvm] r131330 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/movntdq-no-avx.ll Message-ID: <20110514003001.C00482A6C12C@llvm.org> Author: rafael Date: Fri May 13 19:30:01 2011 New Revision: 131330 URL: http://llvm.org/viewvc/llvm-project?rev=131330&view=rev Log: Don't produce a vmovntdq if we don't have AVX support. Added: llvm/trunk/test/CodeGen/X86/movntdq-no-avx.ll 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=131330&r1=131329&r2=131330&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri May 13 19:30:01 2011 @@ -1900,7 +1900,7 @@ addr:$dst)]>, VEX; def : Pat<(alignednontemporalstore (v2i64 VR128:$src), addr:$dst), - (VMOVNTDQmr addr:$dst, VR128:$src)>; + (VMOVNTDQmr addr:$dst, VR128:$src)>, Requires<[HasAVX]>; def VMOVNTPSYmr : VPSI<0x2B, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src), Added: llvm/trunk/test/CodeGen/X86/movntdq-no-avx.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/movntdq-no-avx.ll?rev=131330&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/movntdq-no-avx.ll (added) +++ llvm/trunk/test/CodeGen/X86/movntdq-no-avx.ll Fri May 13 19:30:01 2011 @@ -0,0 +1,12 @@ +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s + +; Test that we produce a movntdq, not a vmovntdq +; CHECK-NOT: vmovntdq + +define void @test(<2 x i64>* nocapture %a, <2 x i64> %b) nounwind optsize { +entry: + store <2 x i64> %b, <2 x i64>* %a, align 16, !nontemporal !0 + ret void +} + +!0 = metadata !{i32 1} From eli.friedman at gmail.com Fri May 13 19:47:51 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Sat, 14 May 2011 00:47:51 -0000 Subject: [llvm-commits] [llvm] r131332 - in /llvm/trunk/lib: CodeGen/SelectionDAG/FastISel.cpp Target/X86/X86FastISel.cpp Message-ID: <20110514004751.B0CAF2A6C12C@llvm.org> Author: efriedma Date: Fri May 13 19:47:51 2011 New Revision: 131332 URL: http://llvm.org/viewvc/llvm-project?rev=131332&view=rev Log: Fix a FIXME by moving the fast-isel implementation of the objectsize intrinsic from the x86 code to the generic code. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/Target/X86/X86FastISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=131332&r1=131331&r2=131332&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri May 13 19:47:51 2011 @@ -628,6 +628,16 @@ return true; } + case Intrinsic::objectsize: { + ConstantInt *CI = cast(Call->getArgOperand(1)); + unsigned long long Res = CI->isZero() ? -1ULL : 0; + Constant *ResCI = ConstantInt::get(Call->getType(), Res); + unsigned ResultReg = getRegForValue(ResCI); + if (ResultReg == 0) + return false; + UpdateValueMap(Call, ResultReg); + return true; + } } // An arbitrary call. Bail. Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=131332&r1=131331&r2=131332&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Fri May 13 19:47:51 2011 @@ -1369,29 +1369,6 @@ if (!X86FastEmitStore(PtrTy, Op1, AM)) return false; return true; } - case Intrinsic::objectsize: { - // FIXME: This should be moved to generic code! - ConstantInt *CI = cast(I.getArgOperand(1)); - const Type *Ty = I.getCalledFunction()->getReturnType(); - - MVT VT; - if (!isTypeLegal(Ty, VT)) - return false; - - unsigned OpC = 0; - if (VT == MVT::i32) - OpC = X86::MOV32ri; - else if (VT == MVT::i64) - OpC = X86::MOV64ri; - else - return false; - - unsigned ResultReg = createResultReg(TLI.getRegClassFor(VT)); - BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(OpC), ResultReg). - addImm(CI->isZero() ? -1ULL : 0); - UpdateValueMap(&I, ResultReg); - return true; - } case Intrinsic::dbg_declare: { const DbgDeclareInst *DI = cast(&I); X86AddressMode AM; From stuart at apple.com Sat May 14 00:55:10 2011 From: stuart at apple.com (Stuart Hastings) Date: Sat, 14 May 2011 05:55:10 -0000 Subject: [llvm-commits] [llvm] r131339 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Message-ID: <20110514055510.F342C2A6C12C@llvm.org> Author: stuart Date: Sat May 14 00:55:10 2011 New Revision: 131339 URL: http://llvm.org/viewvc/llvm-project?rev=131339&view=rev Log: Avoid combining GEPs that might overflow at runtime. rdar://problem/9267970 Patch by Julien Lerouge! Added: llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=131339&r1=131338&r2=131339&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Sat May 14 00:55:10 2011 @@ -634,6 +634,7 @@ if (AllZeros) return FoldGEPICmp(GEPLHS, GEPRHS->getOperand(0), Cond, I); + bool GEPsInBounds = GEPLHS->isInBounds() && GEPRHS->isInBounds(); if (GEPLHS->getNumOperands() == GEPRHS->getNumOperands()) { // If the GEPs only differ by one index, compare it. unsigned NumDifferences = 0; // Keep track of # differences. @@ -656,7 +657,7 @@ ConstantInt::get(Type::getInt1Ty(I.getContext()), ICmpInst::isTrueWhenEqual(Cond))); - else if (NumDifferences == 1) { + else if (NumDifferences == 1 && GEPsInBounds) { Value *LHSV = GEPLHS->getOperand(DiffOperand); Value *RHSV = GEPRHS->getOperand(DiffOperand); // Make sure we do a signed comparison here. @@ -667,6 +668,7 @@ // Only lower this if the icmp is the only user of the GEP or if we expect // the result to fold to a constant! if (TD && + GEPsInBounds && (isa(GEPLHS) || GEPLHS->hasOneUse()) && (isa(GEPRHS) || GEPRHS->hasOneUse())) { // ((gep Ptr, OFFSET1) cmp (gep Ptr, OFFSET2) ---> (OFFSET1 cmp OFFSET2) Added: llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll?rev=131339&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Sat May 14 00:55:10 2011 @@ -0,0 +1,19 @@ +; RUN: opt < %s -instcombine | lli +; rdar://problem/9267970 +; ideally this test will run on a 32-bit host +; must not discard GEPs that might overflow at runtime (aren't inbounds) + +define i32 @main(i32 %argc) { +entry: + %tmp1 = add i32 %argc, -2 + %tmp2 = add i32 %argc, 1879048192 + %p = alloca i8 + %p1 = getelementptr i8* %p, i32 %tmp1 + %p2 = getelementptr i8* %p, i32 %tmp2 + %cmp = icmp ult i8* %p1, %p2 + br i1 %cmp, label %bbtrue, label %bbfalse +bbtrue: ; preds = %entry + ret i32 -1 +bbfalse: ; preds = %entry + ret i32 0 +} From bob.wilson at apple.com Sat May 14 01:09:46 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 13 May 2011 23:09:46 -0700 Subject: [llvm-commits] [PATCH] Error cannot be reached In-Reply-To: <455CB75527BC764BA1E62B31CE4D937C09B67887EE@CFEXMBX.americas.cray.com> References: <4DCC5564.2060406@cray.com> <61B8F381-0482-4745-A404-29EEDF5C5A23@apple.com> <455CB75527BC764BA1E62B31CE4D937C09B67887EE@CFEXMBX.americas.cray.com> Message-ID: <99DD76EE-D12A-4BA4-83B9-90F404FB6BC3@apple.com> On May 12, 2011, at 10:10 PM, Cameron McInally wrote: > Hey Chris, > > The code in trunk looks like this: > > if (R->getName() == "node" && !OpName.empty()) { //Let's call this (1) > if (OpName.empty()) //Let's call this (2) > error("'node' argument requires a name to match with operand list"); > Args.push_back(OpName); > } > > Unless the expression OpName.empty() has side-effects, which I am fairly confident that it does not, the call cannot evaluate to false at (1) and true at (2). I'm assuming that '==' has a higher precedence than '&&' in C++, but maybe I'm mistaken. Is that not correct? That logic is correct, except that the patch does not remove the unreachable code -- it changes the preceding conditional. If OpName is empty, the previous code would skip over "Args.push_back(OpName)" without calling error(). With the patch, it will now produce an error(). It isn't at all obvious that is the right thing to do. If you just want to make an obvious change to remove the dead code, then remove the second conditional (2) and the call to error(). Otherwise, you need to do some more investigation and/or explaining. > > Essentially, this code sequence is: > > bool b = true; > if(b) { > if(!b) { > printf("unreachable\n"); > } > } > > Cameron > > ________________________________________ > From: Chris Lattner [clattner at apple.com] > Sent: Thursday, May 12, 2011 11:18 PM > To: Cameron McInally > Cc: llvm-commits at cs.uiuc.edu > Subject: Re: [llvm-commits] [PATCH] Error cannot be reached > > On May 12, 2011, at 2:47 PM, Cameron McInally wrote: > >> A silly little patch for unreachable code. It's self-explanatory: > > How is that unreachable? OpName != R->getName() > > -Chris > >> >> mcinally/llvm> svn diff >> Index: utils/TableGen/CodeGenDAGPatterns.cpp >> =================================================================== >> --- utils/TableGen/CodeGenDAGPatterns.cpp (revision 131245) >> +++ utils/TableGen/CodeGenDAGPatterns.cpp (working copy) >> @@ -1732,7 +1732,7 @@ >> >> // Input argument? >> TreePatternNode *Res = new TreePatternNode(DI, 1); >> - if (R->getName() == "node" && !OpName.empty()) { >> + if (R->getName() == "node") { >> if (OpName.empty()) >> error("'node' argument requires a name to match with operand >> list"); >> Args.push_back(OpName); >> >> mcinally/llvm> svn info >> Path: . >> URL: http://llvm.org/svn/llvm-project/llvm/trunk >> Repository Root: http://llvm.org/svn/llvm-project >> Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8 >> Revision: 131241 >> Node Kind: directory >> Schedule: normal >> Last Changed Author: evancheng >> Last Changed Rev: 131241 >> Last Changed Date: 2011-05-12 15:30:01 -0500 (Thu, 12 May 2011) >> >> Thanks, >> Cameron >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From benny.kra at googlemail.com Sat May 14 10:55:11 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 14 May 2011 17:55:11 +0200 Subject: [llvm-commits] [llvm] r131339 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll In-Reply-To: <20110514055510.F342C2A6C12C@llvm.org> References: <20110514055510.F342C2A6C12C@llvm.org> Message-ID: <237C9B69-8F29-49E3-91B7-4AA98E06FB4D@googlemail.com> On 14.05.2011, at 07:55, Stuart Hastings wrote: > Author: stuart > Date: Sat May 14 00:55:10 2011 > New Revision: 131339 > > URL: http://llvm.org/viewvc/llvm-project?rev=131339&view=rev > Log: > Avoid combining GEPs that might overflow at runtime. > rdar://problem/9267970 > > Patch by Julien Lerouge! [?] > Added: llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll?rev=131339&view=auto > ============================================================================== > --- llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll (added) > +++ llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Sat May 14 00:55:10 2011 > @@ -0,0 +1,19 @@ > +; RUN: opt < %s -instcombine | lli > +; rdar://problem/9267970 > +; ideally this test will run on a 32-bit host ? but it fails on all other hosts. Please put a target datalayout in there if you want to test for specific platforms. Also, executable tests are strongly discouraged, this test should be converted to use FileCheck instead of executing it with lli. From benny.kra at googlemail.com Sat May 14 10:57:25 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 14 May 2011 15:57:25 -0000 Subject: [llvm-commits] [llvm] r131345 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/switch-masked-bits.ll Message-ID: <20110514155725.424552A6C12C@llvm.org> Author: d0k Date: Sat May 14 10:57:25 2011 New Revision: 131345 URL: http://llvm.org/viewvc/llvm-project?rev=131345&view=rev Log: SimplifyCFG: Use ComputeMaskedBits to prune dead cases from switch instructions. Added: llvm/trunk/test/Transforms/SimplifyCFG/switch-masked-bits.ll 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=131345&r1=131344&r2=131345&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Sat May 14 10:57:25 2011 @@ -20,6 +20,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/GlobalVariable.h" #include "llvm/Analysis/InstructionSimplify.h" +#include "llvm/Analysis/ValueTracking.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/ADT/DenseMap.h" @@ -2383,6 +2384,36 @@ return true; } +/// EliminateDeadSwitchCases - Compute masked bits for the condition of a switch +/// and use it to remove dead cases. +static bool EliminateDeadSwitchCases(SwitchInst *SI) { + Value *Cond = SI->getCondition(); + unsigned Bits = cast(Cond->getType())->getBitWidth(); + APInt KnownZero(Bits, 0), KnownOne(Bits, 0); + ComputeMaskedBits(Cond, APInt::getAllOnesValue(Bits), KnownZero, KnownOne); + + // Gather dead cases. + SmallVector DeadCases; + for (unsigned I = 1, E = SI->getNumCases(); I != E; ++I) { + if ((SI->getCaseValue(I)->getValue() & KnownZero) != 0 || + (SI->getCaseValue(I)->getValue() & KnownOne) != KnownOne) { + DeadCases.push_back(SI->getCaseValue(I)); + DEBUG(dbgs() << "SimplifyCFG: switch case '" + << SI->getCaseValue(I)->getValue() << "' is dead.\n"); + } + } + + // Remove dead cases from the switch. + for (unsigned I = 0, E = DeadCases.size(); I != E; ++I) { + unsigned Case = SI->findCaseValue(DeadCases[I]); + // Prune unused values from PHI nodes. + SI->getSuccessor(Case)->removePredecessor(SI->getParent()); + SI->removeCase(Case); + } + + return !DeadCases.empty(); +} + bool SimplifyCFGOpt::SimplifySwitch(SwitchInst *SI) { // If this switch is too complex to want to look at, ignore it. if (!isValueEqualityComparison(SI)) @@ -2414,7 +2445,11 @@ // Try to transform the switch into an icmp and a branch. if (TurnSwitchRangeIntoICmp(SI)) return SimplifyCFG(BB) | true; - + + // Remove unreachable cases. + if (EliminateDeadSwitchCases(SI)) + return SimplifyCFG(BB) | true; + return false; } Added: llvm/trunk/test/Transforms/SimplifyCFG/switch-masked-bits.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/switch-masked-bits.ll?rev=131345&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/switch-masked-bits.ll (added) +++ llvm/trunk/test/Transforms/SimplifyCFG/switch-masked-bits.ll Sat May 14 10:57:25 2011 @@ -0,0 +1,38 @@ +; RUN: opt -S -simplifycfg < %s | FileCheck %s + +define i32 @test1(i32 %x) nounwind { + %i = shl i32 %x, 1 + switch i32 %i, label %a [ + i32 21, label %b + i32 24, label %c + ] + +a: + ret i32 0 +b: + ret i32 3 +c: + ret i32 5 +; CHECK: @test1 +; CHECK: %cond = icmp eq i32 %i, 24 +; CHECK: %merge = select i1 %cond, i32 5, i32 0 +; CHECK: ret i32 %merge +} + + +define i32 @test2(i32 %x) nounwind { + %i = shl i32 %x, 1 + switch i32 %i, label %a [ + i32 21, label %b + i32 23, label %c + ] + +a: + ret i32 0 +b: + ret i32 3 +c: + ret i32 5 +; CHECK: @test2 +; CHECK: ret i32 0 +} From mcinally at cray.com Sat May 14 11:55:11 2011 From: mcinally at cray.com (Cameron McInally) Date: Sat, 14 May 2011 11:55:11 -0500 Subject: [llvm-commits] [PATCH] Error cannot be reached In-Reply-To: <99DD76EE-D12A-4BA4-83B9-90F404FB6BC3@apple.com> References: <4DCC5564.2060406@cray.com> <61B8F381-0482-4745-A404-29EEDF5C5A23@apple.com> <455CB75527BC764BA1E62B31CE4D937C09B67887EE@CFEXMBX.americas.cray.com>, <99DD76EE-D12A-4BA4-83B9-90F404FB6BC3@apple.com> Message-ID: <455CB75527BC764BA1E62B31CE4D937C09B67887F3@CFEXMBX.americas.cray.com> Ah, right. Good point. When I have some free time, I'll investigate further. Thanks for your help, Bob. ________________________________________ From: Bob Wilson [bob.wilson at apple.com] Sent: Saturday, May 14, 2011 1:09 AM To: Cameron McInally Cc: Chris Lattner; llvm-commits at cs.uiuc.edu Subject: Re: [llvm-commits] [PATCH] Error cannot be reached ... If OpName is empty, the previous code would skip over "Args.push_back(OpName)" without calling error(). With the patch, it will now produce an error(). It isn't at all obvious that is the right thing to do. From stuart at apple.com Sat May 14 13:39:05 2011 From: stuart at apple.com (Stuart Hastings) Date: Sat, 14 May 2011 18:39:05 -0000 Subject: [llvm-commits] [llvm] r131350 - /llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Message-ID: <20110514183905.DE17D2A6C12C@llvm.org> Author: stuart Date: Sat May 14 13:39:05 2011 New Revision: 131350 URL: http://llvm.org/viewvc/llvm-project?rev=131350&view=rev Log: Disable this test while I revise it. rdar://problem/9267970 Modified: llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Modified: llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll?rev=131350&r1=131349&r2=131350&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Sat May 14 13:39:05 2011 @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine | lli +; temporarily disabled: opt < %s -instcombine | lli ; rdar://problem/9267970 ; ideally this test will run on a 32-bit host ; must not discard GEPs that might overflow at runtime (aren't inbounds) From stuart at apple.com Sat May 14 13:45:05 2011 From: stuart at apple.com (Stuart Hastings) Date: Sat, 14 May 2011 11:45:05 -0700 Subject: [llvm-commits] [llvm] r131339 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll In-Reply-To: <237C9B69-8F29-49E3-91B7-4AA98E06FB4D@googlemail.com> References: <20110514055510.F342C2A6C12C@llvm.org> <237C9B69-8F29-49E3-91B7-4AA98E06FB4D@googlemail.com> Message-ID: <2858250F-42BE-4CBB-8CA7-6DCD2DFCC9D0@apple.com> On May 14, 2011, at 8:55 AM, Benjamin Kramer wrote: > > On 14.05.2011, at 07:55, Stuart Hastings wrote: > >> Author: stuart >> Date: Sat May 14 00:55:10 2011 >> New Revision: 131339 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=131339&view=rev >> Log: >> Avoid combining GEPs that might overflow at runtime. >> rdar://problem/9267970 >> >> Patch by Julien Lerouge! > [?] >> Added: llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll?rev=131339&view=auto >> ============================================================================== >> --- llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll (added) >> +++ llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Sat May 14 00:55:10 2011 >> @@ -0,0 +1,19 @@ >> +; RUN: opt < %s -instcombine | lli >> +; rdar://problem/9267970 >> +; ideally this test will run on a 32-bit host > > ? but it fails on all other hosts. Please put a target datalayout in there if you want to test for specific platforms. > Also, executable tests are strongly discouraged, this test should be converted to use FileCheck instead of > executing it with lli. Will do. Disabled for now. Sorry for the breakage, stuart From grosser at fim.uni-passau.de Sat May 14 14:01:37 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:01:37 -0000 Subject: [llvm-commits] [polly] r131351 - /polly/trunk/lib/CodeGeneration.cpp Message-ID: <20110514190137.572992A6C12C@llvm.org> Author: grosser Date: Sat May 14 14:01:37 2011 New Revision: 131351 URL: http://llvm.org/viewvc/llvm-project?rev=131351&view=rev Log: CodeGeneration: Support only simple regions Modified: polly/trunk/lib/CodeGeneration.cpp Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=131351&r1=131350&r2=131351&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Sat May 14 14:01:37 2011 @@ -1364,6 +1364,8 @@ return false; } + assert(R->isSimple() && "Only simple regions supported"); + createSeSeEdges(R); // Create a basic block in which to start code generation. From grosser at fim.uni-passau.de Sat May 14 14:01:49 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:01:49 -0000 Subject: [llvm-commits] [polly] r131352 - in /polly/trunk: include/polly/Support/ScopHelper.h lib/CodeGeneration.cpp lib/Support/ScopHelper.cpp test/CodeGen/split_edges.ll test/CodeGen/split_edges_2.ll Message-ID: <20110514190149.C8BA22A6C12C@llvm.org> Author: grosser Date: Sat May 14 14:01:49 2011 New Revision: 131352 URL: http://llvm.org/viewvc/llvm-project?rev=131352&view=rev Log: CodeGeneration: Do not delete the old version of the Scop. Instead of deleting the old code, keep it on the side in an if-branch. It will either be deleted by the dead code elimination or we can use it as fallback. Added: polly/trunk/test/CodeGen/split_edges.ll polly/trunk/test/CodeGen/split_edges_2.ll Modified: polly/trunk/include/polly/Support/ScopHelper.h polly/trunk/lib/CodeGeneration.cpp polly/trunk/lib/Support/ScopHelper.cpp Modified: polly/trunk/include/polly/Support/ScopHelper.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Support/ScopHelper.h?rev=131352&r1=131351&r2=131352&view=diff ============================================================================== --- polly/trunk/include/polly/Support/ScopHelper.h (original) +++ polly/trunk/include/polly/Support/ScopHelper.h Sat May 14 14:01:49 2011 @@ -72,7 +72,6 @@ llvm::Value *getPointerOperand(llvm::Instruction &Inst); // Helper function for LLVM-IR about Scop. - llvm::BasicBlock *createSingleEntryEdge(llvm::Region *R, llvm::Pass *P); llvm::BasicBlock *createSingleExitEdge(llvm::Region *R, llvm::Pass *P); /// @brief Split the entry block of a function to store the newly inserted Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=131352&r1=131351&r2=131352&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Sat May 14 14:01:49 2011 @@ -34,6 +34,7 @@ #include "llvm/Support/IRBuilder.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/ScalarEvolutionExpander.h" +#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Target/TargetData.h" #include "llvm/Module.h" #include "llvm/ADT/SetVector.h" @@ -1271,6 +1272,7 @@ CloogInfo *C; LoopInfo *LI; TargetData *TD; + RegionInfo *RI; std::vector parallelLoops; @@ -1279,17 +1281,6 @@ CodeGeneration() : ScopPass(ID) {} - void createSeSeEdges(Region *R) { - BasicBlock *newEntry = createSingleEntryEdge(R, this); - - for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) - if ((*SI)->getBasicBlock() == R->getEntry()) - (*SI)->setBasicBlock(newEntry); - - createSingleExitEdge(R, this); - } - - // Adding prototypes required if OpenMP is enabled. void addOpenMPDefinitions(IRBuilder<> &Builder) { @@ -1342,10 +1333,90 @@ } } + // Split the entry edge of the region and generate a new basic block on this + // edge. This function also updates ScopInfo and RegionInfo. + // + // @param region The region where the entry edge will be splitted. + BasicBlock *splitEdgeAdvanced(Region *region) { + BasicBlock *newBlock; + BasicBlock *splitBlock; + + newBlock = SplitEdge(region->getEnteringBlock(), region->getEntry(), this); + + if (DT->dominates(region->getEntry(), newBlock)) { + // Update ScopInfo. + for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) + if ((*SI)->getBasicBlock() == newBlock) { + (*SI)->setBasicBlock(newBlock); + break; + } + + // Update RegionInfo. + splitBlock = region->getEntry(); + region->replaceEntry(newBlock); + } else { + RI->setRegionFor(newBlock, region->getParent()); + splitBlock = newBlock; + } + + return splitBlock; + } + + // Create a split block that branches either to the old code or to a new basic + // block where the new code can be inserted. + // + // @param builder A builder that will be set to point to a basic block, where + // the new code can be generated. + // @return The split basic block. + BasicBlock *addSplitAndStartBlock(IRBuilder<> *builder) { + BasicBlock *splitBlock = splitEdgeAdvanced(region); + + splitBlock->setName("polly.enterScop"); + + Function *function = splitBlock->getParent(); + BasicBlock *startBlock = BasicBlock::Create(function->getContext(), + "polly.start", function); + splitBlock->getTerminator()->eraseFromParent(); + builder->SetInsertPoint(splitBlock); + builder->CreateCondBr(builder->getTrue(), startBlock, region->getEntry()); + DT->addNewBlock(startBlock, splitBlock); + + // Start code generation here. + builder->SetInsertPoint(startBlock); + return splitBlock; + } + + // Merge the control flow of the newly generated code with the existing code. + // + // @param splitBlock The basic block where the control flow was split between + // old and new version of the Scop. + // @param builder An IRBuilder that points to the last instruction of the + // newly generated code. + void mergeControlFlow(BasicBlock *splitBlock, IRBuilder<> *builder) { + BasicBlock *mergeBlock; + Region *R = region; + + if (R->getExit()->getSinglePredecessor()) + // No splitEdge required. A block with a single predecessor cannot have + // PHI nodes that would complicate life. + mergeBlock = R->getExit(); + else { + mergeBlock = SplitEdge(R->getExitingBlock(), R->getExit(), this); + // SplitEdge will never split R->getExit(), as R->getExit() has more than + // one predecessor. Hence, mergeBlock is always a newly generated block. + mergeBlock->setName("polly.finalMerge"); + R->replaceExit(mergeBlock); + } + + builder->CreateBr(mergeBlock); + + if (DT->dominates(splitBlock, mergeBlock)) + DT->changeImmediateDominator(mergeBlock, splitBlock); + } + bool runOnScop(Scop &scop) { S = &scop; region = &S->getRegion(); - Region *R = region; DT = &getAnalysis(); Dependences *DP = &getAnalysis(); SE = &getAnalysis(); @@ -1353,91 +1424,66 @@ C = &getAnalysis(); SD = &getAnalysis(); TD = &getAnalysis(); - - Function *F = R->getEntry()->getParent(); + RI = &getAnalysis(); parallelLoops.clear(); + Function *F = region->getEntry()->getParent(); if (CodegenOnly != "" && CodegenOnly != F->getNameStr()) { errs() << "Codegenerating only function '" << CodegenOnly << "' skipping '" << F->getNameStr() << "' \n"; return false; } - assert(R->isSimple() && "Only simple regions supported"); - - createSeSeEdges(R); + assert(region->isSimple() && "Only simple regions are supported"); - // Create a basic block in which to start code generation. - BasicBlock *PollyBB = BasicBlock::Create(F->getContext(), "pollyBB", F); - IRBuilder<> Builder(PollyBB); - DT->addNewBlock(PollyBB, R->getEntry()); - - const clast_root *clast = (const clast_root *) C->getClast(); + // In the CFG and we generate next to original code of the Scop the + // optimized version. Both the new and the original version of the code + // remain in the CFG. A branch statement decides which version is executed. + // At the moment, we always execute the newly generated version (the old one + // is dead code eliminated by the cleanup passes). Later we may decide to + // execute the new version only under certain conditions. This will be the + // case if we support constructs for which we cannot prove all assumptions + // at compile time. + // + // Before transformation: + // + // bb0 + // | + // orig_scop + // | + // bb1 + // + // After transformation: + // bb0 + // | + // polly.splitBlock + // / \ + // | startBlock + // | | + // orig_scop new_scop + // \ / + // \ / + // bb1 (joinBlock) + IRBuilder<> builder(region->getEntry()); - ClastStmtCodeGen CodeGen(S, *SE, DT, SD, DP, TD, Builder); + // The builder will be set to startBlock. + BasicBlock *splitBlock = addSplitAndStartBlock(&builder); if (OpenMP) - addOpenMPDefinitions(Builder); + addOpenMPDefinitions(builder); - CodeGen.codegen(clast); + ClastStmtCodeGen CodeGen(S, *SE, DT, SD, DP, TD, builder); + CodeGen.codegen((const clast_root *) C->getClast()); - // Save the parallel loops generated. parallelLoops.insert(parallelLoops.begin(), CodeGen.getParallelLoops().begin(), CodeGen.getParallelLoops().end()); - BasicBlock *AfterScop = *pred_begin(R->getExit()); - Builder.CreateBr(AfterScop); - - BasicBlock *successorBlock = *succ_begin(R->getEntry()); - - // Update old PHI nodes to pass LLVM verification. - std::vector PHINodes; - for (BasicBlock::iterator SI = successorBlock->begin(), - SE = successorBlock->getFirstNonPHI(); SI != SE; ++SI) { - PHINode *PN = static_cast(&*SI); - PHINodes.push_back(PN); - } - - for (std::vector::iterator PI = PHINodes.begin(), - PE = PHINodes.end(); PI != PE; ++PI) - (*PI)->removeIncomingValue(R->getEntry()); - - DT->changeImmediateDominator(AfterScop, Builder.GetInsertBlock()); - - BasicBlock *OldRegionEntry = *succ_begin(R->getEntry()); - - // Enable the new polly code. - R->getEntry()->getTerminator()->setSuccessor(0, PollyBB); - - // Remove old Scop nodes from dominator tree. - std::vector ToVisit; - std::vector Visited; - ToVisit.push_back(DT->getNode(OldRegionEntry)); - - while (!ToVisit.empty()) { - DomTreeNode *Node = ToVisit.back(); - - ToVisit.pop_back(); - - if (AfterScop == Node->getBlock()) - continue; - - Visited.push_back(Node); - - std::vector Children = Node->getChildren(); - ToVisit.insert(ToVisit.end(), Children.begin(), Children.end()); - } - - for (std::vector::reverse_iterator I = Visited.rbegin(), - E = Visited.rend(); I != E; ++I) - DT->eraseNode((*I)->getBlock()); - - R->getParent()->removeSubRegion(R); + mergeControlFlow(splitBlock, &builder); - // And forget the Scop if we remove the region. - SD->forgetScop(*R); + // Forget the Scop. + SD->forgetScop(*region); return false; } Modified: polly/trunk/lib/Support/ScopHelper.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/ScopHelper.cpp?rev=131352&r1=131351&r2=131352&view=diff ============================================================================== --- polly/trunk/lib/Support/ScopHelper.cpp (original) +++ polly/trunk/lib/Support/ScopHelper.cpp Sat May 14 14:01:49 2011 @@ -223,39 +223,6 @@ return false; } -// Helper function for LLVM-IR about Scop -BasicBlock *polly::createSingleEntryEdge(Region *R, Pass *P) { - BasicBlock *BB = R->getEntry(); - - BasicBlock::iterator SplitIt = BB->begin(); - - while (isa(SplitIt)) - ++SplitIt; - - BasicBlock *newBB = SplitBlock(BB, SplitIt, P); - - for (BasicBlock::iterator PI = BB->begin(); isa(PI); ++PI) { - PHINode *PN = cast(PI); - PHINode *NPN = - PHINode::Create(PN->getType(), 2, PN->getName()+".ph", newBB->begin()); - - for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) { - if (R->contains(*PI)) { - Value *V = PN->removeIncomingValue(*PI, false); - NPN->addIncoming(V, *PI); - } - } - PN->replaceAllUsesWith(NPN); - NPN->addIncoming(PN,BB); - } - - for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) - if (R->contains(*PI)) - (*PI)->getTerminator()->replaceUsesOfWith(BB, newBB); - - return newBB; -} - BasicBlock *polly::createSingleExitEdge(Region *R, Pass *P) { BasicBlock *BB = R->getExit(); Added: polly/trunk/test/CodeGen/split_edges.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/split_edges.ll?rev=131352&view=auto ============================================================================== --- polly/trunk/test/CodeGen/split_edges.ll (added) +++ polly/trunk/test/CodeGen/split_edges.ll Sat May 14 14:01:49 2011 @@ -0,0 +1,39 @@ +; RUN: opt %loadPolly -polly-codegen -verify-region-info -verify-dom-info -S %s | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-pc-linux-gnu" + +define void @loop_with_condition() nounwind { +bb0: + call void @llvm.memory.barrier(i1 true, i1 true, i1 true, i1 true, i1 false) + br label %bb1 + +bb1: + br i1 true, label %bb2, label %bb3 + +bb2: + %ind1 = phi i32 [0, %bb1], [ %inc1, %bb2] + %inc1 = add i32 %ind1, 1 + %cond1 = icmp eq i32 %ind1, 32 + br i1 %cond1, label %bb4, label %bb2 + +bb3: + %ind2 = phi i32 [0, %bb1], [ %inc2, %bb3] + %inc2 = add i32 %ind2, 1 + br i1 true, label %bb4, label %bb3 + +bb4: + br label %bb5 + +bb5: + call void @llvm.memory.barrier(i1 true, i1 true, i1 true, i1 true, i1 false) + ret void + +} + +declare void @llvm.memory.barrier(i1, i1, i1, i1, i1) nounwind + + +; CHECK: polly.enterScop +; CHECK: polly.finalMerge +; CHECK: polly.enterScop +; CHECK: polly.finalMerge Added: polly/trunk/test/CodeGen/split_edges_2.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/split_edges_2.ll?rev=131352&view=auto ============================================================================== --- polly/trunk/test/CodeGen/split_edges_2.ll (added) +++ polly/trunk/test/CodeGen/split_edges_2.ll Sat May 14 14:01:49 2011 @@ -0,0 +1,35 @@ +; RUN: opt %loadPolly -polly-codegen -verify-region-info -verify-dom-info -S %s | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-pc-linux-gnu" + +define void @loop_with_condition() nounwind { +bb0: + call void @llvm.memory.barrier(i1 true, i1 true, i1 true, i1 true, i1 false) + br label %bb1 + +bb1: + br label %bb2 + +bb2: + %ind1 = phi i32 [0, %bb1], [ %inc1, %bb2] + %inc1 = add i32 %ind1, 1 + %cond1 = icmp eq i32 %ind1, 32 + br i1 %cond1, label %bb4, label %bb2 + +bb4: + br label %bb5 + +bb5: + call void @llvm.memory.barrier(i1 true, i1 true, i1 true, i1 true, i1 false) + ret void + +} + +declare void @llvm.memory.barrier(i1, i1, i1, i1, i1) nounwind + +; CHECK: polly.enterScop +; CHECK-NOT: polly.finalMerge + + + From grosser at fim.uni-passau.de Sat May 14 14:01:56 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:01:56 -0000 Subject: [llvm-commits] [polly] r131353 - /polly/trunk/lib/CodeGeneration.cpp Message-ID: <20110514190156.20B572A6C12D@llvm.org> Author: grosser Date: Sat May 14 14:01:55 2011 New Revision: 131353 URL: http://llvm.org/viewvc/llvm-project?rev=131353&view=rev Log: CodeGeneration: Remove -polly-codegen-only If we only want to optimize a single function, we should extract this function into a separate .ll file. This simplifies the code. Modified: polly/trunk/lib/CodeGeneration.cpp Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=131353&r1=131352&r2=131353&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Sat May 14 14:01:55 2011 @@ -78,12 +78,6 @@ cl::value_desc("OpenMP code generation enabled if true"), cl::init(false)); -static cl::opt -CodegenOnly("polly-codegen-only", - cl::desc("Codegen only this function"), cl::Hidden, - cl::value_desc("The function name to codegen"), - cl::ValueRequired, cl::init("")); - typedef DenseMap ValueMapT; typedef DenseMap CharMapT; typedef std::vector VectorValueMapT; @@ -1354,6 +1348,7 @@ // Update RegionInfo. splitBlock = region->getEntry(); region->replaceEntry(newBlock); + RI->setRegionFor(newBlock, region); } else { RI->setRegionFor(newBlock, region->getParent()); splitBlock = newBlock; @@ -1428,13 +1423,6 @@ parallelLoops.clear(); - Function *F = region->getEntry()->getParent(); - if (CodegenOnly != "" && CodegenOnly != F->getNameStr()) { - errs() << "Codegenerating only function '" << CodegenOnly - << "' skipping '" << F->getNameStr() << "' \n"; - return false; - } - assert(region->isSimple() && "Only simple regions are supported"); // In the CFG and we generate next to original code of the Scop the From grosser at fim.uni-passau.de Sat May 14 14:02:06 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:02:06 -0000 Subject: [llvm-commits] [polly] r131354 - in /polly/trunk: include/polly/LinkAllPasses.h lib/CMakeLists.txt lib/ScheduleOptimizer.cpp utils/pollycc Message-ID: <20110514190206.7FA182A6C12C@llvm.org> Author: grosser Date: Sat May 14 14:02:06 2011 New Revision: 131354 URL: http://llvm.org/viewvc/llvm-project?rev=131354&view=rev Log: ScheduleOptimizer: Add an isl based schedule optimizer The isl based routines implement a new interpretation of the Pluto algorithm new interpretation. This patch requires a recent version of isl to be installed. Added: polly/trunk/lib/ScheduleOptimizer.cpp Modified: polly/trunk/include/polly/LinkAllPasses.h polly/trunk/lib/CMakeLists.txt polly/trunk/utils/pollycc Modified: polly/trunk/include/polly/LinkAllPasses.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/LinkAllPasses.h?rev=131354&r1=131353&r2=131354&view=diff ============================================================================== --- polly/trunk/include/polly/LinkAllPasses.h (original) +++ polly/trunk/include/polly/LinkAllPasses.h Sat May 14 14:02:06 2011 @@ -43,6 +43,7 @@ Pass *createJSONImporterPass(); Pass *createRegionSimplifyPass(); Pass *createScopInfoPass(); + Pass *createScheduleOptimizerPass(); #ifdef OPENSCOP_FOUND Pass *createScopExporterPass(); @@ -87,6 +88,7 @@ createJSONImporterPass(); createRegionSimplifyPass(); createScopInfoPass(); + createScheduleOptimizerPass(); #ifdef OPENSCOP_FOUND createScopExporterPass(); Modified: polly/trunk/lib/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CMakeLists.txt?rev=131354&r1=131353&r2=131354&view=diff ============================================================================== --- polly/trunk/lib/CMakeLists.txt (original) +++ polly/trunk/lib/CMakeLists.txt Sat May 14 14:02:06 2011 @@ -32,6 +32,7 @@ MayAliasSet.cpp Pocc.cpp RegionSimplify.cpp + ScheduleOptimizer.cpp Exchange/JSONExporter.cpp ${POLLY_EXCHANGE_FILES} ${POLLY_SCOPLIB_FILES} Added: polly/trunk/lib/ScheduleOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/ScheduleOptimizer.cpp?rev=131354&view=auto ============================================================================== --- polly/trunk/lib/ScheduleOptimizer.cpp (added) +++ polly/trunk/lib/ScheduleOptimizer.cpp Sat May 14 14:02:06 2011 @@ -0,0 +1,251 @@ +//===- Schedule.cpp - Calculate an optimized schedule ---------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This pass the isl to calculate a schedule that is optimized for parallelism +// and tileablility. The algorithm used in isl is an optimized version of the +// algorithm described in following paper: +// +// U. Bondhugula, A. Hartono, J. Ramanujam, and P. Sadayappan. +// A Practical Automatic Polyhedral Parallelizer and Locality Optimizer. +// In Proceedings of the 2008 ACM SIGPLAN Conference On Programming Language +// Design and Implementation, PLDI ???08, pages 101???113. ACM, 2008. +//===----------------------------------------------------------------------===// + +#include "polly/Cloog.h" +#include "polly/LinkAllPasses.h" + +#include "polly/Dependences.h" +#include "polly/ScopInfo.h" + +#include "isl/dim.h" +#include "isl/map.h" +#include "isl/constraint.h" +#include "isl/schedule.h" + +#define DEBUG_TYPE "polly-optimize-isl" +#include "llvm/Support/Debug.h" + +using namespace llvm; +using namespace polly; + +namespace { + + class ScheduleOptimizer : public ScopPass { + + public: + static char ID; + explicit ScheduleOptimizer() : ScopPass(ID) {} + + virtual bool runOnScop(Scop &S); + void printScop(llvm::raw_ostream &OS) const; + void getAnalysisUsage(AnalysisUsage &AU) const; + }; + +} + +char ScheduleOptimizer::ID = 0; + +static int getSingleMap(__isl_take isl_map *map, void *user) { + isl_map **singleMap = (isl_map **) user; + *singleMap = map; + + return 0; +} + +void extendScattering(Scop &S, unsigned scatDimensions) { + for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) { + ScopStmt *stmt = *SI; + + if (stmt->isFinalRead()) + continue; + + isl_map *scattering = stmt->getScattering(); + isl_dim *dim = isl_dim_alloc(isl_map_get_ctx(scattering), + isl_map_n_param(scattering), + isl_map_n_out(scattering), + scatDimensions); + isl_basic_map *changeScattering = isl_basic_map_universe(isl_dim_copy(dim)); + + for (unsigned i = 0; i < isl_map_n_out(scattering); i++) { + isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint_set_coefficient_si(c, isl_dim_in, i, 1); + isl_constraint_set_coefficient_si(c, isl_dim_out, i, -1); + changeScattering = isl_basic_map_add_constraint(changeScattering, c); + } + + for (unsigned i = isl_map_n_out(scattering); i < scatDimensions; i++) { + isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint_set_coefficient_si(c, isl_dim_out, i, 1); + changeScattering = isl_basic_map_add_constraint(changeScattering, c); + } + + isl_map *changeScatteringMap = isl_map_from_basic_map(changeScattering); + + stmt->setScattering(isl_map_apply_range(scattering, changeScatteringMap)); + } +} + +// @brief Tile a band. +// +// This function recieves a map that assigns to the instances of a statement +// an execution time. +// +// [i_0, i_1, i_2] -> [o_0, o_1, o_2, i_0, i_1, i_2]: +// o_0 % 32 = 0 and o_1 % 32 = 0 and o_2 % 32 = 0 +// and o0 <= i0 <= o0 + 32 and o1 <= i1 <= o1 + 32 and o2 <= i2 <= o2 + 32 + +isl_map *tileBand(isl_map *band) { + int dimensions = isl_map_n_out(band); + int tileSize = 32; + + isl_dim *dim = isl_dim_alloc(isl_map_get_ctx(band), isl_map_n_param(band), + dimensions, dimensions * 3); + isl_basic_map *tiledBand = isl_basic_map_universe(isl_dim_copy(dim)); + + for (int i = 0; i < dimensions; i++) { + isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint_set_coefficient_si(c, isl_dim_out, i, 1); + isl_constraint_set_coefficient_si(c, isl_dim_out, 2 * dimensions + i, + -tileSize); + tiledBand = isl_basic_map_add_constraint(tiledBand, c); + + + c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint_set_coefficient_si(c, isl_dim_in, i, -1); + isl_constraint_set_coefficient_si(c, isl_dim_out, dimensions + i, 1); + tiledBand = isl_basic_map_add_constraint(tiledBand, c); + + c = isl_inequality_alloc(isl_dim_copy(dim)); + isl_constraint_set_coefficient_si(c, isl_dim_out, i, -1); + isl_constraint_set_coefficient_si(c, isl_dim_out, dimensions + i, 1); + tiledBand = isl_basic_map_add_constraint(tiledBand, c); + + c = isl_inequality_alloc(isl_dim_copy(dim)); + isl_constraint_set_coefficient_si(c, isl_dim_out, i, 1); + isl_constraint_set_coefficient_si(c, isl_dim_out, dimensions + i, -1); + isl_constraint_set_constant_si(c, tileSize - 1); + tiledBand = isl_basic_map_add_constraint(tiledBand, c); + } + + // Project out auxilary dimensions (introduced to ensure 'ii % tileSize = 0') + // + // The real dimensions are transformed into existentially quantified ones. + // This reduces the number of visible scattering dimensions. Also, Cloog + // produces better code, if auxilary dimensions are existentially quantified. + tiledBand = isl_basic_map_project_out(tiledBand, isl_dim_out, 2 * dimensions, + dimensions); + + return isl_map_apply_range(band, isl_map_from_basic_map(tiledBand)); +} + +bool ScheduleOptimizer::runOnScop(Scop &S) { + Dependences *D = &getAnalysis(); + + // Build input data. + int dependencyKinds = Dependences::TYPE_RAW + | Dependences::TYPE_WAR + | Dependences::TYPE_WAW; + + isl_union_map *validity = D->getDependences(dependencyKinds); + isl_union_map *proximity = D->getDependences(dependencyKinds); + isl_union_set *domain = NULL; + + for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) + if ((*SI)->isFinalRead()) + continue; + else if (!domain) + domain = isl_union_set_from_set((*SI)->getDomain()); + else + domain = isl_union_set_union(domain, + isl_union_set_from_set((*SI)->getDomain())); + + if (!domain) + return false; + + DEBUG(dbgs() << "\n\nCompute schedule from: "); + DEBUG(dbgs() << "Domain := "; isl_union_set_dump(domain); dbgs() << ";\n"); + DEBUG(dbgs() << "Proximity := "; isl_union_map_dump(proximity); + dbgs() << ";\n"); + DEBUG(dbgs() << "Validity := "; isl_union_map_dump(validity); + dbgs() << ";\n"); + + isl_schedule *schedule; + + schedule = isl_union_set_compute_schedule(domain, validity, proximity); + + // Get the complete schedule. + isl_union_map *scheduleMap = isl_schedule_get_map(schedule); + + DEBUG(dbgs() << "Computed schedule: "); + DEBUG(isl_union_map_dump(scheduleMap)); + DEBUG(dbgs() << "Individual bands: "); + + // Get individual tileable bands. + for (int i = 0; i < isl_schedule_n_band(schedule); i++) { + isl_union_map *band = isl_schedule_get_band(schedule, i); + + DEBUG(dbgs() << "Band " << i << ": "); + DEBUG(isl_union_map_dump(band)); + + for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) { + ScopStmt *stmt = *SI; + + if (stmt->isFinalRead()) + continue; + + isl_set *domain = stmt->getDomain(); + isl_union_map *stmtBand; + stmtBand = isl_union_map_intersect_domain(isl_union_map_copy(band), + isl_union_set_from_set(domain)); + + isl_map *sband; + isl_union_map_foreach_map(stmtBand, getSingleMap, &sband); + + sband = tileBand(sband); + DEBUG(dbgs() << "tiled band: "); + DEBUG(isl_map_dump(sband)); + + if (i == 0) + stmt->setScattering(sband); + else { + isl_map *scattering = stmt->getScattering(); + scattering = isl_map_range_product(scattering, sband); + scattering = isl_map_flatten(scattering); + stmt->setScattering(scattering); + } + } + + } + + unsigned maxScatDims = 0; + + for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) + maxScatDims = std::max(isl_map_n_out((*SI)->getScattering()), maxScatDims); + + extendScattering(S, maxScatDims); + isl_schedule_free(schedule); + return false; +} + +void ScheduleOptimizer::printScop(raw_ostream &OS) const { +} + +void ScheduleOptimizer::getAnalysisUsage(AnalysisUsage &AU) const { + ScopPass::getAnalysisUsage(AU); + AU.addRequired(); +} + +static RegisterPass A("polly-optimize-isl", + "Polly - Calculate optimized " + "schedules using the isl schedule " + "calculator"); + +Pass* polly::createScheduleOptimizerPass() { + return new ScheduleOptimizer(); +} Modified: polly/trunk/utils/pollycc URL: http://llvm.org/viewvc/llvm-project/polly/trunk/utils/pollycc?rev=131354&r1=131353&r2=131354&view=diff ============================================================================== --- polly/trunk/utils/pollycc (original) +++ polly/trunk/utils/pollycc Sat May 14 14:02:06 2011 @@ -94,6 +94,12 @@ if args.fpluto: commandLine.append('-polly-optimize') + if args.foptimize: + commandLine.append('-polly-optimize-isl') + + if args.fatLeastOnce: + commandLine.append('-enable-polly-atLeastOnce') + if args.faligned: commandLine.append('-enable-polly-aligned') @@ -232,8 +238,14 @@ parser.add_argument('-fpolly', help='enable polly', action='store_true') parser.add_argument('-fpluto', help='enable pluto', action='store_true') parser.add_argument('-fpluto-fuse', dest='pluto_fuse', help='enable pluto') + parser.add_argument('-foptimize', + help='Optimize schedule with isl pluto like algorithm', + action='store_true') parser.add_argument('-faligned', help='Assume aligned vector accesses', action='store_true') + parser.add_argument('-fatLeastOnce', + help='Assume all loops are executed at least once', + action='store_true') parser.add_argument('-fview-scops', dest='view', help='Show the scops with graphviz', action='store_true') @@ -285,6 +297,9 @@ if arguments.fpluto: arguments.fpolly = True + if arguments.foptimize: + arguments.fpolly = True + return arguments def createAssemblyFiles(files, args, pollyLib): From grosser at fim.uni-passau.de Sat May 14 14:02:12 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:02:12 -0000 Subject: [llvm-commits] [polly] r131355 - /polly/trunk/lib/CodeGeneration.cpp Message-ID: <20110514190212.86D242A6C12D@llvm.org> Author: grosser Date: Sat May 14 14:02:12 2011 New Revision: 131355 URL: http://llvm.org/viewvc/llvm-project?rev=131355&view=rev Log: CodeGeneration: We do not preserve the PostDominatorTree Modified: polly/trunk/lib/CodeGeneration.cpp Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=131355&r1=131354&r2=131355&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Sat May 14 14:02:12 2011 @@ -1497,7 +1497,6 @@ AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); - AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); From grosser at fim.uni-passau.de Sat May 14 14:02:21 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:02:21 -0000 Subject: [llvm-commits] [polly] r131356 - in /polly/trunk: include/polly/ScopDetection.h lib/Analysis/ScopDetection.cpp lib/CodeGeneration.cpp Message-ID: <20110514190221.61FA92A6C12C@llvm.org> Author: grosser Date: Sat May 14 14:02:21 2011 New Revision: 131356 URL: http://llvm.org/viewvc/llvm-project?rev=131356&view=rev Log: CodeGeneration: No need to forget SCoP. As we do not delete the SCoP, there is no need to remove it from the SCoP detection. Modified: polly/trunk/include/polly/ScopDetection.h polly/trunk/lib/Analysis/ScopDetection.cpp polly/trunk/lib/CodeGeneration.cpp Modified: polly/trunk/include/polly/ScopDetection.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetection.h?rev=131356&r1=131355&r2=131356&view=diff ============================================================================== --- polly/trunk/include/polly/ScopDetection.h (original) +++ polly/trunk/include/polly/ScopDetection.h Sat May 14 14:02:21 2011 @@ -244,11 +244,6 @@ const_iterator end() const { return ValidRegions.end(); } //@} - /// @brief Remove a region and its children from valid region set. - /// - /// @param R The region to remove. - void forgetScop(const Region &R); - /// @brief Mark the function as invalid so we will not extract any scop from /// the function. /// Modified: polly/trunk/lib/Analysis/ScopDetection.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=131356&r1=131355&r2=131356&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopDetection.cpp (original) +++ polly/trunk/lib/Analysis/ScopDetection.cpp Sat May 14 14:02:21 2011 @@ -624,11 +624,6 @@ verifyRegion(**I); } -void ScopDetection::forgetScop(const Region &R) { - assert(isMaxRegionInScop(R) && "R is not a Scop!"); - ValidRegions.erase(&R); -} - void ScopDetection::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.addRequired(); Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=131356&r1=131355&r2=131356&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Sat May 14 14:02:21 2011 @@ -1470,9 +1470,6 @@ mergeControlFlow(splitBlock, &builder); - // Forget the Scop. - SD->forgetScop(*region); - return false; } From grosser at fim.uni-passau.de Sat May 14 14:02:29 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:02:29 -0000 Subject: [llvm-commits] [polly] r131357 - in /polly/trunk: include/polly/Cloog.h lib/Cloog.cpp lib/CodeGeneration.cpp Message-ID: <20110514190229.8D9C92A6C12C@llvm.org> Author: grosser Date: Sat May 14 14:02:29 2011 New Revision: 131357 URL: http://llvm.org/viewvc/llvm-project?rev=131357&view=rev Log: Cloog: Export clast_root Modified: polly/trunk/include/polly/Cloog.h polly/trunk/lib/Cloog.cpp polly/trunk/lib/CodeGeneration.cpp Modified: polly/trunk/include/polly/Cloog.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Cloog.h?rev=131357&r1=131356&r2=131357&view=diff ============================================================================== --- polly/trunk/include/polly/Cloog.h (original) +++ polly/trunk/include/polly/Cloog.h Sat May 14 14:02:29 2011 @@ -53,7 +53,7 @@ void pprint(llvm::raw_ostream &OS); /// Create the CLooG AST from this program. - const struct clast_stmt *getClast(); + const struct clast_root *getClast(); bool runOnScop(Scop &S); void printScop(llvm::raw_ostream &OS) const; Modified: polly/trunk/lib/Cloog.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Cloog.cpp?rev=131357&r1=131356&r2=131357&view=diff ============================================================================== --- polly/trunk/lib/Cloog.cpp (original) +++ polly/trunk/lib/Cloog.cpp Sat May 14 14:02:29 2011 @@ -57,7 +57,7 @@ void pprint(llvm::raw_ostream &OS); /// Create the Cloog AST from this program. - struct clast_stmt *getClast(); + struct clast_root *getClast(); }; Cloog::Cloog(Scop *Scop) : S(Scop) { @@ -137,8 +137,8 @@ } /// Create the Cloog AST from this program. -struct clast_stmt *Cloog::getClast() { - return ClastRoot; +struct clast_root *Cloog::getClast() { + return (clast_root*)ClastRoot; } void Cloog::buildCloogOptions() { @@ -261,7 +261,7 @@ } /// Create the Cloog AST from this program. -const struct clast_stmt *CloogInfo::getClast() { +const struct clast_root *CloogInfo::getClast() { return C->getClast(); } Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=131357&r1=131356&r2=131357&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Sat May 14 14:02:29 2011 @@ -1462,7 +1462,7 @@ addOpenMPDefinitions(builder); ClastStmtCodeGen CodeGen(S, *SE, DT, SD, DP, TD, builder); - CodeGen.codegen((const clast_root *) C->getClast()); + CodeGen.codegen(C->getClast()); parallelLoops.insert(parallelLoops.begin(), CodeGen.getParallelLoops().begin(), From grosser at fim.uni-passau.de Sat May 14 14:02:34 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:02:34 -0000 Subject: [llvm-commits] [polly] r131358 - /polly/trunk/lib/CodeGeneration.cpp Message-ID: <20110514190234.CE71B2A6C12D@llvm.org> Author: grosser Date: Sat May 14 14:02:34 2011 New Revision: 131358 URL: http://llvm.org/viewvc/llvm-project?rev=131358&view=rev Log: CodeGeneration: Admit that we change the code. No need to pretend anymore that we do not update the LLVM-IR. Modified: polly/trunk/lib/CodeGeneration.cpp Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=131358&r1=131357&r2=131358&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Sat May 14 14:02:34 2011 @@ -1470,7 +1470,7 @@ mergeControlFlow(splitBlock, &builder); - return false; + return true; } virtual void printScop(raw_ostream &OS) const { From grosser at fim.uni-passau.de Sat May 14 14:02:39 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:02:39 -0000 Subject: [llvm-commits] [polly] r131359 - /polly/trunk/lib/CodeGeneration.cpp Message-ID: <20110514190240.031E62A6C12C@llvm.org> Author: grosser Date: Sat May 14 14:02:39 2011 New Revision: 131359 URL: http://llvm.org/viewvc/llvm-project?rev=131359&view=rev Log: CodeGeneration: Localize variables Modified: polly/trunk/lib/CodeGeneration.cpp Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=131359&r1=131358&r2=131359&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Sat May 14 14:02:39 2011 @@ -1263,7 +1263,6 @@ DominatorTree *DT; ScalarEvolution *SE; ScopDetection *SD; - CloogInfo *C; LoopInfo *LI; TargetData *TD; RegionInfo *RI; @@ -1416,7 +1415,6 @@ Dependences *DP = &getAnalysis(); SE = &getAnalysis(); LI = &getAnalysis(); - C = &getAnalysis(); SD = &getAnalysis(); TD = &getAnalysis(); RI = &getAnalysis(); @@ -1462,7 +1460,8 @@ addOpenMPDefinitions(builder); ClastStmtCodeGen CodeGen(S, *SE, DT, SD, DP, TD, builder); - CodeGen.codegen(C->getClast()); + CloogInfo &C = getAnalysis(); + CodeGen.codegen(C.getClast()); parallelLoops.insert(parallelLoops.begin(), CodeGen.getParallelLoops().begin(), From grosser at fim.uni-passau.de Sat May 14 14:02:45 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:02:45 -0000 Subject: [llvm-commits] [polly] r131360 - /polly/trunk/lib/CodeGeneration.cpp Message-ID: <20110514190245.B08092A6C12D@llvm.org> Author: grosser Date: Sat May 14 14:02:45 2011 New Revision: 131360 URL: http://llvm.org/viewvc/llvm-project?rev=131360&view=rev Log: CodeGeneration: Cleanup getAnalysis/addPreserved Modified: polly/trunk/lib/CodeGeneration.cpp Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=131360&r1=131359&r2=131360&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Sat May 14 14:02:45 2011 @@ -1263,7 +1263,6 @@ DominatorTree *DT; ScalarEvolution *SE; ScopDetection *SD; - LoopInfo *LI; TargetData *TD; RegionInfo *RI; @@ -1414,7 +1413,6 @@ DT = &getAnalysis(); Dependences *DP = &getAnalysis(); SE = &getAnalysis(); - LI = &getAnalysis(); SD = &getAnalysis(); TD = &getAnalysis(); RI = &getAnalysis(); @@ -1483,7 +1481,6 @@ AU.addRequired(); AU.addRequired(); AU.addRequired(); - AU.addRequired(); AU.addRequired(); AU.addRequired(); AU.addRequired(); @@ -1491,10 +1488,15 @@ AU.addPreserved(); AU.addPreserved(); + + // XXX: We do not create LoopInfo for the newly generated loops. AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); + + // XXX: We do not yet add regions for the newly generated code to the region + // tree. AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); From grosser at fim.uni-passau.de Sat May 14 14:02:51 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 May 2011 19:02:51 -0000 Subject: [llvm-commits] [polly] r131361 - in /polly/trunk/www: content.css todo.html Message-ID: <20110514190251.3F3642A6C12C@llvm.org> Author: grosser Date: Sat May 14 14:02:51 2011 New Revision: 131361 URL: http://llvm.org/viewvc/llvm-project?rev=131361&view=rev Log: www: Colorize TODO status Modified: polly/trunk/www/content.css polly/trunk/www/todo.html Modified: polly/trunk/www/content.css URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/content.css?rev=131361&r1=131360&r2=131361&view=diff ============================================================================== --- polly/trunk/www/content.css (original) +++ polly/trunk/www/content.css Sat May 14 14:02:51 2011 @@ -14,6 +14,10 @@ li { padding-bottom: 0.5em; } ul { padding-left:1.5em; } +TD.done {background-color: #88ff99; text-align: center} +TD.inprogress{background-color: #ffce00; text-align: center} +TD.open{background-color: #e6705f; text-align: center} + PRE.code {padding-left: 0.5em; background-color: #eeeeee} PRE {padding-left: 0.5em} Modified: polly/trunk/www/todo.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/todo.html?rev=131361&r1=131360&r2=131361&view=diff ============================================================================== --- polly/trunk/www/todo.html (original) +++ polly/trunk/www/todo.html Sat May 14 14:02:51 2011 @@ -23,36 +23,36 @@ @@ -164,20 +164,20 @@ @@ -193,18 +193,18 @@ @@ -273,13 +273,13 @@ - @@ -294,7 +294,7 @@ @@ -310,12 +310,12 @@
Task - Status +Task + Status Owner
Move to LLVM svn - done + Move to LLVM SVN + done
+http://llvm.org/svn/llvm-project/polly/trunk/www
Tobias
Get git mirror at llvm.org/git/polly.git - done + Git mirror + done
+git://llvm.org/git/polly.git
Tobias
Setup on commit mails - + Commit mails + done
+llvm-commits at cs.uiuc.edu
Tobias
Add LLVM Bugzilla category -
LLVM Bugzilla category + done
+LLVM Bugzilla +
+(Product is 'Projects', Component is 'Polly') +
Tobias
Create polly.llvm.org website - + Website + in progress +
+http://polly.grosser.es, +later maybe polly.llvm.org +
Tobias
Add Polly buildbot that runs 'polly-test' - +Buildbot that runs 'make polly-test' + + Raghesh, Andreas
Run nightly performance/coverage tests with the llvm -test-suite + Nightly performance/coverage tests
(with the llvm +test-suite) +
+ Andreas +
Move to LLVM SVN - done
+
done
http://llvm.org/svn/llvm-project/polly/trunk/www +>http://llvm.org/svn/llvm-project/polly
Tobias
Git mirror - done
+
done
git://llvm.org/git/polly.git
Tobias
Commit mails - done
+
done
llvm-commits at cs.uiuc.edu
Tobias
LLVM Bugzilla category - done
+
done
LLVM Bugzilla
(Product is 'Projects', Component is 'Polly')
Tobias
Website - in progress + in progress
http://polly.grosser.es, later maybe polly.llvm.org @@ -61,7 +61,7 @@
Buildbot that runs 'make polly-test' - Raghesh, Andreas + Raghesh,
Andreas
Nightly performance/coverage tests
(with the llvm @@ -118,25 +118,25 @@
Implement ISL dependency analysis pass - working + working Tobias
Connect pocc/pluto - working + working Tobias
Finish OpenSCoP support - +Blocked (waiting for OpenSCoP)
Add SCoPLib 0.2 support to connect pocc -done +done Tobias
Add write support for data access functions - +Still open
Create vector loops -70% done +70% done Tobias
Create OpenMP loops -90% done +90% done Raghesh & Tobias
Commit RegionPass patch upstream - done + done Tobias
Build against an installed LLVM - works for cmake + Partial (cmake build without tests) ether
Setup buildbot regression testers using LNT - +Still open @@ -231,34 +231,34 @@
Region detection - works + Committed upstream + Working + Committed upstream Ether
Access Functions - Working - John + Ether + Working +John + Ether
Alias sets - Still open + Still open
Scalar evolution to affine expression - Done + Done Ether
SCoP extraction - Working + Working Tobias + Ether
SCoPs to polyhedral model - Working + Working Tobias + Ether
Define polyhedral description - Working + Working Tobias
Import/Export using openscop - working + Import/Export using current openscop version + Working Tobias
Create LLVM-IR using CLooG - Working + Working Tobias
Setup git repositories - Done + Done Tobias
Add CLooG/isl to build system - Works on Unix + Works on Unix Tobias
From benny.kra at googlemail.com Sat May 14 14:30:39 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 14 May 2011 19:30:39 -0000 Subject: [llvm-commits] [llvm] r131363 - /llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Message-ID: <20110514193039.DA3DA2A6C12C@llvm.org> Author: d0k Date: Sat May 14 14:30:39 2011 New Revision: 131363 URL: http://llvm.org/viewvc/llvm-project?rev=131363&view=rev Log: Disable test harder. Modified: llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Modified: llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll?rev=131363&r1=131362&r2=131363&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Sat May 14 14:30:39 2011 @@ -1,4 +1,5 @@ -; temporarily disabled: opt < %s -instcombine | lli +; RUN: opt < %s -instcombine | lli +; REQUIRES: disabled ; rdar://problem/9267970 ; ideally this test will run on a 32-bit host ; must not discard GEPs that might overflow at runtime (aren't inbounds) From stuart at apple.com Sat May 14 15:38:37 2011 From: stuart at apple.com (Stuart Hastings) Date: Sat, 14 May 2011 13:38:37 -0700 Subject: [llvm-commits] [llvm] r131363 - /llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll In-Reply-To: <20110514193039.DA3DA2A6C12C@llvm.org> References: <20110514193039.DA3DA2A6C12C@llvm.org> Message-ID: <4FE11A03-2966-4F20-8FA9-23D538128DC2@apple.com> On May 14, 2011, at 12:30 PM, Benjamin Kramer wrote: > Author: d0k > Date: Sat May 14 14:30:39 2011 > New Revision: 131363 > > URL: http://llvm.org/viewvc/llvm-project?rev=131363&view=rev > Log: > Disable test harder. Thank you, stuart > > Modified: > llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll > > Modified: llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll?rev=131363&r1=131362&r2=131363&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll (original) > +++ llvm/trunk/test/Transforms/InstCombine/2011-05-13-InBoundsGEP.ll Sat May 14 14:30:39 2011 > @@ -1,4 +1,5 @@ > -; temporarily disabled: opt < %s -instcombine | lli > +; RUN: opt < %s -instcombine | lli > +; REQUIRES: disabled > ; rdar://problem/9267970 > ; ideally this test will run on a 32-bit host > ; must not discard GEPs that might overflow at runtime (aren't inbounds) > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From csdavec at swan.ac.uk Sat May 14 16:01:53 2011 From: csdavec at swan.ac.uk (David Chisnall) Date: Sat, 14 May 2011 22:01:53 +0100 Subject: [llvm-commits] Configurable default pass sets, take 2 Message-ID: Hi Everyone, Here's an updated version of the stuff for allowing plugins to modify the default pass set, incorporating comments. I'm now using this with a plugin, and it seems to work nicely (and it's so much easier to test passes when you can run them automatically from clang without needing to touch any code outside the plugin). David -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm.diff Type: application/octet-stream Size: 39895 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110514/d3997739/attachment-0001.obj From clattner at apple.com Sat May 14 20:35:39 2011 From: clattner at apple.com (Chris Lattner) Date: Sat, 14 May 2011 18:35:39 -0700 Subject: [llvm-commits] [llvm] r130894 - /llvm/trunk/lib/Transforms/Utils/LCSSA.cpp In-Reply-To: <27357309-4B90-4742-BDB7-01A6F51BD608@apple.com> References: <20110504235822.F2B842A6C12C@llvm.org> <5B056F2B-45B0-44A5-B5E0-7F26BBBDC2A6@apple.com> <27357309-4B90-4742-BDB7-01A6F51BD608@apple.com> Message-ID: <561F6D6B-D4A0-4A53-86D0-FFCDD73EDB83@apple.com> On May 5, 2011, at 9:31 AM, Devang Patel wrote: > > On May 4, 2011, at 5:57 PM, Chris Lattner wrote: > >> >> On May 4, 2011, at 4:58 PM, Devang Patel wrote: >> >>> Author: dpatel >>> Date: Wed May 4 18:58:22 2011 >>> New Revision: 130894 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=130894&view=rev >>> Log: >>> Set debug location for new PHI nodes created in exit block. >> >> Devang, >> >> What does a debug loc even mean for a PHI node? Conceptually a phi node is a copy in each of the predecessors, certainly it can't have a single debug loc? >> > > True, but the copy needs a location. Do you have any thoughts on better alternative? Why does the copy need a location? When it gets lowered to a machineinstr, why not use the location of whatever is before it in the block? -Chris From cdavis at mymail.mines.edu Sat May 14 21:43:42 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Sat, 14 May 2011 20:43:42 -0600 Subject: [llvm-commits] [PATCH] Win64 Exception Handling Definitions Message-ID: <4DCF3DDE.1000202@mymail.mines.edu> Hi, The attached patch adds a header with some definitions used to implement Win64 exception handling. OK to commit? Chip -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: w64-eh-header.patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110514/367c04d5/attachment.pl From nicholas at mxc.ca Sun May 15 02:20:34 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 15 May 2011 07:20:34 -0000 Subject: [llvm-commits] [llvm] r131379 - /llvm/trunk/include/llvm-c/Core.h Message-ID: <20110515072034.89E322A6C12C@llvm.org> Author: nicholas Date: Sun May 15 02:20:34 2011 New Revision: 131379 URL: http://llvm.org/viewvc/llvm-project?rev=131379&view=rev Log: Declare this function here so that it doesn't get C++ mangling. Modified: llvm/trunk/include/llvm-c/Core.h Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=131379&r1=131378&r2=131379&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Sun May 15 02:20:34 2011 @@ -282,6 +282,8 @@ LLVMRealPredicateTrue /**< Always true (always folded) */ } LLVMRealPredicate; +void LLVMInitializeCore(LLVMPassRegistryRef R); + /*===-- Error handling ----------------------------------------------------===*/ From anton at korobeynikov.info Sun May 15 04:13:24 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sun, 15 May 2011 13:13:24 +0400 Subject: [llvm-commits] [PATCH] Win64 Exception Handling Definitions In-Reply-To: <4DCF3DDE.1000202@mymail.mines.edu> References: <4DCF3DDE.1000202@mymail.mines.edu> Message-ID: Hi Chip, > The attached patch adds a header with some definitions used to implement > Win64 exception handling. OK to commit? LGTM -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From cdavis at mines.edu Sun May 15 09:42:22 2011 From: cdavis at mines.edu (Charles Davis) Date: Sun, 15 May 2011 14:42:22 -0000 Subject: [llvm-commits] [llvm] r131380 - /llvm/trunk/include/llvm/Support/Win64EH.h Message-ID: <20110515144222.47D2E2A6C12C@llvm.org> Author: cdavis Date: Sun May 15 09:42:22 2011 New Revision: 131380 URL: http://llvm.org/viewvc/llvm-project?rev=131380&view=rev Log: Add a header containing definitions used to implement Win64 exception handling. Added: llvm/trunk/include/llvm/Support/Win64EH.h Added: llvm/trunk/include/llvm/Support/Win64EH.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Win64EH.h?rev=131380&view=auto ============================================================================== --- llvm/trunk/include/llvm/Support/Win64EH.h (added) +++ llvm/trunk/include/llvm/Support/Win64EH.h Sun May 15 09:42:22 2011 @@ -0,0 +1,100 @@ +//===-- llvm/Support/Win64EH.h ---Win64 EH Constants-------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains constants and structures used for implementing +// exception handling on Win64 platforms. For more information, see +// http://msdn.microsoft.com/en-us/library/1eyas8tf.aspx +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_WIN64EH_H +#define LLVM_SUPPORT_WIN64EH_H + +namespace llvm { +namespace Win64EH { + +extern "C" { + +/// UnwindOpcodes - Enumeration whose values specify a single operation in +/// the prolog of a function. +enum UnwindOpcodes { + UOP_PushNonVol = 0, + UOP_AllocLarge, + UOP_AllocSmall, + UOP_SetFPReg, + UOP_SaveNonVol, + UOP_SaveNonVolBig, + UOP_SaveXMM128, + UOP_SaveXMM128Big, + UOP_PushMachFrame +}; + +/// UnwindCode - This union describes a single operation in a function prolog, +/// or part thereof. +union UnwindCode { + struct { + uint8_t codeOffset; + uint8_t unwindOp:4, + opInfo:4; + }; + uint16_t frameOffset; +}; + +enum { + /// UNW_ExceptionHandler - Specifies that this function has an exception + /// handler. + UNW_ExceptionHandler = 0x01, + /// UNW_TerminateHandler - Specifies that this function has a termination + /// handler. + UNW_TerminateHandler = 0x02, + /// UNW_ChainInfo - Specifies that this UnwindInfo structure is chained to + /// another one. + UNW_ChainInfo = 0x04 +}; + +/// UnwindInfo - An entry in the exception table. +struct UnwindInfo { + uint8_t version:3, + flags:5; + uint8_t prologSize; + uint8_t numCodes; + uint8_t frameRegister:4, + frameOffset:4; + UnwindCode unwindCodes[1]; +}; + +inline UnwindCode &getUnwindCodeEntry(UnwindInfo &info, uint32_t index) { + return info.unwindCodes[index]; +} +inline void *getLanguageSpecificData(UnwindInfo &info) { + return reinterpret_cast(&getUnwindCodeEntry(info,info.numCodes+1)&~1); +} +inline uint64_t getLanguageSpecificHandlerOffset(UnwindInfo &info) { + return *reinterpret_cast(getLangaugeSpecificData(info)); +} +inline void setLanguageSpecificHandlerOffset(UnwindInfo &info, uint64_t offset){ + *reinterpret_cast(getLanguageSpecificData(info)) = offset; +} +inline uint64_t getChainedFunctionEntryOffset(UnwindInfo &info) { + return *reinterpret_cast(getLanguageSpecificData(info)); +} +inline void setChainedFunctionEntryOffset(UnwindInfo &info, uint64_t offset) { + *reinterpret_cast(getLanguageSpecificData(info)) = offset; +} +inline void *getExceptionData(UnwindInfo &info) { + return reinterpret_cast(reinterpret_cast( + getLanguageSpecificData(info))+1); +} + +} // End of extern "C" + +} // End of namespace Win64EH +} // End of namespace llvm + +#endif From cdavis at mymail.mines.edu Sun May 15 09:47:55 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Sun, 15 May 2011 08:47:55 -0600 Subject: [llvm-commits] [PATCH] Win64 Exception Handling Definitions In-Reply-To: References: <4DCF3DDE.1000202@mymail.mines.edu> Message-ID: <4DCFE79B.20407@mymail.mines.edu> On 5/15/11 3:13 AM, Anton Korobeynikov wrote: > Hi Chip, > >> The attached patch adds a header with some definitions used to implement >> Win64 exception handling. OK to commit? > LGTM Committed in r131380. Chip From rjmccall at apple.com Sun May 15 12:08:17 2011 From: rjmccall at apple.com (John McCall) Date: Sun, 15 May 2011 10:08:17 -0700 Subject: [llvm-commits] [PATCH] Win64 Exception Handling Definitions In-Reply-To: <4DCFE79B.20407@mymail.mines.edu> References: <4DCF3DDE.1000202@mymail.mines.edu> <4DCFE79B.20407@mymail.mines.edu> Message-ID: <0ED914C6-C3FB-4485-9779-A454DD25AB3A@apple.com> On May 15, 2011, at 7:47 AM, Charles Davis wrote: > On 5/15/11 3:13 AM, Anton Korobeynikov wrote: >> Hi Chip, >> >>> The attached patch adds a header with some definitions used to implement >>> Win64 exception handling. OK to commit? >> LGTM > Committed in r131380. Why are these extern "C"? John. From cdavis at mines.edu Sun May 15 12:09:26 2011 From: cdavis at mines.edu (Charles Davis) Date: Sun, 15 May 2011 17:09:26 -0000 Subject: [llvm-commits] [llvm] r131381 - /llvm/trunk/include/llvm/Support/Win64EH.h Message-ID: <20110515170926.705EB2A6C12C@llvm.org> Author: cdavis Date: Sun May 15 12:09:26 2011 New Revision: 131381 URL: http://llvm.org/viewvc/llvm-project?rev=131381&view=rev Log: Get rid of extern "C" from the Win64 EH header. Modified: llvm/trunk/include/llvm/Support/Win64EH.h Modified: llvm/trunk/include/llvm/Support/Win64EH.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Win64EH.h?rev=131381&r1=131380&r2=131381&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Win64EH.h (original) +++ llvm/trunk/include/llvm/Support/Win64EH.h Sun May 15 12:09:26 2011 @@ -19,8 +19,6 @@ namespace llvm { namespace Win64EH { -extern "C" { - /// UnwindOpcodes - Enumeration whose values specify a single operation in /// the prolog of a function. enum UnwindOpcodes { @@ -92,8 +90,6 @@ getLanguageSpecificData(info))+1); } -} // End of extern "C" - } // End of namespace Win64EH } // End of namespace llvm From cdavis at mymail.mines.edu Sun May 15 12:15:03 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Sun, 15 May 2011 11:15:03 -0600 Subject: [llvm-commits] [PATCH] Win64 Exception Handling Definitions In-Reply-To: <0ED914C6-C3FB-4485-9779-A454DD25AB3A@apple.com> References: <4DCF3DDE.1000202@mymail.mines.edu> <4DCFE79B.20407@mymail.mines.edu> <0ED914C6-C3FB-4485-9779-A454DD25AB3A@apple.com> Message-ID: <4DD00A17.6030807@mymail.mines.edu> On 5/15/11 11:08 AM, John McCall wrote: > On May 15, 2011, at 7:47 AM, Charles Davis wrote: >> On 5/15/11 3:13 AM, Anton Korobeynikov wrote: >>> Hi Chip, >>> >>>> The attached patch adds a header with some definitions used to implement >>>> Win64 exception handling. OK to commit? >>> LGTM >> Committed in r131380. > > Why are these extern "C"? No reason. I got rid of it in r131381. Chip From cdavis at mines.edu Sun May 15 12:20:01 2011 From: cdavis at mines.edu (Charles Davis) Date: Sun, 15 May 2011 17:20:01 -0000 Subject: [llvm-commits] [llvm] r131382 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCStreamer.cpp Message-ID: <20110515172001.CCD882A6C12C@llvm.org> Author: cdavis Date: Sun May 15 12:20:01 2011 New Revision: 131382 URL: http://llvm.org/viewvc/llvm-project?rev=131382&view=rev Log: Add stub methods to MCStreamer for emitting Win64 exception-handling information. Modified: llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/MC/MCStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=131382&r1=131381&r2=131382&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Sun May 15 12:20:01 2011 @@ -293,6 +293,7 @@ /// if non-zero. This must be a power of 2 on some targets. virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment = 0) = 0; + /// @} /// @name Generating Data /// @{ @@ -456,6 +457,13 @@ virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset); virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment); + virtual void EmitWin64EHFrame(MCSymbol *Symbol, MCSymbol *EHandler = 0); + virtual void EmitWin64EHPushReg(int64_t Register); + virtual void EmitWin64EHSetFrame(int64_t Register, int64_t Offset); + virtual void EmitWin64EHAllocStack(int64_t Size); + virtual void EmitWin64EHSaveReg(int64_t Register, int64_t Offset); + virtual void EmitWin64EHPushFrame(bool Code); + /// EmitInstruction - Emit the given @p Instruction into the current /// section. virtual void EmitInstruction(const MCInst &Inst) = 0; Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=131382&r1=131381&r2=131382&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Sun May 15 12:20:01 2011 @@ -310,6 +310,42 @@ CurFrame->Instructions.push_back(Instruction); } +void MCStreamer::EmitWin64EHFrame(MCSymbol *Symbol, MCSymbol *EHandler = 0) +{ + errs() << "Not implemented yet\n"; + abort(); +} + +void MCStreamer::EmitWin64EHPushReg(int64_t Register) +{ + errs() << "Not implemented yet\n"; + abort(); +} + +void MCStreamer::EmitWin64EHSetFrame(int64_t Register, int64_t Offset) +{ + errs() << "Not implemented yet\n"; + abort(); +} + +void MCStreamer::EmitWin64EHAllocStack(int64_t Size) +{ + errs() << "Not implemented yet\n"; + abort(); +} + +void MCStreamer::EmitWin64EHSaveReg(int64_t Register, int64_t Offset) +{ + errs() << "Not implemented yet\n"; + abort(); +} + +void MCStreamer::EmitWin64EHPushFrame(bool Code) +{ + errs() << "Not implemented yet\n"; + abort(); +} + void MCStreamer::EmitFnStart() { errs() << "Not implemented yet\n"; abort(); From cdavis at mines.edu Sun May 15 12:28:27 2011 From: cdavis at mines.edu (Charles Davis) Date: Sun, 15 May 2011 17:28:27 -0000 Subject: [llvm-commits] [llvm] r131384 - /llvm/trunk/lib/MC/MCStreamer.cpp Message-ID: <20110515172827.31FDB2A6C12C@llvm.org> Author: cdavis Date: Sun May 15 12:28:27 2011 New Revision: 131384 URL: http://llvm.org/viewvc/llvm-project?rev=131384&view=rev Log: Fix copy-pasto. Modified: llvm/trunk/lib/MC/MCStreamer.cpp Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=131384&r1=131383&r2=131384&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Sun May 15 12:28:27 2011 @@ -310,7 +310,7 @@ CurFrame->Instructions.push_back(Instruction); } -void MCStreamer::EmitWin64EHFrame(MCSymbol *Symbol, MCSymbol *EHandler = 0) +void MCStreamer::EmitWin64EHFrame(MCSymbol *Symbol, MCSymbol *EHandler) { errs() << "Not implemented yet\n"; abort(); From baldrick at free.fr Sun May 15 14:59:30 2011 From: baldrick at free.fr (Duncan Sands) Date: Sun, 15 May 2011 19:59:30 -0000 Subject: [llvm-commits] [dragonegg] r131388 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp Message-ID: <20110515195930.36C342A6C12C@llvm.org> Author: baldrick Date: Sun May 15 14:59:30 2011 New Revision: 131388 URL: http://llvm.org/viewvc/llvm-project?rev=131388&view=rev Log: Implement REDUC_MAX_EXPR and REDUC_MIN_EXPR differently, always operating in a vector of same type rather than halving the length each time. Modified: dragonegg/trunk/include/dragonegg/Internals.h dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/include/dragonegg/Internals.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=131388&r1=131387&r2=131388&view=diff ============================================================================== --- dragonegg/trunk/include/dragonegg/Internals.h (original) +++ dragonegg/trunk/include/dragonegg/Internals.h Sun May 15 14:59:30 2011 @@ -886,10 +886,6 @@ /// elements of the given vector with indices in the bottom half. Value *VectorLowElements(Value *Vec); - /// ReducMinMaxExprHelper - Split the given vector in two and form the max/min - /// of the two pieces; repeat recursively on the result until scalar. - Value *ReducMinMaxExprHelper(Value *Op, CmpInst::Predicate Pred); - private: // Optional target defined builtin intrinsic expanding function. bool TargetIntrinsicLower(gimple_statement_d *stmt, Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131388&r1=131387&r2=131388&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Sun May 15 14:59:30 2011 @@ -6480,7 +6480,7 @@ Value *Compare; if (FLOAT_TYPE_P(TREE_TYPE(op0))) Compare = Builder.CreateFCmp(FCmpInst::Predicate(FPPred), LHS, RHS); - else if (TYPE_UNSIGNED(TREE_TYPE(op1))) + else if (TYPE_UNSIGNED(TREE_TYPE(op0))) Compare = Builder.CreateICmp(ICmpInst::Predicate(UIPred), LHS, RHS); else Compare = Builder.CreateICmp(ICmpInst::Predicate(SIPred), LHS, RHS); @@ -6488,56 +6488,53 @@ return Builder.CreateSelect(Compare, LHS, RHS); } -/// ReducMinMaxExprHelper - Split the given vector in two and form the max/min -/// of the two pieces; repeat recursively on the result until scalar. -Value *TreeToLLVM::ReducMinMaxExprHelper(Value *Op, CmpInst::Predicate Pred) { - const VectorType *Ty = cast(Op->getType()); - unsigned NumElts = Ty->getNumElements(); - assert(NumElts > 1 && !(NumElts & (NumElts - 1)) && - "Number of vector elements is not a power of 2!"); - - if (NumElts == 2) { - // Extract each of the two elements and return the max/min of them. - const Type *Int32Ty = Type::getInt32Ty(Context); - Value *LHS = Builder.CreateExtractElement(Op, ConstantInt::get(Int32Ty, 0)); - Value *RHS = Builder.CreateExtractElement(Op, ConstantInt::get(Int32Ty, 1)); - Value *Compare = CmpInst::isFPPredicate(Pred) ? - Builder.CreateFCmp(Pred, LHS, RHS) : Builder.CreateICmp(Pred, LHS, RHS); - return Builder.CreateSelect(Compare, LHS, RHS); - } - - // Recursively extract the high and low halves of the vector and take the - // max/min of them. Using vector select like this results in better code - // if the target supports it for at least one of the resulting vector sizes. - Value *LHS = VectorLowElements(Op), *RHS = VectorHighElements(Op); - Value *Compare = CmpInst::isFPPredicate(Pred) ? - Builder.CreateFCmp(Pred, LHS, RHS) : Builder.CreateICmp(Pred, LHS, RHS); - Op = Builder.CreateSelect(Compare, LHS, RHS); - return ReducMinMaxExprHelper(Op, Pred); -} - Value *TreeToLLVM::EmitReg_ReducMinMaxExpr(tree op, unsigned UIPred, unsigned SIPred, unsigned FPPred) { - // Use a divide and conquer scheme that results in the same code as the simple - // scalar implementation on targets that don't support vector select but gives - // better code if vector select is present. - // For example, reduc-max becomes - // v = max , <- vector select - // m = max float v0, float v1 <- scalar select; v = - // The final result, m, equals max(max(x0,x2),max(x1,x3)) = max(x0,x1,x2,x3). + // In the bottom half of the vector, form the max/min of the bottom and top + // halves of the vector. Rinse and repeat on the just computed bottom half: + // in the bottom quarter of the vector, form the max/min of the bottom and + // top halves of the bottom half. Continue until only the first element of + // the vector is computed. For example, reduc-max becomes + // v = max , + // w = max , + // where v = . The first element of w is the max/min + // of x0,x1,x2,x3. Value *Val = EmitRegister(op); - Value *Res; - if (FLOAT_TYPE_P(TREE_TYPE(op))) - Res = ReducMinMaxExprHelper(Val, CmpInst::Predicate(FPPred)); - else if (TYPE_UNSIGNED(TREE_TYPE(op))) - Res = ReducMinMaxExprHelper(Val, CmpInst::Predicate(UIPred)); - else - Res = ReducMinMaxExprHelper(Val, CmpInst::Predicate(SIPred)); + const Type *Ty = Val->getType(); + + CmpInst::Predicate Pred = + CmpInst::Predicate(FLOAT_TYPE_P(TREE_TYPE(op)) ? + FPPred : TYPE_UNSIGNED(TREE_TYPE(op)) ? UIPred : SIPred); + + unsigned Length = TYPE_VECTOR_SUBPARTS(TREE_TYPE(op)); + assert(Length > 1 && !(Length & (Length - 1)) && "Length not a power of 2!"); + SmallVector Mask(Length); + const Type *Int32Ty = Type::getInt32Ty(Context); + Constant *UndefIndex = UndefValue::get(Int32Ty); + for (unsigned Elts = Length >> 1; Elts; Elts >>= 1) { + // In the extracted vectors, elements with index Elts and on are undefined. + for (unsigned i = Elts; i != Length; ++i) + Mask[i] = UndefIndex; + // Extract elements [0, Elts) from Val. + for (unsigned i = 0; i != Elts; ++i) + Mask[i] = ConstantInt::get(Int32Ty, i); + Value *LHS = Builder.CreateShuffleVector(Val, UndefValue::get(Ty), + ConstantVector::get(Mask)); + // Extract elements [Elts, 2*Elts) from Val. + for (unsigned i = 0; i != Elts; ++i) + Mask[i] = ConstantInt::get(Int32Ty, Elts + i); + Value *RHS = Builder.CreateShuffleVector(Val, UndefValue::get(Ty), + ConstantVector::get(Mask)); + + // Replace Val with the max/min of the extracted elements. + Value *Compare = FLOAT_TYPE_P(TREE_TYPE(op)) ? + Builder.CreateFCmp(Pred, LHS, RHS) : Builder.CreateICmp(Pred, LHS, RHS); + Val = Builder.CreateSelect(Compare, LHS, RHS); + + // Repeat, using half as many elements. + } - // The result is vector with the max/min as first element. - return Builder.CreateInsertElement(UndefValue::get(Val->getType()), Res, - ConstantInt::get(Type::getInt32Ty(Context), - 0)); + return Val; } Value *TreeToLLVM::EmitReg_RotateOp(tree type, tree op0, tree op1, From baldrick at free.fr Sun May 15 15:04:52 2011 From: baldrick at free.fr (Duncan Sands) Date: Sun, 15 May 2011 20:04:52 -0000 Subject: [llvm-commits] [dragonegg] r131389 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp Message-ID: <20110515200452.124482A6C12C@llvm.org> Author: baldrick Date: Sun May 15 15:04:51 2011 New Revision: 131389 URL: http://llvm.org/viewvc/llvm-project?rev=131389&view=rev Log: Implement REDUC_PLUS_EXPR (i.e. form the sum of the elements of a vector). Modified: dragonegg/trunk/include/dragonegg/Internals.h dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/include/dragonegg/Internals.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=131389&r1=131388&r2=131389&view=diff ============================================================================== --- dragonegg/trunk/include/dragonegg/Internals.h (original) +++ dragonegg/trunk/include/dragonegg/Internals.h Sun May 15 15:04:51 2011 @@ -712,6 +712,7 @@ Value *EmitReg_PLUS_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_POINTER_PLUS_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_RDIV_EXPR(tree_node *op0, tree_node *op1); + Value *EmitReg_REDUC_PLUS_EXPR(tree_node *op); Value *EmitReg_ROUND_DIV_EXPR(tree_node *op0, tree_node *op1); Value *EmitReg_TRUNC_DIV_EXPR(tree_node *op0, tree_node *op1, bool isExact); Value *EmitReg_TRUNC_MOD_EXPR(tree_node *op0, tree_node *op1); Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131389&r1=131388&r2=131389&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Sun May 15 15:04:51 2011 @@ -6537,6 +6537,48 @@ return Val; } +Value *TreeToLLVM::EmitReg_REDUC_PLUS_EXPR(tree op) { + // In the bottom half of the vector, form the sum of the bottom and top halves + // of the vector. Rinse and repeat on the just computed bottom half: in the + // bottom quarter of the vector, form the sum of the bottom and top halves of + // the bottom half. Continue until only the first element of the vector is + // computed. For example, reduc-plus becomes + // v = + + // w = + + // where v = . The first element of w is x0+x1+x2+x3. + Value *Val = EmitRegister(op); + const Type *Ty = Val->getType(); + + unsigned Length = TYPE_VECTOR_SUBPARTS(TREE_TYPE(op)); + assert(Length > 1 && !(Length & (Length - 1)) && "Length not a power of 2!"); + SmallVector Mask(Length); + const Type *Int32Ty = Type::getInt32Ty(Context); + Constant *UndefIndex = UndefValue::get(Int32Ty); + for (unsigned Elts = Length >> 1; Elts; Elts >>= 1) { + // In the extracted vectors, elements with index Elts and on are undefined. + for (unsigned i = Elts; i != Length; ++i) + Mask[i] = UndefIndex; + // Extract elements [0, Elts) from Val. + for (unsigned i = 0; i != Elts; ++i) + Mask[i] = ConstantInt::get(Int32Ty, i); + Value *LHS = Builder.CreateShuffleVector(Val, UndefValue::get(Ty), + ConstantVector::get(Mask)); + // Extract elements [Elts, 2*Elts) from Val. + for (unsigned i = 0; i != Elts; ++i) + Mask[i] = ConstantInt::get(Int32Ty, Elts + i); + Value *RHS = Builder.CreateShuffleVector(Val, UndefValue::get(Ty), + ConstantVector::get(Mask)); + + // Replace Val with the sum of the extracted elements. + // TODO: Are nsw/nuw flags valid here? + Val = Builder.CreateAdd(LHS, RHS); + + // Repeat, using half as many elements. + } + + return Val; +} + Value *TreeToLLVM::EmitReg_RotateOp(tree type, tree op0, tree op1, unsigned Opc1, unsigned Opc2) { Value *In = EmitRegister(op0); @@ -8064,6 +8106,9 @@ RHS = EmitReg_ReducMinMaxExpr(rhs1, ICmpInst::ICMP_ULE, ICmpInst::ICMP_SLE, FCmpInst::FCMP_OLE); break; + case REDUC_PLUS_EXPR: + RHS = EmitReg_REDUC_PLUS_EXPR(rhs1); + break; case ROUND_DIV_EXPR: RHS = EmitReg_ROUND_DIV_EXPR(rhs1, rhs2); break; case RROTATE_EXPR: From rafael.espindola at gmail.com Sun May 15 22:05:33 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 16 May 2011 03:05:33 -0000 Subject: [llvm-commits] [llvm] r131399 - in /llvm/trunk: include/llvm/Function.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Transforms/Scalar/TailRecursionElimination.cpp lib/VMCore/Function.cpp test/Transforms/TailCallElim/setjmp.ll Message-ID: <20110516030533.786E92A6C12C@llvm.org> Author: rafael Date: Sun May 15 22:05:33 2011 New Revision: 131399 URL: http://llvm.org/viewvc/llvm-project?rev=131399&view=rev Log: Don't do tail calls in a function that call setjmp. The stack might be corrupted when setjmp returns again. Added: llvm/trunk/test/Transforms/TailCallElim/setjmp.ll Modified: llvm/trunk/include/llvm/Function.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/include/llvm/Function.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=131399&r1=131398&r2=131399&view=diff ============================================================================== --- llvm/trunk/include/llvm/Function.h (original) +++ llvm/trunk/include/llvm/Function.h Sun May 15 22:05:33 2011 @@ -414,6 +414,10 @@ /// bool hasAddressTaken(const User** = 0) const; + /// callsFunctionThatReturnsTwice - Return true if the function has a call to + /// setjmp or other function that gcc recognizes as "returning twice". + bool callsFunctionThatReturnsTwice() const; + private: // Shadow Value::setValueSubclassData with a private forwarding method so that // subclasses cannot accidentally use it. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=131399&r1=131398&r2=131399&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun May 15 22:05:33 2011 @@ -208,38 +208,6 @@ MachineFunctionPass::getAnalysisUsage(AU); } -/// FunctionCallsSetJmp - Return true if the function has a call to setjmp or -/// other function that gcc recognizes as "returning twice". This is used to -/// limit code-gen optimizations on the machine function. -/// -/// FIXME: Remove after is fixed. -static bool FunctionCallsSetJmp(const Function *F) { - const Module *M = F->getParent(); - static const char *ReturnsTwiceFns[] = { - "_setjmp", - "setjmp", - "sigsetjmp", - "setjmp_syscall", - "savectx", - "qsetjmp", - "vfork", - "getcontext" - }; - - for (unsigned I = 0; I < array_lengthof(ReturnsTwiceFns); ++I) - if (const Function *Callee = M->getFunction(ReturnsTwiceFns[I])) { - if (!Callee->use_empty()) - for (Value::const_use_iterator - I = Callee->use_begin(), E = Callee->use_end(); - I != E; ++I) - if (const CallInst *CI = dyn_cast(*I)) - if (CI->getParent()->getParent() == F) - return true; - } - - return false; -} - /// SplitCriticalSideEffectEdges - Look for critical edges with a PHI value that /// may trap on it. In this case we have to split the edge so that the path /// through the predecessor block that doesn't go to the phi block doesn't @@ -390,7 +358,7 @@ } // Determine if there is a call to setjmp in the machine function. - MF->setCallsSetJmp(FunctionCallsSetJmp(&Fn)); + MF->setCallsSetJmp(Fn.callsFunctionThatReturnsTwice()); // Replace forward-declared registers with the registers containing // the desired value. Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=131399&r1=131398&r2=131399&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Sun May 15 22:05:33 2011 @@ -59,6 +59,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" +#include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Analysis/CaptureTracking.h" #include "llvm/Analysis/InlineCost.h" @@ -209,10 +210,10 @@ } } - // Finally, if this function contains no non-escaping allocas, mark all calls - // in the function as eligible for tail calls (there is no stack memory for - // them to access). - if (!FunctionContainsEscapingAllocas) + // Finally, if this function contains no non-escaping allocas, or calls + // setjmp, mark all calls in the function as eligible for tail calls + //(there is no stack memory for them to access). + if (!FunctionContainsEscapingAllocas && !F.callsFunctionThatReturnsTwice()) for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) if (CallInst *CI = dyn_cast(I)) { Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=131399&r1=131398&r2=131399&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Sun May 15 22:05:33 2011 @@ -24,6 +24,7 @@ #include "llvm/Support/Threading.h" #include "SymbolTableListTraitsImpl.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" using namespace llvm; @@ -406,4 +407,36 @@ return false; } +/// callsFunctionThatReturnsTwice - Return true if the function has a call to +/// setjmp or other function that gcc recognizes as "returning twice". +/// +/// FIXME: Remove after is fixed. +/// FIXME: Is the obove FIXME valid? +bool Function::callsFunctionThatReturnsTwice() const { + const Module *M = this->getParent(); + static const char *ReturnsTwiceFns[] = { + "_setjmp", + "setjmp", + "sigsetjmp", + "setjmp_syscall", + "savectx", + "qsetjmp", + "vfork", + "getcontext" + }; + + for (unsigned I = 0; I < array_lengthof(ReturnsTwiceFns); ++I) + if (const Function *Callee = M->getFunction(ReturnsTwiceFns[I])) { + if (!Callee->use_empty()) + for (Value::const_use_iterator + I = Callee->use_begin(), E = Callee->use_end(); + I != E; ++I) + if (const CallInst *CI = dyn_cast(*I)) + if (CI->getParent()->getParent() == this) + return true; + } + + return false; +} + // vim: sw=2 ai Added: llvm/trunk/test/Transforms/TailCallElim/setjmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailCallElim/setjmp.ll?rev=131399&view=auto ============================================================================== --- llvm/trunk/test/Transforms/TailCallElim/setjmp.ll (added) +++ llvm/trunk/test/Transforms/TailCallElim/setjmp.ll Sun May 15 22:05:33 2011 @@ -0,0 +1,16 @@ +; RUN: opt < %s -tailcallelim -S | FileCheck %s + +; Test that we don't tail call in a functions that calls setjmp. + +; CHECK-NOT: tail call void @bar() + +define void @foo(i32* %x) { +bb: + %tmp75 = tail call i32 @setjmp(i32* %x) + call void @bar() + ret void +} + +declare i32 @setjmp(i32*) + +declare void @bar()