From evan.cheng at apple.com Mon Feb 20 01:51:59 2012 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 20 Feb 2012 07:51:59 -0000 Subject: [llvm-commits] [llvm] r150949 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp Message-ID: <20120220075159.2A8CA2A6C12F@llvm.org> Author: evancheng Date: Mon Feb 20 01:51:58 2012 New Revision: 150949 URL: http://llvm.org/viewvc/llvm-project?rev=150949&view=rev Log: Make post-ra tail duplication bundle safe. No test case as recent codegen flow changes have already hidden the bug. rdar://10893812 Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=150949&r1=150948&r2=150949&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original) +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Mon Feb 20 01:51:58 2012 @@ -433,7 +433,7 @@ MO.setReg(VI->second); } } - PredBB->insert(PredBB->end(), NewMI); + PredBB->insert(PredBB->instr_end(), NewMI); } /// UpdateSuccessorsPHIs - After FromBB is tail duplicated into its predecessor @@ -778,8 +778,10 @@ // Clone the contents of TailBB into PredBB. DenseMap LocalVRMap; SmallVector, 4> CopyInfos; - MachineBasicBlock::iterator I = TailBB->begin(); - while (I != TailBB->end()) { + // Use instr_iterator here to properly handle bundles, e.g. + // ARM Thumb2 IT block. + MachineBasicBlock::instr_iterator I = TailBB->instr_begin(); + while (I != TailBB->instr_end()) { MachineInstr *MI = &*I; ++I; if (MI->isPHI()) { @@ -849,6 +851,7 @@ // Replace def of virtual registers with new registers, and update // uses with PHI source register or the new registers. MachineInstr *MI = &*I++; + assert(!MI->isBundle() && "Not expecting bundles before regalloc!"); DuplicateInstruction(MI, TailBB, PrevBB, MF, LocalVRMap, UsedByPhi); MI->eraseFromParent(); } From grosser at fim.uni-passau.de Mon Feb 20 02:41:15 2012 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 20 Feb 2012 08:41:15 -0000 Subject: [llvm-commits] [polly] r150950 - /polly/trunk/lib/ScheduleOptimizer.cpp Message-ID: <20120220084115.A6C5B1BE003@llvm.org> Author: grosser Date: Mon Feb 20 02:41:15 2012 New Revision: 150950 URL: http://llvm.org/viewvc/llvm-project?rev=150950&view=rev Log: ScheduleOpt: Add option to bound constant term coefficients Modified: polly/trunk/lib/ScheduleOptimizer.cpp Modified: polly/trunk/lib/ScheduleOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/ScheduleOptimizer.cpp?rev=150950&r1=150949&r2=150950&view=diff ============================================================================== --- polly/trunk/lib/ScheduleOptimizer.cpp (original) +++ polly/trunk/lib/ScheduleOptimizer.cpp Mon Feb 20 02:41:15 2012 @@ -57,6 +57,11 @@ cl::desc("Dependences should be simplified (yes/no)"), cl::Hidden, cl::init("yes")); +static cl::opt +MaxConstantTerm("polly-opt-max-constant-term", + cl::desc("The maximal constant term allowed (-1 is unlimited)"), + cl::Hidden, cl::init(20)); + static cl::opt FusionStrategy("polly-opt-fusion", cl::desc("The fusion strategy to choose (min/max)"), @@ -499,6 +504,7 @@ isl_options_set_schedule_fuse(S.getIslCtx(), IslFusionStrategy); isl_options_set_schedule_maximize_band_depth(S.getIslCtx(), IslMaximizeBands); + isl_options_set_schedule_max_constant_term(S.getIslCtx(), MaxConstantTerm); isl_options_set_on_error(S.getIslCtx(), ISL_ON_ERROR_CONTINUE); isl_schedule *Schedule; From grosser at fim.uni-passau.de Mon Feb 20 02:41:21 2012 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 20 Feb 2012 08:41:21 -0000 Subject: [llvm-commits] [polly] r150951 - /polly/trunk/lib/ScheduleOptimizer.cpp Message-ID: <20120220084122.0A5E91BE003@llvm.org> Author: grosser Date: Mon Feb 20 02:41:21 2012 New Revision: 150951 URL: http://llvm.org/viewvc/llvm-project?rev=150951&view=rev Log: ScheduleOptimizer: Dump the calculated schedule in debug mode Modified: polly/trunk/lib/ScheduleOptimizer.cpp Modified: polly/trunk/lib/ScheduleOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/ScheduleOptimizer.cpp?rev=150951&r1=150950&r2=150951&view=diff ============================================================================== --- polly/trunk/lib/ScheduleOptimizer.cpp (original) +++ polly/trunk/lib/ScheduleOptimizer.cpp Mon Feb 20 02:41:21 2012 @@ -516,6 +516,9 @@ if (!Schedule) return false; + DEBUG(dbgs() << "Schedule := "; isl_schedule_dump(Schedule); + dbgs() << ";\n"); + isl_union_map *ScheduleMap = getScheduleMap(Schedule); for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) { From grosser at fim.uni-passau.de Mon Feb 20 02:41:44 2012 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 20 Feb 2012 08:41:44 -0000 Subject: [llvm-commits] [polly] r150952 - /polly/trunk/utils/checkout_cloog.sh Message-ID: <20120220084144.8A2161BE003@llvm.org> Author: grosser Date: Mon Feb 20 02:41:44 2012 New Revision: 150952 URL: http://llvm.org/viewvc/llvm-project?rev=150952&view=rev Log: Update isl This version of isl, contains some recently committed scheduler patches. Modified: polly/trunk/utils/checkout_cloog.sh Modified: polly/trunk/utils/checkout_cloog.sh URL: http://llvm.org/viewvc/llvm-project/polly/trunk/utils/checkout_cloog.sh?rev=150952&r1=150951&r2=150952&view=diff ============================================================================== --- polly/trunk/utils/checkout_cloog.sh (original) +++ polly/trunk/utils/checkout_cloog.sh Mon Feb 20 02:41:44 2012 @@ -1,7 +1,7 @@ #!/bin/sh CLOOG_HASH="57470e76bfd58a0c38c598e816411663193e0f45" -ISL_HASH="3c66541593a6bf3b5a3d35d31567abe6c9e5a04b" +ISL_HASH="2b54bb607bfc666dfee01c6332e347d0c253335f" PWD=`pwd` From grosser at fim.uni-passau.de Mon Feb 20 02:41:47 2012 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 20 Feb 2012 08:41:47 -0000 Subject: [llvm-commits] [polly] r150953 - /polly/trunk/lib/ScheduleOptimizer.cpp Message-ID: <20120220084147.F2EFE1BE003@llvm.org> Author: grosser Date: Mon Feb 20 02:41:47 2012 New Revision: 150953 URL: http://llvm.org/viewvc/llvm-project?rev=150953&view=rev Log: ScheduleOpt: Add option to bound scheduling coefficients of dimensions. Modified: polly/trunk/lib/ScheduleOptimizer.cpp Modified: polly/trunk/lib/ScheduleOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/ScheduleOptimizer.cpp?rev=150953&r1=150952&r2=150953&view=diff ============================================================================== --- polly/trunk/lib/ScheduleOptimizer.cpp (original) +++ polly/trunk/lib/ScheduleOptimizer.cpp Mon Feb 20 02:41:47 2012 @@ -62,6 +62,11 @@ cl::desc("The maximal constant term allowed (-1 is unlimited)"), cl::Hidden, cl::init(20)); +static cl::opt +MaxCoefficient("polly-opt-max-coefficient", + cl::desc("The maximal coefficient allowed (-1 is unlimited)"), + cl::Hidden, cl::init(20)); + static cl::opt FusionStrategy("polly-opt-fusion", cl::desc("The fusion strategy to choose (min/max)"), @@ -505,6 +510,7 @@ isl_options_set_schedule_fuse(S.getIslCtx(), IslFusionStrategy); isl_options_set_schedule_maximize_band_depth(S.getIslCtx(), IslMaximizeBands); isl_options_set_schedule_max_constant_term(S.getIslCtx(), MaxConstantTerm); + isl_options_set_schedule_max_coefficient(S.getIslCtx(), MaxCoefficient); isl_options_set_on_error(S.getIslCtx(), ISL_ON_ERROR_CONTINUE); isl_schedule *Schedule; From grosser at fim.uni-passau.de Mon Feb 20 02:41:52 2012 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 20 Feb 2012 08:41:52 -0000 Subject: [llvm-commits] [polly] r150954 - in /polly/trunk/www: get_started.html todo.html Message-ID: <20120220084152.316501BE003@llvm.org> Author: grosser Date: Mon Feb 20 02:41:51 2012 New Revision: 150954 URL: http://llvm.org/viewvc/llvm-project?rev=150954&view=rev Log: www: Update links polly.grosser.es -> polly.llvm.org Modified: polly/trunk/www/get_started.html polly/trunk/www/todo.html Modified: polly/trunk/www/get_started.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/get_started.html?rev=150954&r1=150953&r2=150954&view=diff ============================================================================== --- polly/trunk/www/get_started.html (original) +++ polly/trunk/www/get_started.html Mon Feb 20 02:41:51 2012 @@ -23,7 +23,7 @@ of three simple steps:
-wget http://polly.grosser.es/polly.sh
+wget http://polly.llvm.org/polly.sh
 chmod +x polly.sh
 ./polly.sh
 
Modified: polly/trunk/www/todo.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/todo.html?rev=150954&r1=150953&r2=150954&view=diff ============================================================================== --- polly/trunk/www/todo.html (original) +++ polly/trunk/www/todo.html Mon Feb 20 02:41:51 2012 @@ -52,10 +52,9 @@ Tobias Website - in progress +
-http://polly.grosser.es, -later maybe polly.llvm.org +http://polly.llvm.org, Tobias From grosser at fim.uni-passau.de Mon Feb 20 02:41:55 2012 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 20 Feb 2012 08:41:55 -0000 Subject: [llvm-commits] [polly] r150955 - /polly/trunk/www/index.html Message-ID: <20120220084155.CA8EC1BE003@llvm.org> Author: grosser Date: Mon Feb 20 02:41:55 2012 New Revision: 150955 URL: http://llvm.org/viewvc/llvm-project?rev=150955&view=rev Log: Add information, that Polly became a real LLVM project Modified: polly/trunk/www/index.html Modified: polly/trunk/www/index.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/index.html?rev=150955&r1=150954&r2=150955&view=diff ============================================================================== --- polly/trunk/www/index.html (original) +++ polly/trunk/www/index.html Mon Feb 20 02:41:55 2012 @@ -70,6 +70,11 @@ + +
2012

February

+

Polly is an official LLVM project, reachable at http://polly.llvm.org

+

January

Improved support for the isl scheduling optimizer

From james.molloy at arm.com Mon Feb 20 03:24:05 2012 From: james.molloy at arm.com (James Molloy) Date: Mon, 20 Feb 2012 09:24:05 -0000 Subject: [llvm-commits] [llvm] r150956 - in /llvm/trunk: include/llvm/Target/TargetSelectionDAG.td lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrNEON.td Message-ID: <20120220092405.E72572A6C12F@llvm.org> Author: jamesm Date: Mon Feb 20 03:24:05 2012 New Revision: 150956 URL: http://llvm.org/viewvc/llvm-project?rev=150956&view=rev Log: Improve generated code for extending loads and some trunc stores on ARM. Teach TargetSelectionDAG about lengthening loads for vector types and set v4i8 as legal. Allow FP_TO_UINT for v4i16 from v4i32. Modified: llvm/trunk/include/llvm/Target/TargetSelectionDAG.td llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/include/llvm/Target/TargetSelectionDAG.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSelectionDAG.td?rev=150956&r1=150955&r2=150956&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetSelectionDAG.td (original) +++ llvm/trunk/include/llvm/Target/TargetSelectionDAG.td Mon Feb 20 03:24:05 2012 @@ -657,6 +657,51 @@ return cast(N)->getMemoryVT() == MVT::i32; }]>; +def extloadvi1 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i1; +}]>; +def extloadvi8 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i8; +}]>; +def extloadvi16 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i16; +}]>; +def extloadvi32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i32; +}]>; +def extloadvf32 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::f32; +}]>; +def extloadvf64 : PatFrag<(ops node:$ptr), (extload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::f64; +}]>; + +def sextloadvi1 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i1; +}]>; +def sextloadvi8 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i8; +}]>; +def sextloadvi16 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i16; +}]>; +def sextloadvi32 : PatFrag<(ops node:$ptr), (sextload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i32; +}]>; + +def zextloadvi1 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i1; +}]>; +def zextloadvi8 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i8; +}]>; +def zextloadvi16 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i16; +}]>; +def zextloadvi32 : PatFrag<(ops node:$ptr), (zextload node:$ptr), [{ + return cast(N)->getMemoryVT().getScalarType() == MVT::i32; +}]>; + // store fragments. def unindexedstore : PatFrag<(ops node:$val, node:$ptr), (st node:$val, node:$ptr), [{ Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=150956&r1=150955&r2=150956&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Feb 20 03:24:05 2012 @@ -533,9 +533,13 @@ setOperationAction(ISD::SETCC, MVT::v1i64, Expand); setOperationAction(ISD::SETCC, MVT::v2i64, Expand); // Neon does not have single instruction SINT_TO_FP and UINT_TO_FP with - // a destination type that is wider than the source. + // a destination type that is wider than the source, and nor does + // it have a FP_TO_[SU]INT instruction with a narrower destination than + // source. setOperationAction(ISD::SINT_TO_FP, MVT::v4i16, Custom); setOperationAction(ISD::UINT_TO_FP, MVT::v4i16, Custom); + setOperationAction(ISD::FP_TO_UINT, MVT::v4i16, Custom); + setOperationAction(ISD::FP_TO_SINT, MVT::v4i16, Custom); setTargetDAGCombine(ISD::INTRINSIC_VOID); setTargetDAGCombine(ISD::INTRINSIC_W_CHAIN); @@ -555,7 +559,15 @@ setTargetDAGCombine(ISD::FP_TO_UINT); setTargetDAGCombine(ISD::FDIV); - setLoadExtAction(ISD::EXTLOAD, MVT::v4i8, Expand); + // It is legal to extload from v4i8 to v4i16 or v4i32. + MVT Tys[6] = {MVT::v8i8, MVT::v4i8, MVT::v2i8, + MVT::v4i16, MVT::v2i16, + MVT::v2i32}; + for (unsigned i = 0; i < 6; ++i) { + setLoadExtAction(ISD::EXTLOAD, Tys[i], Legal); + setLoadExtAction(ISD::ZEXTLOAD, Tys[i], Legal); + setLoadExtAction(ISD::SEXTLOAD, Tys[i], Legal); + } } computeRegisterProperties(); @@ -3058,12 +3070,22 @@ } static SDValue LowerVectorFP_TO_INT(SDValue Op, SelectionDAG &DAG) { - assert(Op.getValueType().getVectorElementType() == MVT::i32 - && "Unexpected custom lowering"); + EVT VT = Op.getValueType(); + DebugLoc dl = Op.getDebugLoc(); - if (Op.getOperand(0).getValueType().getVectorElementType() == MVT::f32) - return Op; - return DAG.UnrollVectorOp(Op.getNode()); + if (Op.getValueType().getVectorElementType() == MVT::i32) { + if (Op.getOperand(0).getValueType().getVectorElementType() == MVT::f32) + return Op; + return DAG.UnrollVectorOp(Op.getNode()); + } + + assert(Op.getOperand(0).getValueType() == MVT::v4f32 && + "Invalid type for custom lowering!"); + if (VT != MVT::v4i16) + return DAG.UnrollVectorOp(Op.getNode()); + + Op = DAG.getNode(Op.getOpcode(), dl, MVT::v4i32, Op.getOperand(0)); + return DAG.getNode(ISD::TRUNCATE, dl, VT, Op); } static SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) { Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=150956&r1=150955&r2=150956&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Mon Feb 20 03:24:05 2012 @@ -5624,6 +5624,117 @@ def : Pat<(v2f64 (bitconvert (v16i8 QPR:$src))), (v2f64 QPR:$src)>; def : Pat<(v2f64 (bitconvert (v4f32 QPR:$src))), (v2f64 QPR:$src)>; +// Vector lengthening move with load, matching extending loads. + +// extload, zextload and sextload for a standard lengthening load. Example: +// Lengthen_Single<"8", "i16", "i8"> = Pat<(v8i16 (extloadvi8 addrmode5:$addr)) +// (VMOVLuv8i16 (VLDRD addrmode5:$addr))>; +multiclass Lengthen_Single { + def _Any : Pat<(!cast("v" # DestLanes # DestTy) + (!cast("extloadv" # SrcTy) addrmode5:$addr)), + (!cast("VMOVLuv" # DestLanes # DestTy) + (VLDRD addrmode5:$addr))>; + def _Z : Pat<(!cast("v" # DestLanes # DestTy) + (!cast("zextloadv" # SrcTy) addrmode5:$addr)), + (!cast("VMOVLuv" # DestLanes # DestTy) + (VLDRD addrmode5:$addr))>; + def _S : Pat<(!cast("v" # DestLanes # DestTy) + (!cast("sextloadv" # SrcTy) addrmode5:$addr)), + (!cast("VMOVLsv" # DestLanes # DestTy) + (VLDRD addrmode5:$addr))>; +} + +// extload, zextload and sextload for a lengthening load which only uses +// half the lanes available. Example: +// Lengthen_HalfSingle<"4", "i16", "8", "i16", "i8"> = +// Pat<(v4i16 (extloadvi8 addrmode5:$addr)) +// (EXTRACT_SUBREG (VMOVLuv8i16 (INSERT_SUBREG (f64 (IMPLICIT_DEF)), +// (VLDRS addrmode5:$addr), +// ssub_0)), +// dsub_0)>; +multiclass Lengthen_HalfSingle { + def _Any : Pat<(!cast("v" # DestLanes # DestTy) + (!cast("extloadv" # SrcTy) addrmode5:$addr)), + (EXTRACT_SUBREG (!cast("VMOVLuv" # InsnLanes # InsnTy) + (INSERT_SUBREG (f64 (IMPLICIT_DEF)), (VLDRS addrmode5:$addr), ssub_0)), + dsub_0)>; + def _Z : Pat<(!cast("v" # DestLanes # DestTy) + (!cast("zextloadv" # SrcTy) addrmode5:$addr)), + (EXTRACT_SUBREG (!cast("VMOVLuv" # InsnLanes # InsnTy) + (INSERT_SUBREG (f64 (IMPLICIT_DEF)), (VLDRS addrmode5:$addr), ssub_0)), + dsub_0)>; + def _S : Pat<(!cast("v" # DestLanes # DestTy) + (!cast("sextloadv" # SrcTy) addrmode5:$addr)), + (EXTRACT_SUBREG (!cast("VMOVLsv" # InsnLanes # InsnTy) + (INSERT_SUBREG (f64 (IMPLICIT_DEF)), (VLDRS addrmode5:$addr), ssub_0)), + dsub_0)>; +} + +// extload, zextload and sextload for a lengthening load followed by another +// lengthening load, to quadruple the initial length. +// Lengthen_Double<"4", "i32", "i8", "8", "i16", "4", "i32", qsub_0> = +// Pat<(v4i32 (extloadvi8 addrmode5:$addr)) +// (EXTRACT_SUBREG (VMOVLuv4i32 +// (EXTRACT_SUBREG (VMOVLuv8i16 (INSERT_SUBREG (f64 (IMPLICIT_DEF)), +// (VLDRS addrmode5:$addr), +// ssub_0)), +// dsub_0)), +// qsub_0)>; +multiclass Lengthen_Double { + def _Any : Pat<(!cast("v" # DestLanes # DestTy) + (!cast("extloadv" # SrcTy) addrmode5:$addr)), + (EXTRACT_SUBREG (!cast("VMOVLuv" # Insn2Lanes # Insn2Ty) + (EXTRACT_SUBREG (!cast("VMOVLuv" # Insn1Lanes # Insn1Ty) + (INSERT_SUBREG (f64 (IMPLICIT_DEF)), (VLDRS addrmode5:$addr), + ssub_0)), dsub_0)), + RegType)>; + def _Z : Pat<(!cast("v" # DestLanes # DestTy) + (!cast("zextloadv" # SrcTy) addrmode5:$addr)), + (EXTRACT_SUBREG (!cast("VMOVLuv" # Insn2Lanes # Insn2Ty) + (EXTRACT_SUBREG (!cast("VMOVLuv" # Insn1Lanes # Insn1Ty) + (INSERT_SUBREG (f64 (IMPLICIT_DEF)), (VLDRS addrmode5:$addr), + ssub_0)), dsub_0)), + RegType)>; + def _S : Pat<(!cast("v" # DestLanes # DestTy) + (!cast("sextloadv" # SrcTy) addrmode5:$addr)), + (EXTRACT_SUBREG (!cast("VMOVLsv" # Insn2Lanes # Insn2Ty) + (EXTRACT_SUBREG (!cast("VMOVLsv" # Insn1Lanes # Insn1Ty) + (INSERT_SUBREG (f64 (IMPLICIT_DEF)), (VLDRS addrmode5:$addr), + ssub_0)), dsub_0)), + RegType)>; +} + +defm : Lengthen_Single<"8", "i16", "i8">; // v8i8 -> v8i16 +defm : Lengthen_Single<"4", "i32", "i16">; // v4i16 -> v4i32 +defm : Lengthen_Single<"2", "i64", "i32">; // v2i32 -> v2i64 + +defm : Lengthen_HalfSingle<"4", "i16", "i8", "8", "i16">; // v4i8 -> v4i16 +defm : Lengthen_HalfSingle<"2", "i16", "i8", "8", "i16">; // v2i8 -> v2i16 +defm : Lengthen_HalfSingle<"2", "i32", "i16", "4", "i32">; // v2i16 -> v2i32 + +// Double lengthening - v4i8 -> v4i16 -> v4i32 +defm : Lengthen_Double<"4", "i32", "i8", "8", "i16", "4", "i32", qsub_0>; +// v2i8 -> v2i16 -> v2i32 +defm : Lengthen_Double<"2", "i32", "i8", "8", "i16", "4", "i32", dsub_0>; +// v2i16 -> v2i32 -> v2i64 +defm : Lengthen_Double<"2", "i64", "i16", "4", "i32", "2", "i64", qsub_0>; + +// Triple lengthening - v2i8 -> v2i16 -> v2i32 -> v2i64 +def : Pat<(v2i64 (extloadvi8 addrmode5:$addr)), + (VMOVLuv2i64 (EXTRACT_SUBREG (VMOVLuv4i32 (EXTRACT_SUBREG (VMOVLuv8i16 + (INSERT_SUBREG (f64 (IMPLICIT_DEF)), (VLDRS addrmode5:$addr), ssub_0)), + dsub_0)), dsub_0))>; +def : Pat<(v2i64 (zextloadvi8 addrmode5:$addr)), + (VMOVLuv2i64 (EXTRACT_SUBREG (VMOVLuv4i32 (EXTRACT_SUBREG (VMOVLuv8i16 + (INSERT_SUBREG (f64 (IMPLICIT_DEF)), (VLDRS addrmode5:$addr), ssub_0)), + dsub_0)), dsub_0))>; +def : Pat<(v2i64 (sextloadvi8 addrmode5:$addr)), + (VMOVLsv2i64 (EXTRACT_SUBREG (VMOVLsv4i32 (EXTRACT_SUBREG (VMOVLsv8i16 + (INSERT_SUBREG (f64 (IMPLICIT_DEF)), (VLDRS addrmode5:$addr), ssub_0)), + dsub_0)), dsub_0))>; //===----------------------------------------------------------------------===// // Assembler aliases From baldrick at free.fr Mon Feb 20 03:51:40 2012 From: baldrick at free.fr (Duncan Sands) Date: Mon, 20 Feb 2012 10:51:40 +0100 Subject: [llvm-commits] [llvm] r150885 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp In-Reply-To: <4F415BC7.5090408@gmail.com> References: <20120218175143.39EC02A6C12F@llvm.org> <4F400451.9030203@gmail.com> <4F402019.3020805@gmail.com> <4F40C8EE.9070003@free.fr> <4F415BC7.5090408@gmail.com> Message-ID: <4F4217AC.6010204@free.fr> Hi Rafael, On 19/02/12 21:29, Rafael ?vila de Esp?ndola wrote: >> PS: That said, the current logic for handling invokes in dominate does look >> bogus, so I agree with your diagnosis. > > What do you think of the attached patch? I took the liberty of renaming > the function to make it explicit what it computes. I think it is still wrong. What you are forgetting is that it may be possible to get to the normal destination without passing via the block containing the invoke. I suggest you take a look at the logic in the verifier. I looked at it pretty carefully long ago, and concluded that it was correct. I mean this bit onwards: // Check that a definition dominates all of its uses. if (InvokeInst *II = dyn_cast(Op)) { // Invoke results are only usable in the normal destination, not in the // exceptional destination. BasicBlock *NormalDest = II->getNormalDest(); Assert2(NormalDest != II->getUnwindDest(), "No uses of invoke possible due to dominance structure!", Op, &I); ... (Actually it should be possible to slightly simplify this nowadays: it is no longer legal IR if the unwind and normal destinations are the same). The meat of the logic comes after the snippet I've quoted. By the way, if you move this logic into the dominates routine, then I guess the verifier can be simplified by removing all the current logic and just replacing by a call to the improved dominator routine. Ciao, Duncan. From nicholas at mxc.ca Mon Feb 20 06:06:04 2012 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 20 Feb 2012 04:06:04 -0800 Subject: [llvm-commits] cxa_guard elimination In-Reply-To: <9068FFCB-D566-494F-AB5A-74D572BDAEAD@apple.com> References: <4F0903F9.405@mxc.ca> <4F0BF82B.7030206@mxc.ca> <4F24F0E4.4090701@mxc.ca> <4F24FA31.50601@mxc.ca> <0058FB56-53A7-4012-A83D-3860C965113A@apple.com> <4F2B8CFF.9020606@mxc.ca> <4F338A4E.6040607@mxc.ca> <4F340EC5.5030404@mxc.ca> <4F3788A3.5030406@mxc.ca> <9068FFCB-D566-494F-AB5A-74D572BDAEAD@apple.com> Message-ID: <4F42372C.7020309@mxc.ca> Chris Lattner wrote: > On Feb 12, 2012, at 1:38 AM, Nick Lewycky wrote: >> Ok. Some thoughts: >>> >>> >>> virtual void getAnalysisUsage(AnalysisUsage&AU) const { >>> + AU.addRequired(); >>> >>> Is this *really really* required? This will be the first module pass that requires a function pass in mainline IIRC. >> >> We really just need to show that the load/store to the global can't precede the top of the guard. Replacing it with a unique-pred walk will work for cases where it isn't in or preceded by a loop. That's nice, but it isn't good enough. >> >> What I don't need out of DomTree is building out the tree for the entirety of the function, particularly the parts dominated by the guard-top. I'd be happy with a subset. SSAUpdater does this nifty trick where it creates a subset of the CFG then builds a DomTree on that alone. I think that idea would work here, but that's too complicated for me to implement. Refactor-o? > > I'm going to continue to worry about this for a bit. To avoid blocking forward progress, could you go with "uniq dominator chain" for now, and we can talk about switching to dominators as a follow-on patch? I don't think that works. I need to prove that the acquire happens before any use of the global. If I only look up unique preds of the acquire block, I would either see a use of the global (certainly unsafe!) or not. If not, was the use before or after the acquire block? I can't tell. What I'd need is the set of all blocks reachable from entry without going through the acquire (or the inverse, which is what I'm using DomTree for now). > When the time comes, I'd be curious to get numbers about how often it matters. Given that the patterns we're looking for are simple and this is happening before inlining, my guess is that there is a negligible win here. Okay. If we want to avoid the DomTree requirement, the way to do it is to require that the only uses of the global be the ones we simulate. Obviously that's very limiting (we only work on dead variables, that are dead before any other optimizer has run...). >>> Does the passmanager only compute DominatorTree for functions lazily when asking for it? >> >> Yep! This actually works! > > Ok, that's good at least :) > >>> Are you sure that GlobalOpt isn't changing CFGs in a way that would invalidate DomTree? >> >> I've done more than a cursory glance to see that it doesn't play with TerminatorInsts, but I haven't taken the effort to seriously prove it to myself. >> >> I was assuming that calling getAnalysis(F) twice would actually run the domtree analysis on F twice, especially since we don't claim to preserve DominatorTree. I haven't checked though. > > I'm pretty sure that is not the case. getAnalysis<> is supposed to compute and then cache it. The passmgr assumes that if passA uses passB that passA preserves passB across its own execution or across all queries it will do to it. > >>> It's not your bug, but that loop really really should use 'continue' to make the control flow more obvious. >> >> I'm not sure about this. Are you asking for the tests to be flipped around and call continue in the case everything is okay, then have an unconditional "return true" as the fall-through? I'm not sure that would be better? > > I'm saying the control flow should be something like this: > > for () { > > if (something ok) { > ... > continue; > } > > if (something else ok) { > ... > continue; > } > > // can't handle this. > return false; > } Gotcha. That's on my todo list now. >>> +static Instruction *UseToInst(Value *V) { >>> >>> Perhaps this is prevented by how it is called, but you can have an infinite constant loop through a global variable and its initializer. >> >> static char *x = (char*)&x; ?! :-( > > Yeah, GlobalValue isa after all. > >> Good catch, I haven't fixed this yet locally but I'll get to it. I think I want to do away with UseToInst entirely. > > That would be nice :) > >> Digression. I'd recently noticed that we have a number of different little IR interpreters all over, and started making a list. There's globalopt, and there interpreter executionengine, then there's another in jump-threading and SCEV has one (getSCEV) or two (EvaluateExpression) depending on how you count. I suspect there's more, but I'm not actively looking for them, just writing them down as I see them. > > I would rather just remove the EE interpreter than worry about it. It is completely broken in many different ways. > >> Would it help to refactor them? We could do so, where the user provides an InstVisitor implementation and we provide the ability to ask for the result of a given instruction (lazily computing the things it depends on) or forwards computation, or a mix of both. I think it would help. I just didn't want to do all this before committing cxa_guard elimination. > > I'm not sure that this is a good idea. To me this sounds like a constant folding problem :) > >>> The EvaluateBlock/EvaluateFunction interfaces really need to be split out into methods on a helper class that maintain the state, instead of passing the state through a dozen arguments into each recursive call. Can you split this out into its own patch? >>> >>> >>> There are various blocks of logic in OptimizeGuardedInitialization that really need some block comments explaining what is going on :) >>> >>> >>> InstResult = ConstantExpr::get(BO->getOpcode(), >>> - getVal(Values, BO->getOperand(0)), >>> - getVal(Values, BO->getOperand(1))); >>> + Constant *Op0 = getVal(Values, BO->getOperand(0)); >>> + Constant *Op1 = getVal(Values, BO->getOperand(1)); >>> + if (!Op0 || !Op1) return false; >>> >>> It's hard for me to understand what is going on here. Why did getVal suddenly start being able to fail? Can you split this out into its own patch? >> >> This is the ugly part; the constant evaluator for guard elimination shouldn't be the same as the constant evaluator for running global constructors. >> >> When running the global constructors, you start at the beginning of every function, and you run every instruction. You know all function arguments, because the outer-most function call takes void, and everything else is either read from a global or it's an Instruction that dominates it. Furthermore, because this is before-main, you're allowed to assume that any initializer in a global is the value it has at this point, > > >> even if the global isn't constant. > > I'm not sure that this last part is true. Do we care about other ctors known to run earlier with init_priority? What about static ctors in .dll files that are loaded post-main (dlopen)? We don't care. We don't support ctor priority at all. Within a TU the constructors run in source order, but the order between TUs is undefined. >> The way that the cxa_guard elimination works is by finding the first block that only runs on the first execution of the guard, and then simulating from there. Because we haven't simulated the blocks leading up to that point, none of the local variables are present. Furthermore, we can't really rely on ComputeLoadResult because it will look inside non-Constant global variable and trust that the initializer is correct, but we're simulating code past-main so that isn't true any more. The attached patch handles this by making ComputeLoadResult record what GVs it looked at when computing its result, then verifying that there were all constant or set inside the once-initialized code first. > > >> An alternative way to do cxa_guard elimination using the evaluator in globalopt as it exists today would be to start the function and make decisions that would lead you towards the cxa_guard_acquire. This would let us support cases like Bullet returning an identity matrix by alloca'ing the elements, then in the once storing to them and running the copy-constructor. Currently that fails because we haven't executed the allocas. How you actually pick the right values is tricky (especially when both paths in the CFG work), but still possible. > > This is definitely interesting, but it is prone to its own sorts of issues. The code leading up to the static constructor might be completely unrelated to the constructor and may cause evaluation to fail, .e.g: > > static int foo(int y) { return y+4 } > > void bar() { > int a = 4 > printf(); // can't be evaluated > static int x = foo(a); // should be evaluatable! > ... > } > > This is starting to vaguely remind me of "code slicing" problems. Would it be possible to split this into two steps: 1) identify the IR in the outermost function that needs to be simulated, and 2) simulating it? Right now #1 is implicitly the linear sequence of code between the guards. Yes, but this is exactly what we do with static constructors now. A printf will break the simulation. We just think it would be more rare in static constructors than in a function between the start and the guard acquire. However, to handle Bullet case (and the contrived case above), you could start with these instructions, and build up a set of other instructions in the function that are referenced by that initial seed set. In the case of bar above, that would tag the alloca, and then the store to the alloca of 4. Another way to say this is a lazy evaluation plus a scan to eagerly execute the relevant memory operations. > Once all of the instructions are identified, you have sort of a "masked evaluate" operation that would take a SmallPtrSet of Instructions and start simulating from the top of the function. One interesting/tricky aspect here is getting the mod/ref sets right for function calls. Here we have to know that printf can't mod/ref 'a', so the first pass doesn't need to add it to the simulation set. > > >> Anywho... yes I can split this into its own patch, assuming that's still what you want me to do instead of not abusing globalopt like this. :) > > The first right step in this direction (regardless of what approach you take above) is to refactor the existing EvaluateFunction/Block stuff into a class that contains the state. That will make it a lot easier to reason about, and then these guys won't have to take 57 arguments :) Done! :) >>> Overall, I'm really glad you've tackled this. It would help a lot if you could do some of the other patches to make it more clear and straight-forward. It's hard to understand the actual transformation as is :) >> >> Thanks! One of the other cleanups is that I'd like is to make this code use ConstantFoldLoadFromConstPtr somehow. Reusing the constant folder is nice because it knows lots of tricks to loading constants that ComputeLoadResult doesn't, but the gotcha is that bails on globals that aren't marked constant. GlobalOpt wants to use the definitive initializers, even if they aren't constant. > > I haven't looked at this code for some time, but isn't the just like constantfolding an extractvalue from the global's initializer? Yes, they both look at the value of the initializer, but GlobalOpt only checks hasDefiniteInitializer() while constant folding checks hasDefiniteInitializer() && isConstant(). For each TU, the FE emits a single function which calls all the dynamic initializers in order, and then add that function to llvm.global.ctors. GlobalOpt then either simulates all of a TU's initializers, or none of them because the simulation failed. In C++ these is no ordering of the initializers between multiple TUs, so even if we skip the first function in llvm.global.ctors, we can go ahead and simulate the second one thanks to the rule that any order is okay. It's safe for GlobalOpt to read initializers of non-constant globals because both the order of the TUs is arbitrary and because we bail on entire TUs instead of initializing some variables but not others, and because the value of a dynamically initialized global is defined to be zero before its initializer runs. A TU like this: static int a = f(); static int b; int f() { return b + 1 } is required to set b to 1, and globalopt will get that right. If we only looked at constant globals, we wouldn't be able to optimize this example. As for running part of a TU, we need to make sure that we don't leave things in an inconsistent state. If I understand correctly, something like this: extern void doit(); int f() { doit(); return 1; } int x = f(); allows another translation to check whether doit() has been called by looking at the value of 'x'. We can't just statically initialize x = 1 and leave the doit() to be called when the dynamic initializer really happens. Nick From james.molloy at arm.com Mon Feb 20 06:02:38 2012 From: james.molloy at arm.com (James Molloy) Date: Mon, 20 Feb 2012 12:02:38 -0000 Subject: [llvm-commits] [llvm] r150957 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Message-ID: <20120220120238.DD06F2A6C12F@llvm.org> Author: jamesm Date: Mon Feb 20 06:02:38 2012 New Revision: 150957 URL: http://llvm.org/viewvc/llvm-project?rev=150957&view=rev Log: Teach the DAGCombiner that certain loadext nodes followed by ANDs can be converted to zeroexts. 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=150957&r1=150956&r2=150957&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Feb 20 06:02:38 2012 @@ -2391,6 +2391,88 @@ return SDValue(N, 0); // Return N so it doesn't get rechecked! } } + // similarly fold (and (X (load ([non_ext|any_ext|zero_ext] V))), c) -> + // (X (load ([non_ext|zero_ext] V))) if 'and' only clears top bits which must + // already be zero by virtue of the width of the base type of the load. + // + // the 'X' node here can either be nothing or an extract_vector_elt to catch + // more cases. + if ((N0.getOpcode() == ISD::EXTRACT_VECTOR_ELT && + N0.getOperand(0).getOpcode() == ISD::LOAD) || + N0.getOpcode() == ISD::LOAD) { + LoadSDNode *Load = cast( (N0.getOpcode() == ISD::LOAD) ? + N0 : N0.getOperand(0) ); + + // Get the constant (if applicable) the zero'th operand is being ANDed with. + // This can be a pure constant or a vector splat, in which case we treat the + // vector as a scalar and use the splat value. + APInt Constant = APInt::getNullValue(1); + if (const ConstantSDNode *C = dyn_cast(N1)) { + Constant = C->getAPIntValue(); + } else if (BuildVectorSDNode *Vector = dyn_cast(N1)) { + APInt SplatValue, SplatUndef; + unsigned SplatBitSize; + bool HasAnyUndefs; + bool IsSplat = Vector->isConstantSplat(SplatValue, SplatUndef, + SplatBitSize, HasAnyUndefs); + if (IsSplat) { + // Undef bits can contribute to a possible optimisation if set, so + // set them. + SplatValue |= SplatUndef; + + // The splat value may be something like "0x00FFFFFF", which means 0 for + // the first vector value and FF for the rest, repeating. We need a mask + // that will apply equally to all members of the vector, so AND all the + // lanes of the constant together. + EVT VT = Vector->getValueType(0); + unsigned BitWidth = VT.getVectorElementType().getSizeInBits(); + Constant = APInt::getAllOnesValue(BitWidth); + for (unsigned i = 0, n = VT.getVectorNumElements(); i < n; ++i) + Constant &= SplatValue.lshr(i*BitWidth).zextOrTrunc(BitWidth); + } + } + + // If we want to change an EXTLOAD to a ZEXTLOAD, ensure a ZEXTLOAD is + // actually legal and isn't going to get expanded, else this is a false + // optimisation. + bool CanZextLoadProfitably = TLI.isLoadExtLegal(ISD::ZEXTLOAD, + Load->getMemoryVT()); + + // Resize the constant to the same size as the original memory access before + // extension. If it is still the AllOnesValue then this AND is completely + // unneeded. + Constant = + Constant.zextOrTrunc(Load->getMemoryVT().getScalarType().getSizeInBits()); + + bool B; + switch (Load->getExtensionType()) { + default: B = false; break; + case ISD::EXTLOAD: B = CanZextLoadProfitably; break; + case ISD::ZEXTLOAD: + case ISD::NON_EXTLOAD: B = true; break; + } + + if (B && Constant.isAllOnesValue()) { + // If the load type was an EXTLOAD, convert to ZEXTLOAD in order to + // preserve semantics once we get rid of the AND. + SDValue NewLoad(Load, 0); + if (Load->getExtensionType() == ISD::EXTLOAD) { + NewLoad = DAG.getLoad(Load->getAddressingMode(), ISD::ZEXTLOAD, + Load->getValueType(0), Load->getDebugLoc(), + Load->getChain(), Load->getBasePtr(), + Load->getOffset(), Load->getMemoryVT(), + Load->getMemOperand()); + // Replace uses of the EXTLOAD with the new ZEXTLOAD. + CombineTo(Load, NewLoad.getValue(0), NewLoad.getValue(1)); + } + + // Fold the AND away, taking care not to fold to the old load node if we + // replaced it. + CombineTo(N, (N0.getNode() == Load) ? NewLoad : N0); + + return SDValue(N, 0); // Return N so it doesn't get rechecked! + } + } // fold (and (setcc x), (setcc y)) -> (setcc (and x, y)) if (isSetCCEquivalent(N0, LL, LR, CC0) && isSetCCEquivalent(N1, RL, RR, CC1)){ ISD::CondCode Op0 = cast(CC0)->get(); From grosser at fim.uni-passau.de Mon Feb 20 08:03:57 2012 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 20 Feb 2012 14:03:57 -0000 Subject: [llvm-commits] [polly] r150959 - /polly/trunk/www/publications.html Message-ID: <20120220140357.29DD92A6C130@llvm.org> Author: grosser Date: Mon Feb 20 08:03:56 2012 New Revision: 150959 URL: http://llvm.org/viewvc/llvm-project?rev=150959&view=rev Log: www: Fix french special characters Modified: polly/trunk/www/publications.html Modified: polly/trunk/www/publications.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/publications.html?rev=150959&r1=150958&r2=150959&view=diff ============================================================================== --- polly/trunk/www/publications.html (original) +++ polly/trunk/www/publications.html Mon Feb 20 08:03:56 2012 @@ -85,7 +85,7 @@
  • Code Generation in the Polyhedral Model Is Easier Than You Think
    - Cedric Bastoul
    + Cédric Bastoul
    PACT 2004
@@ -117,13 +117,13 @@
  • Iterative optimization in the polyhedral model: Part I, one-dimensional time.
    - Louis-Noel Pouchet, Cedric Bastoul, Albert Cohen and Nicolas Vasilache
    + Louis-Noël Pouchet, Cédric Bastoul, Albert Cohen and Nicolas Vasilache
    CGO 2007
  • Iterative optimization in the polyhedral model: Part II, multidimensional time.
    - Louis-Noel Pouchet, Cedric Bastoul, Albert Cohen and John Cavazos
    + Louis-Noël Pouchet, Cédric Bastoul, Albert Cohen and John Cavazos
    PLDI 2008
  • @@ -131,7 +131,8 @@
    • The Polyhedral Model Is More Widely Applicable Than You Think
      - Mohamed-Walid Benabderrahmane, Louis-No??l Pouchet, Albert Cohen, C??dric + Mohamed-Walid Benabderrahmane, Louis-Noël Pouchet, Albert Cohen, + Cédric Bastoul.
      CC 2010
    • From nadav.rotem at intel.com Mon Feb 20 08:36:01 2012 From: nadav.rotem at intel.com (Rotem, Nadav) Date: Mon, 20 Feb 2012 14:36:01 +0000 Subject: [llvm-commits] Bug in "call __chkstak" on 64 bit OS In-Reply-To: References: Message-ID: <7DE70FDACDE4CD4887C4278C12A2E30508F3E5@HASMSX104.ger.corp.intel.com> Hi Anton, I am not sure I understand. To my understanding, we have the following problem: The JIT uses SearchForAddressOfSymbol from Windows/DynamicLibrary.inc to find the address of "chkstk". It returns the address of the first occurrence it finds. "chkstk" may be present in multiple dlls, some of which may be loaded more than i32 bytes away. The code in X86FrameLowering and X86ISel assumes that "chkstk" is within 2Gig of the Jitted code. IMHO this is a bug. So, the problem with the proposed patch is that it does not honor the code model and that it issues an indirect jump on win64 when a 'small' code model is used, right ? Thanks, Nadav -----Original Message----- From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Anton Korobeynikov Sent: Sunday, February 19, 2012 17:09 To: NAKAMURA Takumi Cc: llvm-commits at cs.uiuc.edu; Yatsina, Marina Subject: Re: [llvm-commits] Bug in "call __chkstak" on 64 bit OS > In usual executable, __chkstk would be resolved as DLL IAT. You would > not need to worry. > In contrast, JIT might resolve __chkstk directly. IMO, you might tweak > EE/JIT symbol resolver (and code emitter). The proper fix is to honor code model. This way special call to chkstk will behave as normal function call. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University _______________________________________________ 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 benny.kra at googlemail.com Mon Feb 20 08:34:58 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 20 Feb 2012 14:34:58 -0000 Subject: [llvm-commits] [llvm] r150961 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAddSub.cpp test/Transforms/InstCombine/sub.ll Message-ID: <20120220143458.2BBD22A6C12F@llvm.org> Author: d0k Date: Mon Feb 20 08:34:57 2012 New Revision: 150961 URL: http://llvm.org/viewvc/llvm-project?rev=150961&view=rev Log: InstCombine: Make OptimizePointerDifference more aggressive. - Ignore pointer casts. - Also expand GEPs that aren't constantexprs when they have one use or only constant indices. - We now compile "&foo[i] - &foo[j]" into "i - j". Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp llvm/trunk/test/Transforms/InstCombine/sub.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=150961&r1=150960&r2=150961&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Mon Feb 20 08:34:57 2012 @@ -479,57 +479,57 @@ // If LHS is a gep based on RHS or RHS is a gep based on LHS, we can optimize // this. bool Swapped = false; - GetElementPtrInst *GEP = 0; - ConstantExpr *CstGEP = 0; - - // TODO: Could also optimize &A[i] - &A[j] -> "i-j", and "&A.foo[i] - &A.foo". + GEPOperator *GEP1 = 0, *GEP2 = 0; + // For now we require one side to be the base pointer "A" or a constant - // expression derived from it. - if (GetElementPtrInst *LHSGEP = dyn_cast(LHS)) { + // GEP derived from it. + if (GEPOperator *LHSGEP = dyn_cast(LHS)) { // (gep X, ...) - X if (LHSGEP->getOperand(0) == RHS) { - GEP = LHSGEP; + GEP1 = LHSGEP; Swapped = false; - } else if (ConstantExpr *CE = dyn_cast(RHS)) { - // (gep X, ...) - (ce_gep X, ...) - if (CE->getOpcode() == Instruction::GetElementPtr && - LHSGEP->getOperand(0) == CE->getOperand(0)) { - CstGEP = CE; - GEP = LHSGEP; + } else if (GEPOperator *RHSGEP = dyn_cast(RHS)) { + // (gep X, ...) - (gep X, ...) + if (LHSGEP->getOperand(0)->stripPointerCasts() == + RHSGEP->getOperand(0)->stripPointerCasts()) { + GEP2 = RHSGEP; + GEP1 = LHSGEP; Swapped = false; } } } - if (GetElementPtrInst *RHSGEP = dyn_cast(RHS)) { + if (GEPOperator *RHSGEP = dyn_cast(RHS)) { // X - (gep X, ...) if (RHSGEP->getOperand(0) == LHS) { - GEP = RHSGEP; + GEP1 = RHSGEP; Swapped = true; - } else if (ConstantExpr *CE = dyn_cast(LHS)) { - // (ce_gep X, ...) - (gep X, ...) - if (CE->getOpcode() == Instruction::GetElementPtr && - RHSGEP->getOperand(0) == CE->getOperand(0)) { - CstGEP = CE; - GEP = RHSGEP; + } else if (GEPOperator *LHSGEP = dyn_cast(LHS)) { + // (gep X, ...) - (gep X, ...) + if (RHSGEP->getOperand(0)->stripPointerCasts() == + LHSGEP->getOperand(0)->stripPointerCasts()) { + GEP2 = LHSGEP; + GEP1 = RHSGEP; Swapped = true; } } } - if (GEP == 0) + // Avoid duplicating the arithmetic if GEP2 has non-constant indices and + // multiple users. + if (GEP1 == 0 || + (GEP2 != 0 && !GEP2->hasAllConstantIndices() && !GEP2->hasOneUse())) return 0; // Emit the offset of the GEP and an intptr_t. - Value *Result = EmitGEPOffset(GEP); + Value *Result = EmitGEPOffset(GEP1); // If we had a constant expression GEP on the other side offsetting the // pointer, subtract it from the offset we have. - if (CstGEP) { - Value *CstOffset = EmitGEPOffset(CstGEP); - Result = Builder->CreateSub(Result, CstOffset); + if (GEP2) { + Value *Offset = EmitGEPOffset(GEP2); + Result = Builder->CreateSub(Result, Offset); } - // If we have p - gep(p, ...) then we have to negate the result. if (Swapped) Modified: llvm/trunk/test/Transforms/InstCombine/sub.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sub.ll?rev=150961&r1=150960&r2=150961&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sub.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/sub.ll Mon Feb 20 08:34:57 2012 @@ -301,3 +301,29 @@ ; CHECK-NEXT: add i32 ; CHECK-NEXT: ret i32 } + +define i64 @test29(i8* %foo, i64 %i, i64 %j) { + %gep1 = getelementptr inbounds i8* %foo, i64 %i + %gep2 = getelementptr inbounds i8* %foo, i64 %j + %cast1 = ptrtoint i8* %gep1 to i64 + %cast2 = ptrtoint i8* %gep2 to i64 + %sub = sub i64 %cast1, %cast2 + ret i64 %sub +; CHECK: @test29 +; CHECK-NEXT: sub i64 %i, %j +; CHECK-NEXT: ret i64 +} + +define i64 @test30(i8* %foo, i64 %i, i64 %j) { + %bit = bitcast i8* %foo to i32* + %gep1 = getelementptr inbounds i32* %bit, i64 %i + %gep2 = getelementptr inbounds i8* %foo, i64 %j + %cast1 = ptrtoint i32* %gep1 to i64 + %cast2 = ptrtoint i8* %gep2 to i64 + %sub = sub i64 %cast1, %cast2 + ret i64 %sub +; CHECK: @test30 +; CHECK-NEXT: %gep1.idx = shl nuw i64 %i, 2 +; CHECK-NEXT: sub i64 %gep1.idx, %j +; CHECK-NEXT: ret i64 +} From anton at korobeynikov.info Mon Feb 20 08:45:32 2012 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Mon, 20 Feb 2012 18:45:32 +0400 Subject: [llvm-commits] Bug in "call __chkstak" on 64 bit OS In-Reply-To: <7DE70FDACDE4CD4887C4278C12A2E30508F3E5@HASMSX104.ger.corp.intel.com> References: <7DE70FDACDE4CD4887C4278C12A2E30508F3E5@HASMSX104.ger.corp.intel.com> Message-ID: Nadav, > ?So, the problem with the proposed patch is that it does not honor the code model and that it issues an indirect jump on win64 when a 'small' code model is used, right ? Almost correct. call to chkstk should behave the same way as all other calls. So, it will be pcrel32 in small, kernel and medium code models. And indirect in large. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From nadav.rotem at intel.com Mon Feb 20 08:50:22 2012 From: nadav.rotem at intel.com (Rotem, Nadav) Date: Mon, 20 Feb 2012 14:50:22 +0000 Subject: [llvm-commits] Bug in "call __chkstak" on 64 bit OS In-Reply-To: References: <7DE70FDACDE4CD4887C4278C12A2E30508F3E5@HASMSX104.ger.corp.intel.com> Message-ID: <7DE70FDACDE4CD4887C4278C12A2E30508F423@HASMSX104.ger.corp.intel.com> It makes sense. Thank you. -----Original Message----- From: Anton Korobeynikov [mailto:anton at korobeynikov.info] Sent: Monday, February 20, 2012 16:46 To: Rotem, Nadav Cc: NAKAMURA Takumi; llvm-commits at cs.uiuc.edu; Yatsina, Marina Subject: Re: [llvm-commits] Bug in "call __chkstak" on 64 bit OS Nadav, > ?So, the problem with the proposed patch is that it does not honor the code model and that it issues an indirect jump on win64 when a 'small' code model is used, right ? Almost correct. call to chkstk should behave the same way as all other calls. So, it will be pcrel32 in small, kernel and medium code models. And indirect in large. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University --------------------------------------------------------------------- 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 geek4civic at gmail.com Mon Feb 20 08:53:33 2012 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 20 Feb 2012 23:53:33 +0900 Subject: [llvm-commits] Bug in "call __chkstak" on 64 bit OS In-Reply-To: <7DE70FDACDE4CD4887C4278C12A2E30508F3E5@HASMSX104.ger.corp.intel.com> References: <7DE70FDACDE4CD4887C4278C12A2E30508F3E5@HASMSX104.ger.corp.intel.com> Message-ID: 2012/2/20 Rotem, Nadav : > I am not sure I understand. ?To my understanding, we have the following problem: ?The JIT uses SearchForAddressOfSymbol from Windows/DynamicLibrary.inc to find the address of "chkstk". It returns the address of the first occurrence it finds. ?"chkstk" may be present in multiple dlls, some of which may be loaded more than i32 bytes away. ?The code in X86FrameLowering and X86ISel assumes that "chkstk" is within 2Gig of the Jitted code. IMHO this is a bug. ?So, the problem with the proposed patch is that it does not honor the code model and that it issues an indirect jump on win64 when a 'small' code model is used, right ? For your issue, it might be better to tweak symbol resolver to find chkstk in your dll at first. (I don't know why DynamicLibrary.inc seeks DLLs at first) Enhancing memory model for win32 would be needed in future, if we should support other models, eg. win32 kernel mode... ...Takumi From benny.kra at googlemail.com Mon Feb 20 09:07:47 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 20 Feb 2012 15:07:47 -0000 Subject: [llvm-commits] [llvm] r150962 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll Message-ID: <20120220150747.D2BEE2A6C12F@llvm.org> Author: d0k Date: Mon Feb 20 09:07:47 2012 New Revision: 150962 URL: http://llvm.org/viewvc/llvm-project?rev=150962&view=rev Log: InstCombine: When comparing two GEPs that were derived from the same base pointer but use different types, expand the offset calculation and to the compare on the offset if profitable. This came up in SmallVector code. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/test/Transforms/InstCombine/icmp.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=150962&r1=150961&r2=150962&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 20 09:07:47 2012 @@ -607,6 +607,20 @@ return new ICmpInst(ICmpInst::getSignedPredicate(Cond), GEPLHS->getOperand(0), GEPRHS->getOperand(0)); + // If we're comparing GEPs with two base pointers that only differ in type + // and both GEPs have only constant indices or just one use, then fold + // the compare with the adjusted indices. + if (TD && + (GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse()) && + (GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse()) && + PtrBase->stripPointerCasts() == + GEPRHS->getOperand(0)->stripPointerCasts()) { + Value *Cmp = Builder->CreateICmp(ICmpInst::getSignedPredicate(Cond), + EmitGEPOffset(GEPLHS), + EmitGEPOffset(GEPRHS)); + return ReplaceInstUsesWith(I, Cmp); + } + // Otherwise, the base pointers are different and the indices are // different, bail out. return 0; Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=150962&r1=150961&r2=150962&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Mon Feb 20 09:07:47 2012 @@ -589,3 +589,29 @@ ret void } declare i32 @test58_d(i64) + +define i1 @test59(i8* %foo) { + %bit = bitcast i8* %foo to i32* + %gep1 = getelementptr inbounds i32* %bit, i64 2 + %gep2 = getelementptr inbounds i8* %foo, i64 10 + %cast1 = bitcast i32* %gep1 to i8* + %cmp = icmp ult i8* %cast1, %gep2 + %use = ptrtoint i8* %cast1 to i64 + %call = call i32 @test58_d(i64 %use) nounwind + ret i1 %cmp +; CHECK: @test59 +; CHECK: ret i1 true +} + +define i1 @test60(i8* %foo, i64 %i, i64 %j) { + %bit = bitcast i8* %foo to i32* + %gep1 = getelementptr inbounds i32* %bit, i64 %i + %gep2 = getelementptr inbounds i8* %foo, i64 %j + %cast1 = bitcast i32* %gep1 to i8* + %cmp = icmp ult i8* %cast1, %gep2 + ret i1 %cmp +; CHECK: @test60 +; CHECK-NEXT: %gep1.idx = shl nuw i64 %i, 2 +; CHECK-NEXT: icmp slt i64 %gep1.idx, %j +; CHECK-NEXT: ret i1 +} From STPWORLD at narod.ru Mon Feb 20 09:58:45 2012 From: STPWORLD at narod.ru (Stepan Dyatkovskiy) Date: Mon, 20 Feb 2012 19:58:45 +0400 Subject: [llvm-commits] New classes for PR1255: Should enhance LLVM switch instruction to take case ranges. In-Reply-To: References: <318431328953921@web153.yandex.ru> <728541329064187@web155.yandex.ru> <4F37ED0D.5080709@free.fr> <503781329070448@web148.yandex.ru> <804331329200372@web140.yandex.ru> <2AFD05C6-756F-4405-BD48-E8E461C190CF@apple.com> <42501329219557@web128.yandex.ru> Message-ID: <92721329753525@web32.yandex.ru> > On Feb 14, 2012, at 3:39 AM, Stepan Dyatkovskiy wrote: > >> ?Hi, Chris. >> ?You last thoughts relative to pr1255 was here: >> ?http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120102/134424.html > > Aha, I thought that I had suggested arrays/vectors somewhere. ?Unfortunately, it doesn't work well because arrays all want the element type to be the same, having some that are scalars and some that are vectors isn't kosher. I propose to store single values as ranges two. Vector with one element - single value; two elements means the range. Instead I mean just a structure here, just a concept. I propose to store union range/single value in array. But now I had undestood you mean - it is non-economical implementation relative to the RAM consumption. Let me think more. The only thing I can propose afterall is ConstantRangesSet + CRSBuilder concept as interface for user. If we accepted some interface we can be free with its implementation. > >>> ?Please remind me why it makes sense to use ConstantArray (or something like it) here. ?It seems that the case values of the switch could be very reasonably represented with APInts, eliminating the Value*'s for the case values all together (which is what I recommended in Comment 15 of PR1255). ?OTOH, I do vaguely remember making the comment about arrays and vectors in some PR (but can't find it). ?Thinking about this a third time now, I really think that avoiding Constant*'s is the right thing to do. >> ?What is the main reason to use APInts? > > There are a bunch of reasons. ?For one, operands (including in a ConstantArray) are very expensive/heavyweight: sizeof(Use) = 64 bytes. ?APInt is lighter weight: sizeof(APInt) = 8 bytes. You right here. So as I said I try to think more about it. > > The other reason is one of purity: these are not IR values that can be used and manipulated like other values. ?There are no defs and uses here. ?The case values are purely an implementation detail of the switch instruction, so they should not be Value*'s or Use's. Its clean for me. Though as I saw Value + Use idea was growed up to something more big and complex. For example AsmPrinter can print Values only. Verifier can assert Values only. It seems that it is in llvm developers mind, that all values are inharited from Value. >From another side (mathematical). SwitchInst is an instruction. Instruction has some arguments and case-values are operands instead. So SwitchInst is S*= I(S, c1,s1, c2, s2, cn, sn), where S - current state. S* - new state. c1 - case #1 s1 - successor #1 .. So "case" should be an operand from this side. >> ?I was need to do a set of workarounds adapting LLVM infrastructure to this feature: back-ends, asm-writer, lazy-values, Verifier.cpp with its original assertions and so on. APInt numbers will like an aliens from another planet, since the will need to work with entities that are from LLVMContext, and often we need to move it back using ConstantInt::get(...). If you have a time you can look at second draft patch attached to this post (cr-0.5.0). I made it two months ago or so on. It also contains changes in indexing I already applied, filtering it you can see what will wait LLVM if we will use APInt for case values. Patch is really huge, just look how SimplifyCFG, AsmWriter and BitcodeWriter will changed. > > I'm not sure what you mean here. ?The first thing that codegen does today is get the APInt out of a ConstantInt. ?Removing the layer should simplify a number of things, particularly if SwitchInst has a good set of helper methods. There are several props and cons. From one side we should to invoke getValue always. From another side we should extend AsmPrinter, Verify asserts adding support fo native APInt and so on. We should brake a little bit c u r r e n t concept of usage Value+Use classes. It is on IMHO rights. I can implement cases either based on APInts or on ConstantInts. But I propose replace ConstantInt with APInt on the last stage of PR1255 implementation. P.S.: Sorry for latency in reply. I'm on my vocation till 5th March. -Stepan. From baldrick at free.fr Mon Feb 20 10:08:44 2012 From: baldrick at free.fr (Duncan Sands) Date: Mon, 20 Feb 2012 17:08:44 +0100 Subject: [llvm-commits] New classes for PR1255: Should enhance LLVM switch instruction to take case ranges. In-Reply-To: <92721329753525@web32.yandex.ru> References: <318431328953921@web153.yandex.ru> <728541329064187@web155.yandex.ru> <4F37ED0D.5080709@free.fr> <503781329070448@web148.yandex.ru> <804331329200372@web140.yandex.ru> <2AFD05C6-756F-4405-BD48-E8E461C190CF@apple.com> <42501329219557@web128.yandex.ru> <92721329753525@web32.yandex.ru> Message-ID: <4F42700C.2040004@free.fr> Hi Stepan, > I propose to store single values as ranges two. Vector with one element - single value; two elements means the range. Instead I mean just a structure here, just a concept. I propose to store union range/single value in array. > But now I had undestood you mean - it is non-economical implementation relative to the RAM consumption. Let me think more. > The only thing I can propose afterall is ConstantRangesSet + CRSBuilder concept as interface for user. If we accepted some interface we can be free with its implementation. why not use the existing ConstantRange class? Ciao, Duncan. From kristof.beyls at arm.com Mon Feb 20 10:14:18 2012 From: kristof.beyls at arm.com (Kristof Beyls) Date: Mon, 20 Feb 2012 16:14:18 -0000 Subject: [llvm-commits] [PATCH] generate ABI-compliant sections for uninitialized static data members in template instantiations Message-ID: <000001ccefea$b3223150$196693f0$@beyls@arm.com> The attached patch fixes a problem where LLVM doesn't generate .bss sections in a C++ ABI-compliant way. Would someone be able to review and apply the patch if fine? Thanks, Kristof Here is some background information: The following section of the generic C++ ABI (http://sourcery.mentor.com/public/cxx-abi/abi.html#vague-itemplate) states: """ 5.2.6 Instantiated Templates An instantiation of a class template requires: .... * Any static member data object is emitted in a COMDAT identified by its mangled name, in any object file with a reference to its name symbol. .... """ However, for uninitialized static member data objects in instantiated templates, LLVM does not produce a COMDAT. For the following test case: template struct C { static int i; static int j; }; template int C::i; template int C::j = 12; void f(C c) { c.i++; c.j++; } LLVM produces the following assembler output for the template instantiations of C::i and C::j: .type _ZN1CIiE1iE,%object @ @_ZN1CIiE1iE .bss .weak _ZN1CIiE1iE .align 2 _ZN1CIiE1iE: .long 0 @ 0x0 .size _ZN1CIiE1iE, 4 .type _ZN1CIiE1jE,%object @ @_ZN1CIiE1jE .section .data._ZN1CIiE1jE,"aGw",%progbits,_ZN1CIiE1jE,comdat .weak _ZN1CIiE1jE .align 2 _ZN1CIiE1jE: .long 12 @ 0xc .size _ZN1CIiE1jE, 4 Note that for C::i (mangled: _ZN1CIiE1iE), no comdat section is produced. OTOH, for C::j, a comdat section is produced. The correct behaviour would be to produce the following section for C::i .type _ZN1CIiE1iE,%object @ @_ZN1CIiE1iE .section .bss._ZN1CIiE1jE,"aGw",%nobits,_ZN1CIiE1jE,comdat .weak _ZN1CIiE1iE .align 2 _ZN1CIiE1iE: .long 0 @ 0x0 .size _ZN1CIiE1iE, 4 This is also what gcc produces. -------------- next part -------------- A non-text attachment was scrubbed... Name: cxx_weak_odr_bss.patch Type: application/octet-stream Size: 2089 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120220/9a52c3a3/attachment.obj From daniel at zuster.org Mon Feb 20 10:56:39 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 20 Feb 2012 16:56:39 -0000 Subject: [llvm-commits] [zorg] r150966 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120220165639.9D01D2A6C12F@llvm.org> Author: ddunbar Date: Mon Feb 20 10:56:39 2012 New Revision: 150966 URL: http://llvm.org/viewvc/llvm-project?rev=150966&view=rev Log: [lnt] lnt.tests.compile print samples more readably. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=150966&r1=150965&r2=150966&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Mon Feb 20 10:56:39 2012 @@ -626,9 +626,10 @@ for basename,test_fn in tests_to_run: for success,name,samples in test_fn(basename, run_info, variables): - print >>sys.stderr, '%s: collected sample: %r - %r' % ( - datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'), - name, samples) + now = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') + print >>sys.stderr, '%s: collected sample: %r' % ( + now, name) + print >>sys.stderr, '%s: %r' % (now, samples) test_name = '%s.%s' % (tag, name) if not success: testsamples.append(lnt.testing.TestSamples( From daniel at zuster.org Mon Feb 20 10:57:32 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 20 Feb 2012 16:57:32 -0000 Subject: [llvm-commits] [zorg] r150967 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120220165732.CE25C2A6C12F@llvm.org> Author: ddunbar Date: Mon Feb 20 10:57:32 2012 New Revision: 150967 URL: http://llvm.org/viewvc/llvm-project?rev=150967&view=rev Log: [lnt] lnt.tests.compile: Change status messages to go into a test.log file, as with lnt.tests.nt. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=150967&r1=150966&r2=150967&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Mon Feb 20 10:57:32 2012 @@ -614,22 +614,26 @@ if not os.path.exists(g_output_dir): os.mkdir(g_output_dir) + # Create the test log. + test_log_path = os.path.join(g_output_dir, 'test.log') + test_log = open(test_log_path, 'w') + # Execute the run. run_info.update(variables) run_info['tag'] = tag = 'compile' testsamples = [] start_time = datetime.utcnow() - print >>sys.stderr, '%s: run started' % start_time.strftime( + print >>test_log, '%s: run started' % start_time.strftime( '%Y-%m-%d %H:%M:%S') try: for basename,test_fn in tests_to_run: for success,name,samples in test_fn(basename, run_info, variables): now = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') - print >>sys.stderr, '%s: collected sample: %r' % ( + print >>test_log, '%s: collected sample: %r' % ( now, name) - print >>sys.stderr, '%s: %r' % (now, samples) + print >>test_log, '%s: %r' % (now, samples) test_name = '%s.%s' % (tag, name) if not success: testsamples.append(lnt.testing.TestSamples( @@ -647,9 +651,11 @@ print >>sys.stderr,'--' run_info['had_errors'] = 1 end_time = datetime.utcnow() - print >>sys.stderr, '%s: run complete' % start_time.strftime( + print >>test_log, '%s: run complete' % start_time.strftime( '%Y-%m-%d %H:%M:%S') + test_log.close() + # Package up the report. machine = lnt.testing.Machine(opts.machine_name, machine_info) run = lnt.testing.Run(start_time, end_time, info = run_info) From daniel at zuster.org Mon Feb 20 10:58:47 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 20 Feb 2012 16:58:47 -0000 Subject: [llvm-commits] [zorg] r150968 - in /zorg/trunk/lnt: lnt/testing/util/valgrind.py tests/testing/ tests/testing/CalltreeDataLoading.py tests/testing/Inputs/ tests/testing/Inputs/test-input-01.out Message-ID: <20120220165848.02F6B2A6C12F@llvm.org> Author: ddunbar Date: Mon Feb 20 10:58:47 2012 New Revision: 150968 URL: http://llvm.org/viewvc/llvm-project?rev=150968&view=rev Log: [lnt] lnt.testing.util.valgrind: Add a basic parser for Valgrind's Calltree profiling format. - This isn't trying to be complete, just enough to parse the most basic --tool=cachegrind output. Added: zorg/trunk/lnt/lnt/testing/util/valgrind.py zorg/trunk/lnt/tests/testing/ zorg/trunk/lnt/tests/testing/CalltreeDataLoading.py zorg/trunk/lnt/tests/testing/Inputs/ zorg/trunk/lnt/tests/testing/Inputs/test-input-01.out Added: zorg/trunk/lnt/lnt/testing/util/valgrind.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/util/valgrind.py?rev=150968&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/testing/util/valgrind.py (added) +++ zorg/trunk/lnt/lnt/testing/util/valgrind.py Mon Feb 20 10:58:47 2012 @@ -0,0 +1,108 @@ +""" +Utilities for working with Valgrind. +""" + +from lnt.testing.util.commands import warning + +# See: +# http://valgrind.org/docs/manual/cl-format.html#cl-format.overview +# for reference on the calltree data format specification. + +class CalltreeParseError(Exception): + pass + +class CalltreeData(object): + @staticmethod + def frompath(path): + with open(path) as file: + return CalltreeData.fromfile(file, path) + + @staticmethod + def fromfile(file, path): + # I love valgrind, but this is really a horribly lame data format. Oh + # well. + + it = iter(file) + + # Read the header. + description_lines = [] + command = None + events = None + positions = initial_positions = ['line'] + for ln in it: + # If there is no colon in the line, we have reached the end of the + # header. + if ':' not in ln: + break + + key,value = ln.split(':', 1) + if key == 'desc': + description_lines.append(value.strip()) + elif key == 'cmd': + if command is not None: + warning("unexpected multiple 'cmd' keys in %r" % (path,)) + command = value.strip() + elif key == 'events': + if events is not None: + warning("unexpected multiple 'events' keys in %r" % (path,)) + events = value.split() + elif key == 'positions': + if positions is not initial_positions: + warning("unexpected multiple 'positions' keys in %r" % ( + path,)) + positions = value.split() + else: + warning("found unknown key %r in %r" % (key, path)) + + # Validate that required fields were present. + if events is None: + raise CalltreeParseError("missing required 'events' key in header") + + # Construct an instance. + data = CalltreeData(events, "\n".join(description_lines), command) + + # Read the file data. + num_samples = len(positions) + len(events) + current_file = None + current_function = None + summary_samples = None + for ln in it: + # Check if this is the closing summary line. + if ln.startswith('summary'): + key,value = ln.split(':', 1) + summary_samples = map(int, value.split()) + break + + # Check if this is an update to the current file or function. + if ln.startswith('fl='): + current_file = ln[3:-1] + elif ln.startswith('fn='): + current_function = ln[3:-1] + else: + # Otherwise, this is a data record. + samples = map(int, ln.split()) + if len(samples) != num_samples: + raise CalltreeParseError( + "invalid record line, unexpected sample count") + data.records.append((current_file, + current_function, + samples)) + + # Validate that there are no more remaining records. + for ln in it: + raise CalltreeParseError("unexpected line in footer: %r" % (ln,)) + + # Validate that the summary line was present. + if summary_samples is None: + raise CalltreeParseError("missing required 'summary' key in footer") + + data.summary = summary_samples + + return data + + def __init__(self, events, description=None, command=None): + self.events = events + self.description = description + self.command = command + self.records = [] + self.summary = None Added: zorg/trunk/lnt/tests/testing/CalltreeDataLoading.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/tests/testing/CalltreeDataLoading.py?rev=150968&view=auto ============================================================================== --- zorg/trunk/lnt/tests/testing/CalltreeDataLoading.py (added) +++ zorg/trunk/lnt/tests/testing/CalltreeDataLoading.py Mon Feb 20 10:58:47 2012 @@ -0,0 +1,15 @@ +# Check the model bindings for test suite instances. +# +# RUN: rm -f %t.db +# RUN: python %s %S/Inputs/test-input-01.out + +import sys + +from lnt.testing.util import valgrind + +data = valgrind.CalltreeData.frompath(sys.argv[1]) +print data + +assert data.command == 'true' +assert tuple(data.events) == ('Ir', 'I1mr', 'ILmr', 'Dr', 'D1mr', 'DLmr', + 'Dw', 'D1mw', 'DLmw',) Added: zorg/trunk/lnt/tests/testing/Inputs/test-input-01.out URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/tests/testing/Inputs/test-input-01.out?rev=150968&view=auto ============================================================================== --- zorg/trunk/lnt/tests/testing/Inputs/test-input-01.out (added) +++ zorg/trunk/lnt/tests/testing/Inputs/test-input-01.out Mon Feb 20 10:58:47 2012 @@ -0,0 +1,839 @@ +desc: I1 cache: 32768 B, 64 B, 8-way associative +desc: D1 cache: 32768 B, 64 B, 8-way associative +desc: LL cache: 6291456 B, 64 B, 24-way associative +cmd: true +events: Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw +fl=/Users/buildslave/public/valgrind/coregrind//vg_preloaded.c +fn=vg_cleanup_env +118 1 0 0 0 0 0 0 0 0 +122 7 0 0 2 0 0 3 0 0 +124 503 4 0 2 0 0 0 0 0 +125 276 1 0 70 0 0 68 0 0 +126 66 0 0 0 0 0 66 0 0 +127 202 1 0 68 0 0 0 0 0 +130 3 0 0 0 0 0 3 0 0 +132 9 0 0 6 0 0 3 0 0 +133 5 0 0 0 0 0 3 0 0 +138 2 1 0 0 0 0 1 0 0 +139 11 1 0 2 0 0 7 0 0 +144 8 1 0 7 0 0 0 0 0 +fl=??? +fn=??? +0 88 3 3 25 1 0 6 0 0 +fn=ImageLoader::ImageLoader(char const*, unsigned int) +0 7056 4 4 1035 1 1 405 38 38 +fn=ImageLoader::applyInterposing(ImageLoader::LinkContext const&) +0 9 1 1 4 0 0 1 0 0 +fn=ImageLoader::compare(ImageLoader const*) const +0 10880 2 0 4008 0 0 716 0 0 +fn=ImageLoader::getShortName() const +0 51 2 2 12 0 0 9 0 0 +fn=ImageLoader::hasHiddenExports() const +0 567 1 1 243 0 0 81 0 0 +fn=ImageLoader::hash(char const*) +0 15502 1 1 2075 0 0 61 0 0 +fn=ImageLoader::isLinked() const +0 14 0 0 6 0 0 2 0 0 +fn=ImageLoader::lastModified() const +0 1610 1 0 966 0 0 322 0 0 +fn=ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, ImageLoader::RPathChain const&) +0 214 8 8 56 3 0 75 1 0 +fn=ImageLoader::matchInstallPath() const +0 4410 1 1 1890 4 0 630 0 0 +fn=ImageLoader::overlapsWithAddressRange(void const*, void const*) const +0 149 4 4 42 0 0 25 0 0 +fn=ImageLoader::recursiveBind(ImageLoader::LinkContext const&, bool) +0 2814 4 4 749 8 0 538 0 0 +fn=ImageLoader::recursiveGetDOFSections(ImageLoader::LinkContext const&, std::vector >&) +0 2371 3 3 641 0 0 457 0 0 +fn=ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&) +0 4141 12 7 1008 7 0 991 1 0 +fn=ImageLoader::recursiveLoadLibraries(ImageLoader::LinkContext const&, bool, ImageLoader::RPathChain const&) +0 10216 16 16 3682 13 2 1979 4 4 +fn=ImageLoader::recursiveRebase(ImageLoader::LinkContext const&) +0 2457 3 3 633 19 0 449 0 0 +fn=ImageLoader::recursiveSpinLock(ImageLoader::recursive_lock&) +0 840 2 1 252 0 0 168 0 0 +fn=ImageLoader::recursiveUpdateDepth(unsigned int) +0 4505 3 3 1236 0 0 933 0 0 +fn=ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) +0 74 4 2 20 1 0 24 0 0 +fn=ImageLoader::setFileInfo(int, unsigned long long, long) +0 182 0 0 52 0 0 104 0 0 +fn=ImageLoader::setMapped(ImageLoader::LinkContext const&) +0 243 1 1 54 0 0 54 0 0 +fn=ImageLoader::setPath(char const*) +0 401 3 3 62 0 0 8 0 0 +fn=ImageLoader::setPathUnowned(char const*) +0 6256 2 2 983 0 0 150 0 0 +fn=ImageLoader::statMatch(stat const&) const +0 3813 1 1 2070 2 2 354 0 0 +fn=ImageLoader::weakBind(ImageLoader::LinkContext const&) +0 104 7 6 34 1 0 26 0 0 +fn=ImageLoaderMachO::ImageLoaderMachO(macho_header const*, char const*, unsigned int, unsigned int*, unsigned int) +0 4251 4 4 1201 0 0 513 6 4 +fn=ImageLoaderMachO::assignSegmentAddresses(ImageLoader::LinkContext const&) +0 3176 8 8 956 3 3 647 10 7 +fn=ImageLoaderMachO::bindLocation(ImageLoader::LinkContext const&, unsigned long, unsigned long, ImageLoader const*, unsigned char, char const*, long, char const*) +0 8853 6 4 2951 44 8 1816 0 0 +fn=ImageLoaderMachO::doGetDOFSections(ImageLoader::LinkContext const&, std::vector >&) +0 989 3 2 350 42 1 182 0 0 +fn=ImageLoaderMachO::doGetDependentLibraries(ImageLoader::DependentLibraryInfo*) +0 5514 4 4 1455 58 0 578 9 9 +fn=ImageLoaderMachO::doGetLibraryInfo() +0 900 2 2 420 3 0 60 0 0 +fn=ImageLoaderMachO::doImageInit(ImageLoader::LinkContext const&) +0 513 1 1 216 0 0 162 0 0 +fn=ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) +0 675 5 2 162 1 0 189 1 0 +fn=ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) +0 1125 9 4 488 68 0 248 0 0 +fn=ImageLoaderMachO::doRebase(ImageLoader::LinkContext const&) +0 644 3 3 242 1 1 108 0 0 +fn=ImageLoaderMachO::findExportedSymbol(char const*, bool, ImageLoader const**) const +0 245136 7 5 67138 10 0 34587 4 1 +fn=ImageLoaderMachO::forceFlat() const +0 8 0 0 4 1 0 1 0 0 +fn=ImageLoaderMachO::getExportedSymbolAddress(ImageLoader::Symbol const*, ImageLoader::LinkContext const&, ImageLoader const*, bool) const +0 1519 1 1 217 0 0 217 0 0 +fn=ImageLoaderMachO::getInstallPath() const +0 4347 0 0 1960 23 0 402 0 0 +fn=ImageLoaderMachO::getMain() const +0 86 0 0 27 0 0 1 0 0 +fn=ImageLoaderMachO::getRPaths(ImageLoader::LinkContext const&, std::vector >&) const +0 3677 4 4 1518 0 0 297 5 2 +fn=ImageLoaderMachO::getSlide() const +0 5 0 0 3 1 0 1 0 0 +fn=ImageLoaderMachO::getSymbolAddress(ImageLoader::Symbol const*, ImageLoader const*, ImageLoader::LinkContext const&, bool) const +0 6293 2 2 2387 2 0 1519 0 0 +fn=ImageLoaderMachO::getUUID(unsigned char*) const +0 1829 1 1 565 0 0 81 0 0 +fn=ImageLoaderMachO::inSharedCache() const +0 609 0 0 261 0 0 87 0 0 +fn=ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) +0 1690 5 5 468 0 0 416 11 11 +fn=ImageLoaderMachO::instantiateMainExecutable(macho_header const*, unsigned long, char const*, ImageLoader::LinkContext const&) +0 34 2 2 9 0 0 7 0 0 +fn=ImageLoaderMachO::isBundle() const +0 224 0 0 112 1 0 28 0 0 +fn=ImageLoaderMachO::isDylib() const +0 896 2 1 448 15 0 112 0 0 +fn=ImageLoaderMachO::isExecutable() const +0 208 0 0 104 0 0 26 0 0 +fn=ImageLoaderMachO::isPrebindable() const +0 872 1 1 436 52 0 109 0 0 +fn=ImageLoaderMachO::machHeader() const +0 1760 1 1 1056 1 0 352 0 0 +fn=ImageLoaderMachO::mapSegments(int, unsigned long long, unsigned long long, unsigned long long, ImageLoader::LinkContext const&) +0 8190 12 12 3245 1 1 1471 8 6 +fn=ImageLoaderMachO::needsAddedLibSystemDepency(unsigned int, macho_header const*) +0 8166 3 3 1492 161 0 412 10 7 +fn=ImageLoaderMachO::needsTermination() +0 189 0 0 81 0 0 27 0 0 +fn=ImageLoaderMachO::parseLoadCmds() +0 21142 14 13 4752 514 454 2335 1 1 +fn=ImageLoaderMachO::participatesInCoalescing() const +0 1296 2 2 405 80 24 243 0 0 +fn=ImageLoaderMachO::preFetchDATA(int, unsigned long long, ImageLoader::LinkContext const&) +0 2181 4 4 744 0 0 502 0 0 +fn=ImageLoaderMachO::registerInterposing() +0 310 5 4 87 0 0 40 0 0 +fn=ImageLoaderMachO::reserveAnAddressRange(unsigned long, ImageLoader::LinkContext const&) +0 598 2 2 156 0 0 104 0 0 +fn=ImageLoaderMachO::segActualEndAddress(unsigned int) const +0 4416 1 1 1656 0 0 1104 1 0 +fn=ImageLoaderMachO::segActualLoadAddress(unsigned int) const +0 9162 1 1 5090 67 1 2036 2 0 +fn=ImageLoaderMachO::segExecutable(unsigned int) const +0 1463 0 0 693 0 0 308 0 0 +fn=ImageLoaderMachO::segFileOffset(unsigned int) const +0 3995 2 2 2115 26 24 940 0 0 +fn=ImageLoaderMachO::segFileSize(unsigned int) const +0 3043 1 1 1611 0 0 716 0 0 +fn=ImageLoaderMachO::segHasPreferredLoadAddress(unsigned int) const +0 494 1 1 234 1 1 104 0 0 +fn=ImageLoaderMachO::segHasRebaseFixUps(unsigned int) const +0 1587 1 1 411 11 10 104 0 0 +fn=ImageLoaderMachO::segName(unsigned int) const +0 1445 2 2 680 1 1 340 0 0 +fn=ImageLoaderMachO::segPreferredLoadAddress(unsigned int) const +0 3077 1 0 1629 0 0 724 0 0 +fn=ImageLoaderMachO::segReadable(unsigned int) const +0 1386 1 1 693 0 0 308 0 0 +fn=ImageLoaderMachO::segSize(unsigned int) const +0 5321 0 0 2817 51 0 1252 0 0 +fn=ImageLoaderMachO::segUnaccessible(unsigned int) const +0 3002 2 2 1422 1 0 632 3 3 +fn=ImageLoaderMachO::segWriteable(unsigned int) const +0 2945 1 0 1395 2 0 620 0 0 +fn=ImageLoaderMachO::segmentCount() const +0 525 0 0 315 0 0 105 0 0 +fn=ImageLoaderMachO::segmentsCanSlide() const +0 390 2 2 130 1 1 78 2 1 +fn=ImageLoaderMachO::segmentsMustSlideTogether() const +0 130 0 0 52 0 0 26 0 0 +fn=ImageLoaderMachO::setSlide(long) +0 135 1 1 54 0 0 54 0 0 +fn=ImageLoaderMachO::setupLazyPointerHandler(ImageLoader::LinkContext const&) +0 6546 7 6 1958 213 0 963 0 0 +fn=ImageLoaderMachO::sniffLoadCommands(macho_header const*, char const*, bool*, unsigned int*, unsigned int*, linkedit_data_command const**) +0 7761 5 5 1234 70 36 268 3 3 +fn=ImageLoaderMachO::usablePrebinding(ImageLoader::LinkContext const&) const +0 1539 2 2 567 1 0 324 0 0 +fn=ImageLoaderMachO::usesTwoLevelNameSpace() const +0 1400 0 0 700 17 0 175 0 0 +fn=ImageLoaderMachOClassic::bindIndirectSymbol(unsigned long*, macho_section const*, char const*, unsigned long, ImageLoader const*, ImageLoader::LinkContext const&) +0 120 6 3 48 0 0 36 0 0 +fn=ImageLoaderMachOClassic::bindIndirectSymbolPointers(ImageLoader::LinkContext const&, bool, bool) +0 391 11 11 178 18 0 40 0 0 +fn=ImageLoaderMachOClassic::doBind(ImageLoader::LinkContext const&, bool) +0 40 3 3 9 0 0 10 0 0 +fn=ImageLoaderMachOClassic::doBindExternalRelocations(ImageLoader::LinkContext const&) +0 45 3 3 17 1 1 19 0 0 +fn=ImageLoaderMachOClassic::doBindLazySymbol(unsigned long*, ImageLoader::LinkContext const&) +0 441 7 5 117 7 0 33 0 0 +fn=ImageLoaderMachOClassic::getFirstWritableSegmentAddress() +0 68 2 2 22 1 0 10 0 0 +fn=ImageLoaderMachOClassic::hasSubLibrary(ImageLoader::LinkContext const&, ImageLoader const*) const +0 68 5 5 26 0 0 20 0 0 +fn=ImageLoaderMachOClassic::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, ImageLoader::LinkContext const&) +0 86 7 7 28 2 2 18 1 1 +fn=ImageLoaderMachOClassic::instantiateStart(macho_header const*, char const*, unsigned int, unsigned int) +0 43 3 3 7 0 0 13 1 1 +fn=ImageLoaderMachOClassic::libImage(unsigned int) const +0 160 2 0 64 1 0 16 0 0 +fn=ImageLoaderMachOClassic::libIsUpward(unsigned int) const +0 22 1 0 8 0 0 2 0 0 +fn=ImageLoaderMachOClassic::mapSegmentsClassic(int, unsigned long long, unsigned long long, unsigned long long, ImageLoader::LinkContext const&) +0 6 2 2 2 0 0 1 0 0 +fn=ImageLoaderMachOClassic::prefetchLINKEDIT(ImageLoader::LinkContext const&) +0 56 4 3 20 1 0 8 0 0 +fn=ImageLoaderMachOClassic::rebase(ImageLoader::LinkContext const&) +0 261 7 7 54 4 0 10 0 0 +fn=ImageLoaderMachOClassic::resolveUndefined(ImageLoader::LinkContext const&, macho_nlist const*, bool, bool, ImageLoader const**) +0 328 24 12 106 0 0 44 0 0 +fn=ImageLoaderMachOClassic::segmentCommandOffsets() const +0 335 3 2 134 0 0 67 0 0 +fn=ImageLoaderMachOClassic::setLibImage(unsigned int, ImageLoader*, bool, bool) +0 34 2 1 6 0 0 4 1 0 +fn=ImageLoaderMachOClassic::setSymbolTableInfo(macho_nlist const*, char const*, dysymtab_command const*) +0 7 1 1 2 0 0 4 0 0 +fn=ImageLoaderMachOCompressed::bindAt(ImageLoader::LinkContext const&, unsigned long, unsigned char, char const*, unsigned char, long, int, char const*, ImageLoaderMachOCompressed::LastLookup*, bool) +0 6390 3 3 1846 0 0 1846 0 0 +fn=ImageLoaderMachOCompressed::doBind(ImageLoader::LinkContext const&, bool) +0 1170 3 3 260 1 0 260 0 0 +fn=ImageLoaderMachOCompressed::doBindFastLazySymbol(unsigned int, ImageLoader::LinkContext const&, void (*)(), void (*)()) +0 23330 12 12 5039 91 72 2295 5 2 +fn=ImageLoaderMachOCompressed::eachBind(ImageLoader::LinkContext const&, unsigned long (ImageLoaderMachOCompressed::*)(ImageLoader::LinkContext const&, unsigned long, unsigned char, char const*, unsigned char, long, int, char const*, ImageLoaderMachOCompress +0 29863 36 36 7080 75 40 2530 0 0 +fn=ImageLoaderMachOCompressed::exportedSymbolAddress(ImageLoader::LinkContext const&, ImageLoader::Symbol const*, bool) const +0 23219 9 8 3430 3 3 1520 0 0 +fn=ImageLoaderMachOCompressed::findExportedSymbol(char const*, ImageLoader const**) const +0 125389 7 6 46207 91 0 29503 10 3 +fn=ImageLoaderMachOCompressed::hasSubLibrary(ImageLoader::LinkContext const&, ImageLoader const*) const +0 170 0 0 68 0 0 34 0 0 +fn=ImageLoaderMachOCompressed::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, ImageLoader::LinkContext const&) +0 2650 9 9 725 1 1 650 7 5 +fn=ImageLoaderMachOCompressed::instantiateMainExecutable(macho_header const*, unsigned long, char const*, unsigned int, unsigned int, ImageLoader::LinkContext const&) +0 58 5 5 11 0 0 16 0 0 +fn=ImageLoaderMachOCompressed::isSubframeworkOf(ImageLoader::LinkContext const&, ImageLoader const*) const +0 180 2 1 72 0 0 36 0 0 +fn=ImageLoaderMachOCompressed::libImage(unsigned int) const +0 36360 1 1 14544 24 0 3636 0 0 +fn=ImageLoaderMachOCompressed::libIsUpward(unsigned int) const +0 418 1 0 152 0 0 38 0 0 +fn=ImageLoaderMachOCompressed::libReExported(unsigned int) const +0 57350 0 0 22940 4 0 5735 0 0 +fn=ImageLoaderMachOCompressed::markLINKEDIT(ImageLoader::LinkContext const&, int) +0 2162 5 5 708 2 0 306 0 0 +fn=ImageLoaderMachOCompressed::rebase(ImageLoader::LinkContext const&) +0 81769 28 28 14622 913 882 744 0 0 +fn=ImageLoaderMachOCompressed::resolve(ImageLoader::LinkContext const&, char const*, unsigned char, int, ImageLoader const**, ImageLoaderMachOCompressed::LastLookup*, bool) +0 15507 8 7 4626 0 0 3530 1 1 +fn=ImageLoaderMachOCompressed::resolveTwolevel(ImageLoader::LinkContext const&, ImageLoader const*, bool, char const*, bool, ImageLoader const**) +0 8733 4 3 2982 0 0 2343 4 2 +fn=ImageLoaderMachOCompressed::segmentCommandOffsets() const +0 11880 1 1 3960 0 0 1980 0 0 +fn=ImageLoaderMachOCompressed::setDyldInfo(dyld_info_command const*) +0 130 1 1 52 0 0 52 0 0 +fn=ImageLoaderMachOCompressed::setLibImage(unsigned int, ImageLoader*, bool, bool) +0 986 1 1 174 2 0 116 3 0 +fn=ImageLoaderMachOCompressed::setSymbolTableInfo(macho_nlist const*, char const*, dysymtab_command const*) +0 104 0 0 52 0 0 26 0 0 +fn=ImageLoaderMachOCompressed::trieWalk(unsigned char const*, unsigned char const*, char const*) +0 1582875 7 5 214444 569 336 6508 6 2 +fn=LockHelper::LockHelper() +0 7 1 1 2 0 0 3 0 0 +fn=LockHelper::~LockHelper() +0 6 1 1 1 0 0 2 0 0 +fn=NSVersionOfLinkTimeLibrary +0 173 3 3 33 10 1 8 0 0 +fn=OSAtomicCompareAndSwap64 +0 5 1 1 1 0 0 1 0 0 +fn=OSAtomicCompareAndSwap64$VARIANT$mp +0 235 3 2 94 1 0 0 0 0 +fn=OSAtomicCompareAndSwap64Barrier +0 5 1 1 1 0 0 1 0 0 +fn=OSMemoryBarrier +0 58 2 2 29 0 0 0 0 0 +fn=_NSGetEnviron +0 80 1 1 48 0 0 16 0 0 +fn=_NSGetMachExecuteHeader +0 10 0 0 6 0 0 2 0 0 +fn=__bsdthread_register +0 5 1 1 1 0 0 0 0 0 +fn=__bzero +0 27 0 0 0 0 0 0 0 0 +fn=__clzsi2 +0 341 45 38 216 21 0 73 0 0 +fn=__cxa_atexit +0 68 3 3 30 0 0 20 0 0 +fn=__cxa_finalize +0 73 6 6 21 0 0 12 0 0 +fn=__dispatch_io_create_with_path_block_invoke_1 +0 10 3 3 6 2 0 2 0 0 +fn=__error +0 80 1 1 32 0 0 8 0 0 +fn=__fcntl +0 120 1 1 24 0 0 0 0 0 +fn=__findenv +0 6187 4 2 1060 19 4 18 0 0 +fn=__guard_setup +0 90 9 9 19 3 2 18 0 0 +fn=__ioctl +0 5 1 1 1 0 0 0 0 0 +fn=__keymgr_initializer +0 61 5 5 18 3 0 20 0 0 +fn=__libc_init +0 42 4 4 6 0 0 15 1 1 +fn=__malloc_entropy_setup +0 54 3 3 12 0 0 13 1 1 +fn=__mmap +0 410 2 2 82 0 0 0 0 0 +fn=__mtx_droplock +0 274 10 10 63 0 0 47 0 0 +fn=__pthread_set_self +0 8 2 2 2 0 0 0 0 0 +fn=__sandbox_ms +0 5 1 1 1 0 0 0 0 0 +fn=__sysctl +0 5 1 1 1 0 0 0 0 0 +fn=__thread_selfid +0 5 1 1 1 0 0 0 0 0 +fn=__xlocale_init +0 10 1 1 3 1 1 2 0 0 +fn=_dyld_fast_stub_entry(void*, long) +0 1279 2 2 341 1 1 256 2 0 +fn=_dyld_func_lookup +0 20 1 1 8 1 0 4 0 0 +fn=_dyld_get_image_slide +0 35 4 4 9 2 1 6 0 0 +fn=_dyld_initializer +0 16 2 2 3 0 0 5 0 0 +fn=_dyld_start +0 15 3 2 3 1 1 2 1 1 +fn=_exit +0 3 1 1 0 0 0 0 0 0 +fn=_get_cpu_capabilities +0 18 2 1 12 3 1 0 0 0 +fn=_init_clock_port +0 27 2 2 6 0 0 5 0 0 +fn=_init_cpu_capabilities +0 6 0 0 2 0 0 3 0 0 +fn=_keymgr_get_and_lock_processwide_ptr_2 +0 24 2 2 7 0 0 6 0 0 +fn=_keymgr_set_and_unlock_processwide_ptr +0 16 0 0 4 0 0 5 0 0 +fn=_libc_fork_init +0 7 1 1 2 0 0 4 1 1 +fn=_libkernel_init +0 13 2 2 7 0 0 5 1 1 +fn=_libxpc_initializer +0 399 8 8 49 5 1 62 0 0 +fn=_malloc_initialize +0 262 7 7 36 1 0 40 1 1 +fn=_mig_get_reply_port +0 672 5 2 308 8 1 84 0 0 +fn=_mig_init +0 16 3 3 4 0 0 6 0 0 +fn=_mig_reply_port_callbacks +0 6 1 1 2 0 0 3 1 1 +fn=_mig_set_reply_port +0 274 3 3 122 0 0 33 0 0 +fn=_program_vars_init +0 14 1 1 7 1 0 6 1 1 +fn=_pthread_create +0 78 6 6 15 0 0 32 0 0 +fn=_pthread_fork_child_postinit +0 11 2 2 4 0 0 2 0 0 +fn=_pthread_keys_init +0 6 2 2 3 1 0 1 0 0 +fn=_pthread_mutex_init +0 104 5 5 18 0 0 34 1 1 +fn=_pthread_set_self +0 32 4 4 7 1 1 7 1 1 +fn=_qsort +0 17587 62 28 5178 0 0 2742 10 0 +fn=_xpc_base_create +0 112 2 2 28 2 0 49 0 0 +fn=_xpc_calloc +0 105 2 2 21 0 0 21 0 0 +fn=_xpc_copyout +0 12 0 0 4 0 0 1 0 0 +fn=_xpc_dictionary_insert +0 260 5 5 50 0 0 90 1 1 +fn=_xpc_dictionary_key_hash +0 382 3 3 61 0 0 15 0 0 +fn=_xpc_domain_create +0 60 4 4 9 1 0 30 0 0 +fn=_xpc_domain_init_local +0 42 3 3 15 3 1 11 1 1 +fn=_xpc_get_asid +0 13 1 1 3 0 0 2 0 0 +fn=_xpc_get_exception_port +0 20 2 2 5 0 0 4 0 0 +fn=_xpc_mach_port_allocate +0 136 2 2 40 1 0 36 0 0 +fn=_xpc_mach_port_make_send +0 36 1 1 12 0 0 12 0 0 +fn=_xpc_mach_port_retain +0 22 2 2 7 0 0 7 0 0 +fn=_xpc_malloc +0 70 1 1 15 0 0 15 0 0 +fn=_xpc_pointer_debug +0 238 27 27 130 16 0 54 0 0 +fn=_xpc_release +0 18 3 3 6 0 0 2 0 0 +fn=_xpc_retain +0 20 2 2 6 0 0 3 0 0 +fn=_xpc_runtime_set_domain +0 38 5 5 7 0 0 11 2 2 +fn=_xpc_strdup +0 140 2 2 30 0 0 30 0 0 +fn=addImagesToAllImages(unsigned int, dyld_image_info const*) +0 1302 4 4 297 0 0 218 1 1 +fn=addNonSharedCacheImageUUID(dyld_uuid_info const&) +0 567 1 1 108 0 0 135 0 0 +fn=allocate_pages +0 273 8 8 30 0 0 36 0 0 +fn=allocate_pages_securely +0 33 2 2 8 1 0 7 0 0 +fn=arc4_fetch +0 100 4 4 16 0 0 24 0 0 +fn=arc4_stir +0 32826 9 9 5644 14 13 5142 1 1 +fn=arc4random +0 558 13 13 150 3 3 108 1 1 +fn=atexit_register +0 45 3 3 15 1 1 13 1 1 +fn=audit_session_self +0 5 2 2 1 0 0 0 0 0 +fn=bootstrap_init +0 101 17 16 30 6 0 32 0 0 +fn=bzero +0 5 1 1 1 0 0 1 0 0 +fn=bzero$VARIANT$sse2 +0 2488 9 7 70 0 0 790 150 150 +fn=calloc +0 147 1 1 49 3 0 28 0 0 +fn=close +0 145 2 2 29 0 0 0 0 0 +fn=close$NOCANCEL +0 15 1 1 3 0 0 0 0 0 +fn=create_scalable_zone +0 283 20 20 45 2 0 78 29 29 +fn=csops +0 5 1 1 1 0 0 0 0 0 +fn=dyld::RegisteredDOF* std::vector >::_M_allocate_and_copy(unsigned long, dyld::RegisteredDOF*, dyld::RegisteredDOF*) +0 13 1 1 4 0 0 4 0 0 +fn=dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**) +0 370 26 26 98 15 10 70 6 4 +fn=dyld::addImage(ImageLoader*) +0 2930 5 5 914 0 0 592 0 0 +fn=dyld::addMappedRange(ImageLoader*, unsigned long, unsigned long) +0 3375 3 3 540 8 4 243 7 7 +fn=dyld::bindLazySymbol(mach_header const*, unsigned long*) +0 54 2 2 15 1 0 12 0 0 +fn=dyld::checkEnvironmentVariables(char const**, bool) +0 672 8 8 87 0 0 88 1 1 +fn=dyld::checkLoadCommandEnvironmentVariables() +0 203 3 3 98 0 0 39 0 0 +fn=dyld::checkVersionedPaths() +0 31 5 5 12 0 0 9 1 1 +fn=dyld::checkandAddImage(ImageLoader*, dyld::LoadContext const&) +0 6253 6 6 1970 7 0 987 0 0 +fn=dyld::clearAllDepths() +0 286 2 2 116 0 0 56 0 0 +fn=dyld::fastBindLazySymbol(ImageLoader**, unsigned long) +0 2054 2 2 760 0 0 358 0 0 +fn=dyld::fatFindBest(fat_header const*, unsigned long long*, unsigned long long*) +0 650 2 2 200 0 0 75 0 0 +fn=dyld::findImageByMachHeader(mach_header const*) +0 4 1 1 1 0 0 1 0 0 +fn=dyld::findInSharedCacheImage(char const*, stat const*, macho_header const**, char const**, long*) +0 624 2 2 208 0 0 260 2 2 +fn=dyld::findLoadedImage(stat const&) +0 4130 3 2 924 0 0 489 3 3 +fn=dyld::findMappedRange(unsigned long) +0 1596 1 1 426 27 0 14 0 0 +fn=dyld::getCoalescedImages(ImageLoader**) +0 468 2 2 230 12 0 62 0 0 +fn=dyld::imageCount() +0 14 0 0 8 0 0 2 0 0 +fn=dyld::imageSorter(void const*, void const*) +0 4296 1 0 2148 0 0 716 0 0 +fn=dyld::initializeMainExecutable() +0 72 6 5 21 5 0 14 0 0 +fn=dyld::libraryLocator(char const*, bool, char const*, ImageLoader::RPathChain const*) +0 1140 1 1 120 0 0 780 0 0 +fn=dyld::link(ImageLoader*, bool, ImageLoader::RPathChain const&) +0 70 4 2 14 2 1 18 0 0 +fn=dyld::load(char const*, dyld::LoadContext const&) +0 2856 6 6 724 0 0 657 9 8 +fn=dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, std::vector >*) +0 3080 3 3 1320 0 0 1056 10 8 +fn=dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, std::vector >*) +0 3077 4 4 957 6 0 528 6 6 +fn=dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, std::vector >*) +0 4928 8 8 1672 0 0 1320 12 9 +fn=dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, std::vector >*) +0 2992 4 4 1144 0 0 880 5 4 +fn=dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, std::vector >*) +0 14021 15 14 5246 14 0 1682 11 8 +fn=dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) +0 2192 9 9 569 3 3 440 9 9 +fn=dyld::notifyBatch(dyld_image_states) +0 48 2 1 8 0 0 8 0 0 +fn=dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) +0 7845 30 16 3337 78 1 1328 1 0 +fn=dyld::notifySingle(dyld_image_states, ImageLoader const*) +0 7236 15 7 1971 8 3 1647 0 0 +fn=dyld::parseColonList(char const*, char const*) +0 1031 8 8 287 0 0 71 3 3 +fn=dyld::paths_expand_roots(char const**, char const*, char const*) +0 148 3 3 25 1 1 31 0 0 +fn=dyld::processDyldEnvironmentVariable(char const*, char const*, char const*) +0 247 19 19 10 0 0 53 1 1 +fn=dyld::registerDOFs(std::vector > const&) +0 236 7 7 64 2 0 43 0 0 +fn=dyld::registerImageStateBatchChangeHandler(dyld_image_states, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) +0 35 4 4 6 1 0 6 0 0 +fn=dyld::runTerminators(void*) +0 22 2 2 6 1 0 5 0 0 +fn=dyld::setContext(macho_header const*, int, char const**, char const**, char const**) +0 88 8 8 8 0 0 33 5 5 +fn=dyld::setErrorStrings(unsigned int, char const*, char const*, char const*) +0 40 1 1 8 0 0 20 1 0 +fn=dyld::setNewProgramVars(ProgramVars const&) +0 25 3 3 14 0 0 10 2 1 +fn=dyld::updateAllImages(dyld_image_states, unsigned int, dyld_image_info const*) +0 270 2 2 81 0 0 54 0 0 +fn=dyldGlobalLockInitialize() +0 17 1 1 3 0 0 5 0 0 +fn=dyld_exceptions_init +0 283 5 5 66 9 9 29 3 3 +fn=dyld_func_lookup +0 4 1 0 0 0 0 0 0 0 +fn=dyld_image_info* std::vector >::_M_allocate_and_copy(unsigned long, dyld_image_info*, dyld_image_info*) +0 13 1 1 4 0 0 4 0 0 +fn=dyld_register_image_state_change_handler +0 52 5 5 12 1 1 12 0 0 +fn=dyld_stub_binder +0 850 2 2 0 0 0 680 5 0 +fn=dyld_stub_binder_ +0 1955 1 1 1530 0 0 85 0 0 +fn=dyld_stub_binding_helper +0 12 1 0 3 0 0 6 0 0 +fn=dyld_uuid_info* std::vector >::_M_allocate_and_copy(unsigned long, dyld_uuid_info*, dyld_uuid_info*) +0 13 1 1 4 0 0 4 0 0 +fn=dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*) +0 404 7 7 153 15 15 46 2 2 +fn=exit +0 15 1 1 3 0 0 3 0 0 +fn=fcntl +0 888 4 4 144 0 0 288 7 1 +fn=find_platform_function +0 218 3 2 46 6 0 20 0 0 +fn=flsl +0 45 1 1 9 0 0 0 0 0 +fn=free +0 48 2 2 18 0 0 6 0 0 +fn=gdb_image_notifier(dyld_image_mode, unsigned int, dyld_image_info const*) +0 8 0 0 4 0 0 2 0 0 +fn=get_or_create_key_element +0 104 6 6 20 1 0 28 0 0 +fn=getaudit_addr +0 5 1 1 1 0 0 0 0 0 +fn=getegid +0 5 0 0 1 0 0 0 0 0 +fn=getenv +0 182 2 1 52 2 0 52 0 0 +fn=geteuid +0 5 2 2 1 0 0 0 0 0 +fn=getpid +0 17 1 1 5 0 0 0 0 0 +fn=global constructors keyed to ImageLoader::fgImagesUsedFromSharedCache +0 22 3 3 2 0 0 9 1 1 +fn=global constructors keyed to _NSGetExecutablePath +0 10 2 2 1 0 0 4 1 1 +fn=global constructors keyed to addImagesToAllImages(unsigned int, dyld_image_info const*) +0 22 3 3 2 0 0 9 1 1 +fn=global constructors keyed to coresymbolication_unload_image(CSCppDyldSharedMemoryPage*, ImageLoader const*) +0 154 9 9 2 0 0 73 11 11 +fn=heapsort +0 48 3 3 14 0 0 20 0 0 +fn=host_get_clock_service +0 69 7 7 17 0 0 19 1 1 +fn=host_info +0 89 9 9 23 0 0 23 0 0 +fn=host_self_trap +0 8 0 0 2 0 0 0 0 0 +fn=ioctl +0 28 2 2 5 0 0 11 0 0 +fn=issetugid +0 5 1 1 1 0 0 0 0 0 +fn=libSystem_atfork_child +0 54 15 0 18 9 0 18 0 0 +fn=libSystem_initializer +0 52 5 0 16 2 0 26 0 0 +fn=libdispatch_init +0 31 4 4 5 1 0 10 2 1 +fn=lookupDyldFunction(char const*, unsigned long*) +0 800 5 3 104 9 6 100 0 0 +fn=mach_absolute_time +0 980 4 2 343 5 1 49 0 0 +fn=mach_host_self +0 8 0 0 2 0 0 2 0 0 +fn=mach_init +0 30 3 3 6 0 0 12 0 0 +fn=mach_msg +0 2072 8 5 448 0 0 560 6 5 +fn=mach_msg_trap +0 224 2 0 56 0 0 0 0 0 +fn=mach_port_allocate +0 320 9 6 90 1 0 95 0 0 +fn=mach_port_deallocate +0 216 10 10 68 1 0 72 0 0 +fn=mach_port_insert_right +0 118 5 5 34 0 0 42 0 0 +fn=mach_port_mod_refs +0 168 5 5 51 0 0 60 0 0 +fn=mach_port_set_attributes +0 264 6 6 72 0 0 88 0 0 +fn=mach_port_set_context +0 110 5 5 34 0 0 38 0 0 +fn=mach_ports_lookup +0 58 6 6 13 1 0 12 0 0 +fn=mach_reply_port +0 124 0 0 31 0 0 0 0 0 +fn=mach_thread_self +0 12 0 0 3 0 0 3 0 0 +fn=madvise +0 5 1 0 1 0 0 0 0 0 +fn=malloc +0 1540 9 6 588 4 0 248 1 1 +fn=malloc_set_zone_name +0 42 3 3 6 0 0 10 0 0 +fn=malloc_zone_calloc +0 203 2 2 63 1 0 42 0 0 +fn=malloc_zone_malloc +0 486 3 2 144 2 0 90 0 0 +fn=malloc_zone_register_while_locked +0 50 5 5 13 2 0 10 1 0 +fn=memcpy +0 446 11 5 47 0 0 38 0 0 +fn=memcpy$VARIANT$sse3x +0 711 7 5 101 0 0 80 5 5 +fn=memset +0 32 2 1 0 0 0 0 0 0 +fn=mig_deallocate +0 8 2 2 2 0 0 1 0 0 +fn=mig_get_reply_port +0 761 6 4 168 0 0 226 2 0 +fn=mig_init +0 6 0 0 2 0 0 1 0 0 +fn=misaligned_stack_error_entering_dyld_stub_binder +0 680 1 1 0 0 0 680 2 0 +fn=mmap +0 820 4 4 82 0 0 82 0 0 +fn=mprotect +0 40 0 0 8 0 0 0 0 0 +fn=munmap +0 10 1 1 2 0 0 0 0 0 +fn=names_match(char*, char const*) +0 60 4 4 7 0 0 11 0 0 +fn=notifyGDB(dyld_image_states, unsigned int, dyld_image_info const*) +0 32 1 1 10 1 0 7 0 0 +fn=open +0 145 1 1 29 0 0 0 0 0 +fn=open$NOCANCEL +0 15 2 2 3 0 0 0 0 0 +fn=operator delete(void*) +0 36 1 1 6 0 0 6 0 0 +fn=operator new(unsigned long) +0 374 5 2 88 0 0 88 1 1 +fn=operator new[](unsigned long) +0 25 1 1 10 0 0 10 0 0 +fn=pread +0 255 0 0 51 0 0 0 0 0 +fn=protect +0 76 3 3 14 0 0 16 0 0 +fn=pthread_init +0 104 10 10 14 1 0 42 7 6 +fn=pthread_key_create +0 37 4 4 9 1 1 6 0 0 +fn=pthread_key_init_np +0 173 2 2 54 0 0 35 3 3 +fn=pthread_mutex_init +0 12 1 1 2 0 0 4 2 2 +fn=pthread_mutex_lock +0 143 7 7 38 0 0 23 0 0 +fn=pthread_mutex_unlock +0 56 4 4 12 0 0 8 0 0 +fn=pthread_mutexattr_destroy +0 13 1 1 4 0 0 3 0 0 +fn=pthread_mutexattr_init +0 24 1 1 6 0 0 8 0 0 +fn=pthread_mutexattr_settype +0 30 2 2 8 0 0 4 0 0 +fn=pthread_setschedparam_internal +0 24 2 2 3 0 0 3 0 0 +fn=pthread_threadid_np +0 100 3 3 28 2 0 20 0 0 +fn=qsort +0 207 4 2 45 0 0 54 4 0 +fn=read +0 10 1 1 2 0 0 0 0 0 +fn=read$NOCANCEL +0 15 1 1 3 0 0 0 0 0 +fn=registerThreadHelpers(dyld::LibSystemHelpers const*) +0 8 2 2 2 0 0 3 1 0 +fn=sandbox_check +0 59 6 6 7 1 1 18 0 0 +fn=sandbox_release_fs_extension +0 6 3 3 2 1 0 2 0 0 +fn=semaphore_create +0 70 7 7 17 0 0 20 0 0 +fn=stat$INODE64 +0 140 3 2 28 0 0 0 0 0 +fn=std::_Vector_base >::_M_allocate(unsigned long) +0 27 0 0 3 0 0 3 0 0 +fn=std::_Vector_base >::_M_allocate(unsigned long) +0 27 1 1 3 0 0 3 0 0 +fn=std::_Vector_base >::_M_allocate(unsigned long) +0 27 4 2 3 0 0 3 0 0 +fn=std::_Vector_base >::_M_allocate(unsigned long) +0 9 1 1 1 0 0 1 0 0 +fn=std::_Vector_base >::_M_allocate(unsigned long) +0 9 1 1 1 0 0 1 0 0 +fn=std::_Vector_base >::_M_allocate(unsigned long) +0 36 2 2 4 0 0 4 0 0 +fn=std::_Vector_base >::_M_allocate(unsigned long) +0 18 0 0 2 0 0 2 0 0 +fn=std::vector >::push_back(ImageLoader* const&) +0 435 1 1 174 0 0 87 5 4 +fn=std::vector >::reserve(unsigned long) +0 138 2 2 33 0 0 33 0 0 +fn=std::vector >::_M_insert_aux(__gnu_cxx::__normal_iterator > >, ImageLoader::DOFInfo const&) +0 253 6 6 60 0 0 53 3 3 +fn=std::vector >::push_back(ImageLoader::DOFInfo const&) +0 27 2 2 9 0 0 3 0 0 +fn=std::vector >::_M_insert_aux(__gnu_cxx::__normal_iterator >::insert(__gnu_cxx::__normal_iterator >::push_back(char const* (* const&)(dyld_image_states, unsigned int, dyld_image_ +0 18 2 2 6 0 0 2 0 0 +fn=std::vector >::push_back(dyld::RegisteredDOF const&) +0 51 2 1 21 2 0 12 1 1 +fn=std::vector >::reserve(unsigned long) +0 46 3 3 11 0 0 10 0 0 +fn=std::vector >::push_back(dyld_image_info const&) +0 513 1 1 216 0 0 135 10 10 +fn=std::vector >::reserve(unsigned long) +0 60 4 4 11 0 0 10 1 1 +fn=std::vector >::_M_insert_aux(__gnu_cxx::__normal_iterator > >, dyld_uuid_info const&) +0 552 5 5 135 2 0 129 12 12 +fn=std::vector >::push_back(dyld_uuid_info const&) +0 483 1 1 201 0 0 123 7 7 +fn=std::vector >::reserve(unsigned long) +0 60 3 3 11 0 0 10 0 0 +fn=std::vector >::reserve(unsigned long) +0 92 4 4 22 0 0 22 0 0 +fn=strcat +0 268 2 2 65 0 0 27 0 0 +fn=strchr +0 252 2 2 45 0 0 2 0 0 +fn=strcmp +0 47432 7 6 7783 315 163 0 0 0 +fn=strcpy +0 325 3 3 23 0 0 28 3 3 +fn=strdup +0 240 2 2 40 0 0 60 0 0 +fn=strlcpy +0 328 5 4 23 0 0 27 1 1 +fn=strlen +0 740 3 3 94 3 1 0 0 0 +fn=strncmp +0 11805 7 5 2393 26 21 0 0 0 +fn=strncpy +0 137 3 3 11 0 0 9 0 0 +fn=strrchr +0 776 4 4 134 4 0 4 0 0 +fn=strstr +0 250 3 3 44 3 2 15 0 0 +fn=stub_binding_helper +0 3 1 0 0 0 0 0 0 0 +fn=stub_binding_helper_interface +0 123 5 4 54 0 0 51 1 0 +fn=syscall +0 5 1 1 1 0 0 0 0 0 +fn=sysctl +0 19 3 3 4 0 0 2 0 0 +fn=szone_calloc +0 98 2 2 7 0 0 7 0 0 +fn=szone_malloc +0 90 1 1 18 0 0 18 0 0 +fn=szone_malloc_should_clear +0 2739 34 33 694 7 3 700 2 2 +fn=task_get_exception_ports +0 326 14 14 60 0 0 30 1 0 +fn=task_get_special_port +0 138 10 6 34 1 1 38 1 1 +fn=task_self_trap +0 12 2 2 3 0 0 0 0 0 +fn=thread_policy +0 75 7 7 21 0 0 25 0 0 +fn=thread_self_trap +0 12 0 0 3 0 0 0 0 0 +fn=tiny_malloc_from_free_list +0 2831 13 13 528 7 4 198 0 0 +fn=tlv_get_addr +0 69 6 6 25 7 0 22 0 0 +fn=tlv_initializer +0 10 2 2 1 0 0 2 0 0 +fn=tlv_load_notification +0 350 4 4 144 27 0 91 0 0 +fn=unlock_node +0 14 2 2 4 0 0 3 0 0 +fn=vm_allocate +0 1742 6 6 494 1 1 546 9 6 +fn=vm_deallocate +0 55 5 5 17 0 0 19 0 0 +fn=vproc_swap_integer +0 62 6 6 10 2 1 9 0 0 +fn=xpc_dictionary_create +0 23 3 3 7 0 0 6 0 0 +fn=xpc_dictionary_set_string +0 110 2 2 20 0 0 30 0 0 +fn=xpc_domain_set_context +0 14 2 2 4 0 0 4 0 0 +fn=xpc_get_type +0 25 1 1 15 0 0 5 0 0 +fn=xpc_release +0 131 3 3 42 0 0 14 0 0 +fn=xpc_retain +0 120 2 2 42 0 0 12 0 0 +fn=xpc_string_create +0 105 2 2 25 0 0 40 0 0 +summary: 2734965 1686 1454 548886 4230 2195 164505 591 489 From aaron at aaronballman.com Mon Feb 20 12:02:11 2012 From: aaron at aaronballman.com (Aaron Ballman) Date: Mon, 20 Feb 2012 12:02:11 -0600 Subject: [llvm-commits] [cfe-commits] [PATCH] Supporting thiscall compatibility with MSVC In-Reply-To: References: Message-ID: Ping? On Sat, Feb 18, 2012 at 11:36 AM, Aaron Ballman wrote: > On Fri, Feb 17, 2012 at 7:30 PM, Eli Friedman wrote: >> On Fri, Feb 17, 2012 at 3:41 PM, Aaron Ballman wrote: >>> On Thu, Feb 16, 2012 at 10:42 PM, Eli Friedman wrote: >>>> On Thu, Feb 16, 2012 at 8:39 PM, Aaron Ballman wrote: >>>>> On Thu, Feb 16, 2012 at 9:50 PM, Eli Friedman wrote: >>>>>> On Thu, Feb 16, 2012 at 7:38 PM, Aaron Ballman wrote: >>>>>>> On Thu, Feb 16, 2012 at 8:52 PM, Eli Friedman wrote: >>>>>>>> On Thu, Feb 16, 2012 at 6:25 PM, Aaron Ballman wrote: >>>>>>>>> Here's the next attempt at the MSVC thiscall support patch, this time >>>>>>>>> with test cases and an improved tablegen declaration. >>>>>>>>> >>>>>>>>> This is the first time I've done a test case for clang or llvm >>>>>>>>> codegen, so please pay special attention to the test cases and let me >>>>>>>>> know if I'm off-base (and what I should do differently). >>>>>>>> >>>>>>>> You might want to make the LLVM testcase a bit stronger by using CHECK-NEXT. >>>>>>> >>>>>>> Does CHECK-NEXT basically chain the checks together to check several >>>>>>> lines as a group? >>>>>> >>>>>> Basically, yes. >>>>> >>>>> The problem is that the assembly is different between O levels. ?So >>>>> -O0 does leal, leal, but -O1 does leal, movl. >>>>> >>>>> Is there a way for me to handle this in the test case, or should I >>>>> just be explicit about the O level and its behavior? >>>> >>>> We always run tests at the same -O level, so you shouldn't worry about >>>> that. ?That said, if you think splitting your testcase into multiple >>>> functions would make it more stable, please do that. >>> >>> Here's another shot at the patch -- this time, I am using the proper >>> way to test for the Win32 ABI, and I've updated the X86 codegen test >>> case so that it's a bit more clear. >> >> Your test somehow disappeared form the clang patch. >> >> Please rename IsWin32FloatStructABI if you're going to use it this >> way. ?I'm still not convinced it's necessary to behave differently >> when targeting MinGW, though. > > That was truly odd -- no idea how the test case got missed, but it's > back again. ?I've also removed the check for the Win32 ABI as it > appears this is used by gcc (4.6 and up) for MS compat as well. > > ~Aaron From echristo at apple.com Mon Feb 20 12:04:14 2012 From: echristo at apple.com (Eric Christopher) Date: Mon, 20 Feb 2012 18:04:14 -0000 Subject: [llvm-commits] [llvm] r150973 - in /llvm/trunk: include/llvm/Analysis/DIBuilder.h lib/Analysis/DIBuilder.cpp Message-ID: <20120220180414.6450A2A6C12F@llvm.org> Author: echristo Date: Mon Feb 20 12:04:14 2012 New Revision: 150973 URL: http://llvm.org/viewvc/llvm-project?rev=150973&view=rev Log: Add support for runtime languages on our forward declarations. Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h llvm/trunk/lib/Analysis/DIBuilder.cpp Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DIBuilder.h?rev=150973&r1=150972&r2=150973&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DIBuilder.h (original) +++ llvm/trunk/include/llvm/Analysis/DIBuilder.h Mon Feb 20 12:04:14 2012 @@ -343,7 +343,7 @@ /// createForwardDecl - Create a temporary forward-declared type. DIType createForwardDecl(unsigned Tag, StringRef Name, DIFile F, - unsigned Line); + unsigned Line, unsigned RuntimeLang = 0); /// retainType - Retain DIType in a module even if it is not referenced /// through debug info anchors. Modified: llvm/trunk/lib/Analysis/DIBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DIBuilder.cpp?rev=150973&r1=150972&r2=150973&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DIBuilder.cpp (original) +++ llvm/trunk/lib/Analysis/DIBuilder.cpp Mon Feb 20 12:04:14 2012 @@ -672,7 +672,7 @@ /// createForwardDecl - Create a temporary forward-declared type that /// can be RAUW'd if the full type is seen. DIType DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, DIFile F, - unsigned Line) { + unsigned Line, unsigned RuntimeLang) { // Create a temporary MDNode. Value *Elts[] = { GetTagConstant(VMContext, Tag), @@ -685,7 +685,10 @@ ConstantInt::get(Type::getInt32Ty(VMContext), 0), ConstantInt::get(Type::getInt32Ty(VMContext), 0), ConstantInt::get(Type::getInt32Ty(VMContext), - DIDescriptor::FlagFwdDecl) + DIDescriptor::FlagFwdDecl), + NULL, + DIArray(), + ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang) }; MDNode *Node = MDNode::getTemporary(VMContext, Elts); return DIType(Node); From echristo at apple.com Mon Feb 20 12:04:35 2012 From: echristo at apple.com (Eric Christopher) Date: Mon, 20 Feb 2012 18:04:35 -0000 Subject: [llvm-commits] [llvm] r150974 - /llvm/trunk/lib/Analysis/DebugInfo.cpp Message-ID: <20120220180435.BD7742A6C12F@llvm.org> Author: echristo Date: Mon Feb 20 12:04:35 2012 New Revision: 150974 URL: http://llvm.org/viewvc/llvm-project?rev=150974&view=rev Log: If a derived type is also a composite type, print that information too. Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=150974&r1=150973&r2=150974&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Mon Feb 20 12:04:35 2012 @@ -721,8 +721,13 @@ if (isBasicType()) DIBasicType(DbgNode).print(OS); - else if (isDerivedType()) - DIDerivedType(DbgNode).print(OS); + else if (isDerivedType()) { + DIDerivedType DTy = DIDerivedType(DbgNode); + DTy.print(OS); + DICompositeType CTy = getDICompositeType(DTy); + if (CTy.Verify()) + CTy.print(OS); + } else if (isCompositeType()) DICompositeType(DbgNode).print(OS); else { From echristo at apple.com Mon Feb 20 12:04:39 2012 From: echristo at apple.com (Eric Christopher) Date: Mon, 20 Feb 2012 18:04:39 -0000 Subject: [llvm-commits] [llvm] r150975 - /llvm/trunk/lib/Analysis/DebugInfo.cpp Message-ID: <20120220180439.4A9D82A6C130@llvm.org> Author: echristo Date: Mon Feb 20 12:04:39 2012 New Revision: 150975 URL: http://llvm.org/viewvc/llvm-project?rev=150975&view=rev Log: Make this a bit prettier and more obvious when a derived type isn't derived from anything. Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=150975&r1=150974&r2=150975&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Mon Feb 20 12:04:39 2012 @@ -745,7 +745,9 @@ /// print - Print derived type. void DIDerivedType::print(raw_ostream &OS) const { - OS << "\n\t Derived From: "; getTypeDerivedFrom().print(OS); + OS << "\n\t Derived From: "; + getTypeDerivedFrom().print(OS); + OS << "\n\t"; } /// print - Print composite type. From baldrick at free.fr Mon Feb 20 12:11:42 2012 From: baldrick at free.fr (Duncan Sands) Date: Mon, 20 Feb 2012 19:11:42 +0100 Subject: [llvm-commits] [llvm] r150962 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll In-Reply-To: <20120220150747.D2BEE2A6C12F@llvm.org> References: <20120220150747.D2BEE2A6C12F@llvm.org> Message-ID: <4F428CDE.7010809@free.fr> Hi Benjamin, > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 20 09:07:47 2012 > @@ -607,6 +607,20 @@ > return new ICmpInst(ICmpInst::getSignedPredicate(Cond), > GEPLHS->getOperand(0), GEPRHS->getOperand(0)); > > + // If we're comparing GEPs with two base pointers that only differ in type > + // and both GEPs have only constant indices or just one use, then fold > + // the compare with the adjusted indices. > + if (TD&& > + (GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse())&& > + (GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse())&& > + PtrBase->stripPointerCasts() == > + GEPRHS->getOperand(0)->stripPointerCasts()) { > + Value *Cmp = Builder->CreateICmp(ICmpInst::getSignedPredicate(Cond), > + EmitGEPOffset(GEPLHS), > + EmitGEPOffset(GEPRHS)); for non-equality comparisons, isn't this only safe if the GEP is inbounds? Otherwise, by removing the base, you may change an overflowing (non-overflowing) GEP into a non-overflowing (overflowing) one, which can completely change the result of the comparison. Ciao, Duncan. > + return ReplaceInstUsesWith(I, Cmp); > + } > + From jay.foad at gmail.com Mon Feb 20 12:38:23 2012 From: jay.foad at gmail.com (Jay Foad) Date: Mon, 20 Feb 2012 18:38:23 +0000 Subject: [llvm-commits] [llvm] r150890 - in /llvm/trunk: include/llvm/ADT/Hashing.h lib/Support/CMakeLists.txt lib/Support/Hashing.cpp unittests/ADT/HashingTest.cpp unittests/CMakeLists.txt In-Reply-To: <20120218210050.320912A6C12F@llvm.org> References: <20120218210050.320912A6C12F@llvm.org> Message-ID: On 18 February 2012 21:00, Talin wrote: > Added: llvm/trunk/include/llvm/ADT/Hashing.h Nitpick: wouldn't this be better in ../Support ? > + ?/// Add a float > + ?GeneralHash& add(float Data) { > + ? ?union { > + ? ? ?float D; uint32_t I; > + ? ?}; > + ? ?D = Data; > + ? ?addInt(I); > + ? ?return *this; > + ?} > + > + ?/// Add a double > + ?GeneralHash& add(double Data) { > + ? ?union { > + ? ? ?double D; uint64_t I; > + ? ?}; > + ? ?D = Data; > + ? ?addInt(I); > + ? ?return *this; > + ?} IMO it would be better not to implement these at all until someone needs them, and decides what to do about the +/- 0 problem. (But that's just another nitpick!) > +// Add a possibly unaligned sequence of bytes. > +void GeneralHash::addUnaligned(const uint8_t *I, const uint8_t *E) { > + ?ptrdiff_t Length = E - I; > + ?if (uintptr_t(I) & 3 == 0) { > + ? ?while (Length > 3) { > + ? ? ?mix(*reinterpret_cast(I)); > + ? ? ?I += 4; > + ? ? ?Length -= 4; > + ? ?} > + ?} else { > + ? ?while (Length > 3) { > + ? ? ?mix( > + ? ? ? ?uint32_t(I[0]) + > + ? ? ? ?(uint32_t(I[1]) << 8) + > + ? ? ? ?(uint32_t(I[2]) << 16) + > + ? ? ? ?(uint32_t(I[3]) << 24)); > + ? ? ?I += 4; > + ? ? ?Length -= 4; > + ? ?} > + ?} I think there's a serious problem here on big-endian hosts, because identical arrays of bytes will hash to different values depending on whether they happen to start on a 4-byte boundary or not. Thanks for working on this! Jay. From benny.kra at googlemail.com Mon Feb 20 12:45:10 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 20 Feb 2012 18:45:10 -0000 Subject: [llvm-commits] [llvm] r150978 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Message-ID: <20120220184510.419FC2A6C12F@llvm.org> Author: d0k Date: Mon Feb 20 12:45:10 2012 New Revision: 150978 URL: http://llvm.org/viewvc/llvm-project?rev=150978&view=rev Log: InstCombine: Removing the base from the address calculation is only safe when the GEPs are inbounds. 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=150978&r1=150977&r2=150978&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 20 12:45:10 2012 @@ -610,7 +610,7 @@ // If we're comparing GEPs with two base pointers that only differ in type // and both GEPs have only constant indices or just one use, then fold // the compare with the adjusted indices. - if (TD && + if (TD && GEPLHS->isInBounds() && GEPRHS->isInBounds() && (GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse()) && (GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse()) && PtrBase->stripPointerCasts() == From benny.kra at googlemail.com Mon Feb 20 12:50:55 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 20 Feb 2012 19:50:55 +0100 Subject: [llvm-commits] [llvm] r150962 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll In-Reply-To: <4F428CDE.7010809@free.fr> References: <20120220150747.D2BEE2A6C12F@llvm.org> <4F428CDE.7010809@free.fr> Message-ID: On 20.02.2012, at 19:11, Duncan Sands wrote: > Hi Benjamin, > >> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) >> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 20 09:07:47 2012 >> @@ -607,6 +607,20 @@ >> return new ICmpInst(ICmpInst::getSignedPredicate(Cond), >> GEPLHS->getOperand(0), GEPRHS->getOperand(0)); >> >> + // If we're comparing GEPs with two base pointers that only differ in type >> + // and both GEPs have only constant indices or just one use, then fold >> + // the compare with the adjusted indices. >> + if (TD&& >> + (GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse())&& >> + (GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse())&& >> + PtrBase->stripPointerCasts() == >> + GEPRHS->getOperand(0)->stripPointerCasts()) { >> + Value *Cmp = Builder->CreateICmp(ICmpInst::getSignedPredicate(Cond), >> + EmitGEPOffset(GEPLHS), >> + EmitGEPOffset(GEPRHS)); > > for non-equality comparisons, isn't this only safe if the GEP is inbounds? > Otherwise, by removing the base, you may change an overflowing (non-overflowing) > GEP into a non-overflowing (overflowing) one, which can completely change the > result of the comparison. Right. For some reason I was thinking that this was checked already before this transform, but looking again shows that's not the case. Fixed in r150978! - Ben > > Ciao, Duncan. > >> + return ReplaceInstUsesWith(I, Cmp); >> + } >> + > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dblaikie at gmail.com Mon Feb 20 12:58:42 2012 From: dblaikie at gmail.com (David Blaikie) Date: Mon, 20 Feb 2012 10:58:42 -0800 Subject: [llvm-commits] [llvm] r150978 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp In-Reply-To: <20120220184510.419FC2A6C12F@llvm.org> References: <20120220184510.419FC2A6C12F@llvm.org> Message-ID: On Mon, Feb 20, 2012 at 10:45 AM, Benjamin Kramer wrote: > Author: d0k > Date: Mon Feb 20 12:45:10 2012 > New Revision: 150978 > > URL: http://llvm.org/viewvc/llvm-project?rev=150978&view=rev > Log: > InstCombine: Removing the base from the address calculation is only safe when the GEPs are inbounds. Worth a test case, too? > > 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=150978&r1=150977&r2=150978&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 20 12:45:10 2012 > @@ -610,7 +610,7 @@ > ? ? ? // If we're comparing GEPs with two base pointers that only differ in type > ? ? ? // and both GEPs have only constant indices or just one use, then fold > ? ? ? // the compare with the adjusted indices. > - ? ? ?if (TD && > + ? ? ?if (TD && GEPLHS->isInBounds() && GEPRHS->isInBounds() && > ? ? ? ? ? (GEPLHS->hasAllConstantIndices() || GEPLHS->hasOneUse()) && > ? ? ? ? ? (GEPRHS->hasAllConstantIndices() || GEPRHS->hasOneUse()) && > ? ? ? ? ? PtrBase->stripPointerCasts() == > > > _______________________________________________ > 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 Mon Feb 20 13:00:28 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 20 Feb 2012 19:00:28 -0000 Subject: [llvm-commits] [llvm] r150979 - /llvm/trunk/test/Transforms/InstCombine/icmp.ll Message-ID: <20120220190028.ACC9F2A6C12F@llvm.org> Author: d0k Date: Mon Feb 20 13:00:28 2012 New Revision: 150979 URL: http://llvm.org/viewvc/llvm-project?rev=150979&view=rev Log: Test case for r150978. Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=150979&r1=150978&r2=150979&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Mon Feb 20 13:00:28 2012 @@ -615,3 +615,16 @@ ; CHECK-NEXT: icmp slt i64 %gep1.idx, %j ; CHECK-NEXT: ret i1 } + +define i1 @test61(i8* %foo, i64 %i, i64 %j) { + %bit = bitcast i8* %foo to i32* + %gep1 = getelementptr i32* %bit, i64 %i + %gep2 = getelementptr i8* %foo, i64 %j + %cast1 = bitcast i32* %gep1 to i8* + %cmp = icmp ult i8* %cast1, %gep2 + ret i1 %cmp +; Don't transform non-inbounds GEPs. +; CHECK: @test61 +; CHECK: icmp ult i8* %cast1, %gep2 +; CHECK-NEXT: ret i1 +} From mcrosier at apple.com Mon Feb 20 13:18:20 2012 From: mcrosier at apple.com (Chad Rosier) Date: Mon, 20 Feb 2012 19:18:20 -0000 Subject: [llvm-commits] [test-suite] r150980 - /test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z01.c Message-ID: <20120220191820.9F8BE2A6C12F@llvm.org> Author: mcrosier Date: Mon Feb 20 13:18:20 2012 New Revision: 150980 URL: http://llvm.org/viewvc/llvm-project?rev=150980&view=rev Log: Replace the use of the __DATE__ and __TIME builtins with something statically defined. This prevents the object files from differing between compiles. Part of rdar://10868863 Modified: test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z01.c Modified: test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z01.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z01.c?rev=150980&r1=150979&r2=150980&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z01.c (original) +++ test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z01.c Mon Feb 20 13:18:20 2012 @@ -421,8 +421,10 @@ "Basser Lout written by:", "Jeffrey H. Kingston (jeff at cs.usyd.edu.au)"); fprintf(stderr, "%-28s %s\n", "Free source available from:", "ftp://ftp.cs.usyd.edu.au/jeff/lout"); - fprintf(stderr, "%-28s %s %s\n", - "This executable compiled:", __TIME__, __DATE__); + //fprintf(stderr, "%-28s %s %s\n", + // "This executable compiled:", __TIME__, __DATE__); + fprintf(stderr, "%-28s %s %s\n", + "This executable compiled:", "00:00:00", "Jan 01 1970"); fprintf(stderr, "%-28s %s%s%s\n", "System include directory:", lib, STR_DIR, INCL_DIR); fprintf(stderr, "%-28s %s%s%s\n", "System database directory:", From chandlerc at gmail.com Mon Feb 20 13:49:07 2012 From: chandlerc at gmail.com (Chandler Carruth) Date: Mon, 20 Feb 2012 11:49:07 -0800 Subject: [llvm-commits] PATCH: Remove lazy-parse support from llvm::Triple Message-ID: Hello LLVM folks (and Clang folks sense triple impacts the Clang driver greatly)! This patch removes the lazy-parsing from the Triple class. From what I could tell, no one deeply relied on this, and it seems unlikely that we want people to be creating enough triples to need them to parse lazily... The code gets significantly simpler with this change, and I'm looking at further changes that will make it more efficient and still cleaner. In passing, it fixes a bug in 'hasEnvironment' which would return the wrong answer if called before any other accessors on a triple. This category of bugs is one of the primary reasons I'm not a fan of deferred parsing here. All existing tests seem happy, and I can add a few more, as well as look for any cleanups I missed, but I wanted to get some feedback on the general direction. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120220/2bdc32ae/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: remove-lazy-parse.patch Type: text/x-patch Size: 9075 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120220/2bdc32ae/attachment.bin From mcrosier at apple.com Mon Feb 20 14:27:15 2012 From: mcrosier at apple.com (Chad Rosier) Date: Mon, 20 Feb 2012 20:27:15 -0000 Subject: [llvm-commits] [test-suite] r150986 - /test-suite/trunk/External/Povray/Makefile Message-ID: <20120220202715.96DF52A6C12F@llvm.org> Author: mcrosier Date: Mon Feb 20 14:27:15 2012 New Revision: 150986 URL: http://llvm.org/viewvc/llvm-project?rev=150986&view=rev Log: Don't define POV_LIB_DIR to prevent the path from being embedded in the object file. This seems to be relevant to only unix.c, but isn't used in our current configuration. Last part of rdar://10868863 Modified: test-suite/trunk/External/Povray/Makefile Modified: test-suite/trunk/External/Povray/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/Povray/Makefile?rev=150986&r1=150985&r2=150986&view=diff ============================================================================== --- test-suite/trunk/External/Povray/Makefile (original) +++ test-suite/trunk/External/Povray/Makefile Mon Feb 20 14:27:15 2012 @@ -12,7 +12,7 @@ Source := $(notdir $(POVRAYSources)) $(notdir $(LIBPNGSources)) -CPPFLAGS += -I$(POVRAY_ROOT)/source/unix -I$(PROJ_SRC_ROOT)/runtime/libpng -DPREFIX=\"$(PROJ_OBJ_DIR)\" -DSYSCONFDIR=\"$(POVRAY_ROOT)\" -DPOV_LIB_DIR=\"$(PROJ_OBJ_DIR)/lib\" -IOutput/src -UHAVE_LIBVGA -I$(POVRAY_ROOT)/source/libpng -I$(POVRAY_ROOT)/source +CPPFLAGS += -I$(POVRAY_ROOT)/source/unix -I$(PROJ_SRC_ROOT)/runtime/libpng -DPREFIX=\"$(PROJ_OBJ_DIR)\" -DSYSCONFDIR=\"$(POVRAY_ROOT)\" -IOutput/src -UHAVE_LIBVGA -I$(POVRAY_ROOT)/source/libpng -I$(POVRAY_ROOT)/source LIBS += -lz -lm LDFLAGS += -lz -lm From joerg at britannica.bec.de Mon Feb 20 14:40:49 2012 From: joerg at britannica.bec.de (Joerg Sonnenberger) Date: Mon, 20 Feb 2012 21:40:49 +0100 Subject: [llvm-commits] PATCH: Remove lazy-parse support from llvm::Triple In-Reply-To: References: Message-ID: <20120220204049.GB21848@britannica.bec.de> On Mon, Feb 20, 2012 at 11:49:07AM -0800, Chandler Carruth wrote: > This patch removes the lazy-parsing from the Triple class. From what I > could tell, no one deeply relied on this, and it seems unlikely that we > want people to be creating enough triples to need them to parse lazily... Yes, please. Joerg From eli.friedman at gmail.com Mon Feb 20 15:11:00 2012 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 20 Feb 2012 13:11:00 -0800 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: On Sat, Feb 18, 2012 at 10:40 PM, Joe Groff wrote: > I posted this patch a month ago, and I wanted to make sure it got > looked at. The Visual Studio linker links floating-point support > conditionally based on the presence of a magic symbol `_fltused` > emitted by the Microsoft C++ compiler. LLVM already properly emits > this symbol for win32 targets during normal instruction selection, but > not during fastisel. This patch makes it so that `_fltused` is also > emitted properly during fastisel. Let me know if there are any changes > necessary. Thanks. Please don't copy-paste the relevant logic. Otherwise, looks okay. -Eli From anton at korobeynikov.info Mon Feb 20 15:59:52 2012 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 21 Feb 2012 01:59:52 +0400 Subject: [llvm-commits] [PATCH] generate ABI-compliant sections for uninitialized static data members in template instantiations In-Reply-To: <4f4271a3.85c52a0a.3533.143cSMTPIN_ADDED@mx.google.com> References: <4f4271a3.85c52a0a.3533.143cSMTPIN_ADDED@mx.google.com> Message-ID: Kristof, > The attached patch fixes a problem where LLVM doesn't generate .bss sections > in a C++ ABI-compliant way. > Would someone be able to review and apply the patch if fine? It seems that the patch is generic, not eabi specific, right? Thus I'd suggest to test also on e.g. x86-linux, where comdats are used. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From mcrosier at apple.com Mon Feb 20 17:13:18 2012 From: mcrosier at apple.com (Chad Rosier) Date: Mon, 20 Feb 2012 23:13:18 -0000 Subject: [llvm-commits] [llvm] r150998 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Message-ID: <20120220231318.2682A2A6C12F@llvm.org> Author: mcrosier Date: Mon Feb 20 17:13:17 2012 New Revision: 150998 URL: http://llvm.org/viewvc/llvm-project?rev=150998&view=rev Log: Fix 80-column violation. Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=150998&r1=150997&r2=150998&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Mon Feb 20 17:13:17 2012 @@ -423,7 +423,8 @@ // Finally, after the scan, check to see if the store is all that is left. if (Info.UsingBlocks.empty()) { - // Record debuginfo for the store and remove the declaration's debuginfo. + // Record debuginfo for the store and remove the declaration's + // debuginfo. if (DbgDeclareInst *DDI = Info.DbgDeclare) { if (!DIB) DIB = new DIBuilder(*DDI->getParent()->getParent()->getParent()); From arcata at gmail.com Mon Feb 20 17:27:28 2012 From: arcata at gmail.com (Joe Groff) Date: Mon, 20 Feb 2012 15:27:28 -0800 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: On Mon, Feb 20, 2012 at 1:11 PM, Eli Friedman wrote: > Please don't copy-paste the relevant logic. ?Otherwise, looks okay. Thank you for the feedback. Where would be the best place to move the common logic? -Joe From evan.cheng at apple.com Mon Feb 20 17:28:17 2012 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 20 Feb 2012 23:28:17 -0000 Subject: [llvm-commits] [llvm] r151002 - in /llvm/trunk: lib/CodeGen/MachineCopyPropagation.cpp lib/CodeGen/Passes.cpp test/CodeGen/X86/2012-02-20-MachineCPBug.ll test/CodeGen/X86/machine-cp.ll Message-ID: <20120220232818.067882A6C12F@llvm.org> Author: evancheng Date: Mon Feb 20 17:28:17 2012 New Revision: 151002 URL: http://llvm.org/viewvc/llvm-project?rev=151002&view=rev Log: Fix machine-cp by having it to check sub-register indicies. e.g. ecx = mov eax al = mov ch The second copy is not a nop because the sub-indices of ecx,ch is not the same of that of eax/al. Re-enabled machine-cp. PR11940 Added: llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll Modified: llvm/trunk/lib/CodeGen/MachineCopyPropagation.cpp llvm/trunk/lib/CodeGen/Passes.cpp llvm/trunk/test/CodeGen/X86/machine-cp.ll Modified: llvm/trunk/lib/CodeGen/MachineCopyPropagation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineCopyPropagation.cpp?rev=151002&r1=151001&r2=151002&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineCopyPropagation.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineCopyPropagation.cpp Mon Feb 20 17:28:17 2012 @@ -99,6 +99,31 @@ return true; } +/// isNopCopy - Return true if the specified copy is really a nop. That is +/// if the source of the copy is the same of the definition of the copy that +/// supplied the source. If the source of the copy is a sub-register than it +/// must check the sub-indices match. e.g. +/// ecx = mov eax +/// al = mov cl +/// But not +/// ecx = mov eax +/// al = mov ch +static bool isNopCopy(MachineInstr *CopyMI, unsigned Def, unsigned Src, + const TargetRegisterInfo *TRI) { + unsigned SrcSrc = CopyMI->getOperand(1).getReg(); + if (Def == SrcSrc) + return true; + if (TRI->isSubRegister(SrcSrc, Def)) { + unsigned SrcDef = CopyMI->getOperand(0).getReg(); + unsigned SubIdx = TRI->getSubRegIndex(SrcSrc, Def); + if (!SubIdx) + return false; + return SubIdx == TRI->getSubRegIndex(SrcDef, Src); + } + + return false; +} + bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) { SmallSetVector MaybeDeadCopies; // Candidates for deletion DenseMap AvailCopyMap; // Def -> available copies map @@ -122,10 +147,9 @@ DenseMap::iterator CI = AvailCopyMap.find(Src); if (CI != AvailCopyMap.end()) { MachineInstr *CopyMI = CI->second; - unsigned SrcSrc = CopyMI->getOperand(1).getReg(); if (!ReservedRegs.test(Def) && (!ReservedRegs.test(Src) || NoInterveningSideEffect(CopyMI, MI)) && - (SrcSrc == Def || TRI->isSubRegister(SrcSrc, Def))) { + isNopCopy(CopyMI, Def, Src, TRI)) { // The two copies cancel out and the source of the first copy // hasn't been overridden, eliminate the second one. e.g. // %ECX = COPY %EAX Modified: llvm/trunk/lib/CodeGen/Passes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=151002&r1=151001&r2=151002&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Passes.cpp (original) +++ llvm/trunk/lib/CodeGen/Passes.cpp Mon Feb 20 17:28:17 2012 @@ -69,7 +69,7 @@ static cl::opt DisableCGP("disable-cgp", cl::Hidden, cl::desc("Disable Codegen Prepare")); static cl::opt DisableCopyProp("disable-copyprop", cl::Hidden, - cl::desc("Disable Copy Propagation pass"), cl::init(true)); // PR11940 + cl::desc("Disable Copy Propagation pass")); static cl::opt PrintLSR("print-lsr-output", cl::Hidden, cl::desc("Print LLVM IR produced by the loop-reduce pass")); static cl::opt PrintISelInput("print-isel-input", cl::Hidden, Added: llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll?rev=151002&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll (added) +++ llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll Mon Feb 20 17:28:17 2012 @@ -0,0 +1,77 @@ +; RUN: llc < %s -mtriple=i386-apple-macosx | FileCheck %s +; PR11940: Do not optimize away movb %al, %ch + +%struct.APInt = type { i64* } + +declare noalias i8* @calloc(i32, i32) nounwind + +define void @bug(%struct.APInt* noalias nocapture sret %agg.result, %struct.APInt* nocapture %this, i32 %rotateAmt) nounwind align 2 { +entry: +; CHECK: bug: + %call = tail call i8* @calloc(i32 1, i32 32) + %call.i = tail call i8* @calloc(i32 1, i32 32) nounwind + %0 = bitcast i8* %call.i to i64* + %rem.i = and i32 %rotateAmt, 63 + %div.i = lshr i32 %rotateAmt, 6 + %cmp.i = icmp eq i32 %rem.i, 0 + br i1 %cmp.i, label %for.cond.preheader.i, label %if.end.i + +for.cond.preheader.i: ; preds = %entry + %sub.i = sub i32 4, %div.i + %cmp23.i = icmp eq i32 %div.i, 4 + br i1 %cmp23.i, label %for.body9.lr.ph.i, label %for.body.lr.ph.i + +for.body.lr.ph.i: ; preds = %for.cond.preheader.i + %pVal.i = getelementptr inbounds %struct.APInt* %this, i32 0, i32 0 + %.pre5.i = load i64** %pVal.i, align 4 + br label %for.body.i + +for.body.i: ; preds = %for.body.i, %for.body.lr.ph.i + %i.04.i = phi i32 [ 0, %for.body.lr.ph.i ], [ %inc.i, %for.body.i ] + %add.i = add i32 %i.04.i, %div.i + %arrayidx.i = getelementptr inbounds i64* %.pre5.i, i32 %add.i + %1 = load i64* %arrayidx.i, align 4 + %arrayidx3.i = getelementptr inbounds i64* %0, i32 %i.04.i + store i64 %1, i64* %arrayidx3.i, align 4 + %inc.i = add i32 %i.04.i, 1 + %cmp2.i = icmp ult i32 %inc.i, %sub.i + br i1 %cmp2.i, label %for.body.i, label %if.end.i + +if.end.i: ; preds = %for.body.i, %entry + %cmp81.i = icmp eq i32 %div.i, 3 + br i1 %cmp81.i, label %_ZNK5APInt4lshrEj.exit, label %for.body9.lr.ph.i + +for.body9.lr.ph.i: ; preds = %if.end.i, %for.cond.preheader.i + %sub58.i = sub i32 3, %div.i + %pVal11.i = getelementptr inbounds %struct.APInt* %this, i32 0, i32 0 + %sh_prom.i = zext i32 %rem.i to i64 + %sub17.i = sub i32 64, %rem.i + %sh_prom18.i = zext i32 %sub17.i to i64 + %.pre.i = load i64** %pVal11.i, align 4 + br label %for.body9.i + +for.body9.i: ; preds = %for.body9.i, %for.body9.lr.ph.i +; CHECK: %for.body9.i +; CHECK: movb %al, %ch + %i6.02.i = phi i32 [ 0, %for.body9.lr.ph.i ], [ %inc21.i, %for.body9.i ] + %add10.i = add i32 %i6.02.i, %div.i + %arrayidx12.i = getelementptr inbounds i64* %.pre.i, i32 %add10.i + %2 = load i64* %arrayidx12.i, align 4 + %shr.i = lshr i64 %2, %sh_prom.i + %add14.i = add i32 %add10.i, 1 + %arrayidx16.i = getelementptr inbounds i64* %.pre.i, i32 %add14.i + %3 = load i64* %arrayidx16.i, align 4 + %shl.i = shl i64 %3, %sh_prom18.i + %or.i = or i64 %shl.i, %shr.i + %arrayidx19.i = getelementptr inbounds i64* %0, i32 %i6.02.i + store i64 %or.i, i64* %arrayidx19.i, align 4 + %inc21.i = add i32 %i6.02.i, 1 + %cmp8.i = icmp ult i32 %inc21.i, %sub58.i + br i1 %cmp8.i, label %for.body9.i, label %_ZNK5APInt4lshrEj.exit + +_ZNK5APInt4lshrEj.exit: ; preds = %for.body9.i, %if.end.i + %call.i1 = tail call i8* @calloc(i32 1, i32 32) nounwind + %4 = getelementptr inbounds %struct.APInt* %agg.result, i32 0, i32 0 + store i64* %0, i64** %4, align 4 + ret void +} Modified: llvm/trunk/test/CodeGen/X86/machine-cp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/machine-cp.ll?rev=151002&r1=151001&r2=151002&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/machine-cp.ll (original) +++ llvm/trunk/test/CodeGen/X86/machine-cp.ll Mon Feb 20 17:28:17 2012 @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=x86_64-apple-macosx -mcpu=nocona < %s -disable-copyprop=false | FileCheck %s +; RUN: llc -mtriple=x86_64-apple-macosx -mcpu=nocona < %s | FileCheck %s ; After tail duplication, two copies in an early exit BB can be cancelled out. ; rdar://10640363 From nicholas at mxc.ca Mon Feb 20 17:32:26 2012 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 20 Feb 2012 23:32:26 -0000 Subject: [llvm-commits] [llvm] r151003 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/invariant.ll Message-ID: <20120220233226.A62772A6C12F@llvm.org> Author: nicholas Date: Mon Feb 20 17:32:26 2012 New Revision: 151003 URL: http://llvm.org/viewvc/llvm-project?rev=151003&view=rev Log: Check for the correct size in the invariant marker. Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/test/Transforms/GlobalOpt/invariant.ll Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=151003&r1=151002&r2=151003&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Feb 20 17:32:26 2012 @@ -2511,10 +2511,13 @@ if (!II->use_empty()) return false; ConstantInt *Size = cast(II->getArgOperand(0)); - if (Size->isAllOnesValue()) { - Value *PtrArg = getVal(II->getArgOperand(1)); - Value *Ptr = PtrArg->stripPointerCasts(); - if (GlobalVariable *GV = dyn_cast(Ptr)) + Value *PtrArg = getVal(II->getArgOperand(1)); + Value *Ptr = PtrArg->stripPointerCasts(); + if (GlobalVariable *GV = dyn_cast(Ptr)) { + Type *ElemTy = cast(GV->getType())->getElementType(); + if (!Size->isAllOnesValue() && + Size->getValue().getLimitedValue() >= + TD->getTypeStoreSize(ElemTy)) Invariants.insert(GV); } // Continue even if we do nothing. Modified: llvm/trunk/test/Transforms/GlobalOpt/invariant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/invariant.ll?rev=151003&r1=151002&r2=151003&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/invariant.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/invariant.ll Mon Feb 20 17:32:26 2012 @@ -1,9 +1,12 @@ ; RUN: opt -globalopt -S -o - < %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-S128" +target triple = "x86_64-unknown-linux-gnu" + declare {}* @llvm.invariant.start(i64 %size, i8* nocapture %ptr) define void @test1(i8* %ptr) { - call {}* @llvm.invariant.start(i64 -1, i8* %ptr) + call {}* @llvm.invariant.start(i64 4, i8* %ptr) ret void } @@ -22,12 +25,35 @@ define void @ctor2() { store i32 -1, i32* @object2 %A = bitcast i32* @object2 to i8* - %B = call {}* @llvm.invariant.start(i64 -1, i8* %A) + %B = call {}* @llvm.invariant.start(i64 4, i8* %A) %C = bitcast {}* %B to i8* ret void } + + at object3 = global i32 0 +; CHECK: @object3 = global i32 -1 +define void @ctor3() { + store i32 -1, i32* @object3 + %A = bitcast i32* @object3 to i8* + call {}* @llvm.invariant.start(i64 3, i8* %A) + ret void +} + + + at object4 = global i32 0 +; CHECK: @object4 = global i32 -1 +define void @ctor4() { + store i32 -1, i32* @object4 + %A = bitcast i32* @object4 to i8* + call {}* @llvm.invariant.start(i64 -1, i8* %A) + ret void +} + + @llvm.global_ctors = appending constant - [2 x { i32, void ()* }] + [4 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @ctor1 }, - { i32, void ()* } { i32 65535, void ()* @ctor2 } ] + { i32, void ()* } { i32 65535, void ()* @ctor2 }, + { i32, void ()* } { i32 65535, void ()* @ctor3 }, + { i32, void ()* } { i32 65535, void ()* @ctor4 } ] From eli.friedman at gmail.com Mon Feb 20 17:45:12 2012 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 20 Feb 2012 15:45:12 -0800 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: On Mon, Feb 20, 2012 at 3:27 PM, Joe Groff wrote: > On Mon, Feb 20, 2012 at 1:11 PM, Eli Friedman wrote: >> Please don't copy-paste the relevant logic. ?Otherwise, looks okay. > > Thank you for the feedback. Where would be the best place to move the > common logic? Not sure off the top of my head; maybe FunctionLoweringInfo? -Eli From lhames at gmail.com Mon Feb 20 18:00:37 2012 From: lhames at gmail.com (Lang Hames) Date: Tue, 21 Feb 2012 00:00:37 -0000 Subject: [llvm-commits] [llvm] r151006 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <20120221000037.15B562A6C12F@llvm.org> Author: lhames Date: Mon Feb 20 18:00:36 2012 New Revision: 151006 URL: http://llvm.org/viewvc/llvm-project?rev=151006&view=rev Log: Fix some bugs in HMEditor's moveAllOperandsInto logic. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=151006&r1=151005&r2=151006&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Feb 20 18:00:36 2012 @@ -1025,7 +1025,7 @@ // IntervalUpdate class. //===----------------------------------------------------------------------===// -/// HMEditor is a toolkit used by handleMove to trim or extend live intervals. +// HMEditor is a toolkit used by handleMove to trim or extend live intervals. class LiveIntervals::HMEditor { private: LiveIntervals& LIS; @@ -1078,11 +1078,14 @@ } - void moveAllOperandsInto(MachineInstr* MI, MachineInstr* BundleStart, - SlotIndex OldIdx) { + void moveAllOperandsInto(MachineInstr* MI, MachineInstr* BundleStart) { if (MI == BundleStart) return; // Bundling instr with itself - nothing to do. + SlotIndex OldIdx = LIS.getSlotIndexes()->getInstructionIndex(MI); + assert(LIS.getSlotIndexes()->getInstructionFromIndex(OldIdx) == MI && + "SlotIndex <-> Instruction mapping broken for MI"); + BundleRanges BR = createBundleRanges(BundleStart); RangeSet Entering, Internal, Exiting; @@ -1201,14 +1204,14 @@ } for (RangeSet::iterator EI = Entering.begin(), EE = Entering.end(); - EI == EE; ++EI) { + EI != EE; ++EI) { LiveInterval* LI = EI->first; LiveRange* LR = EI->second; BR[LI->reg].Use = LR; } for (RangeSet::iterator II = Internal.begin(), IE = Internal.end(); - II == IE; ++II) { + II != IE; ++II) { LiveInterval* LI = II->first; LiveRange* LR = II->second; if (LR->end.isDead()) { @@ -1219,7 +1222,7 @@ } for (RangeSet::iterator EI = Exiting.begin(), EE = Exiting.end(); - EI == EE; ++EI) { + EI != EE; ++EI) { LiveInterval* LI = EI->first; LiveRange* LR = EI->second; BR[LI->reg].Def = LR; @@ -1350,9 +1353,7 @@ } SlotIndex LastUse = findLastUseBefore(LI->reg, OldIdx); - // TODO: Kill flag transfer is broken. For "Into" methods NewIdx is the - // bundle start, so we need another way to find MI. - moveKillFlags(LI->reg, NewIdx, LastUse); + moveKillFlags(LI->reg, OldIdx, LastUse); if (LR->start < NewIdx) { // Becoming a new entering range. From klimek at google.com Mon Feb 20 19:04:53 2012 From: klimek at google.com (Manuel Klimek) Date: Mon, 20 Feb 2012 17:04:53 -0800 Subject: [llvm-commits] [PATCH] YAML parser. In-Reply-To: References: Message-ID: http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp File lib/Support/YAMLParser.cpp (right): http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#ne... lib/Support/YAMLParser.cpp:693: EscapedInput += "\\x" + std::string(HexStr.size() - 2, '0') + HexStr; On 2012/02/16 22:32:42, Bigcheesegs wrote: > On 2012/02/16 15:52:35, klimek wrote: > > Why's the middle part there? > > \x requires two characters after it. This adds the 0 if needed. Ok, shouldn't that be 2 - HexStr.size() then? http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#ne... lib/Support/YAMLParser.cpp:795: if ( u8d.second != 0 On 2012/02/16 22:32:42, Bigcheesegs wrote: > On 2012/02/16 15:52:35, klimek wrote: > > Somehow I cannot match this up with 5.1. > > Especially: > > """On input, a YAML processor must accept all Unicode characters except those > > explicitly excluded above.""" > > > > And, why do we care about non-printable chars at all? > > This excludes the characters listed in 5.1 in addition to the other stuff > removed from nb-char. > > This is needed to skip entire UTF-8 minimal well formed subsequences at a time > to keep proper column counts. If I'm not completely misreading, this excludes much more: """To ensure readability, YAML streams use only the printable subset of the Unicode character set. The allowed character range explicitly excludes the C0 control block #x0-#x1F (except for TAB #x9, LF #xA, and CR #xD which are allowed), DEL #x7F, the C1 control block #x80-#x9F (except for NEL #x85 which is allowed), the surrogate block #xD800-#xDFFF, #xFFFE, and #xFFFF.""" The surrogate block cannot actually come out of decodeUTF8. http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#ne... lib/Support/YAMLParser.cpp:1627: switch (UnquotedValue[0]) { On 2012/02/16 22:32:42, Bigcheesegs wrote: > On 2012/02/16 15:52:35, klimek wrote: > > Do we want to support all possible escapes, or can we get away with the subset > > we really need? > > It's only a few extra lines with no extra complexity... It is code that needs to be maintained ... shrug. On Thu, Feb 16, 2012 at 2:38 PM, Michael Spencer wrote: > http://codereview.appspot.com/5604054/diff/6001/include/llvm/Support/YAMLParser.h > File include/llvm/Support/YAMLParser.h (right): > > http://codereview.appspot.com/5604054/diff/6001/include/llvm/Support/YAMLParser.h#newcode71 > include/llvm/Support/YAMLParser.h:71: std::string escape(StringRef > Input); > On 2012/02/16 15:52:35, klimek wrote: >> >> This is not called anywhere yet(?) Why do we need it? Are we planning > > to write >> >> yaml or do we only need to parse it? > > > It's used when writing out YAML files. > > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp > File lib/Support/YAMLParser.cpp (right): > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode667 > lib/Support/YAMLParser.cpp:667: std::string EscapedInput; > On 2012/02/16 15:52:35, klimek wrote: >> >> Curious: is there a reason not to use a Twine here (which would be my > > default >> >> choice for string concatenation). > > > Twine cannot be used here as it is only valid until the end of the > statement. See Twine.h. > > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode693 > lib/Support/YAMLParser.cpp:693: EscapedInput += "\\x" + > std::string(HexStr.size() - 2, '0') + HexStr; > On 2012/02/16 15:52:35, klimek wrote: >> >> Why's the middle part there? > > > \x requires two characters after it. This adds the 0 if needed. > > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode694 > lib/Support/YAMLParser.cpp:694: } else if (*i & 0x80) { // utf8 > On 2012/02/16 15:52:35, klimek wrote: >> >> // utf8 >> is confusing to me here: >> I thought we always assume utf8, and 0x80 merely means that we have a > > multi-byte >> >> utf8 sequence... > > >> So I'd expect a comment like: >> // utf8 multi-byte sequence > > > Done. > > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode788 > lib/Support/YAMLParser.cpp:788: if ( ? *Position == 0x09 > On 2012/02/16 15:52:35, klimek wrote: >> >> Indentation off? > > > It lines up with the other side of the || below. > > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode795 > lib/Support/YAMLParser.cpp:795: if ( ? u8d.second != 0 > On 2012/02/16 15:52:35, klimek wrote: >> >> Somehow I cannot match this up with 5.1. >> Especially: >> """On input, a YAML processor must accept all Unicode characters > > except those >> >> explicitly excluded above.""" > > >> And, why do we care about non-printable chars at all? > > > This excludes the characters listed in 5.1 in addition to the other > stuff removed from nb-char. > > This is needed to skip entire UTF-8 minimal well formed subsequences at > a time to keep proper column counts. > > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode839 > lib/Support/YAMLParser.cpp:839: if ( ?(C >= '0' && C <= '9') > On 2012/02/16 15:52:35, klimek wrote: >> >> Just return. > > > Done. > > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode847 > lib/Support/YAMLParser.cpp:847: if ( ?C == '-' > On 2012/02/16 15:52:35, klimek wrote: >> >> Just return. > > > Done. > > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode860 > lib/Support/YAMLParser.cpp:860: && Current + 2 < End > On 2012/02/16 15:52:35, klimek wrote: >> >> So we're not inc'ing Current by 3 when encountering %NN because NN > > will be >> >> parsable anyway? > > > Yes, however, there's no reason it can't skip all 3. > > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode1627 > lib/Support/YAMLParser.cpp:1627: switch (UnquotedValue[0]) { > On 2012/02/16 15:52:35, klimek wrote: >> >> Do we want to support all possible escapes, or can we get away with > > the subset >> >> we really need? > > > It's only a few extra lines with no extra complexity... > > http://codereview.appspot.com/5604054/ > > - Michael Spencer From rafael.espindola at gmail.com Mon Feb 20 19:19:51 2012 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 21 Feb 2012 01:19:51 -0000 Subject: [llvm-commits] [llvm] r151015 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Message-ID: <20120221011951.935662A6C12F@llvm.org> Author: rafael Date: Mon Feb 20 19:19:51 2012 New Revision: 151015 URL: http://llvm.org/viewvc/llvm-project?rev=151015&view=rev Log: It turns out that with the current scev organization ReuseOrCreateCast cannot know where users will be added. Because of this, it cannot use Builder.GetInsertPoint at all. This patch * removes the FIXME about adding the assert. * adds a comment explaining hy we don't have one. * removes a broken logic that only works for some callers and is not needed since r150884. * adds an assert to caller that would have caught the bug fixed by r150884. Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=151015&r1=151014&r2=151015&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Feb 20 19:19:51 2012 @@ -31,13 +31,11 @@ Value *SCEVExpander::ReuseOrCreateCast(Value *V, Type *Ty, Instruction::CastOps Op, BasicBlock::iterator IP) { - // All new or reused instructions must strictly dominate the Builder's - // InsertPt to ensure that the expression's expansion dominates its uses. - // Assert that the requested insertion point works at least for new - // instructions. - - // FIXME: disabled to make the bots happy. - //assert(SE.DT->dominates(IP, Builder.GetInsertPoint())); + // All new or reused instructions must strictly dominate their uses. + // It would be nice to assert this here, but we don't always know where + // the next instructions will be added as the the caller can move the + // Builder's InsertPt before creating them and we might be called with + // an invalid InsertPt. // Check to see if there is already a cast! for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); @@ -47,8 +45,7 @@ if (CastInst *CI = dyn_cast(U)) if (CI->getOpcode() == Op) { // If the cast isn't where we want it, fix it. - if (BasicBlock::iterator(CI) != IP - || IP == Builder.GetInsertPoint()) { + if (BasicBlock::iterator(CI) != IP) { // Create a new cast, and leave the old cast in place in case // it is being used as an insert point. Clear its operand // so that it doesn't hold anything live. @@ -506,6 +503,9 @@ V = InsertNoopCastOfTo(V, Type::getInt8PtrTy(Ty->getContext(), PTy->getAddressSpace())); + Instruction *Inst = dyn_cast(V); + assert(!Inst || SE.DT->properlyDominates(Inst, Builder.GetInsertPoint())); + // Expand the operands for a plain byte offset. Value *Idx = expandCodeFor(SE.getAddExpr(Ops), Ty); From chandlerc at google.com Mon Feb 20 19:49:13 2012 From: chandlerc at google.com (Chandler Carruth) Date: Mon, 20 Feb 2012 17:49:13 -0800 Subject: [llvm-commits] [llvm] r151015 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp In-Reply-To: <20120221011951.935662A6C12F@llvm.org> References: <20120221011951.935662A6C12F@llvm.org> Message-ID: On Mon, Feb 20, 2012 at 5:19 PM, Rafael Espindola < rafael.espindola at gmail.com> wrote: > + Instruction *Inst = dyn_cast(V); Either do the dyn_cast in the assertion (my preference) or cast this variable to void to mark it as used in opt builds please. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120220/56baea45/attachment.html From arcata at gmail.com Mon Feb 20 19:52:24 2012 From: arcata at gmail.com (Joe Groff) Date: Mon, 20 Feb 2012 17:52:24 -0800 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: On Mon, Feb 20, 2012 at 3:45 PM, Eli Friedman wrote: > Not sure off the top of my head; maybe FunctionLoweringInfo? I factored the logic to MachineModuleInfo, since that's where the calls...WithFloatingPointArguments state is kept. Attached is the revised patch. -Joe -------------- next part -------------- A non-text attachment was scrubbed... Name: pr11798-3.diff Type: application/octet-stream Size: 6600 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120220/195f838c/attachment.obj From daniel at zuster.org Mon Feb 20 20:53:18 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 02:53:18 -0000 Subject: [llvm-commits] [zorg] r151019 - in /zorg/trunk/lnt/lnt: testing/util/machineinfo.py tests/compile.py Message-ID: <20120221025319.0B3352A6C12F@llvm.org> Author: ddunbar Date: Mon Feb 20 20:53:18 2012 New Revision: 151019 URL: http://llvm.org/viewvc/llvm-project?rev=151019&view=rev Log: [lnt] lnt.tests.compile: Factor out some of the code for querying machine information. Added: zorg/trunk/lnt/lnt/testing/util/machineinfo.py Modified: zorg/trunk/lnt/lnt/tests/compile.py Added: zorg/trunk/lnt/lnt/testing/util/machineinfo.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/util/machineinfo.py?rev=151019&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/testing/util/machineinfo.py (added) +++ zorg/trunk/lnt/lnt/testing/util/machineinfo.py Mon Feb 20 20:53:18 2012 @@ -0,0 +1,178 @@ +""" +Utilities for gathering information on the host machine for inclusion with +results. +""" + +import re + +from lnt.testing.util.commands import capture + +# All the things we care to probe about the system, and whether to track with +# the machine or run. This is a list of (sysctl, kind) where kind is one of: +# machine - key should always be part of machine +# machdep - key should be part of machine, unless --no-machdep-info is set +# run - key should always be part of run +sysctl_info_table = [ + ('hw.activecpu', 'machine'), + ('hw.availcpu', 'machine'), + ('hw.busfrequency', 'machine'), + ('hw.busfrequency_max', 'machine'), + ('hw.busfrequency_min', 'machine'), + ('hw.byteorder', 'machine'), + ('hw.cacheconfig', 'machine'), + ('hw.cachelinesize', 'machine'), + ('hw.cachesize', 'machine'), + ('hw.cpu64bit_capable', 'machine'), + ('hw.cpufamily', 'machine'), + ('hw.cpufrequency', 'machine'), + ('hw.cpufrequency_max', 'machine'), + ('hw.cpufrequency_min', 'machine'), + ('hw.cpusubtype', 'machine'), + ('hw.cputype', 'machine'), + ('hw.epoch', 'machine'), + ('hw.l1dcachesize', 'machine'), + ('hw.l1icachesize', 'machine'), + ('hw.l2cachesize', 'machine'), + ('hw.l2settings', 'machine'), + ('hw.logicalcpu', 'machine'), + ('hw.logicalcpu_max', 'machine'), + ('hw.machine', 'machine'), + ('hw.memsize', 'machine'), + ('hw.model', 'machine'), + ('hw.ncpu', 'machine'), + ('hw.optional.floatingpoint', 'machine'), + ('hw.optional.mmx', 'machine'), + ('hw.optional.sse', 'machine'), + ('hw.optional.sse2', 'machine'), + ('hw.optional.sse3', 'machine'), + ('hw.optional.sse4_1', 'machine'), + ('hw.optional.sse4_2', 'machine'), + ('hw.optional.supplementalsse3', 'machine'), + ('hw.optional.x86_64', 'machine'), + ('hw.packages', 'machine'), + ('hw.pagesize', 'machine'), + ('hw.physicalcpu', 'machine'), + ('hw.physicalcpu_max', 'machine'), + ('hw.physmem', 'machine'), + ('hw.tbfrequency', 'machine'), + ('hw.usermem', 'run' ), + ('hw.vectorunit', 'machine'), + ('kern.aiomax', 'machine'), + ('kern.aioprocmax', 'machine'), + ('kern.aiothreads', 'machine'), + ('kern.argmax', 'machine'), + ('kern.boottime', 'run' ), + ('kern.clockrate: hz', 'machine'), + ('kern.coredump', 'machine'), + ('kern.corefile', 'machine'), + ('kern.delayterm', 'machine'), + ('kern.hostid', 'machine'), + ('kern.hostname', 'machdep'), + ('kern.job_control', 'machine'), + ('kern.maxfiles', 'machine'), + ('kern.maxfilesperproc', 'machine'), + ('kern.maxproc', 'machine'), + ('kern.maxprocperuid', 'machine'), + ('kern.maxvnodes', 'machine'), + ('kern.netboot', 'machine'), + ('kern.ngroups', 'machine'), + ('kern.nisdomainname', 'machine'), + ('kern.nx', 'machine'), + ('kern.osrelease', 'machine'), + ('kern.osrevision', 'machine'), + ('kern.ostype', 'machine'), + ('kern.osversion', 'machine'), + ('kern.posix1version', 'machine'), + ('kern.procname', 'machine'), + ('kern.rage_vnode', 'machine'), + ('kern.safeboot', 'machine'), + ('kern.saved_ids', 'machine'), + ('kern.securelevel', 'machine'), + ('kern.shreg_private', 'machine'), + ('kern.speculative_reads_disabled', 'machine'), + ('kern.sugid_coredump', 'machine'), + ('kern.thread_name', 'machine'), + ('kern.usrstack', 'run'), + ('kern.usrstack64', 'run'), + ('kern.version', 'machine'), + ('machdep.cpu.address_bits.physical', 'machine'), + ('machdep.cpu.address_bits.virtual', 'machine'), + ('machdep.cpu.arch_perf.events', 'machine'), + ('machdep.cpu.arch_perf.events_number', 'machine'), + ('machdep.cpu.arch_perf.fixed_number', 'machine'), + ('machdep.cpu.arch_perf.fixed_width', 'machine'), + ('machdep.cpu.arch_perf.number', 'machine'), + ('machdep.cpu.arch_perf.version', 'machine'), + ('machdep.cpu.arch_perf.width', 'machine'), + ('machdep.cpu.brand', 'machine'), + ('machdep.cpu.brand_string', 'machine'), + ('machdep.cpu.cache.L2_associativity', 'machine'), + ('machdep.cpu.cache.linesize', 'machine'), + ('machdep.cpu.cache.size', 'machine'), + ('machdep.cpu.core_count', 'machine'), + ('machdep.cpu.cores_per_package', 'machine'), + ('machdep.cpu.extfamily', 'machine'), + ('machdep.cpu.extfeature_bits', 'machine'), + ('machdep.cpu.extfeatures', 'machine'), + ('machdep.cpu.extmodel', 'machine'), + ('machdep.cpu.family', 'machine'), + ('machdep.cpu.feature_bits', 'machine'), + ('machdep.cpu.features', 'machine'), + ('machdep.cpu.logical_per_package', 'machine'), + ('machdep.cpu.max_basic', 'machine'), + ('machdep.cpu.max_ext', 'machine'), + ('machdep.cpu.microcode_version', 'machine'), + ('machdep.cpu.model', 'machine'), + ('machdep.cpu.mwait.extensions', 'machine'), + ('machdep.cpu.mwait.linesize_max', 'machine'), + ('machdep.cpu.mwait.linesize_min', 'machine'), + ('machdep.cpu.mwait.sub_Cstates', 'machine'), + ('machdep.cpu.signature', 'machine'), + ('machdep.cpu.stepping', 'machine'), + ('machdep.cpu.thermal.ACNT_MCNT', 'machine'), + ('machdep.cpu.thermal.dynamic_acceleration', 'machine'), + ('machdep.cpu.thermal.sensor', 'machine'), + ('machdep.cpu.thermal.thresholds', 'machine'), + ('machdep.cpu.thread_count', 'machine'), + ('machdep.cpu.tlb.data.large', 'machine'), + ('machdep.cpu.tlb.data.large_level1', 'machine'), + ('machdep.cpu.tlb.data.small', 'machine'), + ('machdep.cpu.tlb.data.small_level1', 'machine'), + ('machdep.cpu.tlb.inst.large', 'machine'), + ('machdep.cpu.tlb.inst.small', 'machine'), + ('machdep.cpu.vendor', 'machine'), + ] + +def _get_mac_addresses(): + lines = capture(['ifconfig']).strip() + current_ifc = None + for ln in lines.split('\n'): + if ln.startswith('\t'): + if current_ifc is None: + fatal('unexpected ifconfig output') + if ln.startswith('\tether '): + yield current_ifc,ln[len('\tether '):].strip() + else: + current_ifc, = re.match(r'([A-Za-z0-9]*): .*', ln).groups() + +def get_machine_information(use_machine_dependent_info = False): + machine_info = {} + run_info = {} + + info_targets = { + 'machdep' : (run_info, machine_info)[ + use_machine_dependent_info], + 'machine' : machine_info, + 'run' : run_info } + for name,target in sysctl_info_table: + info_targets[target][name] = capture(['sysctl','-n',name], + include_stderr=True).strip() + + for ifc,addr in _get_mac_addresses(): + # Ignore virtual machine mac addresses. + if ifc.startswith('vmnet'): + continue + + info_targets['machdep']['mac_addr.%s' % ifc] = addr + + return machine_info, run_info Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151019&r1=151018&r2=151019&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Mon Feb 20 20:53:18 2012 @@ -11,6 +11,7 @@ from lnt.testing.util.commands import note, warning, error, fatal from lnt.testing.util.commands import capture, rm_f from lnt.testing.util.misc import timestamp +from lnt.testing.util import machineinfo # Interface to runN. # @@ -248,154 +249,6 @@ import platform from datetime import datetime -# All the things we care to probe about the system, and whether to track with -# the machine or run. This is a list of (sysctl, kind) where kind is one of: -# machine - key should always be part of machine -# machdep - key should be part of machine, unless --no-machdep-info is set -# run - key should always be part of run -sysctl_info_table = [ - ('hw.activecpu', 'machine'), # 8 - ('hw.availcpu', 'machine'), # 8 - ('hw.busfrequency', 'machine'), # 1600000000 - ('hw.busfrequency_max', 'machine'), # 1600000000 - ('hw.busfrequency_min', 'machine'), # 1600000000 - ('hw.byteorder', 'machine'), # 1234 - ('hw.cacheconfig', 'machine'), # 8 1 2 0 0 0 0 0 0 0 - ('hw.cachelinesize', 'machine'), # 64 - ('hw.cachesize', 'machine'), # 6442450944 32768 6291456 0 0 0 0 0 0 0 - ('hw.cpu64bit_capable', 'machine'), # 1 - ('hw.cpufamily', 'machine'), # 2028621756 - ('hw.cpufrequency', 'machine'), # 2800000000 - ('hw.cpufrequency_max', 'machine'), # 2800000000 - ('hw.cpufrequency_min', 'machine'), # 2800000000 - ('hw.cpusubtype', 'machine'), # 4 - ('hw.cputype', 'machine'), # 7 - ('hw.epoch', 'machine'), # 0 - ('hw.l1dcachesize', 'machine'), # 32768 - ('hw.l1icachesize', 'machine'), # 32768 - ('hw.l2cachesize', 'machine'), # 6291456 - ('hw.l2settings', 'machine'), # 1 - ('hw.logicalcpu', 'machine'), # 8 - ('hw.logicalcpu_max', 'machine'), # 8 - ('hw.machine', 'machine'), # i386 - ('hw.memsize', 'machine'), # 6442450944 - ('hw.model', 'machine'), # MacPro3,1 - ('hw.ncpu', 'machine'), # 8 - ('hw.optional.floatingpoint', 'machine'), # 1 - ('hw.optional.mmx', 'machine'), # 1 - ('hw.optional.sse', 'machine'), # 1 - ('hw.optional.sse2', 'machine'), # 1 - ('hw.optional.sse3', 'machine'), # 1 - ('hw.optional.sse4_1', 'machine'), # 1 - ('hw.optional.sse4_2', 'machine'), # 0 - ('hw.optional.supplementalsse3', 'machine'), # 1 - ('hw.optional.x86_64', 'machine'), # 1 - ('hw.packages', 'machine'), # 2 - ('hw.pagesize', 'machine'), # 4096 - ('hw.physicalcpu', 'machine'), # 8 - ('hw.physicalcpu_max', 'machine'), # 8 - ('hw.physmem', 'machine'), # 2147483648 - ('hw.tbfrequency', 'machine'), # 1000000000 - ('hw.usermem', 'run' ), # 1347354624 - ('hw.vectorunit', 'machine'), # 1 - ('kern.aiomax', 'machine'), # 90 - ('kern.aioprocmax', 'machine'), # 16 - ('kern.aiothreads', 'machine'), # 4 - ('kern.argmax', 'machine'), # 262144 - ('kern.boottime', 'run' ), # Tue Mar 23 18:36:38 2010 - ('kern.clockrate: hz', 'machine'), # 100, tick = 10000, profhz = 100, stathz = 100 - ('kern.coredump', 'machine'), # 1 - ('kern.corefile', 'machine'), # /cores/core.%P - ('kern.delayterm', 'machine'), # 0 - ('kern.hostid', 'machine'), # 0 - ('kern.hostname', 'machdep'), # lordcrumb.apple.com - ('kern.job_control', 'machine'), # 1 - ('kern.maxfiles', 'machine'), # 12288 - ('kern.maxfilesperproc', 'machine'), # 10240 - ('kern.maxproc', 'machine'), # 532 - ('kern.maxprocperuid', 'machine'), # 266 - ('kern.maxvnodes', 'machine'), # 99328 - ('kern.netboot', 'machine'), # 0 - ('kern.ngroups', 'machine'), # 16 - ('kern.nisdomainname', 'machine'), # - ('kern.nx', 'machine'), # 1 - ('kern.osrelease', 'machine'), # 10.2.0 - ('kern.osrevision', 'machine'), # 199506 - ('kern.ostype', 'machine'), # Darwin - ('kern.osversion', 'machine'), # 10C540 - ('kern.posix1version', 'machine'), # 200112 - ('kern.procname', 'machine'), # - ('kern.rage_vnode', 'machine'), # 0 - ('kern.safeboot', 'machine'), # 0 - ('kern.saved_ids', 'machine'), # 1 - ('kern.securelevel', 'machine'), # 0 - ('kern.shreg_private', 'machine'), # 0 - ('kern.speculative_reads_disabled', 'machine'), # 0 - ('kern.sugid_coredump', 'machine'), # 0 - ('kern.thread_name', 'machine'), # kern - ('kern.usrstack', 'run'), # 1606418432 - ('kern.usrstack64', 'run'), # 140734799806464 - ('kern.version', 'machine'), # Darwin Kernel Version 10.2.0: Tue Nov 3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386 - ('machdep.cpu.address_bits.physical', 'machine'), # 38 - ('machdep.cpu.address_bits.virtual', 'machine'), # 48 - ('machdep.cpu.arch_perf.events', 'machine'), # 0 - ('machdep.cpu.arch_perf.events_number', 'machine'), # 7 - ('machdep.cpu.arch_perf.fixed_number', 'machine'), # 3 - ('machdep.cpu.arch_perf.fixed_width', 'machine'), # 40 - ('machdep.cpu.arch_perf.number', 'machine'), # 2 - ('machdep.cpu.arch_perf.version', 'machine'), # 2 - ('machdep.cpu.arch_perf.width', 'machine'), # 40 - ('machdep.cpu.brand', 'machine'), # 0 - ('machdep.cpu.brand_string', 'machine'), # Intel(R) Xeon(R) CPU E5462 @ 2.80GHz - ('machdep.cpu.cache.L2_associativity', 'machine'), # 8 - ('machdep.cpu.cache.linesize', 'machine'), # 64 - ('machdep.cpu.cache.size', 'machine'), # 6144 - ('machdep.cpu.core_count', 'machine'), # 4 - ('machdep.cpu.cores_per_package', 'machine'), # 4 - ('machdep.cpu.extfamily', 'machine'), # 0 - ('machdep.cpu.extfeature_bits', 'machine'), # 537921536 1 - ('machdep.cpu.extfeatures', 'machine'), # SYSCALL XD EM64T - ('machdep.cpu.extmodel', 'machine'), # 1 - ('machdep.cpu.family', 'machine'), # 6 - ('machdep.cpu.feature_bits', 'machine'), # 3219913727 844733 - ('machdep.cpu.features', 'machine'), # FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM SSE3 MON DSCPL VMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 - ('machdep.cpu.logical_per_package', 'machine'), # 4 - ('machdep.cpu.max_basic', 'machine'), # 10 - ('machdep.cpu.max_ext', 'machine'), # 2147483656 - ('machdep.cpu.microcode_version', 'machine'), # 1547 - ('machdep.cpu.model', 'machine'), # 23 - ('machdep.cpu.mwait.extensions', 'machine'), # 3 - ('machdep.cpu.mwait.linesize_max', 'machine'), # 64 - ('machdep.cpu.mwait.linesize_min', 'machine'), # 64 - ('machdep.cpu.mwait.sub_Cstates', 'machine'), # 8736 - ('machdep.cpu.signature', 'machine'), # 67190 - ('machdep.cpu.stepping', 'machine'), # 6 - ('machdep.cpu.thermal.ACNT_MCNT', 'machine'), # 1 - ('machdep.cpu.thermal.dynamic_acceleration', 'machine'), # 0 - ('machdep.cpu.thermal.sensor', 'machine'), # 1 - ('machdep.cpu.thermal.thresholds', 'machine'), # 2 - ('machdep.cpu.thread_count', 'machine'), # 4 - ('machdep.cpu.tlb.data.large', 'machine'), # 16 - ('machdep.cpu.tlb.data.large_level1', 'machine'), # 32 - ('machdep.cpu.tlb.data.small', 'machine'), # 16 - ('machdep.cpu.tlb.data.small_level1', 'machine'), # 256 - ('machdep.cpu.tlb.inst.large', 'machine'), # 8 - ('machdep.cpu.tlb.inst.small', 'machine'), # 128 - ('machdep.cpu.vendor', 'machine'), # GenuineIntel - ] - -def get_mac_addresses(): - lines = capture(['ifconfig']).strip() - current_ifc = None - for ln in lines.split('\n'): - if ln.startswith('\t'): - if current_ifc is None: - fatal('unexpected ifconfig output') - if ln.startswith('\tether '): - yield current_ifc,ln[len('\tether '):].strip() - else: - current_ifc, = re.match(r'([A-Za-z0-9]*): .*', ln).groups() - ### import builtintest @@ -497,7 +350,7 @@ parser.add_option_group(group) group = OptionGroup(parser, "Output Options") - group.add_option("", "--no-machdep-info", dest="machdep_info", + group.add_option("", "--no-machdep-info", dest="use_machdep_info", help=("Don't put machine (instance) dependent " "variables in machine info"), action="store_false", default=True) @@ -538,25 +391,12 @@ raise # Collect machine and run information. - # + machine_info, run_info = machineinfo.get_machine_information( + opts.use_machdep_info) + # FIXME: Include information on test source versions. # # FIXME: Get more machine information? Cocoa.h hash, for example. - machine_info = {} - run_info = {} - info_targets = { 'machdep' : (run_info,machine_info)[opts.machdep_info], - 'machine' : machine_info, - 'run' : run_info } - for name,target in sysctl_info_table: - info_targets[target][name] = capture(['sysctl','-n',name], - include_stderr=True).strip() - - for ifc,addr in get_mac_addresses(): - # Ignore virtual machine mac addresses. - if ifc.startswith('vmnet'): - continue - - info_targets['machdep']['mac_addr.%s' % ifc] = addr for name,cmd in (('sys_cc_version', ('/usr/bin/gcc','-v')), ('sys_as_version', ('/usr/bin/as','-v','/dev/null')), @@ -564,14 +404,14 @@ run_info[name] = capture(cmd, include_stderr=True).strip() # Set command line machine and run information. - for target,params in (('machine',opts.machine_parameters), - ('run',opts.run_parameters)): + for info,params in ((machine_info, opts.machine_parameters), + (run_info, opts.run_parameters)): for entry in params: if '=' not in entry: - name,val = entry,'' + name,value = entry,'' else: - name,val = entry.split('=', 1) - info_targets[target][name] = val + name,value = entry.split('=', 1) + info[name] = value # Set user variables. variables = {} From daniel at zuster.org Mon Feb 20 20:53:27 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 02:53:27 -0000 Subject: [llvm-commits] [zorg] r151020 - in /zorg/trunk/lnt/lnt: testing/util/misc.py tests/compile.py Message-ID: <20120221025327.1EEF42A6C12F@llvm.org> Author: ddunbar Date: Mon Feb 20 20:53:26 2012 New Revision: 151020 URL: http://llvm.org/viewvc/llvm-project?rev=151020&view=rev Log: [lnt] lnt.tests.compile: Log output to stderr as well. - The core infrastructure should just support this, and use the logging module, but I am still lazy. Modified: zorg/trunk/lnt/lnt/testing/util/misc.py zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/testing/util/misc.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/util/misc.py?rev=151020&r1=151019&r2=151020&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/testing/util/misc.py (original) +++ zorg/trunk/lnt/lnt/testing/util/misc.py Mon Feb 20 20:53:26 2012 @@ -1,4 +1,27 @@ import datetime +class TeeStream(object): + """File-like object for writing to multiple output streams.""" + + def __init__(self, a, b): + self.a = a + self.b = b + + def __del__(self): + del self.a + del self.b + + def close(self): + self.a.close() + self.b.close() + + def write(self, value): + self.a.write(value) + self.b.write(value) + + def flush(self): + self.a.flush() + self.b.flush() + def timestamp(): return datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151020&r1=151019&r2=151020&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Mon Feb 20 20:53:26 2012 @@ -10,7 +10,7 @@ import lnt.testing.util.compilers from lnt.testing.util.commands import note, warning, error, fatal from lnt.testing.util.commands import capture, rm_f -from lnt.testing.util.misc import timestamp +from lnt.testing.util.misc import TeeStream, timestamp from lnt.testing.util import machineinfo # Interface to runN. @@ -458,6 +458,9 @@ test_log_path = os.path.join(g_output_dir, 'test.log') test_log = open(test_log_path, 'w') + # Tee the output to stderr as well. + test_log = TeeStream(test_log, sys.stderr) + # Execute the run. run_info.update(variables) run_info['tag'] = tag = 'compile' From daniel at zuster.org Mon Feb 20 20:53:33 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 02:53:33 -0000 Subject: [llvm-commits] [zorg] r151021 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221025333.349A72A6C12F@llvm.org> Author: ddunbar Date: Mon Feb 20 20:53:32 2012 New Revision: 151021 URL: http://llvm.org/viewvc/llvm-project?rev=151021&view=rev Log: [lnt] lnt.tests.compile: Add --show-tests option and sink test list generation into a method. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151021&r1=151020&r2=151021&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Mon Feb 20 20:53:32 2012 @@ -1,10 +1,12 @@ import errno import os +import platform import pprint import re import shlex import subprocess import sys +from datetime import datetime import lnt.testing import lnt.testing.util.compilers @@ -217,37 +219,37 @@ return lambda *args: fn(*args, **kw_args) g_output_dir = None -all_inputs = [('Sketch/Sketch+Accessibility/SKTGraphicView.m', True, ()), - ('403.gcc/combine.c', False, ('-DSPEC_CPU_MACOSX',))] - -flags_to_test = [('-O0',), ('-O0','-g',), ('-Os',)] -stages_to_test = ['driver', 'init', 'syntax', 'irgen_only', 'irgen', 'codegen', - 'assembly'] -all_tests = [] -for f in flags_to_test: - # FIXME: Note that the order matters here, because we need to make sure to - # generate the right PCH file before we try to use it. Ideally the testing - # infrastructure would just handle this. - all_tests.append(('pch-gen/Cocoa', - curry(test_compile, input='Cocoa_Prefix.h', - output='Cocoa_Prefix.h.gch', pch_input=None, - flags=f, stage='pch-gen'))) - for input,uses_pch,extra_flags in all_inputs: - name = input - output = os.path.splitext(os.path.basename(input))[0] + '.o' - for stage in stages_to_test: - pch_input = None - if uses_pch: - pch_input = 'Cocoa_Prefix.h.gch' - all_tests.append(('compile/%s/%s' % (name, stage), - curry(test_compile, input=input, output=output, - pch_input=pch_input, flags=f, stage=stage, - extra_flags=extra_flags))) - -tests_by_name = dict([(k,(k,v)) for k,v in all_tests]) -import platform -from datetime import datetime +def get_single_file_tests(): + all_inputs = [('Sketch/Sketch+Accessibility/SKTGraphicView.m', True, ()), + ('403.gcc/combine.c', False, ('-DSPEC_CPU_MACOSX',))] + + flags_to_test = [('-O0',), ('-O0','-g',), ('-Os',)] + stages_to_test = ['driver', 'init', 'syntax', 'irgen_only', 'irgen', + 'codegen', 'assembly'] + for f in flags_to_test: + # FIXME: Note that the order matters here, because we need to make sure + # to generate the right PCH file before we try to use it. Ideally the + # testing infrastructure would just handle this. + yield (('pch-gen/Cocoa', + curry(test_compile, input='Cocoa_Prefix.h', + output='Cocoa_Prefix.h.gch', pch_input=None, + flags=f, stage='pch-gen'))) + for input,uses_pch,extra_flags in all_inputs: + name = input + output = os.path.splitext(os.path.basename(input))[0] + '.o' + for stage in stages_to_test: + pch_input = None + if uses_pch: + pch_input = 'Cocoa_Prefix.h.gch' + yield (('compile/%s/%s' % (name, stage), + curry(test_compile, input=input, output=output, + pch_input=pch_input, flags=f, stage=stage, + extra_flags=extra_flags))) + +def get_tests(): + for item in get_single_file_tests(): + yield item ### @@ -343,10 +345,12 @@ group.add_option("", "--multisample", dest="run_count", metavar="N", help="Accumulate test data from multiple runs", action="store", type=int, default=3) + group.add_option("", "--show-tests", dest="show_tests", + help="Only list the availables tests that will be run", + action="store_true", default=False) group.add_option("", "--test", dest="tests", metavar="NAME", help="Individual test to run", - action="append", default=[], - choices=[k for k,v in all_tests]) + action="append", default=[]) parser.add_option_group(group) group = OptionGroup(parser, "Output Options") @@ -443,12 +447,30 @@ msg = '\n\t'.join(['using run info:'] + format.splitlines()) note(msg) + # Compute the list of all tests. + all_tests = get_tests() + + # Show the tests, if requested. + if opts.show_tests: + print >>sys.stderr, 'Available Tests' + for name in sorted(set(name for name,_ in all_tests)): + print >>sys.stderr, ' %s' % (name,) + print + raise SystemExit + # Find the tests to run. if not opts.tests: tests_to_run = list(all_tests) else: - tests_to_run = [(k,v) for k,v in all_tests - if k in opts.tests] + tests_to_run = [] + for name in opts.tests: + matching_tests = [test + for test in all_tests + if name == test[0]] + if not matching_tests: + parser.error(("invalid test name %r, use --show-tests to " + "see available tests") % name) + tests_to_run.extend(matching_tests) # Ensure output directory is available. if not os.path.exists(g_output_dir): @@ -485,7 +507,7 @@ testsamples.append(lnt.testing.TestSamples( test_name, samples)) except KeyboardInterrupt: - raise + raise SystemExit("\ninterrupted\n") except: import traceback print >>sys.stderr,'*** EXCEPTION DURING TEST, HALTING ***' From daniel at zuster.org Mon Feb 20 20:53:51 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 02:53:51 -0000 Subject: [llvm-commits] [zorg] r151022 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221025351.7102D2A6C12F@llvm.org> Author: ddunbar Date: Mon Feb 20 20:53:51 2012 New Revision: 151022 URL: http://llvm.org/viewvc/llvm-project?rev=151022&view=rev Log: [lnt] lnt.tests.compile: Add a --flags-to-test option to replace the default list of flags to test (mostly useful for dropping the testing time). Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151022&r1=151021&r2=151022&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Mon Feb 20 20:53:51 2012 @@ -220,11 +220,10 @@ g_output_dir = None -def get_single_file_tests(): +def get_single_file_tests(flags_to_test): all_inputs = [('Sketch/Sketch+Accessibility/SKTGraphicView.m', True, ()), ('403.gcc/combine.c', False, ('-DSPEC_CPU_MACOSX',))] - flags_to_test = [('-O0',), ('-O0','-g',), ('-Os',)] stages_to_test = ['driver', 'init', 'syntax', 'irgen_only', 'irgen', 'codegen', 'assembly'] for f in flags_to_test: @@ -247,8 +246,8 @@ pch_input=pch_input, flags=f, stage=stage, extra_flags=extra_flags))) -def get_tests(): - for item in get_single_file_tests(): +def get_tests(flags_to_test): + for item in get_single_file_tests(flags_to_test): yield item ### @@ -351,6 +350,9 @@ group.add_option("", "--test", dest="tests", metavar="NAME", help="Individual test to run", action="append", default=[]) + group.add_option("", "--flags-to-test", dest="flags_to_test", + help="Add a set of flags to test (space separated)", + metavar="FLAGLIST", action="append", default=[]) parser.add_option_group(group) group = OptionGroup(parser, "Output Options") @@ -447,8 +449,15 @@ msg = '\n\t'.join(['using run info:'] + format.splitlines()) note(msg) + # Compute the set of flags to test. + if not opts.flags_to_test: + flags_to_test = [('-O0',), ('-O0','-g',), ('-Os',)] + else: + flags_to_test = [string.split(' ') + for string in opts.flags_to_test] + # Compute the list of all tests. - all_tests = get_tests() + all_tests = get_tests(flags_to_test) # Show the tests, if requested. if opts.show_tests: From daniel at zuster.org Mon Feb 20 20:54:13 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 02:54:13 -0000 Subject: [llvm-commits] [zorg] r151023 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221025413.76C0B2A6C12F@llvm.org> Author: ddunbar Date: Mon Feb 20 20:54:13 2012 New Revision: 151023 URL: http://llvm.org/viewvc/llvm-project?rev=151023&view=rev Log: [lnt] lnt.tests.compile: Add support for "full build" tests. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151023&r1=151022&r2=151023&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Mon Feb 20 20:54:13 2012 @@ -1,17 +1,21 @@ import errno +import hashlib +import json import os import platform import pprint import re import shlex +import shutil import subprocess import sys +import zipfile from datetime import datetime import lnt.testing import lnt.testing.util.compilers from lnt.testing.util.commands import note, warning, error, fatal -from lnt.testing.util.commands import capture, rm_f +from lnt.testing.util.commands import capture, mkdir_p, rm_f from lnt.testing.util.misc import TeeStream, timestamp from lnt.testing.util import machineinfo @@ -19,19 +23,25 @@ # # FIXME: Simplify. # -# FIXME: Figure out a better way to deal with need to run as root. +# FIXME: Figure out a better way to deal with need to run as root. Maybe farm +# memory sampling process out into something we can setuid? Eek. def runN(args, N, cwd, preprocess_cmd=None, env=None, sample_mem=False, - ignore_stderr=False): + ignore_stderr=False, stdout=None, stderr=None): cmd = ['runN', '-a'] if sample_mem: cmd = ['sudo'] + cmd + ['-m'] if preprocess_cmd is not None: - cmd.append('-p', preprocess_cmd) + cmd.extend(('-p', preprocess_cmd)) + if stdout is not None: + cmd.extend(('--stdout', stdout)) + if stderr is not None: + cmd.extend(('--stderr', stderr)) cmd.append(str(int(N))) cmd.extend(args) if opts.verbose: - note("running %r" % cmd) + print >>test_log, "running: %s" % " ".join("'%s'" % arg + for arg in cmd) p = subprocess.Popen(args=cmd, stdin=None, stdout=subprocess.PIPE, @@ -62,16 +72,18 @@ return os.path.join(opts.test_suite_externals, "lnt-compile-suite-src", *names) -def get_output_path(name): - return os.path.join(g_output_dir, name) +def get_output_path(*names): + return os.path.join(g_output_dir, *names) def get_runN_test_data(name, variables, cmd, ignore_stderr=False, - sample_mem=False, only_mem=False): + sample_mem=False, only_mem=False, + stdout=None, stderr=None, preprocess_cmd=None): if only_mem and not sample_mem: raise ArgumentError,"only_mem doesn't make sense without sample_mem" data = runN(cmd, variables.get('run_count'), cwd='/tmp', - ignore_stderr=ignore_stderr, sample_mem=sample_mem) + ignore_stderr=ignore_stderr, sample_mem=sample_mem, + stdout=stdout, stderr=stderr, preprocess_cmd=preprocess_cmd) if data is not None: if data.get('version') != 0: raise ValueError,'unknown runN data format' @@ -214,12 +226,125 @@ return test_cc_command(name, run_info, variables, input, output, flags, extra_flags, has_output, ignore_stderr, can_memprof) -# Build the test map. +def test_build(name, run_info, variables, project): + # Check if we need to expand the archive into the sandbox. + archive_path = get_input_path(opts, project['archive']) + with open(archive_path) as f: + archive_hash = hashlib.md5(f.read()).hexdigest() + + # Compute the path to unpack to. + source_path = get_output_path("..", "Sources", project['name']) + + # Load the hash of the last unpack, in case the archive has been updated. + last_unpack_hash_path = os.path.join(source_path, "last_unpack_hash.txt") + if os.path.exists(last_unpack_hash_path): + with open(last_unpack_hash_path) as f: + last_unpack_hash = f.read() + else: + last_unpack_hash = None + + # Unpack if necessary. + if last_unpack_hash == archive_hash: + print >>test_log, '%s: reusing sources %r (already unpacked)' % ( + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'), name) + else: + # Remove any existing content, if necessary. + try: + shutil.rmtree(source_path) + except OSError, e: + if e.errno != errno.ENOENT: + raise + + # Extract the zip file. + # + # We shell out to unzip here because zipfile's extractall does not + # appear to preserve permissions properly. + mkdir_p(source_path) + print >>test_log, '%s: extracting sources for %r' % ( + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'), name) + p = subprocess.Popen(args=['unzip', '-q', archive_path], + stdin=None, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=source_path) + stdout,stderr = p.communicate() + if p.wait() != 0: + fatal(("unable to extract archive %r at %r\n" + "-- stdout --\n%s\n" + "-- stderr --\n%s\n") % (archive_path, source_path, + stdout, stderr)) + if p.wait() != 0: + fatal + + # Apply the patch file, if necessary. + patch_file = project.get('patch_file') + if patch_file: + print >>test_log, '%s: applying patch file %r for %r' % ( + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'), + patch_file, name) + patch_file_path = get_input_path(opts, patch_file) + p = subprocess.Popen(args=['patch', '-i', patch_file_path, + '-p', '1'], + stdin=None, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=source_path) + stdout,stderr = p.communicate() + if p.wait() != 0: + fatal(("unable to apply patch file %r in %r\n" + "-- stdout --\n%s\n" + "-- stderr --\n%s\n") % (patch_file_path, source_path, + stdout, stderr)) + + # Write the hash tag. + with open(last_unpack_hash_path, "w") as f: + f.write(archive_hash) + + # Form the test build command. + build_info = project['build_info'] + if build_info['style'].startswith('xcode-'): + file_path = os.path.join(source_path, build_info['file']) + cmd = ['xcodebuild'] + + # Add the arguments to select the build target. + if build_info['style'] == 'xcode-project': + cmd.extend(('-target', build_info['target'], + '-project', file_path)) + elif build_info['style'] == 'xcode-workspace': + cmd.extend(('-scheme', build_info['scheme'], + '-workspace', file_path)) + else: + fatal("unknown build style in project: %r" % project) + + # Add arguments to ensure output files go into our build directory. + output_base = get_output_path(project['name']) + build_base = os.path.join(output_base, 'build') + cmd.append('OBJROOT=%s' % (os.path.join(build_base, 'obj'))) + cmd.append('SYMROOT=%s' % (os.path.join(build_base, 'sym'))) + cmd.append('DSTROOT=%s' % (os.path.join(build_base, 'dst'))) + else: + fatal("unknown build style in project: %r" % project) + + # Create the output base directory. + mkdir_p(output_base) + + # Collect the samples. + print >>test_log, '%s: executing full build: %s' % ( + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'), + " ".join("'%s'" % arg + for arg in cmd)) + stdout_path = os.path.join(output_base, "stdout.log") + stderr_path = os.path.join(output_base, "stderr.log") + for res in get_runN_test_data(name, variables, cmd, + stdout=stdout_path, stderr=stderr_path, + preprocess_cmd='rm -rf "%s"' % (build_base,)): + yield res + +### + def curry(fn, **kw_args): return lambda *args: fn(*args, **kw_args) -g_output_dir = None - def get_single_file_tests(flags_to_test): all_inputs = [('Sketch/Sketch+Accessibility/SKTGraphicView.m', True, ()), ('403.gcc/combine.c', False, ('-DSPEC_CPU_MACOSX',))] @@ -230,10 +355,10 @@ # FIXME: Note that the order matters here, because we need to make sure # to generate the right PCH file before we try to use it. Ideally the # testing infrastructure would just handle this. - yield (('pch-gen/Cocoa', - curry(test_compile, input='Cocoa_Prefix.h', - output='Cocoa_Prefix.h.gch', pch_input=None, - flags=f, stage='pch-gen'))) + yield ('pch-gen/Cocoa', + curry(test_compile, input='Cocoa_Prefix.h', + output='Cocoa_Prefix.h.gch', pch_input=None, + flags=f, stage='pch-gen')) for input,uses_pch,extra_flags in all_inputs: name = input output = os.path.splitext(os.path.basename(input))[0] + '.o' @@ -241,26 +366,40 @@ pch_input = None if uses_pch: pch_input = 'Cocoa_Prefix.h.gch' - yield (('compile/%s/%s' % (name, stage), - curry(test_compile, input=input, output=output, - pch_input=pch_input, flags=f, stage=stage, - extra_flags=extra_flags))) - -def get_tests(flags_to_test): + yield ('compile/%s/%s' % (name, stage), + curry(test_compile, input=input, output=output, + pch_input=pch_input, flags=f, stage=stage, + extra_flags=extra_flags)) + +def get_full_build_tests(test_suite_externals): + # Load the project description file from the externals. + with open(os.path.join(test_suite_externals, "lnt-compile-suite-src", + "project_list.json")) as f: + data = json.load(f) + + for project in data['projects']: + # Check the style. + yield ('build/%s' % (project['name'],), + curry(test_build, project=project)) + +def get_tests(test_suite_externals, flags_to_test): for item in get_single_file_tests(flags_to_test): yield item + for item in get_full_build_tests(test_suite_externals): + yield item + ### import builtintest from optparse import OptionParser, OptionGroup +g_output_dir = None usage_info = """ -Script for testing a few simple dimensions of compile time performance -on individual files. +Script for testing compile time performance. -This is only intended to test the raw compiler performance, not its scalability -or its performance in parallel builds. +Currently this is only intended to test the raw compiler performance, not its +scalability or its performance in parallel builds. This tests: - PCH Generation for Cocoa.h @@ -275,6 +414,8 @@ o File Sizes o Memory Usage o Time + - Full Build Times + o Total Build Time (serialized) (using xcodebuild) TODO: - Objective-C Compile Time, with PCH @@ -299,6 +440,14 @@ - emit-llvm (.bc output time and size, mostly to track output file size) - S (codegen time and size) - c (assembly time and size) + +FIXME: In the past, we have generated breakdown timings of full builds using +Make or xcodebuild by interposing scripts to stub out parts of the compilation +process. This is fragile, but can also be very useful when trying to understand +where the time is going in a full build. + +FIXME: We may want to consider timing non-serial builds in order to start +measuring things like the full-system-performance impact on the compiler. """ class CompileTest(builtintest.BuiltinTest): @@ -457,7 +606,7 @@ for string in opts.flags_to_test] # Compute the list of all tests. - all_tests = get_tests(flags_to_test) + all_tests = get_tests(opts.test_suite_externals, flags_to_test) # Show the tests, if requested. if opts.show_tests: @@ -486,6 +635,7 @@ os.mkdir(g_output_dir) # Create the test log. + global test_log test_log_path = os.path.join(g_output_dir, 'test.log') test_log = open(test_log_path, 'w') @@ -525,7 +675,7 @@ print >>sys.stderr,'--' run_info['had_errors'] = 1 end_time = datetime.utcnow() - print >>test_log, '%s: run complete' % start_time.strftime( + print >>test_log, '%s: run complete' % end_time.strftime( '%Y-%m-%d %H:%M:%S') test_log.close() From chandlerc at gmail.com Mon Feb 20 21:39:37 2012 From: chandlerc at gmail.com (Chandler Carruth) Date: Tue, 21 Feb 2012 03:39:37 -0000 Subject: [llvm-commits] [llvm] r151024 - in /llvm/trunk: include/llvm/ADT/Triple.h include/llvm/Support/TargetRegistry.h lib/MC/MCDisassembler/EDDisassembler.cpp lib/Support/Triple.cpp unittests/ADT/TripleTest.cpp Message-ID: <20120221033937.384542A6C12F@llvm.org> Author: chandlerc Date: Mon Feb 20 21:39:36 2012 New Revision: 151024 URL: http://llvm.org/viewvc/llvm-project?rev=151024&view=rev Log: Switch the llvm::Triple class to immediately parse the triple string on construction. Simplify its interface, implementation, and users accordingly as there is no longer an 'uninitialized' state to check for. Also, fixes a bug lurking in the interface as there was one method that didn't correctly check for initialization. Modified: llvm/trunk/include/llvm/ADT/Triple.h llvm/trunk/include/llvm/Support/TargetRegistry.h llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp llvm/trunk/lib/Support/Triple.cpp llvm/trunk/unittests/ADT/TripleTest.cpp Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=151024&r1=151023&r2=151024&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Mon Feb 20 21:39:36 2012 @@ -64,9 +64,7 @@ ptx32, // PTX: ptx (32-bit) ptx64, // PTX: ptx (64-bit) le32, // le32: generic little-endian 32-bit CPU (PNaCl / Emscripten) - amdil, // amdil: amd IL - - InvalidArch + amdil // amdil: amd IL }; enum VendorType { UnknownVendor, @@ -113,31 +111,29 @@ private: std::string Data; - /// The parsed arch type (or InvalidArch if uninitialized). - mutable ArchType Arch; + /// The parsed arch type. + ArchType Arch; /// The parsed vendor type. - mutable VendorType Vendor; + VendorType Vendor; /// The parsed OS type. - mutable OSType OS; + OSType OS; /// The parsed Environment type. - mutable EnvironmentType Environment; + EnvironmentType Environment; - bool isInitialized() const { return Arch != InvalidArch; } static ArchType ParseArch(StringRef ArchName); static VendorType ParseVendor(StringRef VendorName); static OSType ParseOS(StringRef OSName); static EnvironmentType ParseEnvironment(StringRef EnvironmentName); - void Parse() const; public: /// @name Constructors /// @{ /// \brief Default constructor produces an empty, invalid triple. - Triple() : Data(), Arch(InvalidArch) {} + Triple() : Data(), Arch(), Vendor(), OS(), Environment() {} explicit Triple(const Twine &Str); Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr); @@ -159,22 +155,13 @@ /// @{ /// getArch - Get the parsed architecture type of this triple. - ArchType getArch() const { - if (!isInitialized()) Parse(); - return Arch; - } + ArchType getArch() const { return Arch; } /// getVendor - Get the parsed vendor type of this triple. - VendorType getVendor() const { - if (!isInitialized()) Parse(); - return Vendor; - } + VendorType getVendor() const { return Vendor; } /// getOS - Get the parsed operating system type of this triple. - OSType getOS() const { - if (!isInitialized()) Parse(); - return OS; - } + OSType getOS() const { return OS; } /// hasEnvironment - Does this triple have the optional environment /// (fourth) component? @@ -183,10 +170,7 @@ } /// getEnvironment - Get the parsed environment type of this triple. - EnvironmentType getEnvironment() const { - if (!isInitialized()) Parse(); - return Environment; - } + EnvironmentType getEnvironment() const { return Environment; } /// getOSVersion - Parse the version number from the OS name component of the /// triple, if present. Modified: llvm/trunk/include/llvm/Support/TargetRegistry.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetRegistry.h?rev=151024&r1=151023&r2=151024&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TargetRegistry.h (original) +++ llvm/trunk/include/llvm/Support/TargetRegistry.h Mon Feb 20 21:39:36 2012 @@ -786,7 +786,7 @@ /// extern "C" void LLVMInitializeFooTargetInfo() { /// RegisterTarget X(TheFooTarget, "foo", "Foo description"); /// } - template struct RegisterTarget { RegisterTarget(Target &T, const char *Name, const char *Desc) { Modified: llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp?rev=151024&r1=151023&r2=151024&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp (original) +++ llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp Mon Feb 20 21:39:36 2012 @@ -47,8 +47,7 @@ { Triple::x86, "i386-unknown-unknown" }, { Triple::x86_64, "x86_64-unknown-unknown" }, { Triple::arm, "arm-unknown-unknown" }, - { Triple::thumb, "thumb-unknown-unknown" }, - { Triple::InvalidArch, NULL, } + { Triple::thumb, "thumb-unknown-unknown" } }; /// infoFromArch - Returns the TripleMap corresponding to a given architecture, @@ -128,8 +127,6 @@ ErrorStream(nulls()), Key(key), TgtTriple(key.Triple.c_str()) { - if (TgtTriple.getArch() == Triple::InvalidArch) - return; LLVMSyntaxVariant = getLLVMSyntaxVariant(TgtTriple.getArch(), key.Syntax); Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=151024&r1=151023&r2=151024&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Mon Feb 20 21:39:36 2012 @@ -17,7 +17,6 @@ const char *Triple::getArchTypeName(ArchType Kind) { switch (Kind) { - case InvalidArch: return ""; case UnknownArch: return "unknown"; case arm: return "arm"; @@ -291,24 +290,19 @@ .Default(UnknownEnvironment); } -void Triple::Parse() const { - assert(!isInitialized() && "Invalid parse call."); - - Arch = ParseArch(getArchName()); - Vendor = ParseVendor(getVendorName()); - OS = ParseOS(getOSName()); - Environment = ParseEnvironment(getEnvironmentName()); - - assert(isInitialized() && "Failed to initialize!"); -} - /// \brief Construct a triple from the string representation provided. /// /// This doesn't actually parse the string representation eagerly. Instead it /// stores it, and tracks the fact that it hasn't been parsed. The first time /// any of the structural queries are made, the string is parsed and the /// results cached in various members. -Triple::Triple(const Twine &Str) : Data(Str.str()), Arch(InvalidArch) {} +Triple::Triple(const Twine &Str) + : Data(Str.str()), + Arch(ParseArch(getArchName())), + Vendor(ParseVendor(getVendorName())), + OS(ParseOS(getOSName())), + Environment(ParseEnvironment(getEnvironmentName())) { +} /// \brief Construct a triple from string representations of the architecture, /// vendor, and OS. @@ -318,7 +312,10 @@ /// string, and lazily parses it on use. Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr) : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()), - Arch(InvalidArch) { + Arch(ParseArch(ArchStr.str())), + Vendor(ParseVendor(VendorStr.str())), + OS(ParseOS(OSStr.str())), + Environment() { } /// \brief Construct a triple from string representations of the architecture, @@ -331,7 +328,10 @@ const Twine &EnvironmentStr) : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') + EnvironmentStr).str()), - Arch(InvalidArch) { + Arch(ParseArch(ArchStr.str())), + Vendor(ParseVendor(VendorStr.str())), + OS(ParseOS(OSStr.str())), + Environment(ParseEnvironment(EnvironmentStr.str())) { } std::string Triple::normalize(StringRef Str) { @@ -577,8 +577,7 @@ } void Triple::setTriple(const Twine &Str) { - Data = Str.str(); - Arch = InvalidArch; + *this = Triple(Str); } void Triple::setArch(ArchType Kind) { @@ -632,7 +631,6 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) { switch (Arch) { case llvm::Triple::UnknownArch: - case llvm::Triple::InvalidArch: return 0; case llvm::Triple::msp430: @@ -682,7 +680,6 @@ Triple T(*this); switch (getArch()) { case Triple::UnknownArch: - case Triple::InvalidArch: case Triple::msp430: T.setArch(UnknownArch); break; @@ -718,7 +715,6 @@ Triple Triple::get64BitArchVariant() const { Triple T(*this); switch (getArch()) { - case Triple::InvalidArch: case Triple::UnknownArch: case Triple::amdil: case Triple::arm: Modified: llvm/trunk/unittests/ADT/TripleTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/TripleTest.cpp?rev=151024&r1=151023&r2=151024&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/TripleTest.cpp (original) +++ llvm/trunk/unittests/ADT/TripleTest.cpp Mon Feb 20 21:39:36 2012 @@ -154,7 +154,7 @@ // Check that normalizing a permutated set of valid components returns a // triple with the unpermuted components. StringRef C[4]; - for (int Arch = 1+Triple::UnknownArch; Arch < Triple::InvalidArch; ++Arch) { + for (int Arch = 1+Triple::UnknownArch; Arch <= Triple::amdil; ++Arch) { C[0] = Triple::getArchTypeName(Triple::ArchType(Arch)); for (int Vendor = 1+Triple::UnknownVendor; Vendor <= Triple::PC; ++Vendor) { @@ -273,11 +273,6 @@ EXPECT_FALSE(T.isArch32Bit()); EXPECT_FALSE(T.isArch64Bit()); - T.setArch(Triple::InvalidArch); - EXPECT_FALSE(T.isArch16Bit()); - EXPECT_FALSE(T.isArch32Bit()); - EXPECT_FALSE(T.isArch64Bit()); - T.setArch(Triple::arm); EXPECT_FALSE(T.isArch16Bit()); EXPECT_TRUE(T.isArch32Bit()); From rafael.espindola at gmail.com Mon Feb 20 21:48:30 2012 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 21 Feb 2012 03:48:30 -0000 Subject: [llvm-commits] [llvm] r151025 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Message-ID: <20120221034830.76C1D2A6C12F@llvm.org> Author: rafael Date: Mon Feb 20 21:48:30 2012 New Revision: 151025 URL: http://llvm.org/viewvc/llvm-project?rev=151025&view=rev Log: Avoid warning on non assert builds. Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=151025&r1=151024&r2=151025&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Feb 20 21:48:30 2012 @@ -503,8 +503,9 @@ V = InsertNoopCastOfTo(V, Type::getInt8PtrTy(Ty->getContext(), PTy->getAddressSpace())); - Instruction *Inst = dyn_cast(V); - assert(!Inst || SE.DT->properlyDominates(Inst, Builder.GetInsertPoint())); + assert(!dyn_cast(V) || + SE.DT->properlyDominates(dyn_cast(V), + Builder.GetInsertPoint())); // Expand the operands for a plain byte offset. Value *Idx = expandCodeFor(SE.getAddExpr(Ops), Ty); From rafael.espindola at gmail.com Mon Feb 20 21:51:14 2012 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 21 Feb 2012 03:51:14 -0000 Subject: [llvm-commits] [llvm] r151026 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Message-ID: <20120221035114.94AC72A6C12F@llvm.org> Author: rafael Date: Mon Feb 20 21:51:14 2012 New Revision: 151026 URL: http://llvm.org/viewvc/llvm-project?rev=151026&view=rev Log: Use more idiomatic assert. Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=151026&r1=151025&r2=151026&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Feb 20 21:51:14 2012 @@ -503,8 +503,8 @@ V = InsertNoopCastOfTo(V, Type::getInt8PtrTy(Ty->getContext(), PTy->getAddressSpace())); - assert(!dyn_cast(V) || - SE.DT->properlyDominates(dyn_cast(V), + assert(!isa(V) || + SE.DT->properlyDominates(cast(V), Builder.GetInsertPoint())); // Expand the operands for a plain byte offset. From matthewbg at google.com Mon Feb 20 21:57:40 2012 From: matthewbg at google.com (Matt Beaumont-Gay) Date: Mon, 20 Feb 2012 19:57:40 -0800 Subject: [llvm-commits] [llvm] r151024 - in /llvm/trunk: include/llvm/ADT/Triple.h include/llvm/Support/TargetRegistry.h lib/MC/MCDisassembler/EDDisassembler.cpp lib/Support/Triple.cpp unittests/ADT/TripleTest.cpp In-Reply-To: <20120221033937.384542A6C12F@llvm.org> References: <20120221033937.384542A6C12F@llvm.org> Message-ID: Just a couple of nits. On Mon, Feb 20, 2012 at 19:39, Chandler Carruth wrote: > Author: chandlerc > Date: Mon Feb 20 21:39:36 2012 > New Revision: 151024 > > URL: http://llvm.org/viewvc/llvm-project?rev=151024&view=rev > Log: > Switch the llvm::Triple class to immediately parse the triple string on > construction. Simplify its interface, implementation, and users > accordingly as there is no longer an 'uninitialized' state to check for. > Also, fixes a bug lurking in the interface as there was one method that > didn't correctly check for initialization. > > Modified: > ? ?llvm/trunk/include/llvm/ADT/Triple.h > ? ?llvm/trunk/include/llvm/Support/TargetRegistry.h > ? ?llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp > ? ?llvm/trunk/lib/Support/Triple.cpp > ? ?llvm/trunk/unittests/ADT/TripleTest.cpp > > Modified: llvm/trunk/include/llvm/ADT/Triple.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=151024&r1=151023&r2=151024&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/ADT/Triple.h (original) > +++ llvm/trunk/include/llvm/ADT/Triple.h Mon Feb 20 21:39:36 2012 > @@ -64,9 +64,7 @@ > ? ? ptx32, ? // PTX: ptx (32-bit) > ? ? ptx64, ? // PTX: ptx (64-bit) > ? ? le32, ? ?// le32: generic little-endian 32-bit CPU (PNaCl / Emscripten) > - ? ?amdil, ? // amdil: amd IL > - > - ? ?InvalidArch > + ? ?amdil ? // amdil: amd IL > ? }; > ? enum VendorType { > ? ? UnknownVendor, > @@ -113,31 +111,29 @@ > ?private: > ? std::string Data; > > - ?/// The parsed arch type (or InvalidArch if uninitialized). > - ?mutable ArchType Arch; > + ?/// The parsed arch type. > + ?ArchType Arch; > > ? /// The parsed vendor type. > - ?mutable VendorType Vendor; > + ?VendorType Vendor; > > ? /// The parsed OS type. > - ?mutable OSType OS; > + ?OSType OS; > > ? /// The parsed Environment type. > - ?mutable EnvironmentType Environment; > + ?EnvironmentType Environment; > > - ?bool isInitialized() const { return Arch != InvalidArch; } > ? static ArchType ParseArch(StringRef ArchName); > ? static VendorType ParseVendor(StringRef VendorName); > ? static OSType ParseOS(StringRef OSName); > ? static EnvironmentType ParseEnvironment(StringRef EnvironmentName); > - ?void Parse() const; > > ?public: > ? /// @name Constructors > ? /// @{ > > ? /// \brief Default constructor produces an empty, invalid triple. Maybe update this comment? All fields are unknown, not invalid. > - ?Triple() : Data(), Arch(InvalidArch) {} > + ?Triple() : Data(), Arch(), Vendor(), OS(), Environment() {} > > ? explicit Triple(const Twine &Str); > ? Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr); > @@ -159,22 +155,13 @@ > ? /// @{ > > ? /// getArch - Get the parsed architecture type of this triple. > - ?ArchType getArch() const { > - ? ?if (!isInitialized()) Parse(); > - ? ?return Arch; > - ?} > + ?ArchType getArch() const { return Arch; } > > ? /// getVendor - Get the parsed vendor type of this triple. > - ?VendorType getVendor() const { > - ? ?if (!isInitialized()) Parse(); > - ? ?return Vendor; > - ?} > + ?VendorType getVendor() const { return Vendor; } > > ? /// getOS - Get the parsed operating system type of this triple. > - ?OSType getOS() const { > - ? ?if (!isInitialized()) Parse(); > - ? ?return OS; > - ?} > + ?OSType getOS() const { return OS; } > > ? /// hasEnvironment - Does this triple have the optional environment > ? /// (fourth) component? > @@ -183,10 +170,7 @@ > ? } > > ? /// getEnvironment - Get the parsed environment type of this triple. > - ?EnvironmentType getEnvironment() const { > - ? ?if (!isInitialized()) Parse(); > - ? ?return Environment; > - ?} > + ?EnvironmentType getEnvironment() const { return Environment; } > > ? /// getOSVersion - Parse the version number from the OS name component of the > ? /// triple, if present. > > Modified: llvm/trunk/include/llvm/Support/TargetRegistry.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetRegistry.h?rev=151024&r1=151023&r2=151024&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Support/TargetRegistry.h (original) > +++ llvm/trunk/include/llvm/Support/TargetRegistry.h Mon Feb 20 21:39:36 2012 > @@ -786,7 +786,7 @@ > ? /// extern "C" void LLVMInitializeFooTargetInfo() { > ? /// ? RegisterTarget X(TheFooTarget, "foo", "Foo description"); > ? /// } > - ?template + ?template ? ? ? ? ? ?bool HasJIT = false> > ? struct RegisterTarget { > ? ? RegisterTarget(Target &T, const char *Name, const char *Desc) { > > Modified: llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp?rev=151024&r1=151023&r2=151024&view=diff > ============================================================================== > --- llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp (original) > +++ llvm/trunk/lib/MC/MCDisassembler/EDDisassembler.cpp Mon Feb 20 21:39:36 2012 > @@ -47,8 +47,7 @@ > ? { Triple::x86, ? ? ? ? ?"i386-unknown-unknown" ? ?}, > ? { Triple::x86_64, ? ? ? "x86_64-unknown-unknown" ?}, > ? { Triple::arm, ? ? ? ? ?"arm-unknown-unknown" ? ? }, > - ?{ Triple::thumb, ? ? ? ?"thumb-unknown-unknown" ? }, > - ?{ Triple::InvalidArch, ?NULL, ? ? ? ? ? ? ? ? ? ? } > + ?{ Triple::thumb, ? ? ? ?"thumb-unknown-unknown" ? } > ?}; > > ?/// infoFromArch - Returns the TripleMap corresponding to a given architecture, > @@ -128,8 +127,6 @@ > ? ErrorStream(nulls()), > ? Key(key), > ? TgtTriple(key.Triple.c_str()) { > - ?if (TgtTriple.getArch() == Triple::InvalidArch) > - ? ?return; > > ? LLVMSyntaxVariant = getLLVMSyntaxVariant(TgtTriple.getArch(), key.Syntax); > > > Modified: llvm/trunk/lib/Support/Triple.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=151024&r1=151023&r2=151024&view=diff > ============================================================================== > --- llvm/trunk/lib/Support/Triple.cpp (original) > +++ llvm/trunk/lib/Support/Triple.cpp Mon Feb 20 21:39:36 2012 > @@ -17,7 +17,6 @@ > > ?const char *Triple::getArchTypeName(ArchType Kind) { > ? switch (Kind) { > - ?case InvalidArch: return ""; > ? case UnknownArch: return "unknown"; > > ? case arm: ? ? return "arm"; > @@ -291,24 +290,19 @@ > ? ? .Default(UnknownEnvironment); > ?} > > -void Triple::Parse() const { > - ?assert(!isInitialized() && "Invalid parse call."); > - > - ?Arch = ParseArch(getArchName()); > - ?Vendor = ParseVendor(getVendorName()); > - ?OS = ParseOS(getOSName()); > - ?Environment = ParseEnvironment(getEnvironmentName()); > - > - ?assert(isInitialized() && "Failed to initialize!"); > -} > - > ?/// \brief Construct a triple from the string representation provided. > ?/// > ?/// This doesn't actually parse the string representation eagerly. Instead it > ?/// stores it, and tracks the fact that it hasn't been parsed. The first time > ?/// any of the structural queries are made, the string is parsed and the > ?/// results cached in various members. Stale comment. > -Triple::Triple(const Twine &Str) : Data(Str.str()), Arch(InvalidArch) {} > +Triple::Triple(const Twine &Str) > + ? ?: Data(Str.str()), > + ? ? ?Arch(ParseArch(getArchName())), > + ? ? ?Vendor(ParseVendor(getVendorName())), > + ? ? ?OS(ParseOS(getOSName())), > + ? ? ?Environment(ParseEnvironment(getEnvironmentName())) { > +} > > ?/// \brief Construct a triple from string representations of the architecture, > ?/// vendor, and OS. > @@ -318,7 +312,10 @@ > ?/// string, and lazily parses it on use. > ?Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr) > ? ? : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()), > - ? ? ?Arch(InvalidArch) { > + ? ? ?Arch(ParseArch(ArchStr.str())), > + ? ? ?Vendor(ParseVendor(VendorStr.str())), > + ? ? ?OS(ParseOS(OSStr.str())), > + ? ? ?Environment() { > ?} > > ?/// \brief Construct a triple from string representations of the architecture, > @@ -331,7 +328,10 @@ > ? ? ? ? ? ? ? ?const Twine &EnvironmentStr) > ? ? : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') + > ? ? ? ? ? ? EnvironmentStr).str()), > - ? ? ?Arch(InvalidArch) { > + ? ? ?Arch(ParseArch(ArchStr.str())), > + ? ? ?Vendor(ParseVendor(VendorStr.str())), > + ? ? ?OS(ParseOS(OSStr.str())), > + ? ? ?Environment(ParseEnvironment(EnvironmentStr.str())) { > ?} > > ?std::string Triple::normalize(StringRef Str) { > @@ -577,8 +577,7 @@ > ?} > > ?void Triple::setTriple(const Twine &Str) { > - ?Data = Str.str(); > - ?Arch = InvalidArch; > + ?*this = Triple(Str); > ?} > > ?void Triple::setArch(ArchType Kind) { > @@ -632,7 +631,6 @@ > ?static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) { > ? switch (Arch) { > ? case llvm::Triple::UnknownArch: > - ?case llvm::Triple::InvalidArch: > ? ? return 0; > > ? case llvm::Triple::msp430: > @@ -682,7 +680,6 @@ > ? Triple T(*this); > ? switch (getArch()) { > ? case Triple::UnknownArch: > - ?case Triple::InvalidArch: > ? case Triple::msp430: > ? ? T.setArch(UnknownArch); > ? ? break; > @@ -718,7 +715,6 @@ > ?Triple Triple::get64BitArchVariant() const { > ? Triple T(*this); > ? switch (getArch()) { > - ?case Triple::InvalidArch: > ? case Triple::UnknownArch: > ? case Triple::amdil: > ? case Triple::arm: > > Modified: llvm/trunk/unittests/ADT/TripleTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/TripleTest.cpp?rev=151024&r1=151023&r2=151024&view=diff > ============================================================================== > --- llvm/trunk/unittests/ADT/TripleTest.cpp (original) > +++ llvm/trunk/unittests/ADT/TripleTest.cpp Mon Feb 20 21:39:36 2012 > @@ -154,7 +154,7 @@ > ? // Check that normalizing a permutated set of valid components returns a > ? // triple with the unpermuted components. > ? StringRef C[4]; > - ?for (int Arch = 1+Triple::UnknownArch; Arch < Triple::InvalidArch; ++Arch) { > + ?for (int Arch = 1+Triple::UnknownArch; Arch <= Triple::amdil; ++Arch) { The loop condition here seems brittle. Not sure how to make it more robust, though. From atrick at apple.com Mon Feb 20 22:51:17 2012 From: atrick at apple.com (Andrew Trick) Date: Tue, 21 Feb 2012 04:51:17 -0000 Subject: [llvm-commits] [llvm] r151030 - /llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Message-ID: <20120221045117.CEA232A6C12F@llvm.org> Author: atrick Date: Mon Feb 20 22:51:17 2012 New Revision: 151030 URL: http://llvm.org/viewvc/llvm-project?rev=151030&view=rev Log: whitespace Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=151030&r1=151029&r2=151030&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Mon Feb 20 22:51:17 2012 @@ -20,7 +20,7 @@ #include namespace llvm { - + /// MachineRegisterInfo - Keep track of information for virtual and physical /// registers, including vreg register classes, use/def chains for registers, /// etc. @@ -46,11 +46,11 @@ /// the allocator should prefer the physical register allocated to the virtual /// register of the hint. IndexedMap, VirtReg2IndexFunctor> RegAllocHints; - + /// PhysRegUseDefLists - This is an array of the head of the use/def list for /// physical registers. - MachineOperand **PhysRegUseDefLists; - + MachineOperand **PhysRegUseDefLists; + /// UsedPhysRegs - This is a bit vector that is computed and set by the /// register allocator, and must be kept up to date by passes that run after /// register allocation (though most don't modify this). This is used @@ -79,7 +79,7 @@ /// stored in the second element. std::vector > LiveIns; std::vector LiveOuts; - + MachineRegisterInfo(const MachineRegisterInfo&); // DO NOT IMPLEMENT void operator=(const MachineRegisterInfo&); // DO NOT IMPLEMENT public: @@ -155,7 +155,7 @@ return use_iterator(getRegUseDefListHead(RegNo)); } static use_iterator use_end() { return use_iterator(0); } - + /// use_empty - Return true if there are no instructions using the specified /// register. bool use_empty(unsigned RegNo) const { return use_begin(RegNo) == use_end(); } @@ -171,7 +171,7 @@ return use_nodbg_iterator(getRegUseDefListHead(RegNo)); } static use_nodbg_iterator use_nodbg_end() { return use_nodbg_iterator(0); } - + /// use_nodbg_empty - Return true if there are no non-Debug instructions /// using the specified register. bool use_nodbg_empty(unsigned RegNo) const { @@ -194,7 +194,7 @@ /// That function will return NULL if the virtual registers have incompatible /// constraints. void replaceRegWith(unsigned FromReg, unsigned ToReg); - + /// getRegUseDefListHead - Return the head pointer for the register use/def /// list for the specified virtual or physical register. MachineOperand *&getRegUseDefListHead(unsigned RegNo) { @@ -202,7 +202,7 @@ return VRegInfo[RegNo].second; return PhysRegUseDefLists[RegNo]; } - + MachineOperand *getRegUseDefListHead(unsigned RegNo) const { if (TargetRegisterInfo::isVirtualRegister(RegNo)) return VRegInfo[RegNo].second; @@ -219,7 +219,7 @@ /// optimization passes which extend register lifetimes and need only /// preserve conservative kill flag information. void clearKillFlags(unsigned Reg) const; - + #ifndef NDEBUG void dumpUses(unsigned RegNo) const; #endif @@ -232,7 +232,7 @@ //===--------------------------------------------------------------------===// // Virtual Register Info //===--------------------------------------------------------------------===// - + /// getRegClass - Return the register class of the specified virtual register. /// const TargetRegisterClass *getRegClass(unsigned Reg) const { @@ -298,7 +298,7 @@ //===--------------------------------------------------------------------===// // Physical Register Use Info //===--------------------------------------------------------------------===// - + /// isPhysRegUsed - Return true if the specified register is used in this /// function. This only works after register allocation. bool isPhysRegUsed(unsigned Reg) const { @@ -371,14 +371,14 @@ //===--------------------------------------------------------------------===// // LiveIn/LiveOut Management //===--------------------------------------------------------------------===// - + /// addLiveIn/Out - Add the specified register as a live in/out. Note that it /// is an error to add the same register to the same set more than once. void addLiveIn(unsigned Reg, unsigned vreg = 0) { LiveIns.push_back(std::make_pair(Reg, vreg)); } void addLiveOut(unsigned Reg) { LiveOuts.push_back(Reg); } - + // Iteration support for live in/out sets. These sets are kept in sorted // order by their register number. typedef std::vector >::const_iterator @@ -410,7 +410,7 @@ private: void HandleVRegListReallocation(); - + public: /// defusechain_iterator - This class provides iterator support for machine /// operands in the function that use or define a specific register. If @@ -438,31 +438,31 @@ MachineInstr, ptrdiff_t>::reference reference; typedef std::iterator::pointer pointer; - + defusechain_iterator(const defusechain_iterator &I) : Op(I.Op) {} defusechain_iterator() : Op(0) {} - + bool operator==(const defusechain_iterator &x) const { return Op == x.Op; } bool operator!=(const defusechain_iterator &x) const { return !operator==(x); } - + /// atEnd - return true if this iterator is equal to reg_end() on the value. bool atEnd() const { return Op == 0; } - + // Iterator traversal: forward iteration only defusechain_iterator &operator++() { // Preincrement assert(Op && "Cannot increment end iterator!"); Op = Op->getNextOperandForReg(); - + // If this is an operand we don't care about, skip it. - while (Op && ((!ReturnUses && Op->isUse()) || + while (Op && ((!ReturnUses && Op->isUse()) || (!ReturnDefs && Op->isDef()) || (SkipDebug && Op->isDebug()))) Op = Op->getNextOperandForReg(); - + return *this; } defusechain_iterator operator++(int) { // Postincrement @@ -484,26 +484,26 @@ assert(Op && "Cannot dereference end iterator!"); return *Op; } - + /// getOperandNo - Return the operand # of this MachineOperand in its /// MachineInstr. unsigned getOperandNo() const { assert(Op && "Cannot dereference end iterator!"); return Op - &Op->getParent()->getOperand(0); } - + // Retrieve a reference to the current operand. MachineInstr &operator*() const { assert(Op && "Cannot dereference end iterator!"); return *Op->getParent(); } - + MachineInstr *operator->() const { assert(Op && "Cannot dereference end iterator!"); return Op->getParent(); } }; - + }; } // End llvm namespace From atrick at apple.com Mon Feb 20 22:51:19 2012 From: atrick at apple.com (Andrew Trick) Date: Tue, 21 Feb 2012 04:51:19 -0000 Subject: [llvm-commits] [llvm] r151031 - /llvm/trunk/lib/CodeGen/StackSlotColoring.cpp Message-ID: <20120221045119.DD2A82A6C12F@llvm.org> Author: atrick Date: Mon Feb 20 22:51:19 2012 New Revision: 151031 URL: http://llvm.org/viewvc/llvm-project?rev=151031&view=rev Log: StackSlotColoring does not use a VirtRegMap Modified: llvm/trunk/lib/CodeGen/StackSlotColoring.cpp Modified: llvm/trunk/lib/CodeGen/StackSlotColoring.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackSlotColoring.cpp?rev=151031&r1=151030&r2=151031&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/StackSlotColoring.cpp (original) +++ llvm/trunk/lib/CodeGen/StackSlotColoring.cpp Mon Feb 20 22:51:19 2012 @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "stackcoloring" -#include "VirtRegMap.h" #include "llvm/Function.h" #include "llvm/Module.h" #include "llvm/CodeGen/Passes.h" @@ -92,8 +91,6 @@ AU.addRequired(); AU.addPreserved(); AU.addRequired(); - AU.addRequired(); - AU.addPreserved(); AU.addRequired(); AU.addPreserved(); AU.addPreservedID(MachineDominatorsID); @@ -121,7 +118,6 @@ "Stack Slot Coloring", false, false) INITIALIZE_PASS_DEPENDENCY(SlotIndexes) INITIALIZE_PASS_DEPENDENCY(LiveStacks) -INITIALIZE_PASS_DEPENDENCY(VirtRegMap) INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) INITIALIZE_PASS_END(StackSlotColoring, "stack-slot-coloring", "Stack Slot Coloring", false, false) From atrick at apple.com Mon Feb 20 22:51:24 2012 From: atrick at apple.com (Andrew Trick) Date: Tue, 21 Feb 2012 04:51:24 -0000 Subject: [llvm-commits] [llvm] r151032 - in /llvm/trunk: include/llvm/CodeGen/MachineRegisterInfo.h lib/CodeGen/MachineRegisterInfo.cpp lib/CodeGen/PrologEpilogInserter.cpp lib/CodeGen/RegAllocBasic.cpp lib/CodeGen/RegAllocFast.cpp lib/CodeGen/RegAllocGreedy.cpp lib/CodeGen/RegAllocPBQP.cpp lib/CodeGen/ScheduleDAGInstrs.cpp lib/Target/PTX/PTXTargetMachine.cpp Message-ID: <20120221045124.585CD2A6C12F@llvm.org> Author: atrick Date: Mon Feb 20 22:51:23 2012 New Revision: 151032 URL: http://llvm.org/viewvc/llvm-project?rev=151032&view=rev Log: Clear virtual registers after they are no longer referenced. Passes after RegAlloc should be able to rely on MRI->getNumVirtRegs() == 0. This makes sharing code for pre/postRA passes more robust. Now, to check if a pass is running before the RA pipeline begins, use MRI->isSSA(). To check if a pass is running after the RA pipeline ends, use !MRI->getNumVirtRegs(). PEI resets virtual regs when it's done scavenging. PTX will either have to provide its own PEI pass or assign physregs. Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp llvm/trunk/lib/CodeGen/RegAllocBasic.cpp llvm/trunk/lib/CodeGen/RegAllocFast.cpp llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=151032&r1=151031&r2=151032&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Mon Feb 20 22:51:23 2012 @@ -273,6 +273,9 @@ /// unsigned getNumVirtRegs() const { return VRegInfo.size(); } + /// clearVirtRegs - Remove all virtual registers (after physreg assignment). + void clearVirtRegs(); + /// setRegAllocationHint - Specify a register allocation hint for the /// specified virtual register. void setRegAllocationHint(unsigned Reg, unsigned Type, unsigned PrefReg) { Modified: llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp?rev=151032&r1=151031&r2=151032&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp Mon Feb 20 22:51:23 2012 @@ -31,9 +31,7 @@ MachineRegisterInfo::~MachineRegisterInfo() { #ifndef NDEBUG - for (unsigned i = 0, e = getNumVirtRegs(); i != e; ++i) - assert(VRegInfo[TargetRegisterInfo::index2VirtReg(i)].second == 0 && - "Vreg use list non-empty still?"); + clearVirtRegs(); for (unsigned i = 0, e = UsedPhysRegs.size(); i != e; ++i) assert(!PhysRegUseDefLists[i] && "PhysRegUseDefLists has entries after all instructions are deleted"); @@ -118,6 +116,16 @@ return Reg; } +/// clearVirtRegs - Remove all virtual registers (after physreg assignment). +void MachineRegisterInfo::clearVirtRegs() { +#ifndef NDEBUG + for (unsigned i = 0, e = getNumVirtRegs(); i != e; ++i) + assert(VRegInfo[TargetRegisterInfo::index2VirtReg(i)].second == 0 && + "Vreg use list non-empty still?"); +#endif + VRegInfo.clear(); +} + /// HandleVRegListReallocation - We just added a virtual register to the /// VRegInfo info list and it reallocated. Update the use/def lists info /// pointers. Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=151032&r1=151031&r2=151032&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original) +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Mon Feb 20 22:51:23 2012 @@ -69,6 +69,8 @@ const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo(); const TargetFrameLowering *TFI = Fn.getTarget().getFrameLowering(); + assert(!Fn.getRegInfo().getNumVirtRegs() && "Regalloc must assign all vregs"); + RS = TRI->requiresRegisterScavenging(Fn) ? new RegScavenger() : NULL; FrameIndexVirtualScavenging = TRI->requiresFrameIndexScavenging(Fn); @@ -123,6 +125,9 @@ if (TRI->requiresRegisterScavenging(Fn) && FrameIndexVirtualScavenging) scavengeFrameVirtualRegs(Fn); + // Clear any vregs created by virtual scavenging. + Fn.getRegInfo().clearVirtRegs(); + delete RS; clearAllSets(); return true; @@ -803,6 +808,10 @@ /// scavengeFrameVirtualRegs - Replace all frame index virtual registers /// with physical registers. Use the register scavenger to find an /// appropriate register to use. +/// +/// FIXME: Iterating over the instruction stream is unnecessary. We can simply +/// iterate over the vreg use list, which at this point only contains machine +/// operands for which eliminateFrameIndex need a new scratch reg. void PEI::scavengeFrameVirtualRegs(MachineFunction &Fn) { // Run through the instructions and find any virtual registers. for (MachineFunction::iterator BB = Fn.begin(), Modified: llvm/trunk/lib/CodeGen/RegAllocBasic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocBasic.cpp?rev=151032&r1=151031&r2=151032&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocBasic.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Mon Feb 20 22:51:23 2012 @@ -342,7 +342,10 @@ // Write out new DBG_VALUE instructions. getAnalysis().emitDebugValues(VRM); - // The pass output is in VirtRegMap. Release all the transient data. + // All machine operands and other references to virtual registers have been + // replaced. Remove the virtual registers and release all the transient data. + VRM->clearAllVirt(); + MRI->clearVirtRegs(); releaseMemory(); return true; Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocFast.cpp?rev=151032&r1=151031&r2=151032&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocFast.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocFast.cpp Mon Feb 20 22:51:23 2012 @@ -1104,6 +1104,10 @@ while (*Defs) MRI->setPhysRegUsed(*Defs++); + // All machine operands and other references to virtual registers have been + // replaced. Remove the virtual registers. + MRI->clearVirtRegs(); + SkippedInstrs.clear(); StackSlotForVirtReg.clear(); LiveDbgValueMap.clear(); Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=151032&r1=151031&r2=151032&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Mon Feb 20 22:51:23 2012 @@ -1698,7 +1698,10 @@ DebugVars->emitDebugValues(VRM); } - // The pass output is in VirtRegMap. Release all the transient data. + // All machine operands and other references to virtual registers have been + // replaced. Remove the virtual registers and release all the transient data. + VRM->clearAllVirt(); + MRI->clearVirtRegs(); releaseMemory(); return true; Modified: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp?rev=151032&r1=151031&r2=151032&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Mon Feb 20 22:51:23 2012 @@ -667,6 +667,11 @@ // Run rewriter vrm->rewrite(lis->getSlotIndexes()); + // All machine operands and other references to virtual registers have been + // replaced. Remove the virtual registers. + vrm->clearAllVirt(); + mri->clearVirtRegs(); + return true; } Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=151032&r1=151031&r2=151032&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Mon Feb 20 22:51:23 2012 @@ -40,6 +40,8 @@ UnitLatencies(false), Defs(TRI->getNumRegs()), Uses(TRI->getNumRegs()), LoopRegs(MLI, MDT), FirstDbgValue(0) { DbgValues.clear(); + assert(!(IsPostRA && MF.getRegInfo().getNumVirtRegs()) && + "Virtual registers must be removed prior to PostRA scheduling"); } /// Run - perform scheduling. Modified: llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp?rev=151032&r1=151031&r2=151032&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp Mon Feb 20 22:51:23 2012 @@ -126,7 +126,9 @@ } // namespace TargetPassConfig *PTXTargetMachine::createPassConfig(PassManagerBase &PM) { - return new PTXPassConfig(this, PM); + PTXPassConfig *PassConfig = new PTXPassConfig(this, PM); + PassConfig->disablePass(PrologEpilogCodeInserterID); + return PassConfig; } bool PTXPassConfig::addInstSelector() { From rafael.espindola at gmail.com Mon Feb 20 23:22:41 2012 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Tue, 21 Feb 2012 00:22:41 -0500 Subject: [llvm-commits] [llvm] r150885 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp In-Reply-To: <4F4217AC.6010204@free.fr> References: <20120218175143.39EC02A6C12F@llvm.org> <4F400451.9030203@gmail.com> <4F402019.3020805@gmail.com> <4F40C8EE.9070003@free.fr> <4F415BC7.5090408@gmail.com> <4F4217AC.6010204@free.fr> Message-ID: <4F432A21.5060208@gmail.com> > By the way, if you move this logic into the dominates routine, then I > guess the > verifier can be simplified by removing all the current logic and just > replacing > by a call to the improved dominator routine. Thanks again for the review. Exactly what these functions do was a bit fuzzy in my head. I really like the idea of sharing as much code as possible. The attached patches do that, but unfortunately they cannot fully replace the logic in the verifier. The interface doesn't provide which edge of a phi to consider, so they have to be conservative and check all. > Ciao, Duncan. Cheers, Rafael -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 0001-Rename-dominates-to-dominatesUse.patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120221/87a73f96/attachment.pl -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 0002-Fix-the-implementation.patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120221/87a73f96/attachment-0001.pl -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 0003-Use-the-DT-dominate-function-in-the-verifier.patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120221/87a73f96/attachment-0002.pl From craig.topper at gmail.com Tue Feb 21 00:22:36 2012 From: craig.topper at gmail.com (Craig Topper) Date: Tue, 21 Feb 2012 06:22:36 -0000 Subject: [llvm-commits] [llvm] r151038 - /llvm/trunk/include/llvm/MC/MCRegisterInfo.h Message-ID: <20120221062236.D87A82A6C12F@llvm.org> Author: ctopper Date: Tue Feb 21 00:22:36 2012 New Revision: 151038 URL: http://llvm.org/viewvc/llvm-project?rev=151038&view=rev Log: Merge some tables in generated RegisterInfo file. Store indices into larger table instead of pointers to reduce relocations and shrink table size on 64-bit builds. Shaves ~24K off X86MCTargetDesc.o Modified: llvm/trunk/include/llvm/MC/MCRegisterInfo.h Modified: llvm/trunk/include/llvm/MC/MCRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCRegisterInfo.h?rev=151038&r1=151037&r2=151038&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCRegisterInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCRegisterInfo.h Tue Feb 21 00:22:36 2012 @@ -105,10 +105,10 @@ /// of AX. /// struct MCRegisterDesc { - const char *Name; // Printable name for the reg (for debugging) - const unsigned *Overlaps; // Overlapping registers, described above - const unsigned *SubRegs; // Sub-register set, described above - const unsigned *SuperRegs; // Super-register set, described above + const char *Name; // Printable name for the reg (for debugging) + int Overlaps; // Overlapping registers, described above + int SubRegs; // Sub-register set, described above + int SuperRegs; // Super-register set, described above }; /// MCRegisterInfo base class - We assume that the target defines a static @@ -132,6 +132,9 @@ unsigned RAReg; // Return address register const MCRegisterClass *Classes; // Pointer to the regclass array unsigned NumClasses; // Number of entries in the array + const unsigned *Overlaps; // Pointer to the overlaps array + const unsigned *SubRegs; // Pointer to the subregs array + const unsigned *SuperRegs; // Pointer to the superregs array DenseMap L2DwarfRegs; // LLVM to Dwarf regs mapping DenseMap EHL2DwarfRegs; // LLVM to Dwarf regs mapping EH DenseMap Dwarf2LRegs; // Dwarf to LLVM regs mapping @@ -142,11 +145,16 @@ /// InitMCRegisterInfo - Initialize MCRegisterInfo, called by TableGen /// auto-generated routines. *DO NOT USE*. void InitMCRegisterInfo(const MCRegisterDesc *D, unsigned NR, unsigned RA, - const MCRegisterClass *C, unsigned NC) { + const MCRegisterClass *C, unsigned NC, + const unsigned *O, const unsigned *Sub, + const unsigned *Super) { Desc = D; NumRegs = NR; RAReg = RA; Classes = C; + Overlaps = O; + SubRegs = Sub; + SuperRegs = Super; NumClasses = NC; } @@ -204,7 +212,8 @@ /// const unsigned *getAliasSet(unsigned RegNo) const { // The Overlaps set always begins with Reg itself. - return get(RegNo).Overlaps + 1; + if (get(RegNo).Overlaps < 0) return 0; + return Overlaps + get(RegNo).Overlaps + 1; } /// getOverlaps - Return a list of registers that overlap Reg, including @@ -213,7 +222,8 @@ /// These are exactly the registers in { x | regsOverlap(x, Reg) }. /// const unsigned *getOverlaps(unsigned RegNo) const { - return get(RegNo).Overlaps; + if (get(RegNo).Overlaps < 0) return 0; + return Overlaps + get(RegNo).Overlaps; } /// getSubRegisters - Return the list of registers that are sub-registers of @@ -222,7 +232,8 @@ /// relations. e.g. X86::RAX's sub-register list is EAX, AX, AL, AH. /// const unsigned *getSubRegisters(unsigned RegNo) const { - return get(RegNo).SubRegs; + if (get(RegNo).SubRegs < 0) return 0; + return SubRegs + get(RegNo).SubRegs; } /// getSuperRegisters - Return the list of registers that are super-registers @@ -231,7 +242,8 @@ /// relations. e.g. X86::AL's super-register list is AX, EAX, RAX. /// const unsigned *getSuperRegisters(unsigned RegNo) const { - return get(RegNo).SuperRegs; + if (get(RegNo).SuperRegs < 0) return 0; + return SuperRegs + get(RegNo).SuperRegs; } /// getName - Return the human-readable symbolic target-specific name for the From craig.topper at gmail.com Tue Feb 21 00:23:21 2012 From: craig.topper at gmail.com (Craig Topper) Date: Tue, 21 Feb 2012 06:23:21 -0000 Subject: [llvm-commits] [llvm] r151039 - /llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Message-ID: <20120221062321.E45EE2A6C12F@llvm.org> Author: ctopper Date: Tue Feb 21 00:23:21 2012 New Revision: 151039 URL: http://llvm.org/viewvc/llvm-project?rev=151039&view=rev Log: Merge some tables in generated RegisterInfo file. Store indices into larger table instead of pointers to reduce relocations and shrink table size on 64-bit builds. Shaves ~24K off X86MCTargetDesc.o. Accidentally commited only part of this in r151038. 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=151039&r1=151038&r2=151039&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Tue Feb 21 00:23:21 2012 @@ -255,26 +255,28 @@ const std::string &TargetName = Target.getName(); - OS << "\nnamespace {\n"; - const std::vector &Regs = RegBank.getRegisters(); + OS << "extern const unsigned " << TargetName << "RegOverlaps[] = {\n"; + // Emit an overlap list for all registers. for (unsigned i = 0, e = Regs.size(); i != e; ++i) { const CodeGenRegister *Reg = Regs[i]; const CodeGenRegister::Set &O = Overlaps[Reg]; // Move Reg to the front so TRI::getAliasSet can share the list. - OS << " const unsigned " << Reg->getName() << "_Overlaps[] = { " + OS << " /* " << Reg->getName() << "_Overlaps */ " << getQualifiedName(Reg->TheDef) << ", "; for (CodeGenRegister::Set::const_iterator I = O.begin(), E = O.end(); I != E; ++I) if (*I != Reg) OS << getQualifiedName((*I)->TheDef) << ", "; - OS << "0 };\n"; + OS << "0,\n"; } + OS << "};\n\n"; + OS << "extern const unsigned " << TargetName << "SubRegsSet[] = {\n"; // Emit the empty sub-registers list - OS << " const unsigned Empty_SubRegsSet[] = { 0 };\n"; + OS << " /* Empty_SubRegsSet */ 0,\n"; // Loop over all of the registers which have sub-registers, emitting the // sub-registers list to memory. for (unsigned i = 0, e = Regs.size(); i != e; ++i) { @@ -284,14 +286,16 @@ // getSubRegs() orders by SubRegIndex. We want a topological order. SetVector SR; Reg.addSubRegsPreOrder(SR, RegBank); - OS << " const unsigned " << Reg.getName() << "_SubRegsSet[] = { "; + OS << " /* " << Reg.getName() << "_SubRegsSet */ "; for (unsigned j = 0, je = SR.size(); j != je; ++j) OS << getQualifiedName(SR[j]->TheDef) << ", "; - OS << "0 };\n"; + OS << "0,\n"; } + OS << "};\n\n"; + OS << "extern const unsigned " << TargetName << "SuperRegsSet[] = {\n"; // Emit the empty super-registers list - OS << " const unsigned Empty_SuperRegsSet[] = { 0 };\n"; + OS << " /* Empty_SuperRegsSet */ 0,\n"; // Loop over all of the registers which have super-registers, emitting the // super-registers list to memory. for (unsigned i = 0, e = Regs.size(); i != e; ++i) { @@ -299,31 +303,42 @@ const CodeGenRegister::SuperRegList &SR = Reg.getSuperRegs(); if (SR.empty()) continue; - OS << " const unsigned " << Reg.getName() << "_SuperRegsSet[] = { "; + OS << " /* " << Reg.getName() << "_SuperRegsSet */ "; for (unsigned j = 0, je = SR.size(); j != je; ++j) OS << getQualifiedName(SR[j]->TheDef) << ", "; - OS << "0 };\n"; + OS << "0,\n"; } - OS << "}\n"; // End of anonymous namespace... + OS << "};\n\n"; - OS << "\nextern const MCRegisterDesc " << TargetName + OS << "extern const MCRegisterDesc " << TargetName << "RegDesc[] = { // Descriptors\n"; - OS << " { \"NOREG\",\t0,\t0,\t0 },\n"; + OS << " { \"NOREG\", -1, -1, -1 },\n"; // Now that register alias and sub-registers sets have been emitted, emit the // register descriptors now. + unsigned OverlapsIndex = 0; + unsigned SubRegIndex = 1; // skip 1 for empty set + unsigned SuperRegIndex = 1; // skip 1 for empty set for (unsigned i = 0, e = Regs.size(); i != e; ++i) { - const CodeGenRegister &Reg = *Regs[i]; + const CodeGenRegister *Reg = Regs[i]; OS << " { \""; - OS << Reg.getName() << "\",\t" << Reg.getName() << "_Overlaps,\t"; - if (!Reg.getSubRegs().empty()) - OS << Reg.getName() << "_SubRegsSet,\t"; - else - OS << "Empty_SubRegsSet,\t"; - if (!Reg.getSuperRegs().empty()) - OS << Reg.getName() << "_SuperRegsSet"; - else - OS << "Empty_SuperRegsSet"; + OS << Reg->getName() << "\", /* " << Reg->getName() << "_Overlaps */ " + << OverlapsIndex << ", "; + OverlapsIndex += Overlaps[Reg].size() + 1; + if (!Reg->getSubRegs().empty()) { + OS << "/* " << Reg->getName() << "_SubRegsSet */ " << SubRegIndex + << ", "; + // FIXME not very nice to recalculate this + SetVector SR; + Reg->addSubRegsPreOrder(SR, RegBank); + SubRegIndex += SR.size() + 1; + } else + OS << "/* Empty_SubRegsSet */ 0, "; + if (!Reg->getSuperRegs().empty()) { + OS << "/* " << Reg->getName() << "_SuperRegsSet */ " << SuperRegIndex; + SuperRegIndex += Reg->getSuperRegs().size() + 1; + } else + OS << "/* Empty_SuperRegsSet */ 0"; OS << " },\n"; } OS << "};\n\n"; // End of register descriptors... @@ -343,7 +358,7 @@ // Emit the register list now. OS << " // " << Name << " Register Class...\n" - << " static const unsigned " << Name + << " const unsigned " << Name << "[] = {\n "; for (unsigned i = 0, e = Order.size(); i != e; ++i) { Record *Reg = Order[i]; @@ -352,7 +367,7 @@ OS << "\n };\n\n"; OS << " // " << Name << " Bit set.\n" - << " static const unsigned char " << Name + << " const unsigned char " << Name << "Bits[] = {\n "; BitVectorEmitter BVE; for (unsigned i = 0, e = Order.size(); i != e; ++i) { @@ -390,7 +405,8 @@ << "unsigned DwarfFlavour = 0, unsigned EHFlavour = 0) {\n"; OS << " RI->InitMCRegisterInfo(" << TargetName << "RegDesc, " << Regs.size()+1 << ", RA, " << TargetName << "MCRegisterClasses, " - << RegisterClasses.size() << ");\n\n"; + << RegisterClasses.size() << ", " << TargetName << "RegOverlaps, " + << TargetName << "SubRegsSet, " << TargetName << "SuperRegsSet);\n\n"; EmitRegMapping(OS, Regs, false); @@ -521,7 +537,7 @@ // Emit the register list now. OS << " // " << Name << " Register Class Value Types...\n" - << " static const MVT::SimpleValueType " << Name + << " const MVT::SimpleValueType " << Name << "[] = {\n "; for (unsigned i = 0, e = RC.VTs.size(); i != e; ++i) OS << getEnumName(RC.VTs[i]) << ", "; @@ -871,6 +887,9 @@ // Emit the constructor of the class... OS << "extern const MCRegisterDesc " << TargetName << "RegDesc[];\n"; + OS << "extern const unsigned " << TargetName << "RegOverlaps[];\n"; + OS << "extern const unsigned " << TargetName << "SubRegsSet[];\n"; + OS << "extern const unsigned " << TargetName << "SuperRegsSet[];\n"; OS << ClassName << "::" << ClassName << "(unsigned RA, unsigned DwarfFlavour, unsigned EHFlavour)\n" @@ -879,7 +898,8 @@ << " " << TargetName << "SubRegIndexTable) {\n" << " InitMCRegisterInfo(" << TargetName << "RegDesc, " << Regs.size()+1 << ", RA, " << TargetName << "MCRegisterClasses, " - << RegisterClasses.size() << ");\n\n"; + << RegisterClasses.size() << ", " << TargetName << "RegOverlaps, " + << TargetName << "SubRegsSet, " << TargetName << "SuperRegsSet);\n\n"; EmitRegMapping(OS, Regs, true); From viridia at gmail.com Tue Feb 21 00:43:03 2012 From: viridia at gmail.com (Talin) Date: Mon, 20 Feb 2012 22:43:03 -0800 Subject: [llvm-commits] [llvm] r150890 - in /llvm/trunk: include/llvm/ADT/Hashing.h lib/Support/CMakeLists.txt lib/Support/Hashing.cpp unittests/ADT/HashingTest.cpp unittests/CMakeLists.txt In-Reply-To: References: <20120218210050.320912A6C12F@llvm.org> Message-ID: On Mon, Feb 20, 2012 at 10:38 AM, Jay Foad wrote: > On 18 February 2012 21:00, Talin wrote: > > Added: llvm/trunk/include/llvm/ADT/Hashing.h > > Nitpick: wouldn't this be better in ../Support ? > I'm not sure what the boundary between ADT and Support is - I put it in ADT because containers use it. However, if someone moves it to Support I won't complain. > > > + /// Add a float > > + GeneralHash& add(float Data) { > > + union { > > + float D; uint32_t I; > > + }; > > + D = Data; > > + addInt(I); > > + return *this; > > + } > > + > > + /// Add a double > > + GeneralHash& add(double Data) { > > + union { > > + double D; uint64_t I; > > + }; > > + D = Data; > > + addInt(I); > > + return *this; > > + } > > IMO it would be better not to implement these at all until someone > needs them, and decides what to do about the +/- 0 problem. (But > that's just another nitpick!) > > For uniquing of ConstantFPs, I think you do want to distinguish between +/- 0. > > +// Add a possibly unaligned sequence of bytes. > > +void GeneralHash::addUnaligned(const uint8_t *I, const uint8_t *E) { > > + ptrdiff_t Length = E - I; > > + if (uintptr_t(I) & 3 == 0) { > > + while (Length > 3) { > > + mix(*reinterpret_cast(I)); > > + I += 4; > > + Length -= 4; > > + } > > + } else { > > + while (Length > 3) { > > + mix( > > + uint32_t(I[0]) + > > + (uint32_t(I[1]) << 8) + > > + (uint32_t(I[2]) << 16) + > > + (uint32_t(I[3]) << 24)); > > + I += 4; > > + Length -= 4; > > + } > > + } > > I think there's a serious problem here on big-endian hosts, because > identical arrays of bytes will hash to different values depending on > whether they happen to start on a 4-byte boundary or not. > Good catch. Shouldn't be hard to fix I would think. > > Thanks for working on this! > Jay. > -- -- Talin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120220/5aafe0f2/attachment.html From arcata at gmail.com Tue Feb 21 00:46:55 2012 From: arcata at gmail.com (Joe Groff) Date: Mon, 20 Feb 2012 22:46:55 -0800 Subject: [llvm-commits] Patch for pr9213: Emit global_ctors into MSVCRT-compatible '.CRT$XCU' section for win32 targets Message-ID: Here's a partial fix I sent a while back for pr9213. With this patch, global_ctors pointers will be generated into the '.CRT$XCU' section of the COFF output file instead of '.ctors' when targeting *-*-win32, so that global_ctors will be run automatically by the Microsoft CRT. (MSVCRT does not support an analog to the sysv '.dtors' section, so this patch does not affect global_dtors, which still will not be run by the stock CRT on win32 targets.) Let me know if any changes are necessary. Thanks. -Joe -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-pr9213-2.diff Type: application/octet-stream Size: 2761 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120220/ec9ec43b/attachment-0001.obj From craig.topper at gmail.com Tue Feb 21 00:54:41 2012 From: craig.topper at gmail.com (Craig Topper) Date: Tue, 21 Feb 2012 06:54:41 -0000 Subject: [llvm-commits] [llvm] r151041 - in /llvm/trunk: include/llvm/MC/MCRegisterInfo.h utils/TableGen/RegisterInfoEmitter.cpp Message-ID: <20120221065441.788D72A6C12F@llvm.org> Author: ctopper Date: Tue Feb 21 00:54:41 2012 New Revision: 151041 URL: http://llvm.org/viewvc/llvm-project?rev=151041&view=rev Log: In generated RegisterInfo files, replace a pointer to the end of an array with just the size of the array to avoid relocations. Modified: llvm/trunk/include/llvm/MC/MCRegisterInfo.h llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Modified: llvm/trunk/include/llvm/MC/MCRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCRegisterInfo.h?rev=151041&r1=151040&r2=151041&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCRegisterInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCRegisterInfo.h Tue Feb 21 00:54:41 2012 @@ -33,7 +33,8 @@ const unsigned RegSize, Alignment; // Size & Alignment of register in bytes const int CopyCost; const bool Allocatable; - const iterator RegsBegin, RegsEnd; + const iterator RegsBegin; + unsigned RegsSize; const unsigned char *const RegSet; const unsigned RegSetSize; @@ -48,11 +49,11 @@ /// begin/end - Return all of the registers in this class. /// iterator begin() const { return RegsBegin; } - iterator end() const { return RegsEnd; } + iterator end() const { return RegsBegin + RegsSize; } /// getNumRegs - Return the number of registers in this class. /// - unsigned getNumRegs() const { return (unsigned)(RegsEnd-RegsBegin); } + unsigned getNumRegs() const { return RegsSize; } /// getRegister - Return the specified register in the class. /// Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=151041&r1=151040&r2=151041&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Tue Feb 21 00:54:41 2012 @@ -391,10 +391,8 @@ << RC.SpillAlignment/8 << ", " << RC.CopyCost << ", " << RC.Allocatable << ", " - << RC.getName() << ", " << RC.getName() << " + " - << RC.getOrder().size() << ", " - << RC.getName() << "Bits, sizeof(" << RC.getName() << "Bits)" - << " },\n"; + << RC.getName() << ", " << RC.getOrder().size() << ", " + << RC.getName() << "Bits, sizeof(" << RC.getName() << "Bits) },\n"; } OS << "};\n\n"; From anton at korobeynikov.info Tue Feb 21 01:12:37 2012 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 21 Feb 2012 11:12:37 +0400 Subject: [llvm-commits] Patch for pr9213: Emit global_ctors into MSVCRT-compatible '.CRT$XCU' section for win32 targets In-Reply-To: References: Message-ID: > Here's a partial fix I sent a while back for pr9213. With this patch, > global_ctors pointers will be generated into the '.CRT$XCU' section of > the COFF output file instead of '.ctors' when targeting *-*-win32, so > that global_ctors will be run automatically by the Microsoft CRT. > (MSVCRT does not support an analog to the sysv '.dtors' section, so > this patch does not affect global_dtors, which still will not be run > by the stock CRT on win32 targets.) Let me know if any changes are > necessary. Thanks. LGTM -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From samsonov at google.com Tue Feb 21 01:08:38 2012 From: samsonov at google.com (Alexey Samsonov) Date: Tue, 21 Feb 2012 07:08:38 -0000 Subject: [llvm-commits] [compiler-rt] r151042 - /compiler-rt/trunk/lib/asan/output_tests/test_output.sh Message-ID: <20120221070838.D1A882A6C12F@llvm.org> Author: samsonov Date: Tue Feb 21 01:08:38 2012 New Revision: 151042 URL: http://llvm.org/viewvc/llvm-project?rev=151042&view=rev Log: AddressSanitizer: don't use /tmp for temporary file in output tests. Modified: compiler-rt/trunk/lib/asan/output_tests/test_output.sh Modified: compiler-rt/trunk/lib/asan/output_tests/test_output.sh URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/test_output.sh?rev=151042&r1=151041&r2=151042&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/output_tests/test_output.sh (original) +++ compiler-rt/trunk/lib/asan/output_tests/test_output.sh Tue Feb 21 01:08:38 2012 @@ -8,7 +8,7 @@ FILE_CHECK=$3 CXXFLAGS="-mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls" SYMBOLIZER=../scripts/asan_symbolize.py -TMP_ASAN_REPORT=/tmp/asan_report +TMP_ASAN_REPORT=asan_report.tmp run_program() { ./$1 2>&1 | $SYMBOLIZER 2> /dev/null | c++filt > $TMP_ASAN_REPORT @@ -18,6 +18,7 @@ check_program() { run_program $1 $FILE_CHECK $2 --check-prefix=$3 < $TMP_ASAN_REPORT + rm -f $TMP_ASAN_REPORT } C_TEST=use-after-free @@ -63,6 +64,7 @@ $FILE_CHECK $c.cc --check-prefix="Check-$OS" < $TMP_ASAN_REPORT fi rm ./$exe + rm ./$TMP_ASAN_REPORT [ -e "$so" ] && rm ./$so done done From asl at math.spbu.ru Tue Feb 21 01:20:59 2012 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 21 Feb 2012 11:20:59 +0400 Subject: [llvm-commits] LLVM patch to support ARM fused multiply add/subtract instructions In-Reply-To: <016b01ccdbbc$d32677f0$797367d0$@org> References: <00f601ccdaf6$e6cdf8d0$b469ea70$@org> <016b01ccdbbc$d32677f0$797367d0$@org> Message-ID: Hi Ana, Sorry, I somehow missed this e-mail earlier. > - I have updated fusedMAC.ll to include Neon fused multiply add/sub test cases. The patch is attached. Ok. Please commit. > So I think it just relies on -mfpu=neon-vfpv4 to imply Neon2. Ok, but this is user-level interface. Are you interested in adding clang support for vfpv4 ? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From anton at korobeynikov.info Tue Feb 21 01:39:55 2012 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 21 Feb 2012 11:39:55 +0400 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: Joe, > I factored the logic to MachineModuleInfo, since that's where the > calls...WithFloatingPointArguments state is kept. Attached is the > revised patch. I don't think that this routine should be in the common code... However, I do not see the proper place right now. Maybe Eli knows :) The comments wrt patch: 1. Use the same code style as all other routines in the file. 2. > + FunctionType *FT = dyn_cast( > + I->getCalledValue()->getType()->getContainedType(0)); This definitely looks wrong. What if you're doing indirect call? This way I->getCalledValue() will return GlobalValue, not Function. 3. + assert(FT); Use cast instead of dyn_cast + assert. Also, when doing assert provide meaningful assertion messages. 4 + if (FT->isVarArg() && + !callsExternalVAFunctionWithFloatingPointArguments()) { Just early exit here 5. + for (po_iterator i = po_begin(T), e = po_end(T); Should we traverse the whole Type tree here? Should fltused be emitted even if we e.g. passing point to struct contaning float? Also... is is possible somehow shorten "setCallsExternalVAFunctionWithFloatingPointArguments".... ? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From craig.topper at gmail.com Tue Feb 21 01:36:39 2012 From: craig.topper at gmail.com (Craig Topper) Date: Tue, 21 Feb 2012 07:36:39 -0000 Subject: [llvm-commits] [llvm] r151043 - in /llvm/trunk: include/llvm/MC/MCRegisterInfo.h utils/TableGen/RegisterInfoEmitter.cpp Message-ID: <20120221073639.EB9922A6C12F@llvm.org> Author: ctopper Date: Tue Feb 21 01:36:39 2012 New Revision: 151043 URL: http://llvm.org/viewvc/llvm-project?rev=151043&view=rev Log: Reorder some members in MCRegisterClass to remove padding on 64-bit builds. Modified: llvm/trunk/include/llvm/MC/MCRegisterInfo.h llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Modified: llvm/trunk/include/llvm/MC/MCRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCRegisterInfo.h?rev=151043&r1=151042&r2=151043&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCRegisterInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCRegisterInfo.h Tue Feb 21 01:36:39 2012 @@ -28,14 +28,14 @@ typedef const unsigned* iterator; typedef const unsigned* const_iterator; - unsigned ID; + const unsigned ID; const char *Name; const unsigned RegSize, Alignment; // Size & Alignment of register in bytes const int CopyCost; const bool Allocatable; const iterator RegsBegin; - unsigned RegsSize; const unsigned char *const RegSet; + const unsigned RegsSize; const unsigned RegSetSize; /// getID() - Return the register class ID number. Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=151043&r1=151042&r2=151043&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Tue Feb 21 01:36:39 2012 @@ -391,8 +391,8 @@ << RC.SpillAlignment/8 << ", " << RC.CopyCost << ", " << RC.Allocatable << ", " - << RC.getName() << ", " << RC.getOrder().size() << ", " - << RC.getName() << "Bits, sizeof(" << RC.getName() << "Bits) },\n"; + << RC.getName() << ", " << RC.getName() << "Bits, " + << RC.getOrder().size() << ", sizeof(" << RC.getName() << "Bits) },\n"; } OS << "};\n\n"; From samsonov at google.com Tue Feb 21 02:04:49 2012 From: samsonov at google.com (samsonov at google.com) Date: Tue, 21 Feb 2012 08:04:49 +0000 Subject: [llvm-commits] PATCH: AddressSanitizer: Don't include GrandCentralDispatch headers in asan headers on Mac (issue 5689057) Message-ID: <20cf305642d76c507e04b974dd4a@google.com> Reviewers: ramosian.glider, Description: AddressSanitizer: Don't include GrandCentralDispatch headers in asan headers on Mac Please review this at http://codereview.appspot.com/5689057/ Affected files: M asan_mac.h -------------- next part -------------- Index: asan_mac.h =================================================================== --- asan_mac.h (revision 151037) +++ asan_mac.h (working copy) @@ -18,8 +18,6 @@ #include "asan_interceptors.h" -// TODO(glider): need to check if the OS X version is 10.6 or greater. -#include #include #include @@ -37,6 +35,9 @@ typedef void* pthread_workqueue_t; typedef void* pthread_workitem_handle_t; +typedef void* dispatch_group_t; +typedef void* dispatch_queue_t; +typedef uint64_t dispatch_time_t; typedef void (*dispatch_function_t)(void *block); typedef void* (*worker_t)(void *block); @@ -78,10 +79,16 @@ extern "C" { -// dispatch_barrier_async_f() is not declared in . -void dispatch_barrier_async_f(dispatch_queue_t dq, - void *ctxt, dispatch_function_t func); -// Neither is pthread_workqueue_additem_np(). +void dispatch_async_f(dispatch_queue_t dq, void *ctxt, + dispatch_function_t func); +void dispatch_sync_f(dispatch_queue_t dq, void *ctxt, + dispatch_function_t func); +void dispatch_after_f(dispatch_time_t when, dispatch_queue_t dq, void *ctxt, + dispatch_function_t func); +void dispatch_barrier_async_f(dispatch_queue_t dq, void *ctxt, + dispatch_function_t func); +void dispatch_group_async_f(dispatch_group_t group, dispatch_queue_t dq, + void *ctxt, dispatch_function_t func); int pthread_workqueue_additem_np(pthread_workqueue_t workq, void *(*workitem_func)(void *), void * workitem_arg, pthread_workitem_handle_t * itemhandlep, unsigned int *gencountp); From baldrick at free.fr Tue Feb 21 02:10:42 2012 From: baldrick at free.fr (Duncan Sands) Date: Tue, 21 Feb 2012 09:10:42 +0100 Subject: [llvm-commits] [llvm] r150978 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp In-Reply-To: <20120220184510.419FC2A6C12F@llvm.org> References: <20120220184510.419FC2A6C12F@llvm.org> Message-ID: <4F435182.8040109@free.fr> Hi Benjamin, > InstCombine: Removing the base from the address calculation is only safe when the GEPs are inbounds. since GEP is implicitly a signed computation, isn't this only true for signed comparisons? I.e. mightn't an inbounds GEP overflow when viewed as an unsigned computation, leading to wrongness for unsigned comparisons? Ciao, Duncan. From baldrick at free.fr Tue Feb 21 02:17:17 2012 From: baldrick at free.fr (Duncan Sands) Date: Tue, 21 Feb 2012 09:17:17 +0100 Subject: [llvm-commits] PATCH: Remove lazy-parse support from llvm::Triple In-Reply-To: References: Message-ID: <4F43530D.2060100@free.fr> Hi Chandler, > This patch removes the lazy-parsing from the Triple class. From what I could > tell, no one deeply relied on this, and it seems unlikely that we want people to > be creating enough triples to need them to parse lazily... LGTM. Ciao, Duncan. From glider at google.com Tue Feb 21 02:20:08 2012 From: glider at google.com (glider at google.com) Date: Tue, 21 Feb 2012 08:20:08 +0000 Subject: [llvm-commits] AddressSanitizer: Don't include GrandCentralDispatch headers in asan headers on Mac (issue 5689057) Message-ID: <20cf305643213a9cf804b9751429@google.com> LGTM http://codereview.appspot.com/5689057/ From baldrick at free.fr Tue Feb 21 02:21:00 2012 From: baldrick at free.fr (Duncan Sands) Date: Tue, 21 Feb 2012 09:21:00 +0100 Subject: [llvm-commits] [llvm] r151003 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/invariant.ll In-Reply-To: <20120220233226.A62772A6C12F@llvm.org> References: <20120220233226.A62772A6C12F@llvm.org> Message-ID: <4F4353EC.7020607@free.fr> Hi Nick, > --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Feb 20 17:32:26 2012 > @@ -2511,10 +2511,13 @@ > if (!II->use_empty()) > return false; > ConstantInt *Size = cast(II->getArgOperand(0)); > - if (Size->isAllOnesValue()) { > - Value *PtrArg = getVal(II->getArgOperand(1)); > - Value *Ptr = PtrArg->stripPointerCasts(); > - if (GlobalVariable *GV = dyn_cast(Ptr)) > + Value *PtrArg = getVal(II->getArgOperand(1)); > + Value *Ptr = PtrArg->stripPointerCasts(); > + if (GlobalVariable *GV = dyn_cast(Ptr)) { > + Type *ElemTy = cast(GV->getType())->getElementType(); > + if (!Size->isAllOnesValue()&& so previously you only added to Invariants if it was -1, while now you don't add to Invariants if it is -1? I.e. completely the opposite? Can you please add a comment explaining why you exclude -1 here. > + Size->getValue().getLimitedValue()>= > + TD->getTypeStoreSize(ElemTy)) > Invariants.insert(GV); > } > // Continue even if we do nothing. Ciao, Duncan. From baldrick at free.fr Tue Feb 21 02:23:29 2012 From: baldrick at free.fr (Duncan Sands) Date: Tue, 21 Feb 2012 09:23:29 +0100 Subject: [llvm-commits] [llvm] r151015 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp In-Reply-To: <20120221011951.935662A6C12F@llvm.org> References: <20120221011951.935662A6C12F@llvm.org> Message-ID: <4F435481.50309@free.fr> Hi Rafael, > --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) > +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Feb 20 19:19:51 2012 > @@ -31,13 +31,11 @@ > Value *SCEVExpander::ReuseOrCreateCast(Value *V, Type *Ty, > Instruction::CastOps Op, > BasicBlock::iterator IP) { > - // All new or reused instructions must strictly dominate the Builder's > - // InsertPt to ensure that the expression's expansion dominates its uses. > - // Assert that the requested insertion point works at least for new > - // instructions. > - > - // FIXME: disabled to make the bots happy. > - //assert(SE.DT->dominates(IP, Builder.GetInsertPoint())); > + // All new or reused instructions must strictly dominate their uses. > + // It would be nice to assert this here, but we don't always know where > + // the next instructions will be added as the the caller can move the the the -> the Ciao, Duncan. From eugeni.stepanov at gmail.com Tue Feb 21 02:24:11 2012 From: eugeni.stepanov at gmail.com (eugeni.stepanov at gmail.com) Date: Tue, 21 Feb 2012 08:24:11 +0000 Subject: [llvm-commits] AddressSanitizer: Don't include GrandCentralDispatch headers in asan headers on Mac (issue 5689057) Message-ID: <20cf302d4c50b226f304b9752224@google.com> lgtm http://codereview.appspot.com/5689057/diff/1/asan_mac.h File asan_mac.h (right): http://codereview.appspot.com/5689057/diff/1/asan_mac.h#newcode38 asan_mac.h:38: typedef void* dispatch_group_t; Not a big deal, but I would just use void* in the function signatures. http://codereview.appspot.com/5689057/ From baldrick at free.fr Tue Feb 21 02:25:09 2012 From: baldrick at free.fr (Duncan Sands) Date: Tue, 21 Feb 2012 09:25:09 +0100 Subject: [llvm-commits] [llvm] r151025 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp In-Reply-To: <20120221034830.76C1D2A6C12F@llvm.org> References: <20120221034830.76C1D2A6C12F@llvm.org> Message-ID: <4F4354E5.8060200@free.fr> Hi Rafael, > --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) > +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Feb 20 21:48:30 2012 > @@ -503,8 +503,9 @@ > V = InsertNoopCastOfTo(V, > Type::getInt8PtrTy(Ty->getContext(), PTy->getAddressSpace())); > > - Instruction *Inst = dyn_cast(V); > - assert(!Inst || SE.DT->properlyDominates(Inst, Builder.GetInsertPoint())); > + assert(!dyn_cast(V) || this should use: isa(V) > + SE.DT->properlyDominates(dyn_cast(V), this should use: cast(V) Ciao, Duncan. From glider at google.com Tue Feb 21 02:34:55 2012 From: glider at google.com (glider at google.com) Date: Tue, 21 Feb 2012 08:34:55 +0000 Subject: [llvm-commits] AddressSanitizer: Don't include GrandCentralDispatch headers in asan headers on Mac (issue 5689057) Message-ID: <20cf3005e0f616995c04b975491a@google.com> http://codereview.appspot.com/5689057/diff/1/asan_mac.h File asan_mac.h (right): http://codereview.appspot.com/5689057/diff/1/asan_mac.h#newcode38 asan_mac.h:38: typedef void* dispatch_group_t; On 2012/02/21 08:24:11, eugeni.stepanov wrote: > Not a big deal, but I would just use void* in the function signatures. Please no. We'll end up having (void*, void*, void*) function prototypes and soon won't be able to tell which original types were there. http://codereview.appspot.com/5689057/ From samsonov at google.com Tue Feb 21 02:30:57 2012 From: samsonov at google.com (Alexey Samsonov) Date: Tue, 21 Feb 2012 08:30:57 -0000 Subject: [llvm-commits] [compiler-rt] r151044 - /compiler-rt/trunk/lib/asan/asan_mac.h Message-ID: <20120221083057.F0AE42A6C130@llvm.org> Author: samsonov Date: Tue Feb 21 02:30:57 2012 New Revision: 151044 URL: http://llvm.org/viewvc/llvm-project?rev=151044&view=rev Log: AddressSanitizer: Don't include GrandCentralDispatch headers in asan headers on Mac Modified: compiler-rt/trunk/lib/asan/asan_mac.h Modified: compiler-rt/trunk/lib/asan/asan_mac.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.h?rev=151044&r1=151043&r2=151044&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_mac.h (original) +++ compiler-rt/trunk/lib/asan/asan_mac.h Tue Feb 21 02:30:57 2012 @@ -18,8 +18,6 @@ #include "asan_interceptors.h" -// TODO(glider): need to check if the OS X version is 10.6 or greater. -#include #include #include @@ -37,6 +35,9 @@ typedef void* pthread_workqueue_t; typedef void* pthread_workitem_handle_t; +typedef void* dispatch_group_t; +typedef void* dispatch_queue_t; +typedef uint64_t dispatch_time_t; typedef void (*dispatch_function_t)(void *block); typedef void* (*worker_t)(void *block); @@ -78,10 +79,16 @@ extern "C" { -// dispatch_barrier_async_f() is not declared in . -void dispatch_barrier_async_f(dispatch_queue_t dq, - void *ctxt, dispatch_function_t func); -// Neither is pthread_workqueue_additem_np(). +void dispatch_async_f(dispatch_queue_t dq, void *ctxt, + dispatch_function_t func); +void dispatch_sync_f(dispatch_queue_t dq, void *ctxt, + dispatch_function_t func); +void dispatch_after_f(dispatch_time_t when, dispatch_queue_t dq, void *ctxt, + dispatch_function_t func); +void dispatch_barrier_async_f(dispatch_queue_t dq, void *ctxt, + dispatch_function_t func); +void dispatch_group_async_f(dispatch_group_t group, dispatch_queue_t dq, + void *ctxt, dispatch_function_t func); int pthread_workqueue_additem_np(pthread_workqueue_t workq, void *(*workitem_func)(void *), void * workitem_arg, pthread_workitem_handle_t * itemhandlep, unsigned int *gencountp); From chandlerc at gmail.com Tue Feb 21 02:31:18 2012 From: chandlerc at gmail.com (Chandler Carruth) Date: Tue, 21 Feb 2012 08:31:18 -0000 Subject: [llvm-commits] [llvm] r151045 - in /llvm/trunk: include/llvm/ADT/Triple.h lib/Support/Triple.cpp Message-ID: <20120221083118.EB8DF2A6C130@llvm.org> Author: chandlerc Date: Tue Feb 21 02:31:18 2012 New Revision: 151045 URL: http://llvm.org/viewvc/llvm-project?rev=151045&view=rev Log: Clean up comments that I missed when changing the triple representation. Somehow, I even missed the ones I wrote just the other day... Thanks to Matt for the code review. Modified: llvm/trunk/include/llvm/ADT/Triple.h llvm/trunk/lib/Support/Triple.cpp Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=151045&r1=151044&r2=151045&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Tue Feb 21 02:31:18 2012 @@ -132,7 +132,8 @@ /// @name Constructors /// @{ - /// \brief Default constructor produces an empty, invalid triple. + /// \brief Default constructor is the same as an empty string and leaves all + /// triple fields unknown. Triple() : Data(), Arch(), Vendor(), OS(), Environment() {} explicit Triple(const Twine &Str); Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=151045&r1=151044&r2=151045&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Tue Feb 21 02:31:18 2012 @@ -292,10 +292,8 @@ /// \brief Construct a triple from the string representation provided. /// -/// This doesn't actually parse the string representation eagerly. Instead it -/// stores it, and tracks the fact that it hasn't been parsed. The first time -/// any of the structural queries are made, the string is parsed and the -/// results cached in various members. +/// This stores the string representation and parses the various pieces into +/// enum members. Triple::Triple(const Twine &Str) : Data(Str.str()), Arch(ParseArch(getArchName())), @@ -307,9 +305,9 @@ /// \brief Construct a triple from string representations of the architecture, /// vendor, and OS. /// -/// This doesn't actually use these already distinct strings to setup the -/// triple information. Instead it joins them into a canonical form of a triple -/// string, and lazily parses it on use. +/// This joins each argument into a canonical string representation and parses +/// them into enum members. It leaves the environment unknown and omits it from +/// the string representation. Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr) : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()), Arch(ParseArch(ArchStr.str())), @@ -321,9 +319,8 @@ /// \brief Construct a triple from string representations of the architecture, /// vendor, OS, and environment. /// -/// This doesn't actually use these already distinct strings to setup the -/// triple information. Instead it joins them into a canonical form of a triple -/// string, and lazily parses it on use. +/// This joins each argument into a canonical string representation and parses +/// them into enum members. Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr, const Twine &EnvironmentStr) : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') + From chandlerc at gmail.com Tue Feb 21 02:36:28 2012 From: chandlerc at gmail.com (Chandler Carruth) Date: Tue, 21 Feb 2012 00:36:28 -0800 Subject: [llvm-commits] [llvm] r151024 - in /llvm/trunk: include/llvm/ADT/Triple.h include/llvm/Support/TargetRegistry.h lib/MC/MCDisassembler/EDDisassembler.cpp lib/Support/Triple.cpp unittests/ADT/TripleTest.cpp In-Reply-To: References: <20120221033937.384542A6C12F@llvm.org> Message-ID: On Mon, Feb 20, 2012 at 7:57 PM, Matt Beaumont-Gay wrote: > Just a couple of nits. > Addressed in r151045, thanks! The loop condition here seems brittle. Not sure how to make it more > robust, though. > Yea, sadly I've no real ideas either... All of these loops are now equally brittle. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120221/9647d61e/attachment.html From samsonov at google.com Tue Feb 21 02:36:46 2012 From: samsonov at google.com (samsonov at google.com) Date: Tue, 21 Feb 2012 08:36:46 +0000 Subject: [llvm-commits] AddressSanitizer: Don't include GrandCentralDispatch headers in asan headers on Mac (issue 5689057) Message-ID: <001636ed7545b5ef2204b9754f85@google.com> r151044 http://codereview.appspot.com/5689057/diff/1/asan_mac.h File asan_mac.h (right): http://codereview.appspot.com/5689057/diff/1/asan_mac.h#newcode38 asan_mac.h:38: typedef void* dispatch_group_t; On 2012/02/21 08:34:55, glider wrote: > On 2012/02/21 08:24:11, eugeni.stepanov wrote: > > Not a big deal, but I would just use void* in the function signatures. > Please no. We'll end up having (void*, void*, void*) function prototypes and > soon won't be able to tell which original types were there. Yeah, I left typedefs to make function decl look similar to the original. http://codereview.appspot.com/5689057/ From glider at google.com Tue Feb 21 02:45:42 2012 From: glider at google.com (Alexander Potapenko) Date: Tue, 21 Feb 2012 08:45:42 -0000 Subject: [llvm-commits] [compiler-rt] r151046 - in /compiler-rt/trunk/lib/asan: asan_allocator.h asan_thread_registry.cc Message-ID: <20120221084544.07A262A6C130@llvm.org> Author: glider Date: Tue Feb 21 02:45:41 2012 New Revision: 151046 URL: http://llvm.org/viewvc/llvm-project?rev=151046&view=rev Log: Check that the FakeStack size is non-zero before looking into it. Sometimes DescribeStackAddress is called before another thread's FakeStack is initialized, which could previously cause a check to fire. Modified: compiler-rt/trunk/lib/asan/asan_allocator.h compiler-rt/trunk/lib/asan/asan_thread_registry.cc Modified: compiler-rt/trunk/lib/asan/asan_allocator.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.h?rev=151046&r1=151045&r2=151046&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_allocator.h (original) +++ compiler-rt/trunk/lib/asan/asan_allocator.h Tue Feb 21 02:45:41 2012 @@ -107,6 +107,7 @@ static void OnFree(size_t ptr, size_t size, size_t real_stack); // Return the bottom of the maped region. uintptr_t AddrIsInFakeStack(uintptr_t addr); + bool StackSize() { return stack_size_; } private: static const size_t kMinStackFrameSizeLog = 9; // Min frame is 512B. static const size_t kMaxStackFrameSizeLog = 16; // Max stack frame is 64K. Modified: compiler-rt/trunk/lib/asan/asan_thread_registry.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread_registry.cc?rev=151046&r1=151045&r2=151046&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_thread_registry.cc (original) +++ compiler-rt/trunk/lib/asan/asan_thread_registry.cc Tue Feb 21 02:45:41 2012 @@ -141,7 +141,7 @@ // Scanning the thread list backwards makes this function more reliable. for (int tid = n_threads_ - 1; tid >= 0; tid--) { AsanThread *t = thread_summaries_[tid]->thread(); - if (!t) continue; + if (!t || !(t->fake_stack().StackSize())) continue; if (t->fake_stack().AddrIsInFakeStack(addr) || t->AddrIsInStack(addr)) { return t; } From chandlerc at gmail.com Tue Feb 21 02:53:32 2012 From: chandlerc at gmail.com (Chandler Carruth) Date: Tue, 21 Feb 2012 08:53:32 -0000 Subject: [llvm-commits] [llvm] r151047 - in /llvm/trunk: include/llvm/ADT/Triple.h lib/Support/Triple.cpp Message-ID: <20120221085333.221C82A6C130@llvm.org> Author: chandlerc Date: Tue Feb 21 02:53:32 2012 New Revision: 151047 URL: http://llvm.org/viewvc/llvm-project?rev=151047&view=rev Log: Pull the parsing helper functions out of the Triple interface entirely. They're private static methods but we can just make them static functions in the implementation. It makes the implementations a touch more wordy, but takes another chunk out of the header file. Also, take the opportunity to switch the names to the new coding conventions. No functionality changed here. Modified: llvm/trunk/include/llvm/ADT/Triple.h llvm/trunk/lib/Support/Triple.cpp Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=151047&r1=151046&r2=151047&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Tue Feb 21 02:53:32 2012 @@ -123,11 +123,6 @@ /// The parsed Environment type. EnvironmentType Environment; - static ArchType ParseArch(StringRef ArchName); - static VendorType ParseVendor(StringRef VendorName); - static OSType ParseOS(StringRef OSName); - static EnvironmentType ParseEnvironment(StringRef EnvironmentName); - public: /// @name Constructors /// @{ Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=151047&r1=151046&r2=151047&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Tue Feb 21 02:53:32 2012 @@ -214,80 +214,81 @@ .Default(NULL); } -Triple::ArchType Triple::ParseArch(StringRef ArchName) { - return StringSwitch(ArchName) - .Cases("i386", "i486", "i586", "i686", x86) - .Cases("i786", "i886", "i986", x86) // FIXME: Do we need to support these? - .Cases("amd64", "x86_64", x86_64) - .Case("powerpc", ppc) - .Cases("powerpc64", "ppu", ppc64) - .Case("mblaze", mblaze) - .Cases("arm", "xscale", arm) +static Triple::ArchType parseArch(StringRef ArchName) { + return StringSwitch(ArchName) + .Cases("i386", "i486", "i586", "i686", Triple::x86) + // FIXME: Do we need to support these? + .Cases("i786", "i886", "i986", Triple::x86) + .Cases("amd64", "x86_64", Triple::x86_64) + .Case("powerpc", Triple::ppc) + .Cases("powerpc64", "ppu", Triple::ppc64) + .Case("mblaze", Triple::mblaze) + .Cases("arm", "xscale", Triple::arm) // FIXME: It would be good to replace these with explicit names for all the // various suffixes supported. - .StartsWith("armv", arm) - .Case("thumb", thumb) - .StartsWith("thumbv", thumb) - .Cases("spu", "cellspu", cellspu) - .Case("msp430", msp430) - .Cases("mips", "mipseb", "mipsallegrex", mips) - .Cases("mipsel", "mipsallegrexel", "psp", mipsel) - .Cases("mips64", "mips64eb", mips64) - .Case("mips64el", mips64el) - .Case("hexagon", hexagon) - .Case("sparc", sparc) - .Case("sparcv9", sparcv9) - .Case("tce", tce) - .Case("xcore", xcore) - .Case("ptx32", ptx32) - .Case("ptx64", ptx64) - .Case("le32", le32) - .Case("amdil", amdil) - .Default(UnknownArch); -} - -Triple::VendorType Triple::ParseVendor(StringRef VendorName) { - return StringSwitch(VendorName) - .Case("apple", Apple) - .Case("pc", PC) - .Case("scei", SCEI) - .Default(UnknownVendor); -} - -Triple::OSType Triple::ParseOS(StringRef OSName) { - return StringSwitch(OSName) - .StartsWith("auroraux", AuroraUX) - .StartsWith("cygwin", Cygwin) - .StartsWith("darwin", Darwin) - .StartsWith("dragonfly", DragonFly) - .StartsWith("freebsd", FreeBSD) - .StartsWith("ios", IOS) - .StartsWith("kfreebsd", KFreeBSD) - .StartsWith("linux", Linux) - .StartsWith("lv2", Lv2) - .StartsWith("macosx", MacOSX) - .StartsWith("mingw32", MinGW32) - .StartsWith("netbsd", NetBSD) - .StartsWith("openbsd", OpenBSD) - .StartsWith("psp", Psp) - .StartsWith("solaris", Solaris) - .StartsWith("win32", Win32) - .StartsWith("haiku", Haiku) - .StartsWith("minix", Minix) - .StartsWith("rtems", RTEMS) - .StartsWith("nacl", NativeClient) - .Default(UnknownOS); -} - -Triple::EnvironmentType Triple::ParseEnvironment(StringRef EnvironmentName) { - return StringSwitch(EnvironmentName) - .StartsWith("eabi", EABI) - .StartsWith("gnueabihf", GNUEABIHF) - .StartsWith("gnueabi", GNUEABI) - .StartsWith("gnu", GNU) - .StartsWith("macho", MachO) - .StartsWith("androideabi", ANDROIDEABI) - .Default(UnknownEnvironment); + .StartsWith("armv", Triple::arm) + .Case("thumb", Triple::thumb) + .StartsWith("thumbv", Triple::thumb) + .Cases("spu", "cellspu", Triple::cellspu) + .Case("msp430", Triple::msp430) + .Cases("mips", "mipseb", "mipsallegrex", Triple::mips) + .Cases("mipsel", "mipsallegrexel", "psp", Triple::mipsel) + .Cases("mips64", "mips64eb", Triple::mips64) + .Case("mips64el", Triple::mips64el) + .Case("hexagon", Triple::hexagon) + .Case("sparc", Triple::sparc) + .Case("sparcv9", Triple::sparcv9) + .Case("tce", Triple::tce) + .Case("xcore", Triple::xcore) + .Case("ptx32", Triple::ptx32) + .Case("ptx64", Triple::ptx64) + .Case("le32", Triple::le32) + .Case("amdil", Triple::amdil) + .Default(Triple::UnknownArch); +} + +static Triple::VendorType parseVendor(StringRef VendorName) { + return StringSwitch(VendorName) + .Case("apple", Triple::Apple) + .Case("pc", Triple::PC) + .Case("scei", Triple::SCEI) + .Default(Triple::UnknownVendor); +} + +static Triple::OSType parseOS(StringRef OSName) { + return StringSwitch(OSName) + .StartsWith("auroraux", Triple::AuroraUX) + .StartsWith("cygwin", Triple::Cygwin) + .StartsWith("darwin", Triple::Darwin) + .StartsWith("dragonfly", Triple::DragonFly) + .StartsWith("freebsd", Triple::FreeBSD) + .StartsWith("ios", Triple::IOS) + .StartsWith("kfreebsd", Triple::KFreeBSD) + .StartsWith("linux", Triple::Linux) + .StartsWith("lv2", Triple::Lv2) + .StartsWith("macosx", Triple::MacOSX) + .StartsWith("mingw32", Triple::MinGW32) + .StartsWith("netbsd", Triple::NetBSD) + .StartsWith("openbsd", Triple::OpenBSD) + .StartsWith("psp", Triple::Psp) + .StartsWith("solaris", Triple::Solaris) + .StartsWith("win32", Triple::Win32) + .StartsWith("haiku", Triple::Haiku) + .StartsWith("minix", Triple::Minix) + .StartsWith("rtems", Triple::RTEMS) + .StartsWith("nacl", Triple::NativeClient) + .Default(Triple::UnknownOS); +} + +static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { + return StringSwitch(EnvironmentName) + .StartsWith("eabi", Triple::EABI) + .StartsWith("gnueabihf", Triple::GNUEABIHF) + .StartsWith("gnueabi", Triple::GNUEABI) + .StartsWith("gnu", Triple::GNU) + .StartsWith("macho", Triple::MachO) + .StartsWith("androideabi", Triple::ANDROIDEABI) + .Default(Triple::UnknownEnvironment); } /// \brief Construct a triple from the string representation provided. @@ -296,10 +297,10 @@ /// enum members. Triple::Triple(const Twine &Str) : Data(Str.str()), - Arch(ParseArch(getArchName())), - Vendor(ParseVendor(getVendorName())), - OS(ParseOS(getOSName())), - Environment(ParseEnvironment(getEnvironmentName())) { + Arch(parseArch(getArchName())), + Vendor(parseVendor(getVendorName())), + OS(parseOS(getOSName())), + Environment(parseEnvironment(getEnvironmentName())) { } /// \brief Construct a triple from string representations of the architecture, @@ -310,9 +311,9 @@ /// the string representation. Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr) : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()), - Arch(ParseArch(ArchStr.str())), - Vendor(ParseVendor(VendorStr.str())), - OS(ParseOS(OSStr.str())), + Arch(parseArch(ArchStr.str())), + Vendor(parseVendor(VendorStr.str())), + OS(parseOS(OSStr.str())), Environment() { } @@ -325,10 +326,10 @@ const Twine &EnvironmentStr) : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') + EnvironmentStr).str()), - Arch(ParseArch(ArchStr.str())), - Vendor(ParseVendor(VendorStr.str())), - OS(ParseOS(OSStr.str())), - Environment(ParseEnvironment(EnvironmentStr.str())) { + Arch(parseArch(ArchStr.str())), + Vendor(parseVendor(VendorStr.str())), + OS(parseOS(OSStr.str())), + Environment(parseEnvironment(EnvironmentStr.str())) { } std::string Triple::normalize(StringRef Str) { @@ -346,16 +347,16 @@ // valid os. ArchType Arch = UnknownArch; if (Components.size() > 0) - Arch = ParseArch(Components[0]); + Arch = parseArch(Components[0]); VendorType Vendor = UnknownVendor; if (Components.size() > 1) - Vendor = ParseVendor(Components[1]); + Vendor = parseVendor(Components[1]); OSType OS = UnknownOS; if (Components.size() > 2) - OS = ParseOS(Components[2]); + OS = parseOS(Components[2]); EnvironmentType Environment = UnknownEnvironment; if (Components.size() > 3) - Environment = ParseEnvironment(Components[3]); + Environment = parseEnvironment(Components[3]); // Note which components are already in their final position. These will not // be moved. @@ -383,19 +384,19 @@ switch (Pos) { default: llvm_unreachable("unexpected component type!"); case 0: - Arch = ParseArch(Comp); + Arch = parseArch(Comp); Valid = Arch != UnknownArch; break; case 1: - Vendor = ParseVendor(Comp); + Vendor = parseVendor(Comp); Valid = Vendor != UnknownVendor; break; case 2: - OS = ParseOS(Comp); + OS = parseOS(Comp); Valid = OS != UnknownOS; break; case 3: - Environment = ParseEnvironment(Comp); + Environment = parseEnvironment(Comp); Valid = Environment != UnknownEnvironment; break; } From chandlerc at gmail.com Tue Feb 21 03:12:48 2012 From: chandlerc at gmail.com (Chandler Carruth) Date: Tue, 21 Feb 2012 09:12:48 -0000 Subject: [llvm-commits] [llvm] r151048 - /llvm/trunk/lib/Support/Triple.cpp Message-ID: <20120221091248.DD7D12A6C12F@llvm.org> Author: chandlerc Date: Tue Feb 21 03:12:48 2012 New Revision: 151048 URL: http://llvm.org/viewvc/llvm-project?rev=151048&view=rev Log: Replace a hand rolled loop with a lovely StringRef helper we have these days. No functionality changed. Modified: llvm/trunk/lib/Support/Triple.cpp Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=151048&r1=151047&r2=151048&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Tue Feb 21 03:12:48 2012 @@ -335,10 +335,7 @@ std::string Triple::normalize(StringRef Str) { // Parse into components. SmallVector Components; - for (size_t First = 0, Last = 0; Last != StringRef::npos; First = Last + 1) { - Last = Str.find('-', First); - Components.push_back(Str.slice(First, Last)); - } + Str.split(Components, "-"); // If the first component corresponds to a known architecture, preferentially // use it for the architecture. If the second component corresponds to a From kristof.beyls at arm.com Tue Feb 21 03:25:17 2012 From: kristof.beyls at arm.com (Kristof Beyls) Date: Tue, 21 Feb 2012 09:25:17 -0000 Subject: [llvm-commits] [PATCH] generate ABI-compliant sections for uninitialized static data members in template instantiations In-Reply-To: References: <4f4271a3.85c52a0a.3533.143cSMTPIN_ADDED@mx.google.com> Message-ID: <000401ccf07a$b9dd5bb0$2d981310$@beyls@arm.com> Thanks for looking at this Anton. Yes, this patch is generic, and yes, x86-linux is also affected. I think that all platforms following the Itanium C++ ABI are affected. I've compared the output with what gcc produces for the reduced test case in my earlier mail on arm-linux, x86-linux and x86-macosx. With the patch, clang now seems to be doing the correct thing on x86-linux and arm-linux. I've added x86-linux to the regression test (see attached updated patch). The patch doesn't seem to change anything on macosx, as expected. Thanks, Kristof > -----Original Message----- > From: Anton Korobeynikov [mailto:anton at korobeynikov.info] > Sent: 20 February 2012 22:00 > To: Kristof Beyls > Cc: llvm-commits at cs.uiuc.edu > Subject: Re: [llvm-commits] [PATCH] generate ABI-compliant sections for > uninitialized static data members in template instantiations > > Kristof, > > > The attached patch fixes a problem where LLVM doesn't generate .bss > sections > > in a C++ ABI-compliant way. > > Would someone be able to review and apply the patch if fine? > It seems that the patch is generic, not eabi specific, right? Thus I'd > suggest to test also on e.g. x86-linux, where comdats are used. > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University -------------- next part -------------- A non-text attachment was scrubbed... Name: cxx_weak_odr_bss2.patch Type: application/octet-stream Size: 2355 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120221/1859799a/attachment.obj From jay.foad at gmail.com Tue Feb 21 03:25:52 2012 From: jay.foad at gmail.com (Jay Foad) Date: Tue, 21 Feb 2012 09:25:52 -0000 Subject: [llvm-commits] [llvm] r151049 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp Message-ID: <20120221092552.752B42A6C12F@llvm.org> Author: foad Date: Tue Feb 21 03:25:52 2012 New Revision: 151049 URL: http://llvm.org/viewvc/llvm-project?rev=151049&view=rev Log: PR1210: make uniquing of struct and function types more efficient by using a DenseMap and Talin's new GeneralHash, avoiding the need for a temporary std::vector on every lookup. Patch by Meador Inge! Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=151049&r1=151048&r2=151049&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Tue Feb 21 03:25:52 2012 @@ -29,6 +29,7 @@ #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/Hashing.h" #include namespace llvm { @@ -89,6 +90,107 @@ } }; +struct AnonStructTypeKeyInfo { + struct KeyTy { + ArrayRef ETypes; + bool isPacked; + KeyTy(const ArrayRef& E, bool P) : + ETypes(E), isPacked(P) {} + KeyTy(const KeyTy& that) : + ETypes(that.ETypes), isPacked(that.isPacked) {} + KeyTy(const StructType* ST) : + ETypes(ArrayRef(ST->element_begin(), ST->element_end())), + isPacked(ST->isPacked()) {} + bool operator==(const KeyTy& that) const { + if (isPacked != that.isPacked) + return false; + if (ETypes != that.ETypes) + return false; + return true; + } + bool operator!=(const KeyTy& that) const { + return !this->operator==(that); + } + }; + static inline StructType* getEmptyKey() { + return DenseMapInfo::getEmptyKey(); + } + static inline StructType* getTombstoneKey() { + return DenseMapInfo::getTombstoneKey(); + } + static unsigned getHashValue(const KeyTy& Key) { + GeneralHash Hash; + Hash.add(Key.ETypes); + Hash.add(Key.isPacked); + return Hash.finish(); + } + static unsigned getHashValue(const StructType *ST) { + return getHashValue(KeyTy(ST)); + } + static bool isEqual(const KeyTy& LHS, const StructType *RHS) { + if (RHS == getEmptyKey() || RHS == getTombstoneKey()) + return false; + return LHS == KeyTy(RHS); + } + static bool isEqual(const StructType *LHS, const StructType *RHS) { + return LHS == RHS; + } +}; + +struct FunctionTypeKeyInfo { + struct KeyTy { + const Type *ReturnType; + ArrayRef Params; + bool isVarArg; + KeyTy(const Type* R, const ArrayRef& P, bool V) : + ReturnType(R), Params(P), isVarArg(V) {} + KeyTy(const KeyTy& that) : + ReturnType(that.ReturnType), + Params(that.Params), + isVarArg(that.isVarArg) {} + KeyTy(const FunctionType* FT) : + ReturnType(FT->getReturnType()), + Params(ArrayRef(FT->param_begin(), FT->param_end())), + isVarArg(FT->isVarArg()) {} + bool operator==(const KeyTy& that) const { + if (ReturnType != that.ReturnType) + return false; + if (isVarArg != that.isVarArg) + return false; + if (Params != that.Params) + return false; + return true; + } + bool operator!=(const KeyTy& that) const { + return !this->operator==(that); + } + }; + static inline FunctionType* getEmptyKey() { + return DenseMapInfo::getEmptyKey(); + } + static inline FunctionType* getTombstoneKey() { + return DenseMapInfo::getTombstoneKey(); + } + static unsigned getHashValue(const KeyTy& Key) { + GeneralHash Hash; + Hash.add(Key.ReturnType); + Hash.add(Key.Params); + Hash.add(Key.isVarArg); + return Hash.finish(); + } + static unsigned getHashValue(const FunctionType *FT) { + return getHashValue(KeyTy(FT)); + } + static bool isEqual(const KeyTy& LHS, const FunctionType *RHS) { + if (RHS == getEmptyKey() || RHS == getTombstoneKey()) + return false; + return LHS == KeyTy(RHS); + } + static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) { + return LHS == RHS; + } +}; + /// DebugRecVH - This is a CallbackVH used to keep the Scope -> index maps /// up to date as MDNodes mutate. This class is implemented in DebugLoc.cpp. class DebugRecVH : public CallbackVH { @@ -180,9 +282,10 @@ DenseMap IntegerTypes; - // TODO: Optimize FunctionTypes/AnonStructTypes! - std::map, FunctionType*> FunctionTypes; - std::map, StructType*> AnonStructTypes; + typedef DenseMap FunctionTypeMap; + FunctionTypeMap FunctionTypes; + typedef DenseMap StructTypeMap; + StructTypeMap AnonStructTypes; StringMap NamedStructTypes; unsigned NamedStructTypesUniqueID; Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=151049&r1=151048&r2=151049&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Feb 21 03:25:52 2012 @@ -390,24 +390,20 @@ // FunctionType::get - The factory function for the FunctionType class. FunctionType *FunctionType::get(Type *ReturnType, ArrayRef Params, bool isVarArg) { - // TODO: This is brutally slow. - unsigned ParamsSize = Params.size(); - std::vector Key; - Key.reserve(ParamsSize + 2); - Key.push_back(const_cast(ReturnType)); - for (unsigned i = 0, e = ParamsSize; i != e; ++i) - Key.push_back(const_cast(Params[i])); - if (isVarArg) - Key.push_back(0); - LLVMContextImpl *pImpl = ReturnType->getContext().pImpl; - FunctionType *&FT = pImpl->FunctionTypes[Key]; - - if (FT == 0) { + FunctionTypeKeyInfo::KeyTy Key(ReturnType, Params, isVarArg); + LLVMContextImpl::FunctionTypeMap::iterator I = + pImpl->FunctionTypes.find_as(Key); + FunctionType *FT; + + if (I == pImpl->FunctionTypes.end()) { FT = (FunctionType*) pImpl->TypeAllocator. - Allocate(sizeof(FunctionType) + sizeof(Type*) * (ParamsSize + 1), + Allocate(sizeof(FunctionType) + sizeof(Type*) * (Params.size() + 1), AlignOf::Alignment); new (FT) FunctionType(ReturnType, Params, isVarArg); + pImpl->FunctionTypes[FT] = true; + } else { + FT = I->first; } return FT; @@ -440,24 +436,22 @@ StructType *StructType::get(LLVMContext &Context, ArrayRef ETypes, bool isPacked) { - // FIXME: std::vector is horribly inefficient for this probe. - unsigned ETypesSize = ETypes.size(); - std::vector Key(ETypesSize); - for (unsigned i = 0, e = ETypesSize; i != e; ++i) { - assert(isValidElementType(ETypes[i]) && - "Invalid type for structure element!"); - Key[i] = ETypes[i]; + LLVMContextImpl *pImpl = Context.pImpl; + AnonStructTypeKeyInfo::KeyTy Key(ETypes, isPacked); + LLVMContextImpl::StructTypeMap::iterator I = + pImpl->AnonStructTypes.find_as(Key); + StructType *ST; + + if (I == pImpl->AnonStructTypes.end()) { + // Value not found. Create a new type! + ST = new (Context.pImpl->TypeAllocator) StructType(Context); + ST->setSubclassData(SCDB_IsLiteral); // Literal struct. + ST->setBody(ETypes, isPacked); + Context.pImpl->AnonStructTypes[ST] = true; + } else { + ST = I->first; } - if (isPacked) - Key.push_back(0); - - StructType *&ST = Context.pImpl->AnonStructTypes[Key]; - if (ST) return ST; - - // Value not found. Create a new type! - ST = new (Context.pImpl->TypeAllocator) StructType(Context); - ST->setSubclassData(SCDB_IsLiteral); // Literal struct. - ST->setBody(ETypes, isPacked); + return ST; } From chandlerc at gmail.com Tue Feb 21 03:29:14 2012 From: chandlerc at gmail.com (Chandler Carruth) Date: Tue, 21 Feb 2012 09:29:14 -0000 Subject: [llvm-commits] [llvm] r151050 - /llvm/trunk/lib/Support/Triple.cpp Message-ID: <20120221092914.402942A6C12F@llvm.org> Author: chandlerc Date: Tue Feb 21 03:29:14 2012 New Revision: 151050 URL: http://llvm.org/viewvc/llvm-project?rev=151050&view=rev Log: Tiny cosmetic change to use the same style for all of the while loops in the normalize routine, especially the empty while loops. Modified: llvm/trunk/lib/Support/Triple.cpp Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=151050&r1=151049&r2=151050&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Tue Feb 21 03:29:14 2012 @@ -414,7 +414,8 @@ // components to the right. for (unsigned i = Pos; !CurrentComponent.empty(); ++i) { // Skip over any fixed components. - while (i < array_lengthof(Found) && Found[i]) ++i; + while (i < array_lengthof(Found) && Found[i]) + ++i; // Place the component at the new position, getting the component // that was at this position - it will be moved right. std::swap(CurrentComponent, Components[i]); @@ -442,7 +443,8 @@ Components.push_back(CurrentComponent); // Advance Idx to the component's new position. - while (++Idx < array_lengthof(Found) && Found[Idx]) {} + while (++Idx < array_lengthof(Found) && Found[Idx]) + ; } while (Idx < Pos); // Add more until the final position is reached. } assert(Pos < Components.size() && Components[Pos] == Comp && From arcata at gmail.com Tue Feb 21 03:54:48 2012 From: arcata at gmail.com (Joe Groff) Date: Tue, 21 Feb 2012 01:54:48 -0800 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: On Mon, Feb 20, 2012 at 11:39 PM, Anton Korobeynikov wrote: > I don't think that this routine should be in the common code... > However, I do not see the proper place right now. Maybe Eli knows :) No problem. I can move it to FunctionInfo instead as Eli originally recommended. > 1. Use the same code style as all other routines in the file. What needs to change exactly? I thought I was just moving existing code around. > 5. + ? ? ?for (po_iterator i = po_begin(T), e = po_end(T); > Should we traverse the whole Type tree here? Should fltused be emitted > even if we e.g. passing point to struct contaning float? I believe the important case is printf("%f"), so going one layer deep should be sufficient. However, I'm not enough of a Windows expert to know if it's technically necessary in deeper case. > Also... is is possible somehow shorten > "setCallsExternalVAFunctionWithFloatingPointArguments".... ? Sure, I'll do that. Thanks for the feedback, Anton. -Joe From baldrick at free.fr Tue Feb 21 03:56:15 2012 From: baldrick at free.fr (Duncan Sands) Date: Tue, 21 Feb 2012 10:56:15 +0100 Subject: [llvm-commits] [llvm] r151049 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp In-Reply-To: <20120221092552.752B42A6C12F@llvm.org> References: <20120221092552.752B42A6C12F@llvm.org> Message-ID: <4F436A3F.7060008@free.fr> Hi Jay, this nightly test builder http://lab.llvm.org:8011/builders/clang-x86_64-debian-fnt is showing many failures since your commit. Ciao, Duncan. On 21/02/12 10:25, Jay Foad wrote: > Author: foad > Date: Tue Feb 21 03:25:52 2012 > New Revision: 151049 > > URL: http://llvm.org/viewvc/llvm-project?rev=151049&view=rev > Log: > PR1210: make uniquing of struct and function types more efficient by > using a DenseMap and Talin's new GeneralHash, avoiding the need for a > temporary std::vector on every lookup. > > Patch by Meador Inge! > > Modified: > llvm/trunk/lib/VMCore/LLVMContextImpl.h > llvm/trunk/lib/VMCore/Type.cpp > > Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=151049&r1=151048&r2=151049&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original) > +++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Tue Feb 21 03:25:52 2012 > @@ -29,6 +29,7 @@ > #include "llvm/ADT/FoldingSet.h" > #include "llvm/ADT/SmallPtrSet.h" > #include "llvm/ADT/StringMap.h" > +#include "llvm/ADT/Hashing.h" > #include > > namespace llvm { > @@ -89,6 +90,107 @@ > } > }; > > +struct AnonStructTypeKeyInfo { > + struct KeyTy { > + ArrayRef ETypes; > + bool isPacked; > + KeyTy(const ArrayRef& E, bool P) : > + ETypes(E), isPacked(P) {} > + KeyTy(const KeyTy& that) : > + ETypes(that.ETypes), isPacked(that.isPacked) {} > + KeyTy(const StructType* ST) : > + ETypes(ArrayRef(ST->element_begin(), ST->element_end())), > + isPacked(ST->isPacked()) {} > + bool operator==(const KeyTy& that) const { > + if (isPacked != that.isPacked) > + return false; > + if (ETypes != that.ETypes) > + return false; > + return true; > + } > + bool operator!=(const KeyTy& that) const { > + return !this->operator==(that); > + } > + }; > + static inline StructType* getEmptyKey() { > + return DenseMapInfo::getEmptyKey(); > + } > + static inline StructType* getTombstoneKey() { > + return DenseMapInfo::getTombstoneKey(); > + } > + static unsigned getHashValue(const KeyTy& Key) { > + GeneralHash Hash; > + Hash.add(Key.ETypes); > + Hash.add(Key.isPacked); > + return Hash.finish(); > + } > + static unsigned getHashValue(const StructType *ST) { > + return getHashValue(KeyTy(ST)); > + } > + static bool isEqual(const KeyTy& LHS, const StructType *RHS) { > + if (RHS == getEmptyKey() || RHS == getTombstoneKey()) > + return false; > + return LHS == KeyTy(RHS); > + } > + static bool isEqual(const StructType *LHS, const StructType *RHS) { > + return LHS == RHS; > + } > +}; > + > +struct FunctionTypeKeyInfo { > + struct KeyTy { > + const Type *ReturnType; > + ArrayRef Params; > + bool isVarArg; > + KeyTy(const Type* R, const ArrayRef& P, bool V) : > + ReturnType(R), Params(P), isVarArg(V) {} > + KeyTy(const KeyTy& that) : > + ReturnType(that.ReturnType), > + Params(that.Params), > + isVarArg(that.isVarArg) {} > + KeyTy(const FunctionType* FT) : > + ReturnType(FT->getReturnType()), > + Params(ArrayRef(FT->param_begin(), FT->param_end())), > + isVarArg(FT->isVarArg()) {} > + bool operator==(const KeyTy& that) const { > + if (ReturnType != that.ReturnType) > + return false; > + if (isVarArg != that.isVarArg) > + return false; > + if (Params != that.Params) > + return false; > + return true; > + } > + bool operator!=(const KeyTy& that) const { > + return !this->operator==(that); > + } > + }; > + static inline FunctionType* getEmptyKey() { > + return DenseMapInfo::getEmptyKey(); > + } > + static inline FunctionType* getTombstoneKey() { > + return DenseMapInfo::getTombstoneKey(); > + } > + static unsigned getHashValue(const KeyTy& Key) { > + GeneralHash Hash; > + Hash.add(Key.ReturnType); > + Hash.add(Key.Params); > + Hash.add(Key.isVarArg); > + return Hash.finish(); > + } > + static unsigned getHashValue(const FunctionType *FT) { > + return getHashValue(KeyTy(FT)); > + } > + static bool isEqual(const KeyTy& LHS, const FunctionType *RHS) { > + if (RHS == getEmptyKey() || RHS == getTombstoneKey()) > + return false; > + return LHS == KeyTy(RHS); > + } > + static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) { > + return LHS == RHS; > + } > +}; > + > /// DebugRecVH - This is a CallbackVH used to keep the Scope -> index maps > /// up to date as MDNodes mutate. This class is implemented in DebugLoc.cpp. > class DebugRecVH : public CallbackVH { > @@ -180,9 +282,10 @@ > > DenseMap IntegerTypes; > > - // TODO: Optimize FunctionTypes/AnonStructTypes! > - std::map, FunctionType*> FunctionTypes; > - std::map, StructType*> AnonStructTypes; > + typedef DenseMap FunctionTypeMap; > + FunctionTypeMap FunctionTypes; > + typedef DenseMap StructTypeMap; > + StructTypeMap AnonStructTypes; > StringMap NamedStructTypes; > unsigned NamedStructTypesUniqueID; > > > Modified: llvm/trunk/lib/VMCore/Type.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=151049&r1=151048&r2=151049&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/Type.cpp (original) > +++ llvm/trunk/lib/VMCore/Type.cpp Tue Feb 21 03:25:52 2012 > @@ -390,24 +390,20 @@ > // FunctionType::get - The factory function for the FunctionType class. > FunctionType *FunctionType::get(Type *ReturnType, > ArrayRef Params, bool isVarArg) { > - // TODO: This is brutally slow. > - unsigned ParamsSize = Params.size(); > - std::vector Key; > - Key.reserve(ParamsSize + 2); > - Key.push_back(const_cast(ReturnType)); > - for (unsigned i = 0, e = ParamsSize; i != e; ++i) > - Key.push_back(const_cast(Params[i])); > - if (isVarArg) > - Key.push_back(0); > - > LLVMContextImpl *pImpl = ReturnType->getContext().pImpl; > - FunctionType *&FT = pImpl->FunctionTypes[Key]; > - > - if (FT == 0) { > + FunctionTypeKeyInfo::KeyTy Key(ReturnType, Params, isVarArg); > + LLVMContextImpl::FunctionTypeMap::iterator I = > + pImpl->FunctionTypes.find_as(Key); > + FunctionType *FT; > + > + if (I == pImpl->FunctionTypes.end()) { > FT = (FunctionType*) pImpl->TypeAllocator. > - Allocate(sizeof(FunctionType) + sizeof(Type*) * (ParamsSize + 1), > + Allocate(sizeof(FunctionType) + sizeof(Type*) * (Params.size() + 1), > AlignOf::Alignment); > new (FT) FunctionType(ReturnType, Params, isVarArg); > + pImpl->FunctionTypes[FT] = true; > + } else { > + FT = I->first; > } > > return FT; > @@ -440,24 +436,22 @@ > > StructType *StructType::get(LLVMContext&Context, ArrayRef ETypes, > bool isPacked) { > - // FIXME: std::vector is horribly inefficient for this probe. > - unsigned ETypesSize = ETypes.size(); > - std::vector Key(ETypesSize); > - for (unsigned i = 0, e = ETypesSize; i != e; ++i) { > - assert(isValidElementType(ETypes[i])&& > - "Invalid type for structure element!"); > - Key[i] = ETypes[i]; > + LLVMContextImpl *pImpl = Context.pImpl; > + AnonStructTypeKeyInfo::KeyTy Key(ETypes, isPacked); > + LLVMContextImpl::StructTypeMap::iterator I = > + pImpl->AnonStructTypes.find_as(Key); > + StructType *ST; > + > + if (I == pImpl->AnonStructTypes.end()) { > + // Value not found. Create a new type! > + ST = new (Context.pImpl->TypeAllocator) StructType(Context); > + ST->setSubclassData(SCDB_IsLiteral); // Literal struct. > + ST->setBody(ETypes, isPacked); > + Context.pImpl->AnonStructTypes[ST] = true; > + } else { > + ST = I->first; > } > - if (isPacked) > - Key.push_back(0); > - > - StructType *&ST = Context.pImpl->AnonStructTypes[Key]; > - if (ST) return ST; > - > - // Value not found. Create a new type! > - ST = new (Context.pImpl->TypeAllocator) StructType(Context); > - ST->setSubclassData(SCDB_IsLiteral); // Literal struct. > - ST->setBody(ETypes, isPacked); > + > return ST; > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From timurrrr at google.com Tue Feb 21 03:56:51 2012 From: timurrrr at google.com (timurrrr at google.com) Date: Tue, 21 Feb 2012 09:56:51 +0000 Subject: [llvm-commits] [ASan] Author one FIXME - re-enable "free-not-malloced" reports on Windows (issue 5688058) Message-ID: <001636c92b721981df04b9766ede@google.com> Reviewers: Evgeniy Stepanov, Message: Hi Evgeniy, Can you please take a look at this small CL? Thanks, Timur Description: Author one FIXME - re-enable "free-not-malloced" reports on Windows Please review this at http://codereview.appspot.com/5688058/ Affected files: M lib/asan/asan_allocator.cc Index: lib/asan/asan_allocator.cc diff --git a/lib/asan/asan_allocator.cc b/lib/asan/asan_allocator.cc index 28a3ef355fefeb07d5d7f49d8ef6d1621d83b006..5ac22df61b9c54793d3d74e8a475a8da8be7c5ad 100644 --- a/lib/asan/asan_allocator.cc +++ b/lib/asan/asan_allocator.cc @@ -695,11 +695,6 @@ static void Deallocate(uint8_t *ptr, AsanStackTrace *stack) { Describe((uintptr_t)ptr, 1); ShowStatsAndAbort(); } else if (m->chunk_state != CHUNK_ALLOCATED) { - if (ASAN_WINDOWS) { - // FIXME: On Windows there are a few extra "unknown free()s" - // from __endstdio, need investigating. - return; - } Report("ERROR: AddressSanitizer attempting free on address which was not" " malloc()-ed: %p\n", ptr); stack->PrintStack(); From timurrrr at google.com Tue Feb 21 03:58:32 2012 From: timurrrr at google.com (timurrrr at google.com) Date: Tue, 21 Feb 2012 09:58:32 +0000 Subject: [llvm-commits] [ASan] Remove one FIXME - re-enable "free-not-malloced" reports on Windows (issue 5688058) Message-ID: <0050450295092509ee04b9767430@google.com> [changing subject as I used the wrong verb] More details on why this was needed in the first place: http://code.google.com/p/address-sanitizer/issues/detail?id=43 http://codereview.appspot.com/5688058/ From eugenis at google.com Tue Feb 21 04:02:08 2012 From: eugenis at google.com (eugenis at google.com) Date: Tue, 21 Feb 2012 10:02:08 +0000 Subject: [llvm-commits] [ASan] Remove one FIXME - re-enable "free-not-malloced" reports on Windows (issue 5688058) Message-ID: <20cf302d4c5003fbe604b9768119@google.com> LGTM if it works for you http://codereview.appspot.com/5688058/ From timurrrr at google.com Tue Feb 21 03:58:40 2012 From: timurrrr at google.com (Timur Iskhodzhanov) Date: Tue, 21 Feb 2012 09:58:40 -0000 Subject: [llvm-commits] [compiler-rt] r151051 - /compiler-rt/trunk/lib/asan/asan_allocator.cc Message-ID: <20120221095840.1B2382A6C12F@llvm.org> Author: timurrrr Date: Tue Feb 21 03:58:39 2012 New Revision: 151051 URL: http://llvm.org/viewvc/llvm-project?rev=151051&view=rev Log: [ASan] Remove one FIXME - re-enable "free-not-malloced" reports on Windows Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=151051&r1=151050&r2=151051&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_allocator.cc (original) +++ compiler-rt/trunk/lib/asan/asan_allocator.cc Tue Feb 21 03:58:39 2012 @@ -695,11 +695,6 @@ Describe((uintptr_t)ptr, 1); ShowStatsAndAbort(); } else if (m->chunk_state != CHUNK_ALLOCATED) { - if (ASAN_WINDOWS) { - // FIXME: On Windows there are a few extra "unknown free()s" - // from __endstdio, need investigating. - return; - } Report("ERROR: AddressSanitizer attempting free on address which was not" " malloc()-ed: %p\n", ptr); stack->PrintStack(); From timurrrr at google.com Tue Feb 21 04:03:15 2012 From: timurrrr at google.com (timurrrr at google.com) Date: Tue, 21 Feb 2012 10:03:15 +0000 Subject: [llvm-commits] [ASan] Remove one FIXME - re-enable "free-not-malloced" reports on Windows (issue 5688058) Message-ID: <20cf3005e0f6ff9abc04b97684a3@google.com> On 2012/02/21 10:02:08, Evgeniy Stepanov wrote: > LGTM if it works for you Thanks, r151051 http://codereview.appspot.com/5688058/ From jay.foad at gmail.com Tue Feb 21 04:30:20 2012 From: jay.foad at gmail.com (Jay Foad) Date: Tue, 21 Feb 2012 10:30:20 +0000 Subject: [llvm-commits] [llvm] r151049 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp In-Reply-To: <4F436A3F.7060008@free.fr> References: <20120221092552.752B42A6C12F@llvm.org> <4F436A3F.7060008@free.fr> Message-ID: On 21 February 2012 09:56, Duncan Sands wrote: > Hi Jay, this nightly test builder > ? http://lab.llvm.org:8011/builders/clang-x86_64-debian-fnt > is showing many failures since your commit. Yes, but I can't reproduce them! I'm about to ask for help on llvmdev. Of course I'll revert the commit if necessary. Thanks, Jay. From benny.kra at googlemail.com Tue Feb 21 04:55:17 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 21 Feb 2012 11:55:17 +0100 Subject: [llvm-commits] [llvm] r150978 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp In-Reply-To: <4F435182.8040109@free.fr> References: <20120220184510.419FC2A6C12F@llvm.org> <4F435182.8040109@free.fr> Message-ID: On 21.02.2012, at 09:10, Duncan Sands wrote: > Hi Benjamin, > >> InstCombine: Removing the base from the address calculation is only safe when the GEPs are inbounds. > > since GEP is implicitly a signed computation, isn't this only true for signed > comparisons? I.e. mightn't an inbounds GEP overflow when viewed as an unsigned > computation, leading to wrongness for unsigned comparisons? Not sure if I understand. We're folding this to an index compare so the resulting icmp will always be signed. Also, overflow on inbounds GEPs is undefined behavior. - Ben > > Ciao, Duncan. > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From baldrick at free.fr Tue Feb 21 05:11:57 2012 From: baldrick at free.fr (Duncan Sands) Date: Tue, 21 Feb 2012 12:11:57 +0100 Subject: [llvm-commits] [llvm] r150978 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp In-Reply-To: References: <20120220184510.419FC2A6C12F@llvm.org> <4F435182.8040109@free.fr> Message-ID: <4F437BFD.70102@free.fr> Hi Benjamin, >>> InstCombine: Removing the base from the address calculation is only safe when the GEPs are inbounds. >> >> since GEP is implicitly a signed computation, isn't this only true for signed >> comparisons? I.e. mightn't an inbounds GEP overflow when viewed as an unsigned >> computation, leading to wrongness for unsigned comparisons? > > Not sure if I understand. We're folding this to an index compare so the resulting icmp will always be signed. Also, overflow on inbounds GEPs is undefined behavior. what does "overflow" mean? Suppose a pointer has 8 bits, so the values are: -128, -127, ..., -1, 0, 1, ..., 127 Can I have an object that spans addresses -1, 0, 1? Can I have an object that occupies addresses 127 and -128? If either of these is yes, then we had better be allowing inbounds GEP that (in the first case) has an unsigned overflow, and (if the second case is allowed) signed overflow. Ciao, Duncan. From jay.foad at gmail.com Tue Feb 21 05:37:51 2012 From: jay.foad at gmail.com (Jay Foad) Date: Tue, 21 Feb 2012 11:37:51 +0000 Subject: [llvm-commits] [llvm] r150890 - in /llvm/trunk: include/llvm/ADT/Hashing.h lib/Support/CMakeLists.txt lib/Support/Hashing.cpp unittests/ADT/HashingTest.cpp unittests/CMakeLists.txt In-Reply-To: <20120218210050.320912A6C12F@llvm.org> References: <20120218210050.320912A6C12F@llvm.org> Message-ID: On 18 February 2012 21:00, Talin wrote: > Author: talin > Date: Sat Feb 18 15:00:49 2012 > New Revision: 150890 > > URL: http://llvm.org/viewvc/llvm-project?rev=150890&view=rev > Log: > Hashing.h - utilities for hashing various data types. > > > Added: > ? ?llvm/trunk/include/llvm/ADT/Hashing.h > ? ?llvm/trunk/lib/Support/Hashing.cpp > ? ?llvm/trunk/unittests/ADT/HashingTest.cpp > Modified: > ? ?llvm/trunk/lib/Support/CMakeLists.txt > ? ?llvm/trunk/unittests/CMakeLists.txt > > Added: llvm/trunk/include/llvm/ADT/Hashing.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Hashing.h?rev=150890&view=auto > ============================================================================== > --- llvm/trunk/include/llvm/ADT/Hashing.h (added) > +++ llvm/trunk/include/llvm/ADT/Hashing.h Sat Feb 18 15:00:49 2012 > @@ -0,0 +1,180 @@ > +//===-- llvm/ADT/Hashing.h - Utilities for hashing --------------*- 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 utilities for computing hash values for various data types. > +// > +//===----------------------------------------------------------------------===// > + > +#ifndef LLVM_ADT_HASHING_H > +#define LLVM_ADT_HASHING_H > + > +#include "llvm/ADT/ArrayRef.h" > +#include "llvm/ADT/StringRef.h" > +#include "llvm/Support/AlignOf.h" > +#include "llvm/Support/Compiler.h" > +#include "llvm/Support/DataTypes.h" > + > +namespace llvm { > + > +/// Class to compute a hash value from multiple data fields of arbitrary > +/// types. Note that if you are hashing a single data type, such as a > +/// string, it may be cheaper to use a hash algorithm that is tailored > +/// for that specific data type. > +/// Typical Usage: > +/// ? ?GeneralHash Hash; > +/// ? ?Hash.add(someValue); > +/// ? ?Hash.add(someOtherValue); > +/// ? ?return Hash.finish(); > +/// Adapted from MurmurHash2 by Austin Appleby > +class GeneralHash { > +private: > + ?enum { > + ? ?M = 0x5bd1e995 > + ?}; > + ?unsigned Hash; > + ?unsigned Count; > +public: > + ?GeneralHash(unsigned Seed = 0) : Hash(Seed), Count(0) {} > + > + ?/// Add a pointer value. > + ?/// Note: this adds pointers to the hash using sizes and endianness that > + ?/// depend on the host. ?It doesn't matter however, because hashing on > + ?/// pointer values is inherently unstable. > + ?template > + ?GeneralHash& add(const T *PtrVal) { > + ? ?addBits(&PtrVal, &PtrVal + 1); > + ? ?return *this; > + ?} > + > + ?/// Add an ArrayRef of arbitrary data. > + ?template > + ?GeneralHash& add(ArrayRef ArrayVal) { > + ? ?addBits(ArrayVal.begin(), ArrayVal.end()); > + ? ?return *this; > + ?} > + > + ?/// Add a string > + ?GeneralHash& add(StringRef StrVal) { > + ? ?addBits(StrVal.begin(), StrVal.end()); > + ? ?return *this; > + ?} > + > + ?/// Add an signed 32-bit integer. > + ?GeneralHash& add(int32_t Data) { > + ? ?addInt(uint32_t(Data)); > + ? ?return *this; > + ?} > + > + ?/// Add an unsigned 32-bit integer. > + ?GeneralHash& add(uint32_t Data) { > + ? ?addInt(Data); > + ? ?return *this; > + ?} > + > + ?/// Add an signed 64-bit integer. > + ?GeneralHash& add(int64_t Data) { > + ? ?addInt(uint64_t(Data)); > + ? ?return *this; > + ?} > + > + ?/// Add an unsigned 64-bit integer. > + ?GeneralHash& add(uint64_t Data) { > + ? ?addInt(Data); > + ? ?return *this; > + ?} > + > + ?/// Add a float > + ?GeneralHash& add(float Data) { > + ? ?union { > + ? ? ?float D; uint32_t I; > + ? ?}; > + ? ?D = Data; > + ? ?addInt(I); > + ? ?return *this; > + ?} > + > + ?/// Add a double > + ?GeneralHash& add(double Data) { > + ? ?union { > + ? ? ?double D; uint64_t I; > + ? ?}; > + ? ?D = Data; > + ? ?addInt(I); > + ? ?return *this; > + ?} > + > + ?// Do a few final mixes of the hash to ensure the last few > + ?// bytes are well-incorporated. > + ?unsigned finish() { > + ? ?mix(Count); > + ? ?Hash ^= Hash >> 13; > + ? ?Hash *= M; > + ? ?Hash ^= Hash >> 15; > + ? ?return Hash; > + ?} > + > +private: > + ?void mix(uint32_t Data) { > + ? ?++Count; > + ? ?Data *= M; > + ? ?Data ^= Data >> 24; > + ? ?Data *= M; > + ? ?Hash *= M; > + ? ?Hash ^= Data; > + ?} > + > + ?// Add a single uint32 value > + ?void addInt(uint32_t Val) { > + ? ?mix(Val); > + ?} > + > + ?// Add a uint64 value > + ?void addInt(uint64_t Val) { > + ? ?mix(uint32_t(Val >> 32)); > + ? ?mix(uint32_t(Val)); > + ?} > + > + ?template > + ?struct addBitsImpl { > + ? ?static void add(GeneralHash &Hash, const T *I, const T *E) { > + ? ? ?Hash.addUnaligned( > + ? ? ? ?reinterpret_cast(I), > + ? ? ? ?reinterpret_cast(E)); > + ? ?} > + ?}; > + > + ?template > + ?struct addBitsImpl { > + ? ?static void add(GeneralHash &Hash, const T *I, const T *E) { > + ? ? ?Hash.addAligned( > + ? ? ? ?reinterpret_cast(I), > + ? ? ? ?reinterpret_cast(E)); > + ? ?} > + ?}; > + > + ?// Add a range of bits from I to E. > + ?template > + ?void addBits(const T *I, const T *E) { > + ? ?addBitsImpl::Alignment_GreaterEqual_4Bytes>::add(*this, I, E); > + ?} > + > + ?// Add a range of uint32s > + ?void addAligned(const uint32_t *I, const uint32_t *E) { > + ? ?while (I < E) { > + ? ? ?mix(*I++); > + ? ?} > + ?} > + > + ?// Add a possibly unaligned sequence of bytes. > + ?void addUnaligned(const uint8_t *I, const uint8_t *E); > +}; > + > +} // end namespace llvm > + > +#endif > > Modified: llvm/trunk/lib/Support/CMakeLists.txt > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=150890&r1=150889&r2=150890&view=diff > ============================================================================== > --- llvm/trunk/lib/Support/CMakeLists.txt (original) > +++ llvm/trunk/lib/Support/CMakeLists.txt Sat Feb 18 15:00:49 2012 > @@ -26,6 +26,7 @@ > ? FoldingSet.cpp > ? FormattedStream.cpp > ? GraphWriter.cpp > + ?Hashing.cpp > ? IntEqClasses.cpp > ? IntervalMap.cpp > ? IntrusiveRefCntPtr.cpp > > Added: llvm/trunk/lib/Support/Hashing.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Hashing.cpp?rev=150890&view=auto > ============================================================================== > --- llvm/trunk/lib/Support/Hashing.cpp (added) > +++ llvm/trunk/lib/Support/Hashing.cpp Sat Feb 18 15:00:49 2012 > @@ -0,0 +1,46 @@ > +//===-- llvm/ADT/Hashing.cpp - Utilities for hashing ------------*- C++ -*-===// > +// > +// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > + > +#include "llvm/ADT/Hashing.h" > + > +namespace llvm { > + > +// Add a possibly unaligned sequence of bytes. > +void GeneralHash::addUnaligned(const uint8_t *I, const uint8_t *E) { > + ?ptrdiff_t Length = E - I; > + ?if (uintptr_t(I) & 3 == 0) { > + ? ?while (Length > 3) { > + ? ? ?mix(*reinterpret_cast(I)); > + ? ? ?I += 4; > + ? ? ?Length -= 4; > + ? ?} > + ?} else { > + ? ?while (Length > 3) { > + ? ? ?mix( > + ? ? ? ?uint32_t(I[0]) + > + ? ? ? ?(uint32_t(I[1]) << 8) + > + ? ? ? ?(uint32_t(I[2]) << 16) + > + ? ? ? ?(uint32_t(I[3]) << 24)); > + ? ? ?I += 4; > + ? ? ?Length -= 4; > + ? ?} > + ?} > + > + ?if (Length & 3) { > + ? ?uint32_t Data = 0; > + ? ?switch (Length & 3) { > + ? ? ?case 3: Data |= uint32_t(I[2]) << 16; ? // fall through > + ? ? ?case 2: Data |= uint32_t(I[1]) << 8; ? ?// fall through > + ? ? ?case 1: Data |= uint32_t(I[0]); break; > + ? ?} > + ? ?mix(Data); > + ?} > +} > + > +} > > Added: llvm/trunk/unittests/ADT/HashingTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/HashingTest.cpp?rev=150890&view=auto > ============================================================================== > --- llvm/trunk/unittests/ADT/HashingTest.cpp (added) > +++ llvm/trunk/unittests/ADT/HashingTest.cpp Sat Feb 18 15:00:49 2012 > @@ -0,0 +1,57 @@ > +//===- llvm/unittest/ADT/HashingTest.cpp ----------------------------------===// > +// > +// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// Hashing.h unit tests. > +// > +//===----------------------------------------------------------------------===// > + > +#include "gtest/gtest.h" > +#include "llvm/ADT/Hashing.h" > + > +using namespace llvm; > + > +namespace { > + > +TEST(HashingTest, EmptyHashTest) { > + ?GeneralHash Hash; > + ?ASSERT_EQ(0u, Hash.finish()); > +} > + > +TEST(HashingTest, IntegerHashTest) { > + ?ASSERT_TRUE(GeneralHash().add(1).finish() == GeneralHash().add(1).finish()); > + ?ASSERT_TRUE(GeneralHash().add(1).finish() != GeneralHash().add(2).finish()); > +} > + > +TEST(HashingTest, StringHashTest) { > + ?ASSERT_TRUE( > + ? ?GeneralHash().add("abc").finish() == GeneralHash().add("abc").finish()); > + ?ASSERT_TRUE( > + ? ?GeneralHash().add("abc").finish() != GeneralHash().add("abcd").finish()); > +} > + > +TEST(HashingTest, FloatHashTest) { > + ?ASSERT_TRUE( > + ? ?GeneralHash().add(1.0f).finish() == GeneralHash().add(1.0f).finish()); > + ?ASSERT_TRUE( > + ? ?GeneralHash().add(1.0f).finish() != GeneralHash().add(2.0f).finish()); > +} > + > +TEST(HashingTest, DoubleHashTest) { > + ?ASSERT_TRUE(GeneralHash().add(1.).finish() == GeneralHash().add(1.).finish()); > + ?ASSERT_TRUE(GeneralHash().add(1.).finish() != GeneralHash().add(2.).finish()); > +} > + > +TEST(HashingTest, IntegerArrayHashTest) { > + ?int a[] = { 1, 2 }; > + ?int b[] = { 1, 3 }; > + ?ASSERT_TRUE(GeneralHash().add(a).finish() == GeneralHash().add(a).finish()); > + ?ASSERT_TRUE(GeneralHash().add(a).finish() != GeneralHash().add(b).finish()); > +} > + > +} > > Modified: llvm/trunk/unittests/CMakeLists.txt > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CMakeLists.txt?rev=150890&r1=150889&r2=150890&view=diff > ============================================================================== > --- llvm/trunk/unittests/CMakeLists.txt (original) > +++ llvm/trunk/unittests/CMakeLists.txt Sat Feb 18 15:00:49 2012 > @@ -60,6 +60,7 @@ > ? ADT/DenseMapTest.cpp > ? ADT/DenseSetTest.cpp > ? ADT/FoldingSet.cpp > + ?ADT/HashingTest.cpp > ? ADT/ilistTest.cpp > ? ADT/ImmutableSetTest.cpp > ? ADT/IntEqClassesTest.cpp > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits After committing Meador's patch to use this for uniquing struct and function types, I get this GCC warning about strict aliasing: In file included from /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/lib/VMCore/ConstantsContext.h:18, from /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/lib/VMCore/LLVMContextImpl.h:19, from /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/lib/VMCore/Type.cpp:14: /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/include/llvm/ADT/Hashing.h: In member function 'void llvm::DenseMap::grow(unsigned int) [with KeyT = llvm::FunctionType*, ValueT = bool, KeyInfoT = llvm::FunctionTypeKeyInfo, ValueInfoT = llvm::DenseMapInfo]': /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/include/llvm/ADT/Hashing.h:170: warning: dereferencing pointer 'I' does break strict-aliasing rules /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/include/llvm/ADT/Hashing.h:155: note: initialized from here Jay. From jay.foad at gmail.com Tue Feb 21 05:44:46 2012 From: jay.foad at gmail.com (Jay Foad) Date: Tue, 21 Feb 2012 11:44:46 -0000 Subject: [llvm-commits] [llvm] r151052 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp Message-ID: <20120221114446.DF6CD2A6C12F@llvm.org> Author: foad Date: Tue Feb 21 05:44:46 2012 New Revision: 151052 URL: http://llvm.org/viewvc/llvm-project?rev=151052&view=rev Log: Revert r151049 cos it broke the buildbots. Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=151052&r1=151051&r2=151052&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Tue Feb 21 05:44:46 2012 @@ -29,7 +29,6 @@ #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringMap.h" -#include "llvm/ADT/Hashing.h" #include namespace llvm { @@ -90,107 +89,6 @@ } }; -struct AnonStructTypeKeyInfo { - struct KeyTy { - ArrayRef ETypes; - bool isPacked; - KeyTy(const ArrayRef& E, bool P) : - ETypes(E), isPacked(P) {} - KeyTy(const KeyTy& that) : - ETypes(that.ETypes), isPacked(that.isPacked) {} - KeyTy(const StructType* ST) : - ETypes(ArrayRef(ST->element_begin(), ST->element_end())), - isPacked(ST->isPacked()) {} - bool operator==(const KeyTy& that) const { - if (isPacked != that.isPacked) - return false; - if (ETypes != that.ETypes) - return false; - return true; - } - bool operator!=(const KeyTy& that) const { - return !this->operator==(that); - } - }; - static inline StructType* getEmptyKey() { - return DenseMapInfo::getEmptyKey(); - } - static inline StructType* getTombstoneKey() { - return DenseMapInfo::getTombstoneKey(); - } - static unsigned getHashValue(const KeyTy& Key) { - GeneralHash Hash; - Hash.add(Key.ETypes); - Hash.add(Key.isPacked); - return Hash.finish(); - } - static unsigned getHashValue(const StructType *ST) { - return getHashValue(KeyTy(ST)); - } - static bool isEqual(const KeyTy& LHS, const StructType *RHS) { - if (RHS == getEmptyKey() || RHS == getTombstoneKey()) - return false; - return LHS == KeyTy(RHS); - } - static bool isEqual(const StructType *LHS, const StructType *RHS) { - return LHS == RHS; - } -}; - -struct FunctionTypeKeyInfo { - struct KeyTy { - const Type *ReturnType; - ArrayRef Params; - bool isVarArg; - KeyTy(const Type* R, const ArrayRef& P, bool V) : - ReturnType(R), Params(P), isVarArg(V) {} - KeyTy(const KeyTy& that) : - ReturnType(that.ReturnType), - Params(that.Params), - isVarArg(that.isVarArg) {} - KeyTy(const FunctionType* FT) : - ReturnType(FT->getReturnType()), - Params(ArrayRef(FT->param_begin(), FT->param_end())), - isVarArg(FT->isVarArg()) {} - bool operator==(const KeyTy& that) const { - if (ReturnType != that.ReturnType) - return false; - if (isVarArg != that.isVarArg) - return false; - if (Params != that.Params) - return false; - return true; - } - bool operator!=(const KeyTy& that) const { - return !this->operator==(that); - } - }; - static inline FunctionType* getEmptyKey() { - return DenseMapInfo::getEmptyKey(); - } - static inline FunctionType* getTombstoneKey() { - return DenseMapInfo::getTombstoneKey(); - } - static unsigned getHashValue(const KeyTy& Key) { - GeneralHash Hash; - Hash.add(Key.ReturnType); - Hash.add(Key.Params); - Hash.add(Key.isVarArg); - return Hash.finish(); - } - static unsigned getHashValue(const FunctionType *FT) { - return getHashValue(KeyTy(FT)); - } - static bool isEqual(const KeyTy& LHS, const FunctionType *RHS) { - if (RHS == getEmptyKey() || RHS == getTombstoneKey()) - return false; - return LHS == KeyTy(RHS); - } - static bool isEqual(const FunctionType *LHS, const FunctionType *RHS) { - return LHS == RHS; - } -}; - /// DebugRecVH - This is a CallbackVH used to keep the Scope -> index maps /// up to date as MDNodes mutate. This class is implemented in DebugLoc.cpp. class DebugRecVH : public CallbackVH { @@ -282,10 +180,9 @@ DenseMap IntegerTypes; - typedef DenseMap FunctionTypeMap; - FunctionTypeMap FunctionTypes; - typedef DenseMap StructTypeMap; - StructTypeMap AnonStructTypes; + // TODO: Optimize FunctionTypes/AnonStructTypes! + std::map, FunctionType*> FunctionTypes; + std::map, StructType*> AnonStructTypes; StringMap NamedStructTypes; unsigned NamedStructTypesUniqueID; Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=151052&r1=151051&r2=151052&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Feb 21 05:44:46 2012 @@ -390,20 +390,24 @@ // FunctionType::get - The factory function for the FunctionType class. FunctionType *FunctionType::get(Type *ReturnType, ArrayRef Params, bool isVarArg) { + // TODO: This is brutally slow. + unsigned ParamsSize = Params.size(); + std::vector Key; + Key.reserve(ParamsSize + 2); + Key.push_back(const_cast(ReturnType)); + for (unsigned i = 0, e = ParamsSize; i != e; ++i) + Key.push_back(const_cast(Params[i])); + if (isVarArg) + Key.push_back(0); + LLVMContextImpl *pImpl = ReturnType->getContext().pImpl; - FunctionTypeKeyInfo::KeyTy Key(ReturnType, Params, isVarArg); - LLVMContextImpl::FunctionTypeMap::iterator I = - pImpl->FunctionTypes.find_as(Key); - FunctionType *FT; - - if (I == pImpl->FunctionTypes.end()) { + FunctionType *&FT = pImpl->FunctionTypes[Key]; + + if (FT == 0) { FT = (FunctionType*) pImpl->TypeAllocator. - Allocate(sizeof(FunctionType) + sizeof(Type*) * (Params.size() + 1), + Allocate(sizeof(FunctionType) + sizeof(Type*) * (ParamsSize + 1), AlignOf::Alignment); new (FT) FunctionType(ReturnType, Params, isVarArg); - pImpl->FunctionTypes[FT] = true; - } else { - FT = I->first; } return FT; @@ -436,22 +440,24 @@ StructType *StructType::get(LLVMContext &Context, ArrayRef ETypes, bool isPacked) { - LLVMContextImpl *pImpl = Context.pImpl; - AnonStructTypeKeyInfo::KeyTy Key(ETypes, isPacked); - LLVMContextImpl::StructTypeMap::iterator I = - pImpl->AnonStructTypes.find_as(Key); - StructType *ST; - - if (I == pImpl->AnonStructTypes.end()) { - // Value not found. Create a new type! - ST = new (Context.pImpl->TypeAllocator) StructType(Context); - ST->setSubclassData(SCDB_IsLiteral); // Literal struct. - ST->setBody(ETypes, isPacked); - Context.pImpl->AnonStructTypes[ST] = true; - } else { - ST = I->first; + // FIXME: std::vector is horribly inefficient for this probe. + unsigned ETypesSize = ETypes.size(); + std::vector Key(ETypesSize); + for (unsigned i = 0, e = ETypesSize; i != e; ++i) { + assert(isValidElementType(ETypes[i]) && + "Invalid type for structure element!"); + Key[i] = ETypes[i]; } - + if (isPacked) + Key.push_back(0); + + StructType *&ST = Context.pImpl->AnonStructTypes[Key]; + if (ST) return ST; + + // Value not found. Create a new type! + ST = new (Context.pImpl->TypeAllocator) StructType(Context); + ST->setSubclassData(SCDB_IsLiteral); // Literal struct. + ST->setBody(ETypes, isPacked); return ST; } From geek4civic at gmail.com Tue Feb 21 05:56:42 2012 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 21 Feb 2012 11:56:42 -0000 Subject: [llvm-commits] [llvm] r151053 - /llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll Message-ID: <20120221115642.8CEA32A6C12F@llvm.org> Author: chapuni Date: Tue Feb 21 05:56:42 2012 New Revision: 151053 URL: http://llvm.org/viewvc/llvm-project?rev=151053&view=rev Log: test/CodeGen/X86/2012-02-20-MachineCPBug.ll: Fix on generic(non-x86) hosts to add -mattr=+sse. Modified: llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll Modified: llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll?rev=151053&r1=151052&r2=151053&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2012-02-20-MachineCPBug.ll Tue Feb 21 05:56:42 2012 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=i386-apple-macosx | FileCheck %s +; RUN: llc < %s -mtriple=i386-apple-macosx -mattr=+sse | FileCheck %s ; PR11940: Do not optimize away movb %al, %ch %struct.APInt = type { i64* } From baldrick at free.fr Tue Feb 21 06:00:25 2012 From: baldrick at free.fr (Duncan Sands) Date: Tue, 21 Feb 2012 12:00:25 -0000 Subject: [llvm-commits] [llvm] r151054 - in /llvm/trunk/lib/Support: StringExtras.cpp StringRef.cpp Message-ID: <20120221120026.01D762A6C12F@llvm.org> Author: baldrick Date: Tue Feb 21 06:00:25 2012 New Revision: 151054 URL: http://llvm.org/viewvc/llvm-project?rev=151054&view=rev Log: Move the implementation of StringRef::split out of StringExtras.cpp and into StringRef.cpp, which is where the other StringRef stuff is. Modified: llvm/trunk/lib/Support/StringExtras.cpp llvm/trunk/lib/Support/StringRef.cpp Modified: llvm/trunk/lib/Support/StringExtras.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=151054&r1=151053&r2=151054&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringExtras.cpp (original) +++ llvm/trunk/lib/Support/StringExtras.cpp Tue Feb 21 06:00:25 2012 @@ -57,24 +57,3 @@ S = getToken(S.second, Delimiters); } } - -void llvm::StringRef::split(SmallVectorImpl &A, - StringRef Separators, int MaxSplit, - bool KeepEmpty) const { - StringRef rest = *this; - - // rest.data() is used to distinguish cases like "a," that splits into - // "a" + "" and "a" that splits into "a" + 0. - for (int splits = 0; - rest.data() != NULL && (MaxSplit < 0 || splits < MaxSplit); - ++splits) { - std::pair p = rest.split(Separators); - - if (p.first.size() != 0 || KeepEmpty) - A.push_back(p.first); - rest = p.second; - } - // If we have a tail left, add it. - if (rest.data() != NULL && (rest.size() != 0 || KeepEmpty)) - A.push_back(rest); -} Modified: llvm/trunk/lib/Support/StringRef.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringRef.cpp?rev=151054&r1=151053&r2=151054&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringRef.cpp (original) +++ llvm/trunk/lib/Support/StringRef.cpp Tue Feb 21 06:00:25 2012 @@ -229,6 +229,27 @@ return npos; } +void StringRef::split(SmallVectorImpl &A, + StringRef Separators, int MaxSplit, + bool KeepEmpty) const { + StringRef rest = *this; + + // rest.data() is used to distinguish cases like "a," that splits into + // "a" + "" and "a" that splits into "a" + 0. + for (int splits = 0; + rest.data() != NULL && (MaxSplit < 0 || splits < MaxSplit); + ++splits) { + std::pair p = rest.split(Separators); + + if (p.first.size() != 0 || KeepEmpty) + A.push_back(p.first); + rest = p.second; + } + // If we have a tail left, add it. + if (rest.data() != NULL && (rest.size() != 0 || KeepEmpty)) + A.push_back(rest); +} + //===----------------------------------------------------------------------===// // Helpful Algorithms //===----------------------------------------------------------------------===// From pekka.jaaskelainen at tut.fi Tue Feb 21 06:17:15 2012 From: pekka.jaaskelainen at tut.fi (=?UTF-8?B?UGVra2EgSsOkw6Rza2Vsw6RpbmVu?=) Date: Tue, 21 Feb 2012 14:17:15 +0200 Subject: [llvm-commits] [llvm] r151049 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp In-Reply-To: References: <20120221092552.752B42A6C12F@llvm.org> <4F436A3F.7060008@free.fr> Message-ID: <4F438B4B.5080007@tut.fi> On 02/21/2012 12:30 PM, Jay Foad wrote: > On 21 February 2012 09:56, Duncan Sands wrote: >> Hi Jay, this nightly test builder >> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fnt >> is showing many failures since your commit. > > Yes, but I can't reproduce them! I'm about to ask for help on llvmdev. > Of course I'll revert the commit if necessary. Unsure if this was due to your commit, but at least it got fixed after your revert: http://codepad.org/Muc4VPwb -- Pekka From jay.foad at gmail.com Tue Feb 21 06:23:01 2012 From: jay.foad at gmail.com (Jay Foad) Date: Tue, 21 Feb 2012 12:23:01 +0000 Subject: [llvm-commits] [llvm] r151049 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp In-Reply-To: <4F438B4B.5080007@tut.fi> References: <20120221092552.752B42A6C12F@llvm.org> <4F436A3F.7060008@free.fr> <4F438B4B.5080007@tut.fi> Message-ID: On 21 February 2012 12:17, Pekka J??skel?inen wrote: > Unsure if this was due to your commit, but at least it got fixed after > your revert: > > http://codepad.org/Muc4VPwb How did you build llvm+clang? Was it a release or debug build? What version of gcc (or other compiler) did you build it with? I'm only seeing "make check" failures with certain build configurations: gcc 4.4 release: fail gcc 4.4 debug: pass gcc 4.6 release: pass gcc 4.6 debug: pass Thanks, Jay. From anton at korobeynikov.info Tue Feb 21 07:10:51 2012 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 21 Feb 2012 16:10:51 +0300 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: Joe, > I believe the important case is printf("%f"), so going one layer deep > should be sufficient. However, I'm not enough of a Windows expert to > know if it's technically necessary in deeper case. Well... Do you have vcpp in hand? You can check in which conditions call to fltused is emitted. Typical cases: 1. Ordinary floating point operand 2. float* 3. struct { float } 4. struct { float } * -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From aaron at aaronballman.com Tue Feb 21 07:11:35 2012 From: aaron at aaronballman.com (Aaron Ballman) Date: Tue, 21 Feb 2012 07:11:35 -0600 Subject: [llvm-commits] Patch for pr9213: Emit global_ctors into MSVCRT-compatible '.CRT$XCU' section for win32 targets In-Reply-To: References: Message-ID: On Tue, Feb 21, 2012 at 12:46 AM, Joe Groff wrote: > Here's a partial fix I sent a while back for pr9213. With this patch, > global_ctors pointers will be generated into the '.CRT$XCU' section of > the COFF output file instead of '.ctors' when targeting *-*-win32, so > that global_ctors will be run automatically by the Microsoft CRT. > (MSVCRT does not support an analog to the sysv '.dtors' section, so > this patch does not affect global_dtors, which still will not be run > by the stock CRT on win32 targets.) Let me know if any changes are > necessary. Thanks. LGTM -- but if you can send svn diffs, that would make it easier to commit (at least for me). ~Aaron From benny.kra at googlemail.com Tue Feb 21 07:31:09 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 21 Feb 2012 13:31:09 -0000 Subject: [llvm-commits] [llvm] r151055 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll Message-ID: <20120221133109.A85E62A6C12F@llvm.org> Author: d0k Date: Tue Feb 21 07:31:09 2012 New Revision: 151055 URL: http://llvm.org/viewvc/llvm-project?rev=151055&view=rev Log: InstCombine: Don't transform a signed icmp of two GEPs into a signed compare of the indices. This transformation is not safe in some pathological cases (signed icmp of pointers should be an extremely rare thing, but it's valid IR!). Add an explanatory comment. Kudos to Duncan for pointing out this edge case (and not giving up explaining it until I finally got it). Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/test/Transforms/InstCombine/icmp.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=151055&r1=151054&r2=151055&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Feb 21 07:31:09 2012 @@ -571,6 +571,14 @@ Instruction *InstCombiner::FoldGEPICmp(GEPOperator *GEPLHS, Value *RHS, ICmpInst::Predicate Cond, Instruction &I) { + // Don't transform signed compares of GEPs into index compares. Even if the + // GEP is inbounds, the final add of the base pointer can have signed overflow + // and would change the result of the icmp. + // e.g. "&foo[0] (RHS)) RHS = BCI->getOperand(0); Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=151055&r1=151054&r2=151055&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Tue Feb 21 07:31:09 2012 @@ -628,3 +628,14 @@ ; CHECK: icmp ult i8* %cast1, %gep2 ; CHECK-NEXT: ret i1 } + +define i1 @test62(i8* %a) { + %arrayidx1 = getelementptr inbounds i8* %a, i64 1 + %arrayidx2 = getelementptr inbounds i8* %a, i64 10 + %cmp = icmp slt i8* %arrayidx1, %arrayidx2 + ret i1 %cmp +; Don't turn a signed cmp of GEPs into an index compare. +; CHECK: @test62 +; CHECK: %cmp = icmp slt i8* %arrayidx1, %arrayidx2 +; CHECK-NEXT: ret i1 %cmp +} From benny.kra at googlemail.com Tue Feb 21 07:37:40 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 21 Feb 2012 14:37:40 +0100 Subject: [llvm-commits] [llvm] r150978 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp In-Reply-To: <4F437BFD.70102@free.fr> References: <20120220184510.419FC2A6C12F@llvm.org> <4F435182.8040109@free.fr> <4F437BFD.70102@free.fr> Message-ID: <95A6D725-0D4A-4D10-9D2F-6928E3383F8C@googlemail.com> On 21.02.2012, at 12:11, Duncan Sands wrote: > Hi Benjamin, > >>>> InstCombine: Removing the base from the address calculation is only safe when the GEPs are inbounds. >>> >>> since GEP is implicitly a signed computation, isn't this only true for signed >>> comparisons? I.e. mightn't an inbounds GEP overflow when viewed as an unsigned >>> computation, leading to wrongness for unsigned comparisons? >> >> Not sure if I understand. We're folding this to an index compare so the resulting icmp will always be signed. Also, overflow on inbounds GEPs is undefined behavior. > > what does "overflow" mean? Suppose a pointer has 8 bits, so the values are: > > -128, -127, ..., -1, 0, 1, ..., 127 > > Can I have an object that spans addresses -1, 0, 1? Can I have an object that > occupies addresses 127 and -128? If either of these is yes, then we had better > be allowing inbounds GEP that (in the first case) has an unsigned overflow, and > (if the second case is allowed) signed overflow. After some discussion on IRC it became clear that this transformation is not valid for signed ICMPs. I added a check for them and some explanation in r151055. Thanks Duncan! - Ben > > Ciao, Duncan. From baldrick at free.fr Tue Feb 21 07:38:27 2012 From: baldrick at free.fr (Duncan Sands) Date: Tue, 21 Feb 2012 14:38:27 +0100 Subject: [llvm-commits] [llvm] r151055 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll In-Reply-To: <20120221133109.A85E62A6C12F@llvm.org> References: <20120221133109.A85E62A6C12F@llvm.org> Message-ID: <4F439E53.7050105@free.fr> Hi Benjamin, > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Feb 21 07:31:09 2012 > @@ -571,6 +571,14 @@ > Instruction *InstCombiner::FoldGEPICmp(GEPOperator *GEPLHS, Value *RHS, > ICmpInst::Predicate Cond, > Instruction&I) { > + // Don't transform signed compares of GEPs into index compares. Even if the > + // GEP is inbounds, the final add of the base pointer can have signed overflow > + // and would change the result of the icmp. > + // e.g. "&foo[0] + // the minimum signed value for the pointer type. I just this should be: the maximum signed value. Ciao, Duncan. From benny.kra at googlemail.com Tue Feb 21 07:40:06 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 21 Feb 2012 13:40:06 -0000 Subject: [llvm-commits] [llvm] r151056 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Message-ID: <20120221134008.08F8B2A6C12F@llvm.org> Author: d0k Date: Tue Feb 21 07:40:06 2012 New Revision: 151056 URL: http://llvm.org/viewvc/llvm-project?rev=151056&view=rev Log: Fix unsigned off-by-one in comment. 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=151056&r1=151055&r2=151056&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Feb 21 07:40:06 2012 @@ -575,7 +575,7 @@ // GEP is inbounds, the final add of the base pointer can have signed overflow // and would change the result of the icmp. // e.g. "&foo[0] References: <20120218210050.320912A6C12F@llvm.org> Message-ID: On 21 February 2012 11:37, Jay Foad wrote: > After committing Meador's patch to use this for uniquing struct and > function types, I get this GCC warning about strict aliasing: > > In file included from > /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/lib/VMCore/ConstantsContext.h:18, > ? ? ? ? ? ? ? ? from > /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/lib/VMCore/LLVMContextImpl.h:19, > ? ? ? ? ? ? ? ? from > /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/lib/VMCore/Type.cpp:14: > /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/include/llvm/ADT/Hashing.h: > In member function 'void llvm::DenseMap ValueInfoT>::grow(unsigned int) [with KeyT = llvm::FunctionType*, > ValueT = bool, KeyInfoT = llvm::FunctionTypeKeyInfo, ValueInfoT = > llvm::DenseMapInfo]': > /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/include/llvm/ADT/Hashing.h:170: > warning: dereferencing pointer 'I' does break strict-aliasing rules > /home/baldrick/osuosl/slave/clang-x86_64-debian-fnt/llvm.src/include/llvm/ADT/Hashing.h:155: > note: initialized from here ... and I'm pretty sure that this is the reason for the "make check" failures I see in a Release+Asserts build built with GCC 4.4. I tried this workaround: Index: include/llvm/ADT/Hashing.h =================================================================== --- include/llvm/ADT/Hashing.h (revision 151050) +++ include/llvm/ADT/Hashing.h (working copy) @@ -167,7 +167,9 @@ // Add a range of uint32s void addAligned(const uint32_t *I, const uint32_t *E) { while (I < E) { - mix(*I++); + uint32_t u; + memcpy(&u, I++, sizeof u); + mix(u); } } and it fixes all the failures. But I have no idea what it does to the generated code, or whether it's really a good way to work around the aliasing problems. Jay. From glider at google.com Tue Feb 21 08:11:52 2012 From: glider at google.com (Alexander Potapenko) Date: Tue, 21 Feb 2012 14:11:52 -0000 Subject: [llvm-commits] [compiler-rt] r151057 - /compiler-rt/trunk/lib/asan/Makefile.old Message-ID: <20120221141152.540652A6C12F@llvm.org> Author: glider Date: Tue Feb 21 08:11:52 2012 New Revision: 151057 URL: http://llvm.org/viewvc/llvm-project?rev=151057&view=rev Log: Fix the lib32 and lib64 targets. Modified: compiler-rt/trunk/lib/asan/Makefile.old Modified: compiler-rt/trunk/lib/asan/Makefile.old URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/Makefile.old?rev=151057&r1=151056&r2=151057&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/Makefile.old (original) +++ compiler-rt/trunk/lib/asan/Makefile.old Tue Feb 21 08:11:52 2012 @@ -227,9 +227,9 @@ $(MAKE) -f $(MAKEFILE) ARCH=i386 asan_test asan_benchmarks lib64: - $(MAKE) $(MAKEFILE) ARCH=x86_64 lib + $(MAKE) -f $(MAKEFILE) ARCH=x86_64 lib lib32: - $(MAKE) $(MAKEFILE) ARCH=i386 lib + $(MAKE) -f $(MAKEFILE) ARCH=i386 lib mk_bin_dir: mkdir -p $(BIN) @@ -284,7 +284,7 @@ lib: $(LIBASAN_A) -$(LIBASAN_A): $(BIN) $(LIBASAN_OBJ) $(MAKEFILE) +$(LIBASAN_A): mk_bin_dir $(LIBASAN_OBJ) $(MAKEFILE) mkdir -p $(LIBASAN_INST_DIR) ar ru $@ $(LIBASAN_OBJ) $(CXX) -shared $(CFLAGS) $(LIBASAN_OBJ) $(LD_FLAGS) -o $(BIN)/libasan$(SUFF).so From dblaikie at gmail.com Tue Feb 21 10:05:51 2012 From: dblaikie at gmail.com (David Blaikie) Date: Tue, 21 Feb 2012 08:05:51 -0800 Subject: [llvm-commits] Patch for pr9213: Emit global_ctors into MSVCRT-compatible '.CRT$XCU' section for win32 targets In-Reply-To: References: Message-ID: On Tue, Feb 21, 2012 at 5:11 AM, Aaron Ballman wrote: > On Tue, Feb 21, 2012 at 12:46 AM, Joe Groff wrote: >> Here's a partial fix I sent a while back for pr9213. With this patch, >> global_ctors pointers will be generated into the '.CRT$XCU' section of >> the COFF output file instead of '.ctors' when targeting *-*-win32, so >> that global_ctors will be run automatically by the Microsoft CRT. >> (MSVCRT does not support an analog to the sysv '.dtors' section, so >> this patch does not affect global_dtors, which still will not be run >> by the stock CRT on win32 targets.) Let me know if any changes are >> necessary. Thanks. > > LGTM -- but if you can send svn diffs, that would make it easier to > commit (at least for me). When applying git diffs you can use patch -p1 instead of patch -p0 (though I guess you work on Windows - not sure what tools you use there/or what their equivalent operation would be) - David From timurrrr at google.com Tue Feb 21 10:22:02 2012 From: timurrrr at google.com (timurrrr at google.com) Date: Tue, 21 Feb 2012 16:22:02 +0000 Subject: [llvm-commits] [ASan] Add __asan_init to the list of C dynamic initializers to support /MD (issue 5688060) Message-ID: <20cf303bfd22a5bed504b97bcf39@google.com> Reviewers: glider, Message: Hi Alexander, Can you please review this small patch? [Remember we were doing experiments on the .CRT sections together an hour ago?] Thanks, Timur Description: [ASan] Add __asan_init to the list of C dynamic initializers to support /MD Please review this at http://codereview.appspot.com/5688060/ Affected files: M lib/asan/asan_rtl.cc Index: lib/asan/asan_rtl.cc diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index e0a920756c85fc0cff42abc80c36efffac44572a..4fb873fced33e419dc245a917c4ae3b558cae3e5 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -508,9 +508,15 @@ void __asan_init() { } #if defined(ASAN_USE_PREINIT_ARRAY) -// On Linux, we force __asan_init to be called before anyone else -// by placing it into .preinit_array section. -// FIXME: do we have anything like this on Mac? -__attribute__((section(".preinit_array"))) - typeof(__asan_init) *__asan_preinit =__asan_init; + // On Linux, we force __asan_init to be called before anyone else + // by placing it into .preinit_array section. + // FIXME: do we have anything like this on Mac? + __attribute__((section(".preinit_array"))) + typeof(__asan_init) *__asan_preinit =__asan_init; +#elif defined(_WIN32) && defined(_DLL) + // On Windows, when using dynamic CRT (/MD), we can put a pointer to __asan_init + // into the global list of C initializers. + // See crt0dat.c in the CRT sources for the details. + #pragma section(".CRT$XIB",long,read) + __declspec(allocate(".CRT$XIB")) void (*__asan_preinit)() = __asan_init; #endif From glider at google.com Tue Feb 21 10:27:35 2012 From: glider at google.com (glider at google.com) Date: Tue, 21 Feb 2012 16:27:35 +0000 Subject: [llvm-commits] [ASan] Add __asan_init to the list of C dynamic initializers to support /MD (issue 5688060) Message-ID: <20cf305640d17ce1df04b97be390@google.com> LGTM http://codereview.appspot.com/5688060/ From timurrrr at google.com Tue Feb 21 10:24:23 2012 From: timurrrr at google.com (Timur Iskhodzhanov) Date: Tue, 21 Feb 2012 16:24:23 -0000 Subject: [llvm-commits] [compiler-rt] r151059 - /compiler-rt/trunk/lib/asan/asan_rtl.cc Message-ID: <20120221162423.EB41F2A6C12F@llvm.org> Author: timurrrr Date: Tue Feb 21 10:24:23 2012 New Revision: 151059 URL: http://llvm.org/viewvc/llvm-project?rev=151059&view=rev Log: [ASan] Add __asan_init to the list of C dynamic initializers to support /MD on Windows Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=151059&r1=151058&r2=151059&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_rtl.cc (original) +++ compiler-rt/trunk/lib/asan/asan_rtl.cc Tue Feb 21 10:24:23 2012 @@ -508,9 +508,15 @@ } #if defined(ASAN_USE_PREINIT_ARRAY) -// On Linux, we force __asan_init to be called before anyone else -// by placing it into .preinit_array section. -// FIXME: do we have anything like this on Mac? -__attribute__((section(".preinit_array"))) - typeof(__asan_init) *__asan_preinit =__asan_init; + // On Linux, we force __asan_init to be called before anyone else + // by placing it into .preinit_array section. + // FIXME: do we have anything like this on Mac? + __attribute__((section(".preinit_array"))) + typeof(__asan_init) *__asan_preinit =__asan_init; +#elif defined(_WIN32) && defined(_DLL) + // On Windows, when using dynamic CRT (/MD), we can put a pointer + // to __asan_init into the global list of C initializers. + // See crt0dat.c in the CRT sources for the details. + #pragma section(".CRT$XIB",long,read) + __declspec(allocate(".CRT$XIB")) void (*__asan_preinit)() = __asan_init; #endif From timurrrr at google.com Tue Feb 21 10:29:01 2012 From: timurrrr at google.com (timurrrr at google.com) Date: Tue, 21 Feb 2012 16:29:01 +0000 Subject: [llvm-commits] [ASan] Add __asan_init to the list of C dynamic initializers to support /MD (issue 5688060) Message-ID: <001636ed6cd79ddbad04b97be80f@google.com> On 2012/02/21 16:27:35, glider wrote: > LGTM Thanks, r151059! http://codereview.appspot.com/5688060/ From daniel at zuster.org Tue Feb 21 10:43:08 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 16:43:08 -0000 Subject: [llvm-commits] [zorg] r151061 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221164308.712B22A6C130@llvm.org> Author: ddunbar Date: Tue Feb 21 10:43:08 2012 New Revision: 151061 URL: http://llvm.org/viewvc/llvm-project?rev=151061&view=rev Log: [lnt] lnt.tests.compile: Blow away the user's Xcode DerivedData folder for now until I can find a better way to guarantee that Xcode won't reuse a shared PCH file. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151061&r1=151060&r2=151061&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 10:43:08 2012 @@ -339,9 +339,16 @@ for arg in cmd)) stdout_path = os.path.join(output_base, "stdout.log") stderr_path = os.path.join(output_base, "stderr.log") + # FIXME: I haven't figured out how to prevent Xcode from putting some data + # (shared PCH files, notably) in the derived data folder. There is most + # likely a command line setting to override this, but I don't know it + # yet. Until then, we just blow away the users entire DerivedData folder! + preprocess_cmd = 'rm -rf "%s" "%s"' % ( + build_base, + os.path.expanduser("~/Library/Developer/Xcode/DerivedData")) for res in get_runN_test_data(name, variables, cmd, stdout=stdout_path, stderr=stderr_path, - preprocess_cmd='rm -rf "%s"' % (build_base,)): + preprocess_cmd=preprocess_cmd): yield res ### From daniel at zuster.org Tue Feb 21 10:43:13 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 16:43:13 -0000 Subject: [llvm-commits] [zorg] r151062 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221164313.F32622A6C130@llvm.org> Author: ddunbar Date: Tue Feb 21 10:43:13 2012 New Revision: 151062 URL: http://llvm.org/viewvc/llvm-project?rev=151062&view=rev Log: [lnt] lnt.tests.compile: Add a -test-filter option for easily running some subsets of the tests. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151062&r1=151061&r2=151062&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 10:43:13 2012 @@ -511,6 +511,9 @@ group.add_option("", "--test", dest="tests", metavar="NAME", help="Individual test to run", action="append", default=[]) + group.add_option("", "--test-filter", dest="test_filters", + help="Run tests matching the given pattern", + metavar="REGEXP", action="append", default=[]) group.add_option("", "--flags-to-test", dest="flags_to_test", help="Add a set of flags to test (space separated)", metavar="FLAGLIST", action="append", default=[]) @@ -627,8 +630,8 @@ jobs_to_test = opts.jobs_to_test # Compute the list of all tests. - all_tests = get_tests(opts.test_suite_externals, flags_to_test, - jobs_to_test) + all_tests = list(get_tests(opts.test_suite_externals, flags_to_test, + jobs_to_test)) # Show the tests, if requested. if opts.show_tests: @@ -639,18 +642,33 @@ raise SystemExit # Find the tests to run. - if not opts.tests: + if not opts.tests and not opts.test_filters: tests_to_run = list(all_tests) else: - tests_to_run = [] - for name in opts.tests: - matching_tests = [test - for test in all_tests - if name == test[0]] - if not matching_tests: - parser.error(("invalid test name %r, use --show-tests to " - "see available tests") % name) - tests_to_run.extend(matching_tests) + all_test_names = set(test[0] for test in all_tests) + + # Validate the test names. + requested_tests = set(opts.tests) + missing_tests = requested_tests - all_test_names + if missing_tests: + parser.error(("invalid test names %s, use --show-tests to " + "see available tests") % ( + ", ".join(map(repr, missing_tests)),)) + + # Validate the test filters. + test_filters = [re.compile(pattern) + for pattern in opts.test_filters] + + # Form the list of tests. + tests_to_run = [test + for test in all_tests + if (test[0] in requested_tests or + [True + for filter in test_filters + if filter.search(test[0])])] + if not tests_to_run: + parser.error( + "no tests requested (invalid --test or --test-filter options)!") # Ensure output directory is available. if not os.path.exists(g_output_dir): From daniel at zuster.org Tue Feb 21 10:43:19 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 16:43:19 -0000 Subject: [llvm-commits] [zorg] r151063 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221164319.986542A6C130@llvm.org> Author: ddunbar Date: Tue Feb 21 10:43:19 2012 New Revision: 151063 URL: http://llvm.org/viewvc/llvm-project?rev=151063&view=rev Log: [lnt] lnt.tests.compile: Tweak to use module level names. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151063&r1=151062&r2=151063&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 10:43:19 2012 @@ -15,9 +15,8 @@ import lnt.testing import lnt.testing.util.compilers from lnt.testing.util.commands import note, warning, error, fatal -from lnt.testing.util.commands import capture, mkdir_p, rm_f from lnt.testing.util.misc import TeeStream, timestamp -from lnt.testing.util import machineinfo +from lnt.testing.util import commands, machineinfo # Interface to runN. # @@ -126,8 +125,8 @@ if can_memprof and opts.memory_profiling: # Find the cc1 command, which we use to do memory profiling. To do this # we execute the compiler with '-###' to figure out what it wants to do. - cc_output = capture(cmd + ['-o','/dev/null','-###'], - include_stderr=True).strip() + cc_output = cmmands.capture(cmd + ['-o','/dev/null','-###'], + include_stderr=True).strip() cc_commands = [] for ln in cc_output.split('\n'): # Filter out known garbage. @@ -148,7 +147,7 @@ sample_mem=True, only_mem=True): yield res - rm_f(output) + commands.rm_f(output) for res in get_runN_test_data(name, variables, cmd + ['-o',output], ignore_stderr=ignore_stderr): yield res @@ -260,7 +259,7 @@ # # We shell out to unzip here because zipfile's extractall does not # appear to preserve permissions properly. - mkdir_p(source_path) + commands.mkdir_p(source_path) print >>test_log, '%s: extracting sources for %r' % ( datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'), name) p = subprocess.Popen(args=['unzip', '-q', archive_path], @@ -330,7 +329,7 @@ fatal("unknown build style in project: %r" % project) # Create the output base directory. - mkdir_p(output_base) + commands.mkdir_p(output_base) # Collect the samples. print >>test_log, '%s: executing full build: %s' % ( @@ -574,7 +573,7 @@ for name,cmd in (('sys_cc_version', ('/usr/bin/gcc','-v')), ('sys_as_version', ('/usr/bin/as','-v','/dev/null')), ('sys_ld_version', ('/usr/bin/ld','-v'))): - run_info[name] = capture(cmd, include_stderr=True).strip() + run_info[name] = commands.capture(cmd, include_stderr=True).strip() # Set command line machine and run information. for info,params in ((machine_info, opts.machine_parameters), @@ -646,7 +645,7 @@ tests_to_run = list(all_tests) else: all_test_names = set(test[0] for test in all_tests) - + # Validate the test names. requested_tests = set(opts.tests) missing_tests = requested_tests - all_test_names From daniel at zuster.org Tue Feb 21 10:43:26 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 16:43:26 -0000 Subject: [llvm-commits] [zorg] r151064 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221164326.282982A6C130@llvm.org> Author: ddunbar Date: Tue Feb 21 10:43:25 2012 New Revision: 151064 URL: http://llvm.org/viewvc/llvm-project?rev=151064&view=rev Log: [lnt] lnt.tests.compile: Actually bother to test the right compiler. Just a small detail! - Also, add --cxx option (inferred, usually). - Also, normalize and report the compiler under test paths. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151064&r1=151063&r2=151064&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 10:43:25 2012 @@ -323,6 +323,10 @@ cmd.append('SYMROOT=%s' % (os.path.join(build_base, 'sym'))) cmd.append('DSTROOT=%s' % (os.path.join(build_base, 'dst'))) + # Add arguments to force the appropriate compiler. + cmd.append('CC=%s' % (opts.cc,)) + cmd.append('CPLUSPLUS=%s' % (opts.cxx,)) + # Add additional arguments to force the build scenario we want. cmd.extend(('-jobs', str(num_jobs))) else: @@ -479,8 +483,11 @@ group = OptionGroup(parser, "Test Options") group.add_option("", "--cc", dest="cc", type='str', - help="Compiler under test", + help="Path to the compiler under test", action="store", default=None) + group.add_option("", "--cxx", dest="cxx", + help="Path to the C++ compiler to test", + type=str, default=None) group.add_option("", "--test-externals", dest="test_suite_externals", help="Path to the LLVM test-suite externals", type=str, default=None, metavar="PATH") @@ -536,14 +543,39 @@ if len(args) != 0: parser.error("invalid number of arguments") + # Attempt to infer the cxx compiler if not given. + if opts.cc and opts.cxx is None: + name = os.path.basename(opts.cc) + cxx_name = { 'clang' : 'clang++', + 'gcc' : 'g++', + 'llvm-gcc' : 'llvm-g++' }.get(name) + if cxx_name is not None: + opts.cxx = os.path.join(os.path.dirname(opts.cc), + cxx_name) + note("inferred C++ compiler: %r" % (opts.cxx,)) + # Validate options. if opts.cc is None: parser.error('--cc is required') + if opts.cxx is None: + parser.error('--cxx is required (and could not be inferred)') if opts.sandbox_path is None: parser.error('--sandbox is required') if opts.test_suite_externals is None: parser.error("--test-externals option is required") + # Force the CC and CXX variables to be absolute paths. + cc_abs = os.path.abspath(commands.which(opts.cc)) + cxx_abs = os.path.abspath(commands.which(opts.cxx)) + if not os.path.exists(cc_abs): + parser.error("unable to determine absolute path for --cc: %r" % ( + opts.cc,)) + if not os.path.exists(cxx_abs): + parser.error("unable to determine absolute path for --cc: %r" % ( + opts.cc,)) + opts.cc = cc_abs + opts.cxx = cxx_abs + # Set up the sandbox. global g_output_dir if not os.path.exists(opts.sandbox_path): @@ -689,6 +721,10 @@ start_time = datetime.utcnow() print >>test_log, '%s: run started' % start_time.strftime( '%Y-%m-%d %H:%M:%S') + print >>test_log, '%s: using CC: %r' % (start_time.strftime( + '%Y-%m-%d %H:%M:%S'), opts.cc) + print >>test_log, '%s: using CXX: %r' % (start_time.strftime( + '%Y-%m-%d %H:%M:%S'), opts.cxx) try: for basename,test_fn in tests_to_run: for success,name,samples in test_fn(basename, run_info, From daniel at zuster.org Tue Feb 21 10:43:03 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 16:43:03 -0000 Subject: [llvm-commits] [zorg] r151060 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221164303.683192A6C12F@llvm.org> Author: ddunbar Date: Tue Feb 21 10:43:03 2012 New Revision: 151060 URL: http://llvm.org/viewvc/llvm-project?rev=151060&view=rev Log: [lnt] lnt.tests.compile: Add support for testing multiple job sizes for full build tests. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151060&r1=151059&r2=151060&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 10:43:03 2012 @@ -226,7 +226,8 @@ return test_cc_command(name, run_info, variables, input, output, flags, extra_flags, has_output, ignore_stderr, can_memprof) -def test_build(name, run_info, variables, project): +def test_build(base_name, run_info, variables, project, num_jobs): + name = '%s(j=%d)' % (base_name, num_jobs) # Check if we need to expand the archive into the sandbox. archive_path = get_input_path(opts, project['archive']) with open(archive_path) as f: @@ -317,11 +318,14 @@ fatal("unknown build style in project: %r" % project) # Add arguments to ensure output files go into our build directory. - output_base = get_output_path(project['name']) + output_base = get_output_path(name) build_base = os.path.join(output_base, 'build') cmd.append('OBJROOT=%s' % (os.path.join(build_base, 'obj'))) cmd.append('SYMROOT=%s' % (os.path.join(build_base, 'sym'))) cmd.append('DSTROOT=%s' % (os.path.join(build_base, 'dst'))) + + # Add additional arguments to force the build scenario we want. + cmd.extend(('-jobs', str(num_jobs))) else: fatal("unknown build style in project: %r" % project) @@ -371,22 +375,23 @@ pch_input=pch_input, flags=f, stage=stage, extra_flags=extra_flags)) -def get_full_build_tests(test_suite_externals): +def get_full_build_tests(jobs_to_test, test_suite_externals): # Load the project description file from the externals. with open(os.path.join(test_suite_externals, "lnt-compile-suite-src", "project_list.json")) as f: data = json.load(f) - for project in data['projects']: - # Check the style. - yield ('build/%s' % (project['name'],), - curry(test_build, project=project)) + for jobs in jobs_to_test: + for project in data['projects']: + # Check the style. + yield ('build/%s' % (project['name'],), + curry(test_build, project=project, num_jobs=jobs)) -def get_tests(test_suite_externals, flags_to_test): +def get_tests(test_suite_externals, flags_to_test, jobs_to_test): for item in get_single_file_tests(flags_to_test): yield item - for item in get_full_build_tests(test_suite_externals): + for item in get_full_build_tests(jobs_to_test, test_suite_externals): yield item ### @@ -502,6 +507,9 @@ group.add_option("", "--flags-to-test", dest="flags_to_test", help="Add a set of flags to test (space separated)", metavar="FLAGLIST", action="append", default=[]) + group.add_option("", "--jobs-to-test", dest="jobs_to_test", + help="Add a job count to test (full builds)", + metavar="NUM", action="append", default=[], type=int) parser.add_option_group(group) group = OptionGroup(parser, "Output Options") @@ -605,8 +613,15 @@ flags_to_test = [string.split(' ') for string in opts.flags_to_test] + # Compute the set of job counts to use in full build tests. + if not opts.jobs_to_test: + jobs_to_test = [1, 2, 4, 8] + else: + jobs_to_test = opts.jobs_to_test + # Compute the list of all tests. - all_tests = get_tests(opts.test_suite_externals, flags_to_test) + all_tests = get_tests(opts.test_suite_externals, flags_to_test, + jobs_to_test) # Show the tests, if requested. if opts.show_tests: From daniel at zuster.org Tue Feb 21 10:45:12 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 16:45:12 -0000 Subject: [llvm-commits] [zorg] r151065 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221164512.A95B02A6C12F@llvm.org> Author: ddunbar Date: Tue Feb 21 10:45:12 2012 New Revision: 151065 URL: http://llvm.org/viewvc/llvm-project?rev=151065&view=rev Log: [lnt] lnt.tests.compile: Remove a resolved FIXME. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151065&r1=151064&r2=151065&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 10:45:12 2012 @@ -413,8 +413,8 @@ usage_info = """ Script for testing compile time performance. -Currently this is only intended to test the raw compiler performance, not its -scalability or its performance in parallel builds. +Currently this is primarily intended to test the raw compiler performance (not +its scalability or its performance in parallel builds). This tests: - PCH Generation for Cocoa.h @@ -460,9 +460,6 @@ Make or xcodebuild by interposing scripts to stub out parts of the compilation process. This is fragile, but can also be very useful when trying to understand where the time is going in a full build. - -FIXME: We may want to consider timing non-serial builds in order to start -measuring things like the full-system-performance impact on the compiler. """ class CompileTest(builtintest.BuiltinTest): From emenezes at codeaurora.org Tue Feb 21 10:59:07 2012 From: emenezes at codeaurora.org (Evandro Menezes) Date: Tue, 21 Feb 2012 10:59:07 -0600 Subject: [llvm-commits] Hexagon: Add pattern for truncated word store In-Reply-To: <4F3EC198.6070409@codeaurora.org> References: <4F3EC198.6070409@codeaurora.org> Message-ID: <4F43CD5B.4000100@codeaurora.org> Resubmitting the patch to fix a typo. -- Evandro Menezes Austin, TX emenezes at codeaurora.org Qualcomm Innovation Center, Inc is a member of the Code Aurora Forum On 02/17/12 15:07, Evandro Menezes wrote: > This patch for Hexagon replaces an insn definition with a pattern for > truncated word stores. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: bug6132.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120221/911ba202/attachment.txt From daniel at zuster.org Tue Feb 21 11:39:33 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 17:39:33 -0000 Subject: [llvm-commits] [zorg] r151067 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221173933.A38782A6C12F@llvm.org> Author: ddunbar Date: Tue Feb 21 11:39:33 2012 New Revision: 151067 URL: http://llvm.org/viewvc/llvm-project?rev=151067&view=rev Log: [lnt] lnt.tests.compile: Set LDPLUSPLUS when invoking xcodebuild, to ensure we use a valid compiler driver when we try to link. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151067&r1=151066&r2=151067&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 11:39:33 2012 @@ -327,6 +327,11 @@ cmd.append('CC=%s' % (opts.cc,)) cmd.append('CPLUSPLUS=%s' % (opts.cxx,)) + # We need to force this variable here because Xcode has some completely + # broken logic for deriving this variable from the compiler + # name. + cmd.append('LDPLUSPLUS=%s' % (opts.cxx,)) + # Add additional arguments to force the build scenario we want. cmd.extend(('-jobs', str(num_jobs))) else: From daniel at zuster.org Tue Feb 21 11:41:35 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 17:41:35 -0000 Subject: [llvm-commits] [zorg] r151068 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221174135.630A62A6C12F@llvm.org> Author: ddunbar Date: Tue Feb 21 11:41:35 2012 New Revision: 151068 URL: http://llvm.org/viewvc/llvm-project?rev=151068&view=rev Log: [lnt] lnt.tests.compile: Fix a facto-re. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151068&r1=151067&r2=151068&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 11:41:35 2012 @@ -125,8 +125,8 @@ if can_memprof and opts.memory_profiling: # Find the cc1 command, which we use to do memory profiling. To do this # we execute the compiler with '-###' to figure out what it wants to do. - cc_output = cmmands.capture(cmd + ['-o','/dev/null','-###'], - include_stderr=True).strip() + cc_output = commands.capture(cmd + ['-o','/dev/null','-###'], + include_stderr=True).strip() cc_commands = [] for ln in cc_output.split('\n'): # Filter out known garbage. From marina.yatsina at intel.com Tue Feb 21 12:05:54 2012 From: marina.yatsina at intel.com (Yatsina, Marina) Date: Tue, 21 Feb 2012 18:05:54 +0000 Subject: [llvm-commits] Bug in "call __chkstak" on 64 bit OS In-Reply-To: References: <7DE70FDACDE4CD4887C4278C12A2E30508F3E5@HASMSX104.ger.corp.intel.com> Message-ID: Hi, I've fixed the patch according to the feedback, honoring the code model. -----Original Message----- From: Anton Korobeynikov [mailto:anton at korobeynikov.info] Sent: Monday, February 20, 2012 16:46 To: Rotem, Nadav Cc: NAKAMURA Takumi; llvm-commits at cs.uiuc.edu; Yatsina, Marina Subject: Re: [llvm-commits] Bug in "call __chkstak" on 64 bit OS Nadav, > ?So, the problem with the proposed patch is that it does not honor the code model and that it issues an indirect jump on win64 when a 'small' code model is used, right ? Almost correct. call to chkstk should behave the same way as all other calls. So, it will be pcrel32 in small, kernel and medium code models. And indirect in large. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University --------------------------------------------------------------------- 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 -------------- A non-text attachment was scrubbed... Name: Win64CallCheckStackLLVMTrunk.patch Type: application/octet-stream Size: 8351 bytes Desc: Win64CallCheckStackLLVMTrunk.patch Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120221/6ba9d8a5/attachment.obj From mcrosier at apple.com Tue Feb 21 12:27:26 2012 From: mcrosier at apple.com (Chad Rosier) Date: Tue, 21 Feb 2012 10:27:26 -0800 Subject: [llvm-commits] Hexagon: Add pattern for truncated word store In-Reply-To: <4F43CD5B.4000100@codeaurora.org> References: <4F3EC198.6070409@codeaurora.org> <4F43CD5B.4000100@codeaurora.org> Message-ID: Testcase? :) On Feb 21, 2012, at 8:59 AM, Evandro Menezes wrote: > Resubmitting the patch to fix a typo. > > -- > Evandro Menezes Austin, TX emenezes at codeaurora.org > Qualcomm Innovation Center, Inc is a member of the Code Aurora Forum > > > On 02/17/12 15:07, Evandro Menezes wrote: >> This patch for Hexagon replaces an insn definition with a pattern for >> truncated word stores. > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From daniel at zuster.org Tue Feb 21 12:33:54 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 18:33:54 -0000 Subject: [llvm-commits] [zorg] r151070 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221183354.CD3012A6C12F@llvm.org> Author: ddunbar Date: Tue Feb 21 12:33:54 2012 New Revision: 151070 URL: http://llvm.org/viewvc/llvm-project?rev=151070&view=rev Log: [lnt] lnt.tests.compile: Track xcodebuild version. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151070&r1=151069&r2=151070&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 12:33:54 2012 @@ -354,6 +354,12 @@ preprocess_cmd = 'rm -rf "%s" "%s"' % ( build_base, os.path.expanduser("~/Library/Developer/Xcode/DerivedData")) + + # FIXME: It might be a good idea to audit the stdout files here from the + # build system and check that they are "about" the same. For example, I + # believe an Xcode build log should always be the same size if each + # iterating did a clean build (even though the results might show up in a + # different order). for res in get_runN_test_data(name, variables, cmd, stdout=stdout_path, stderr=stderr_path, preprocess_cmd=preprocess_cmd): @@ -606,7 +612,8 @@ for name,cmd in (('sys_cc_version', ('/usr/bin/gcc','-v')), ('sys_as_version', ('/usr/bin/as','-v','/dev/null')), - ('sys_ld_version', ('/usr/bin/ld','-v'))): + ('sys_ld_version', ('/usr/bin/ld','-v')), + ('sys_xcodebuild', ('xcodebuild','-version'))): run_info[name] = commands.capture(cmd, include_stderr=True).strip() # Set command line machine and run information. From daniel at zuster.org Tue Feb 21 12:55:05 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 18:55:05 -0000 Subject: [llvm-commits] [zorg] r151073 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221185505.123522A6C12F@llvm.org> Author: ddunbar Date: Tue Feb 21 12:55:04 2012 New Revision: 151073 URL: http://llvm.org/viewvc/llvm-project?rev=151073&view=rev Log: [lnt] lnt.tests.compile: Fix codegen and assembly stages to make sense in an integrated assembler world. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151073&r1=151072&r2=151073&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 12:55:04 2012 @@ -103,8 +103,7 @@ # FIXME: Encode dependency on output automatically, for simpler test execution. def test_cc_command(base_name, run_info, variables, input, output, flags, - extra_flags, has_output=True, ignore_stderr=False, - can_memprof=True): + extra_flags, has_output=True, ignore_stderr=False): name = '%s/(%s)' % (base_name,' '.join(flags),) input = get_input_path(opts, input) output = get_output_path(output) @@ -122,7 +121,7 @@ # # FIXME: Doing this as a separate step seems silly. We shouldn't do any # extra run just to get the memory statistics. - if can_memprof and opts.memory_profiling: + if opts.memory_profiling: # Find the cc1 command, which we use to do memory profiling. To do this # we execute the compiler with '-###' to figure out what it wants to do. cc_output = commands.capture(cmd + ['-o','/dev/null','-###'], @@ -182,11 +181,11 @@ is_clang = not (cc_name in ('gcc', 'llvm-gcc')) # Ignore irgen stages for non-LLVM compilers. - if not is_llvm and stage in ('irgen', 'irgen_only',): + if not is_llvm and stage in ('irgen', 'irgen_only'): return () - # Ignore 'init' and 'irgen_only' stages for non-Clang. - if not is_clang and stage in ('init', 'irgen_only'): + # Ignore 'init', 'irgen_only', and 'codegen' stages for non-Clang. + if not is_clang and stage in ('init', 'irgen_only', 'codegen'): return () # Force gnu99 mode for all compilers. @@ -203,18 +202,15 @@ '-Xclang','-emit-llvm-only'), False), 'irgen' : (('-emit-llvm','-c'), True), - 'codegen' : (('-S',), True), + 'codegen' : (('-c', + '-Xclang', '-emit-codegen-only'), + False), 'assembly' : (('-c',), True), }[stage] # Ignore stderr output (instead of failing) in 'driver' stage, -### output # goes to stderr by default. ignore_stderr = stage == 'driver' - # We can't memory profile an assembly command. - # - # FIXME: Actually, we can with -integrated-as. - can_memprof = stage != 'assembly' - extra_flags.extend(stage_flags) if pch_input is not None: assert pch_input.endswith('.gch') @@ -223,7 +219,7 @@ extra_flags.extend(['-I', os.path.dirname(get_input_path(opts, input))]) return test_cc_command(name, run_info, variables, input, output, flags, - extra_flags, has_output, ignore_stderr, can_memprof) + extra_flags, has_output, ignore_stderr) def test_build(base_name, run_info, variables, project, num_jobs): name = '%s(j=%d)' % (base_name, num_jobs) From bigcheesegs at gmail.com Tue Feb 21 13:12:32 2012 From: bigcheesegs at gmail.com (Michael Spencer) Date: Tue, 21 Feb 2012 11:12:32 -0800 Subject: [llvm-commits] [PATCH] YAML parser. In-Reply-To: References: Message-ID: On Mon, Feb 20, 2012 at 5:04 PM, Manuel Klimek wrote: > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp > File lib/Support/YAMLParser.cpp (right): > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#ne... > lib/Support/YAMLParser.cpp:693: EscapedInput += "\\x" + > std::string(HexStr.size() - 2, '0') + HexStr; > On 2012/02/16 22:32:42, Bigcheesegs wrote: >> On 2012/02/16 15:52:35, klimek wrote: >> > Why's the middle part there? >> >> \x requires two characters after it. This adds the 0 if needed. > > Ok, shouldn't that be 2 - HexStr.size() then? Oh, you're right. I fixed that later in the code, but not up here. Fixed. > > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#ne... > lib/Support/YAMLParser.cpp:795: if ( ? u8d.second != 0 > On 2012/02/16 22:32:42, Bigcheesegs wrote: >> On 2012/02/16 15:52:35, klimek wrote: >> > Somehow I cannot match this up with 5.1. >> > Especially: >> > """On input, a YAML processor must accept all Unicode characters except > those >> > explicitly excluded above.""" >> > >> > And, why do we care about non-printable chars at all? >> >> This excludes the characters listed in 5.1 in addition to the other stuff >> removed from nb-char. >> >> This is needed to skip entire UTF-8 minimal well formed subsequences at a time >> to keep proper column counts. > > If I'm not completely misreading, this excludes much more: > """To ensure readability, YAML streams use only the printable subset of the > Unicode character set. The allowed character range explicitly excludes the C0 > control block #x0-#x1F (except for TAB #x9, LF #xA, and CR #xD which are > allowed), DEL #x7F, the C1 control block #x80-#x9F (except for NEL #x85 which is > allowed), the surrogate block #xD800-#xDFFF, #xFFFE, and #xFFFF.""" > > The surrogate block cannot actually come out of decodeUTF8. All of the ranges excluded there are excluded by skip_nb_char. Yes, the surrogate block check is redundant. It documents the exact ranges that will be accepted. > http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#ne... > lib/Support/YAMLParser.cpp:1627: switch (UnquotedValue[0]) { > On 2012/02/16 22:32:42, Bigcheesegs wrote: >> On 2012/02/16 15:52:35, klimek wrote: >> > Do we want to support all possible escapes, or can we get away with the > subset >> > we really need? >> >> It's only a few extra lines with no extra complexity... > > It is code that needs to be maintained ... shrug. > > On Thu, Feb 16, 2012 at 2:38 PM, Michael Spencer wrote: >> http://codereview.appspot.com/5604054/diff/6001/include/llvm/Support/YAMLParser.h >> File include/llvm/Support/YAMLParser.h (right): >> >> http://codereview.appspot.com/5604054/diff/6001/include/llvm/Support/YAMLParser.h#newcode71 >> include/llvm/Support/YAMLParser.h:71: std::string escape(StringRef >> Input); >> On 2012/02/16 15:52:35, klimek wrote: >>> >>> This is not called anywhere yet(?) Why do we need it? Are we planning >> >> to write >>> >>> yaml or do we only need to parse it? >> >> >> It's used when writing out YAML files. >> >> >> http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp >> File lib/Support/YAMLParser.cpp (right): >> >> http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode667 >> lib/Support/YAMLParser.cpp:667: std::string EscapedInput; >> On 2012/02/16 15:52:35, klimek wrote: >>> >>> Curious: is there a reason not to use a Twine here (which would be my >> >> default >>> >>> choice for string concatenation). >> >> >> Twine cannot be used here as it is only valid until the end of the >> statement. See Twine.h. >> >> >> http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode693 >> lib/Support/YAMLParser.cpp:693: EscapedInput += "\\x" + >> std::string(HexStr.size() - 2, '0') + HexStr; >> On 2012/02/16 15:52:35, klimek wrote: >>> >>> Why's the middle part there? >> >> >> \x requires two characters after it. This adds the 0 if needed. >> >> >> http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode694 >> lib/Support/YAMLParser.cpp:694: } else if (*i & 0x80) { // utf8 >> On 2012/02/16 15:52:35, klimek wrote: >>> >>> // utf8 >>> is confusing to me here: >>> I thought we always assume utf8, and 0x80 merely means that we have a >> >> multi-byte >>> >>> utf8 sequence... >> >> >>> So I'd expect a comment like: >>> // utf8 multi-byte sequence >> >> >> Done. >> >> >> http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode788 >> lib/Support/YAMLParser.cpp:788: if ( ? *Position == 0x09 >> On 2012/02/16 15:52:35, klimek wrote: >>> >>> Indentation off? >> >> >> It lines up with the other side of the || below. >> >> >> http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode795 >> lib/Support/YAMLParser.cpp:795: if ( ? u8d.second != 0 >> On 2012/02/16 15:52:35, klimek wrote: >>> >>> Somehow I cannot match this up with 5.1. >>> Especially: >>> """On input, a YAML processor must accept all Unicode characters >> >> except those >>> >>> explicitly excluded above.""" >> >> >>> And, why do we care about non-printable chars at all? >> >> >> This excludes the characters listed in 5.1 in addition to the other >> stuff removed from nb-char. >> >> This is needed to skip entire UTF-8 minimal well formed subsequences at >> a time to keep proper column counts. >> >> >> http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode839 >> lib/Support/YAMLParser.cpp:839: if ( ?(C >= '0' && C <= '9') >> On 2012/02/16 15:52:35, klimek wrote: >>> >>> Just return. >> >> >> Done. >> >> >> http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode847 >> lib/Support/YAMLParser.cpp:847: if ( ?C == '-' >> On 2012/02/16 15:52:35, klimek wrote: >>> >>> Just return. >> >> >> Done. >> >> >> http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode860 >> lib/Support/YAMLParser.cpp:860: && Current + 2 < End >> On 2012/02/16 15:52:35, klimek wrote: >>> >>> So we're not inc'ing Current by 3 when encountering %NN because NN >> >> will be >>> >>> parsable anyway? >> >> >> Yes, however, there's no reason it can't skip all 3. >> >> >> http://codereview.appspot.com/5604054/diff/6001/lib/Support/YAMLParser.cpp#newcode1627 >> lib/Support/YAMLParser.cpp:1627: switch (UnquotedValue[0]) { >> On 2012/02/16 15:52:35, klimek wrote: >>> >>> Do we want to support all possible escapes, or can we get away with >> >> the subset >>> >>> we really need? >> >> >> It's only a few extra lines with no extra complexity... >> >> http://codereview.appspot.com/5604054/ >> >> - Michael Spencer Attached is a new patch that includes your changes, and the updated decodeUTF8 you posted on IRC. - Michael Spencer -------------- next part -------------- A non-text attachment was scrubbed... Name: yaml-parser-21-02-2012.patch Type: application/octet-stream Size: 164928 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120221/a2022c4a/attachment-0001.obj From bigcheesegs at gmail.com Tue Feb 21 13:17:16 2012 From: bigcheesegs at gmail.com (Michael Spencer) Date: Tue, 21 Feb 2012 11:17:16 -0800 Subject: [llvm-commits] [PATCH] Handle negative values in StringRef::getAsInteger(unsigned Radix, APInt &). In-Reply-To: References: <7A0EF93B-7C20-490F-AF3E-1FAB42D28536@apple.com> Message-ID: On Thu, Feb 16, 2012 at 2:45 PM, Michael Spencer wrote: > On Thu, Feb 16, 2012 at 8:20 AM, Chris Lattner wrote: >> >> On Feb 15, 2012, at 4:25 PM, Michael Spencer wrote: >> >>> I have a use case for this in lld. >> >> >> This is sorta strange to me, how about adding an APSInt overload that allows negative (also weird) or a new getAsSignedInteger method (probably better)? >> >> -Chris > > There is already precedent in the other StringRef::getAsInteger > functions to accept negative values. I believe the interface should be > uniform. > > All I actually need is uint64_t and int64_t, however, these are > unsigned long and long on my platform (x86-64 Linux), and thus don't > match any of the overloads. > > Would it be better for me to just cleanup the overload set? > > - Michael Spencer Ping. - Michael Spencer From daniel at zuster.org Tue Feb 21 13:14:17 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 19:14:17 -0000 Subject: [llvm-commits] [zorg] r151078 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221191417.608D22A6C12F@llvm.org> Author: ddunbar Date: Tue Feb 21 13:14:17 2012 New Revision: 151078 URL: http://llvm.org/viewvc/llvm-project?rev=151078&view=rev Log: [lnt] lnt.tests.compile: Add --min-sample-time option, to try and get the same relative variance for short running tests. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151078&r1=151077&r2=151078&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 13:14:17 2012 @@ -35,6 +35,8 @@ cmd.extend(('--stdout', stdout)) if stderr is not None: cmd.extend(('--stderr', stderr)) + cmd.extend(('--min-sample-time', repr(opts.min_sample_time))) + cmd.extend(('--max-num-samples', '100')) cmd.append(str(int(N))) cmd.extend(args) @@ -515,6 +517,9 @@ group.add_option("", "--multisample", dest="run_count", metavar="N", help="Accumulate test data from multiple runs", action="store", type=int, default=3) + group.add_option("", "--min-sample-time", dest="min_sample_time", + help="Ensure all tests run for at least N seconds", + metavar="N", action="store", type=float, default=.5) group.add_option("", "--show-tests", dest="show_tests", help="Only list the availables tests that will be run", action="store_true", default=False) From rafael.espindola at gmail.com Tue Feb 21 13:27:16 2012 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 21 Feb 2012 19:27:16 -0000 Subject: [llvm-commits] [llvm] r151079 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Message-ID: <20120221192716.B34412A6C131@llvm.org> Author: rafael Date: Tue Feb 21 13:27:16 2012 New Revision: 151079 URL: http://llvm.org/viewvc/llvm-project?rev=151079&view=rev Log: s/the the/the/ Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=151079&r1=151078&r2=151079&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Tue Feb 21 13:27:16 2012 @@ -33,7 +33,7 @@ BasicBlock::iterator IP) { // All new or reused instructions must strictly dominate their uses. // It would be nice to assert this here, but we don't always know where - // the next instructions will be added as the the caller can move the + // the next instructions will be added as the caller can move the // Builder's InsertPt before creating them and we might be called with // an invalid InsertPt. From arcata at gmail.com Tue Feb 21 14:02:32 2012 From: arcata at gmail.com (Joe Groff) Date: Tue, 21 Feb 2012 12:02:32 -0800 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: On Tue, Feb 21, 2012 at 5:10 AM, Anton Korobeynikov wrote: > Well... Do you have vcpp in hand? You can check in which conditions > call to fltused is emitted. > Typical cases: > ?1. Ordinary floating point operand > ?2. float* > ?3. struct { float } > ?4. struct { float } * It appears that VC generates a _fltused reference if a float type is referenced in any context, even if the type isn't ever used as an argument. Perhaps LLVM should be changed so that the "reference _fltused" flag is enabled when a FloatType is instantiated, rather than by checking CallInsts during instruction lowering. Is that a sensible change? -Joe From anton at korobeynikov.info Tue Feb 21 14:06:33 2012 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 22 Feb 2012 00:06:33 +0400 Subject: [llvm-commits] Bug in "call __chkstak" on 64 bit OS In-Reply-To: References: <7DE70FDACDE4CD4887C4278C12A2E30508F3E5@HASMSX104.ger.corp.intel.com> Message-ID: Marina, > I've fixed the patch according to the feedback, honoring the code model. Why all these blank lines needed for? Also, will you please factor the function which emits indirect call into its own helper function. And check spelling as well :) -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From anton at korobeynikov.info Tue Feb 21 14:27:05 2012 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 22 Feb 2012 00:27:05 +0400 Subject: [llvm-commits] [PATCH] generate ABI-compliant sections for uninitialized static data members in template instantiations In-Reply-To: <4f43630a.863cd80a.1c23.6679SMTPIN_ADDED@mx.google.com> References: <4f4271a3.85c52a0a.3533.143cSMTPIN_ADDED@mx.google.com> <4f43630a.863cd80a.1c23.6679SMTPIN_ADDED@mx.google.com> Message-ID: Kristof, > Yes, this patch is generic, and yes, x86-linux is also affected. > I think that all platforms following the Itanium C++ ABI are affected. Patch looks good to me, but if possible I'd like to ask someone else to look into this as well. Rafael, what do you think? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From evan.cheng at apple.com Tue Feb 21 14:46:01 2012 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 21 Feb 2012 20:46:01 -0000 Subject: [llvm-commits] [llvm] r151083 - in /llvm/trunk: lib/Target/ARM/ARMAsmPrinter.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMSelectionDAGInfo.cpp lib/Target/ARM/ARMSubtarget.cpp test/CodeGen/ARM/memfunc.ll Message-ID: <20120221204601.24D592A6C12F@llvm.org> Author: evancheng Date: Tue Feb 21 14:46:00 2012 New Revision: 151083 URL: http://llvm.org/viewvc/llvm-project?rev=151083&view=rev Log: Proper support for a bastardized darwin-eabi hybird ABI. Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMSelectionDAGInfo.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp llvm/trunk/test/CodeGen/ARM/memfunc.ll Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=151083&r1=151082&r2=151083&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Tue Feb 21 14:46:00 2012 @@ -599,10 +599,8 @@ OutStreamer.EmitAssemblerFlag(MCAF_SyntaxUnified); // Emit ARM Build Attributes - if (Subtarget->isTargetELF()) { - + if (Subtarget->isTargetELF()) emitAttributes(); - } } Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=151083&r1=151082&r2=151083&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Feb 21 14:46:00 2012 @@ -261,7 +261,7 @@ setLibcallName(RTLIB::SRL_I128, 0); setLibcallName(RTLIB::SRA_I128, 0); - if (Subtarget->isAAPCS_ABI()) { + if (Subtarget->isAAPCS_ABI() && !Subtarget->isTargetDarwin()) { // Double-precision floating-point arithmetic helper functions // RTABI chapter 4.1.2, Table 2 setLibcallName(RTLIB::ADD_F64, "__aeabi_dadd"); Modified: llvm/trunk/lib/Target/ARM/ARMSelectionDAGInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSelectionDAGInfo.cpp?rev=151083&r1=151082&r2=151083&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSelectionDAGInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSelectionDAGInfo.cpp Tue Feb 21 14:46:00 2012 @@ -145,8 +145,8 @@ SDValue Src, SDValue Size, unsigned Align, bool isVolatile, MachinePointerInfo DstPtrInfo) const { - // Use default for non AAPCS subtargets - if (!Subtarget->isAAPCS_ABI()) + // Use default for non AAPCS (or Darwin) subtargets + if (!Subtarget->isAAPCS_ABI() || Subtarget->isTargetDarwin()) return SDValue(); const ARMTargetLowering &TLI = Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=151083&r1=151082&r2=151083&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Tue Feb 21 14:46:00 2012 @@ -105,6 +105,8 @@ computeIssueWidth(); if (TT.find("eabi") != std::string::npos) + // FIXME: We might want to separate AAPCS and EABI. Some systems, e.g. + // Darwin-EABI conforms to AACPS but not the rest of EABI. TargetABI = ARM_ABI_AAPCS; if (isAAPCS_ABI()) @@ -115,8 +117,7 @@ else { IsR9Reserved = ReserveR9 | !HasV6Ops; UseMovt = DarwinUseMOVT && hasV6T2Ops(); - const Triple &T = getTargetTriple(); - SupportsTailCall = !T.isOSVersionLT(5, 0); + SupportsTailCall = !getTargetTriple().isOSVersionLT(5, 0); } if (!isThumb() || hasThumb2()) Modified: llvm/trunk/test/CodeGen/ARM/memfunc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/memfunc.ll?rev=151083&r1=151082&r2=151083&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/memfunc.ll (original) +++ llvm/trunk/test/CodeGen/ARM/memfunc.ll Tue Feb 21 14:46:00 2012 @@ -1,4 +1,5 @@ ; RUN: llc < %s -mtriple=armv7-apple-ios -o - | FileCheck %s +; RUN: llc < %s -mtriple=thumbv7m-darwin-eabi -o - | FileCheck %s --check-prefix=DARWIN ; RUN: llc < %s -mtriple=arm-none-eabi -o - | FileCheck --check-prefix=EABI %s @from = common global [500 x i32] zeroinitializer, align 4 @@ -18,6 +19,8 @@ ; EABI memset swaps arguments ; CHECK: mov r1, #0 ; CHECK: memset + ; DARWIN: movs r1, #0 + ; DARWIN: memset ; EABI: mov r2, #0 ; EABI: __aeabi_memset call void @llvm.memset.p0i8.i32(i8* bitcast ([500 x i32]* @from to i8*), i8 0, i32 500, i32 0, i1 false) From rafael.espindola at gmail.com Tue Feb 21 15:25:59 2012 From: rafael.espindola at gmail.com (=?UTF-8?Q?Rafael_Esp=C3=ADndola?=) Date: Tue, 21 Feb 2012 16:25:59 -0500 Subject: [llvm-commits] [PATCH] generate ABI-compliant sections for uninitialized static data members in template instantiations In-Reply-To: References: <4f4271a3.85c52a0a.3533.143cSMTPIN_ADDED@mx.google.com> <4f43630a.863cd80a.1c23.6679SMTPIN_ADDED@mx.google.com> Message-ID: > Rafael, what do you think? LGTM! Thanks, Rafael From daniel at zuster.org Tue Feb 21 15:56:25 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 21:56:25 -0000 Subject: [llvm-commits] [zorg] r151091 - in /zorg/trunk/lnt/lnt/server: db/testsuitedb.py reporting/analysis.py ui/views.py Message-ID: <20120221215625.EFE8A2A6C12F@llvm.org> Author: ddunbar Date: Tue Feb 21 15:56:25 2012 New Revision: 151091 URL: http://llvm.org/viewvc/llvm-project?rev=151091&view=rev Log: [lnt/v0.4] Change how missing sample values are reported. - Previously, we assumed a run would always report values for every subtest. We would default every field to being 0 which was a particularly bad idea. - We properly record such values as NULL. - Updated report and graph functionality to properly handle possibly-null cases. - I'm not 100% sure I got all the instances, but hopefully they will show up in obvious ways (as opposed to, just, say reporting the wrong data? hmmm?). Modified: zorg/trunk/lnt/lnt/server/db/testsuitedb.py zorg/trunk/lnt/lnt/server/reporting/analysis.py zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/server/db/testsuitedb.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/db/testsuitedb.py?rev=151091&r1=151090&r2=151091&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/db/testsuitedb.py (original) +++ zorg/trunk/lnt/lnt/server/db/testsuitedb.py Tue Feb 21 15:56:25 2012 @@ -288,7 +288,7 @@ # Initialize sample fields (defaulting to 0, for now). for item in self.fields: - self.set_field(item, kwargs.get(item.name, 0)) + self.set_field(item, kwargs.get(item.name, None)) def __repr__(self): fields = dict((item.name, self.get_field(item)) Modified: zorg/trunk/lnt/lnt/server/reporting/analysis.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/reporting/analysis.py?rev=151091&r1=151090&r2=151091&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/reporting/analysis.py (original) +++ zorg/trunk/lnt/lnt/server/reporting/analysis.py Tue Feb 21 15:56:25 2012 @@ -48,8 +48,10 @@ prev_failed |= sample[status_field.index] == FAIL # Get the current and previous values. - run_values = [s[field.index] for s in run_samples] - prev_values = [s[field.index] for s in prev_samples] + run_values = [s[field.index] for s in run_samples + if s[field.index] is not None] + prev_values = [s[field.index] for s in prev_samples + if s[field.index] is not None] if run_values: run_value = min(run_values) else: @@ -94,16 +96,14 @@ # noise level from a list of values. Probably better to just find a way # to kill this code though. if stddev is None: - # Get all previous values in the comparison window, for passing - # runs. - # - # FIXME: This is using the wrong status kind. :/ + # Get all previous values in the comparison window. prev_samples = [s for run in comparison_window - for s in self.sample_map.get((run.id, test_id), ())] + for s in self.sample_map.get((run.id, test_id), ()) + if s[field.index] is not None] # Filter out failing samples. if status_field: prev_samples = [s for s in prev_samples - if s[status_field.index] == PASS] + if s[status_field.index] != FAIL] if prev_samples: prev_values = [s[field.index] for s in prev_samples] Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=151091&r1=151090&r2=151091&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Feb 21 15:56:25 2012 @@ -996,12 +996,14 @@ q = ts.query(field.column, ts.Order.llvm_project_revision).\ join(ts.Run).join(ts.Order).\ filter(ts.Run.machine == run.machine).\ - filter(ts.Sample.test == test) + filter(ts.Sample.test == test).\ + filter(field.column != None) # Unless all samples requested, filter out failing tests. if not show_failures: if field.status_field: - q = q.filter(field.status_field.column == PASS) + q = q.filter((field.status_field.column == PASS) | + (field.status_field.column == None)) # Aggregate by revision. data = util.multidict((int(r),v) From daniel at zuster.org Tue Feb 21 15:56:28 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 21:56:28 -0000 Subject: [llvm-commits] [zorg] r151092 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120221215628.2BA982A6C12F@llvm.org> Author: ddunbar Date: Tue Feb 21 15:56:27 2012 New Revision: 151092 URL: http://llvm.org/viewvc/llvm-project?rev=151092&view=rev Log: [lnt] lnt.tests.compile: Save a copy of the report to the test directory. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151092&r1=151091&r2=151092&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Tue Feb 21 15:56:27 2012 @@ -769,7 +769,14 @@ machine = lnt.testing.Machine(opts.machine_name, machine_info) run = lnt.testing.Run(start_time, end_time, info = run_info) - return lnt.testing.Report(machine, run, testsamples) + # Write out the report. + lnt_report_path = os.path.join(g_output_dir, 'report.json') + report = lnt.testing.Report(machine, run, testsamples) + lnt_report_file = open(lnt_report_path, 'w') + print >>lnt_report_file, report.render() + lnt_report_file.close() + + return report def create_instance(): return CompileTest() From nicholas at mxc.ca Tue Feb 21 16:08:06 2012 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 21 Feb 2012 22:08:06 -0000 Subject: [llvm-commits] [llvm] r151093 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/constantfold-initializers.ll Message-ID: <20120221220806.ED6AD2A6C12F@llvm.org> Author: nicholas Date: Tue Feb 21 16:08:06 2012 New Revision: 151093 URL: http://llvm.org/viewvc/llvm-project?rev=151093&view=rev Log: Use the target-aware constant folder on expressions to improve the chance they'll be simple enough to simulate, and to reduce the chance we'll encounter equal but different simple pointer constants. This removes the symptoms from PR11352 but is not a full fix. A proper fix would either require a guarantee that two constant objects we simulate are folded when equal, or a different way of handling equal pointers (ie., trying a constantexpr icmp on them to see whether we know they're equal or non-equal or unsure). Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=151093&r1=151092&r2=151093&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Feb 21 16:08:06 2012 @@ -2388,6 +2388,8 @@ if (StoreInst *SI = dyn_cast(CurInst)) { if (!SI->isSimple()) return false; // no volatile/atomic accesses. Constant *Ptr = getVal(SI->getOperand(1)); + if (ConstantExpr *CE = dyn_cast(Ptr)) + Ptr = ConstantFoldConstantExpression(CE, TD, TLI); if (!isSimpleEnoughPointerToCommit(Ptr)) // If this is too complex for us to commit, reject it. return false; @@ -2423,7 +2425,9 @@ Constant * const IdxList[] = {IdxZero, IdxZero}; Ptr = ConstantExpr::getGetElementPtr(Ptr, IdxList); - + if (ConstantExpr *CE = dyn_cast(Ptr)) + Ptr = ConstantFoldConstantExpression(CE, TD, TLI); + // If we can't improve the situation by introspecting NewTy, // we have to give up. } else { @@ -2464,7 +2468,10 @@ cast(GEP)->isInBounds()); } else if (LoadInst *LI = dyn_cast(CurInst)) { if (!LI->isSimple()) return false; // no volatile/atomic accesses. - InstResult = ComputeLoadResult(getVal(LI->getOperand(0))); + Constant *Ptr = getVal(LI->getOperand(0)); + if (ConstantExpr *CE = dyn_cast(Ptr)) + Ptr = ConstantFoldConstantExpression(CE, TD, TLI); + InstResult = ComputeLoadResult(Ptr); if (InstResult == 0) return false; // Could not evaluate load. } else if (AllocaInst *AI = dyn_cast(CurInst)) { if (AI->isArrayAllocation()) return false; // Cannot handle array allocs. Modified: llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll?rev=151093&r1=151092&r2=151093&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll Tue Feb 21 16:08:06 2012 @@ -6,3 +6,46 @@ ; CHECK: @A = global i1 false @A = global i1 icmp ne (i64 sub nsw (i64 ptrtoint (i8* getelementptr inbounds ([3 x i8]* @.str91250, i64 0, i64 1) to i64), i64 ptrtoint ([3 x i8]* @.str91250 to i64)), i64 1) + +; PR11352 + + at xs = global [2 x i32] zeroinitializer, align 4 +; CHECK: @xs = global [2 x i32] [i32 1, i32 1] + +define internal void @test1() { +entry: + store i32 1, i32* getelementptr inbounds ([2 x i32]* @xs, i64 0, i64 0) + %0 = load i32* getelementptr inbounds ([2 x i32]* @xs, i32 0, i64 0), align 4 + store i32 %0, i32* getelementptr inbounds ([2 x i32]* @xs, i64 0, i64 1) + ret void +} + +; PR12060 + +%closure = type { i32 } + + at f = internal global %closure zeroinitializer, align 4 + at m = global i32 0, align 4 +; CHECK-NOT: @f +; CHECK: @m = global i32 13 + +define internal i32 @test2_helper(%closure* %this, i32 %b) { +entry: + %0 = getelementptr inbounds %closure* %this, i32 0, i32 0 + %1 = load i32* %0, align 4 + %add = add nsw i32 %1, %b + ret i32 %add +} + +define internal void @test2() { +entry: + store i32 4, i32* getelementptr inbounds (%closure* @f, i32 0, i32 0) + %call = call i32 @test2_helper(%closure* @f, i32 9) + store i32 %call, i32* @m, align 4 + ret void +} + + at llvm.global_ctors = appending constant + [2 x { i32, void ()* }] + [{ i32, void ()* } { i32 65535, void ()* @test1 }, + { i32, void ()* } { i32 65535, void ()* @test2 }] From daniel at zuster.org Tue Feb 21 16:25:44 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 21 Feb 2012 22:25:44 -0000 Subject: [llvm-commits] [zorg] r151096 - in /zorg/trunk/lnt/lnt: lnttool/main.py lnttool/updatedb.py server/db/testsuitedb.py Message-ID: <20120221222544.7E5F62A6C12F@llvm.org> Author: ddunbar Date: Tue Feb 21 16:25:44 2012 New Revision: 151096 URL: http://llvm.org/viewvc/llvm-project?rev=151096&view=rev Log: [lnt] lnttool: Add an 'updatedb' command, which at the moment just provides an easy way to delete machines and runs. - Should be part of the web app but haven't built any log in functionality yet. Added: zorg/trunk/lnt/lnt/lnttool/updatedb.py Modified: zorg/trunk/lnt/lnt/lnttool/main.py zorg/trunk/lnt/lnt/server/db/testsuitedb.py Modified: zorg/trunk/lnt/lnt/lnttool/main.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/main.py?rev=151096&r1=151095&r2=151096&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/main.py (original) +++ zorg/trunk/lnt/lnt/lnttool/main.py Tue Feb 21 16:25:44 2012 @@ -60,6 +60,7 @@ from convert import action_convert from import_data import action_import from report import action_report +from updatedb import action_updatedb def action_checkformat(name, args): """check the format of an LNT test report file""" Added: zorg/trunk/lnt/lnt/lnttool/updatedb.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/updatedb.py?rev=151096&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/updatedb.py (added) +++ zorg/trunk/lnt/lnt/lnttool/updatedb.py Tue Feb 21 16:25:44 2012 @@ -0,0 +1,78 @@ +import os +from optparse import OptionParser, OptionGroup + +import lnt.server.config +from lnt.testing.util.commands import note, warning, error, fatal + +def action_updatedb(name, args): + """modify a database""" + + from optparse import OptionParser, OptionGroup + + parser = OptionParser("%%prog %s [options] +"%name) + parser.add_option("", "--database", dest="database", default="default", + help="database to modify [%default]") + parser.add_option("", "--testsuite", dest="testsuite", + help="testsuite to modify") + parser.add_option("", "--commit", dest="commit", type=int, + default=False) + parser.add_option("", "--show-sql", dest="show_sql", action="store_true", + default=False) + parser.add_option("", "--delete-machine", dest="delete_machines", + action="append", default=[]) + parser.add_option("", "--delete-run", dest="delete_runs", + action="append", default=[], type=int) + (opts, args) = parser.parse_args(args) + + if len(args) != 1: + parser.error("invalid number of arguments") + + if opts.testsuite is None: + parser.error("--testsuite is required") + + config, = args + + # Accept paths to config files, or to directories containing 'lnt.cfg'. + if os.path.isdir(config): + tmp = os.path.join(config, 'lnt.cfg') + if os.path.exists(tmp): + config = tmp + + # Load the config file. + config_data = {} + exec open(config) in config_data + config = lnt.server.config.Config.fromData(config, config_data) + + # Get the database and test suite. + db = config.get_database(opts.database, echo=opts.show_sql) + ts = db.testsuite[opts.testsuite] + + # Compute a list of all the runs to delete. + runs_to_delete = list(opts.delete_runs) + if opts.delete_machines: + runs_to_delete.extend( + id + for id, in ts.query(ts.Run.id).\ + join(ts.Machine).\ + filter(ts.Machine.name.in_(opts.delete_machines))) + + # Delete all samples associated with those runs. + ts.query(ts.Sample).\ + filter(ts.Sample.run_id.in_(runs_to_delete)).\ + delete(synchronize_session=False) + + # Delete all those runs. + ts.query(ts.Run).\ + filter(ts.Run.id.in_(runs_to_delete)).\ + delete(synchronize_session=False) + + # Delete the machines. + for name in opts.delete_machines: + num_deletes = ts.query(ts.Machine).filter_by(name=name).delete() + if num_deletes == 0: + warning("unable to find machine named: %r" % name) + + if opts.commit: + db.commit() + else: + db.rollback() Modified: zorg/trunk/lnt/lnt/server/db/testsuitedb.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/db/testsuitedb.py?rev=151096&r1=151095&r2=151096&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/db/testsuitedb.py (original) +++ zorg/trunk/lnt/lnt/server/db/testsuitedb.py Tue Feb 21 16:25:44 2012 @@ -319,6 +319,7 @@ self.base.metadata.create_all(self.v4db.engine) # Add several shortcut aliases, similar to the ones on the v4db. + self.session = self.v4db.session self.add = self.v4db.add self.commit = self.v4db.commit self.query = self.v4db.query From echristo at apple.com Tue Feb 21 16:25:56 2012 From: echristo at apple.com (Eric Christopher) Date: Tue, 21 Feb 2012 22:25:56 -0000 Subject: [llvm-commits] [llvm] r151098 - /llvm/trunk/test/DebugInfo/X86/DW_AT_byte_size.ll Message-ID: <20120221222556.E68862A6C130@llvm.org> Author: echristo Date: Tue Feb 21 16:25:56 2012 New Revision: 151098 URL: http://llvm.org/viewvc/llvm-project?rev=151098&view=rev Log: Testcase for previous commit. rdar://10493979 Added: llvm/trunk/test/DebugInfo/X86/DW_AT_byte_size.ll Added: llvm/trunk/test/DebugInfo/X86/DW_AT_byte_size.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/DW_AT_byte_size.ll?rev=151098&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/X86/DW_AT_byte_size.ll (added) +++ llvm/trunk/test/DebugInfo/X86/DW_AT_byte_size.ll Tue Feb 21 16:25:56 2012 @@ -0,0 +1,45 @@ +; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj +; RUN: llvm-dwarfdump %t | FileCheck %s + +; Checks that we don't emit a size for a pointer type. +; CHECK: DW_TAG_pointer_type +; CHECK-NEXT: DW_AT_type +; CHECK-NOT-NEXT: DW_AT_byte_size + +%struct.A = type { i32 } + +define i32 @_Z3fooP1A(%struct.A* %a) nounwind uwtable ssp { +entry: + %a.addr = alloca %struct.A*, align 8 + store %struct.A* %a, %struct.A** %a.addr, align 8 + call void @llvm.dbg.declare(metadata !{%struct.A** %a.addr}, metadata !16), !dbg !17 + %0 = load %struct.A** %a.addr, align 8, !dbg !18 + %b = getelementptr inbounds %struct.A* %0, i32 0, i32 0, !dbg !18 + %1 = load i32* %b, align 4, !dbg !18 + ret i32 %1, !dbg !18 +} + +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{i32 786449, i32 0, i32 4, metadata !"foo.cpp", metadata !"/Users/echristo", metadata !"clang version 3.1 (trunk 150996)", i1 true, i1 false, metadata !"", i32 0, metadata !1, metadata !1, metadata !3, metadata !1} ; [ DW_TAG_compile_unit ] +!1 = metadata !{metadata !2} +!2 = metadata !{i32 0} +!3 = metadata !{metadata !4} +!4 = metadata !{metadata !5} +!5 = metadata !{i32 786478, i32 0, metadata !6, metadata !"foo", metadata !"foo", metadata !"_Z3fooP1A", metadata !6, i32 3, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (%struct.A*)* @_Z3fooP1A, null, null, metadata !14} ; [ DW_TAG_subprogram ] +!6 = metadata !{i32 786473, metadata !"foo.cpp", metadata !"/Users/echristo", null} ; [ DW_TAG_file_type ] +!7 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!8 = metadata !{metadata !9, metadata !10} +!9 = metadata !{i32 786468, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!10 = metadata !{i32 786447, null, metadata !"", null, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !11} ; [ DW_TAG_pointer_type ] +!11 = metadata !{i32 786434, null, metadata !"A", metadata !6, i32 1, i64 32, i64 32, i32 0, i32 0, null, metadata !12, i32 0, null, null} ; [ DW_TAG_class_type ] +!12 = metadata !{metadata !13} +!13 = metadata !{i32 786445, metadata !11, metadata !"b", metadata !6, i32 1, i64 32, i64 32, i64 0, i32 0, metadata !9} ; [ DW_TAG_member ] +!14 = metadata !{metadata !15} +!15 = metadata !{i32 786468} ; [ DW_TAG_base_type ] +!16 = metadata !{i32 786689, metadata !5, metadata !"a", metadata !6, i32 16777219, metadata !10, i32 0, i32 0} ; [ DW_TAG_arg_variable ] +!17 = metadata !{i32 3, i32 13, metadata !5, null} +!18 = metadata !{i32 4, i32 3, metadata !19, null} +!19 = metadata !{i32 786443, metadata !5, i32 3, i32 16, metadata !6, i32 0} ; [ DW_TAG_lexical_block ] From echristo at apple.com Tue Feb 21 16:25:54 2012 From: echristo at apple.com (Eric Christopher) Date: Tue, 21 Feb 2012 22:25:54 -0000 Subject: [llvm-commits] [llvm] r151097 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp test/DebugInfo/X86/DW_AT_specification.ll test/DebugInfo/X86/concrete_out_of_line.ll test/DebugInfo/X86/pr11300.ll Message-ID: <20120221222554.494272A6C12F@llvm.org> Author: echristo Date: Tue Feb 21 16:25:53 2012 New Revision: 151097 URL: http://llvm.org/viewvc/llvm-project?rev=151097&view=rev Log: There's no need for a DW_AT_byte_size on a pointer type. Part of rdar://10493979 where it reduces by about .5% (10k) Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll llvm/trunk/test/DebugInfo/X86/pr11300.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=151097&r1=151096&r2=151097&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Tue Feb 21 16:25:53 2012 @@ -723,7 +723,7 @@ addString(&Buffer, dwarf::DW_AT_name, Name); // Add size if non-zero (derived types might be zero-sized.) - if (Size) + if (Size && Tag != dwarf::DW_TAG_pointer_type) addUInt(&Buffer, dwarf::DW_AT_byte_size, 0, Size); // Add source line info if available and TyDesc is not a forward declaration. Modified: llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll?rev=151097&r1=151096&r2=151097&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll (original) +++ llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll Tue Feb 21 16:25:53 2012 @@ -4,7 +4,7 @@ ; test that the DW_AT_specification is a back edge in the file. ; CHECK: 0x00000038: DW_TAG_subprogram [5] * -; CHECK: 0x00000060: DW_AT_specification [DW_FORM_ref4] (cu + 0x0038 => {0x00000038}) +; CHECK: 0x0000005f: DW_AT_specification [DW_FORM_ref4] (cu + 0x0038 => {0x00000038}) @_ZZN3foo3barEvE1x = constant i32 0, align 4 Modified: llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll?rev=151097&r1=151096&r2=151097&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll (original) +++ llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll Tue Feb 21 16:25:53 2012 @@ -7,7 +7,7 @@ ; first check that we have a TAG_subprogram at a given offset and it has ; AT_inline. -; CHECK: 0x00000136: DW_TAG_subprogram +; CHECK: 0x00000134: DW_TAG_subprogram ; CHECK-NEXT: DW_AT_MIPS_linkage_name ; CHECK-NEXT: DW_AT_specification ; CHECK-NEXT: DW_AT_inline @@ -15,8 +15,8 @@ ; and then that a TAG_subprogram refers to it with AT_abstract_origin. -; CHECK: 0x00000186: DW_TAG_subprogram -; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x0136 => {0x00000136}) +; CHECK: 0x00000184: DW_TAG_subprogram +; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x0134 => {0x00000134}) define i32 @_ZN17nsAutoRefCnt7ReleaseEv() { entry: Modified: llvm/trunk/test/DebugInfo/X86/pr11300.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/pr11300.ll?rev=151097&r1=151096&r2=151097&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/X86/pr11300.ll (original) +++ llvm/trunk/test/DebugInfo/X86/pr11300.ll Tue Feb 21 16:25:53 2012 @@ -4,7 +4,7 @@ ; test that the DW_AT_specification is a back edge in the file. ; CHECK: 0x0000005b: DW_TAG_subprogram [5] -; CHECK: 0x0000007d: DW_AT_specification [DW_FORM_ref4] (cu + 0x005b => {0x0000005b}) +; CHECK: 0x0000007c: DW_AT_specification [DW_FORM_ref4] (cu + 0x005b => {0x0000005b}) %struct.foo = type { i8 } From lhames at gmail.com Tue Feb 21 16:29:38 2012 From: lhames at gmail.com (Lang Hames) Date: Tue, 21 Feb 2012 22:29:38 -0000 Subject: [llvm-commits] [llvm] r151099 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <20120221222938.463052A6C12F@llvm.org> Author: lhames Date: Tue Feb 21 16:29:38 2012 New Revision: 151099 URL: http://llvm.org/viewvc/llvm-project?rev=151099&view=rev Log: Add API "handleMoveIntoBundl" for updating liveness when moving instructions into bundles. This method takes a bundle start and an MI being bundled, and makes the intervals for the MI's operands appear to start/end on the bundle start. Also fixes some minor cosmetic issues (whitespace, naming convention) in the HMEditor code. Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=151099&r1=151098&r2=151099&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Tue Feb 21 16:29:38 2012 @@ -284,7 +284,15 @@ /// instruction 'mi' has been moved within a basic block. This will update /// the live intervals for all operands of mi. Moves between basic blocks /// are not supported. - void handleMove(MachineInstr* mi); + void handleMove(MachineInstr* MI); + + /// moveIntoBundle - Update intervals for operands of MI so that they + /// begin/end on the SlotIndex for BundleStart. + /// + /// Requires MI and BundleStart to have SlotIndexes, and assumes + /// existing liveness is accurate. BundleStart should be the first + /// instruction in the Bundle. + void handleMoveIntoBundle(MachineInstr* MI, MachineInstr* BundleStart); // Register mask functions. // Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=151099&r1=151098&r2=151099&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Feb 21 16:29:38 2012 @@ -1053,7 +1053,7 @@ // Update intervals for all operands of MI from OldIdx to NewIdx. // This assumes that MI used to be at OldIdx, and now resides at // NewIdx. - void moveAllOperandsFrom(MachineInstr* MI, SlotIndex OldIdx) { + void moveAllRangesFrom(MachineInstr* MI, SlotIndex OldIdx) { assert(NewIdx != OldIdx && "No-op move? That's a bit strange."); // Collect the operands. @@ -1078,7 +1078,9 @@ } - void moveAllOperandsInto(MachineInstr* MI, MachineInstr* BundleStart) { + // Update intervals for all operands of MI to refer to BundleStart's + // SlotIndex. + void moveAllRangesInto(MachineInstr* MI, MachineInstr* BundleStart) { if (MI == BundleStart) return; // Bundling instr with itself - nothing to do. @@ -1086,16 +1088,33 @@ assert(LIS.getSlotIndexes()->getInstructionFromIndex(OldIdx) == MI && "SlotIndex <-> Instruction mapping broken for MI"); - BundleRanges BR = createBundleRanges(BundleStart); - + // Collect all ranges already in the bundle. + MachineBasicBlock::instr_iterator BII(BundleStart); RangeSet Entering, Internal, Exiting; bool hasRegMaskOp = false; + collectRanges(BII, Entering, Internal, Exiting, hasRegMaskOp, NewIdx); + assert(!hasRegMaskOp && "Can't have RegMask operand in bundle."); + for (++BII; &*BII == MI || BII->isInsideBundle(); ++BII) { + if (&*BII == MI) + continue; + collectRanges(BII, Entering, Internal, Exiting, hasRegMaskOp, NewIdx); + assert(!hasRegMaskOp && "Can't have RegMask operand in bundle."); + } + + BundleRanges BR = createBundleRanges(Entering, Internal, Exiting); + collectRanges(MI, Entering, Internal, Exiting, hasRegMaskOp, OldIdx); + assert(!hasRegMaskOp && "Can't have RegMask operand in bundle."); + + DEBUG(dbgs() << "Entering: " << Entering.size() << "\n"); + DEBUG(dbgs() << "Internal: " << Internal.size() << "\n"); + DEBUG(dbgs() << "Exiting: " << Exiting.size() << "\n"); moveAllEnteringFromInto(OldIdx, Entering, BR); moveAllInternalFromInto(OldIdx, Internal, BR); moveAllExitingFromInto(OldIdx, Exiting, BR); + #ifndef NDEBUG LIValidator validator; std::for_each(Entering.begin(), Entering.end(), validator); @@ -1192,16 +1211,46 @@ } } - BundleRanges createBundleRanges(MachineInstr* BundleMI) { - BundleRanges BR; + // Collect IntRangePairs for all operands of MI that may need fixing. + void collectRangesInBundle(MachineInstr* MI, RangeSet& Entering, + RangeSet& Exiting, SlotIndex MIStartIdx, + SlotIndex MIEndIdx) { + for (MachineInstr::mop_iterator MOI = MI->operands_begin(), + MOE = MI->operands_end(); + MOI != MOE; ++MOI) { + const MachineOperand& MO = *MOI; + assert(!MO.isRegMask() && "Can't have RegMasks in bundles."); + if (!MO.isReg() || MO.getReg() == 0) + continue; - MachineBasicBlock::instr_iterator BII(BundleMI); - RangeSet Entering, Internal, Exiting; - bool hasRegMaskOp = false; - collectRanges(BII, Entering, Internal, Exiting, hasRegMaskOp, NewIdx); - for (++BII; BII->isInsideBundle(); ++BII) { - collectRanges(BII, Entering, Internal, Exiting, hasRegMaskOp, NewIdx); + unsigned Reg = MO.getReg(); + + // TODO: Currently we're skipping uses that are reserved or have no + // interval, but we're not updating their kills. This should be + // fixed. + if (!LIS.hasInterval(Reg) || + (TargetRegisterInfo::isPhysicalRegister(Reg) && LIS.isReserved(Reg))) + continue; + + LiveInterval* LI = &LIS.getInterval(Reg); + + if (MO.readsReg()) { + LiveRange* LR = LI->getLiveRangeContaining(MIStartIdx); + if (LR != 0) + Entering.insert(std::make_pair(LI, LR)); + } + if (MO.isDef()) { + assert(!MO.isEarlyClobber() && "Early clobbers not allowed in bundles."); + assert(!MO.isDead() && "Dead-defs not allowed in bundles."); + LiveRange* LR = LI->getLiveRangeContaining(MIEndIdx.getDeadSlot()); + assert(LR != 0 && "Internal ranges not allowed in bundles."); + Exiting.insert(std::make_pair(LI, LR)); + } } + } + + BundleRanges createBundleRanges(RangeSet& Entering, RangeSet& Internal, RangeSet& Exiting) { + BundleRanges BR; for (RangeSet::iterator EI = Entering.begin(), EE = Entering.end(); EI != EE; ++EI) { @@ -1481,5 +1530,11 @@ assert(!MI->isBundled() && "Can't handle bundled instructions yet."); HMEditor HME(*this, *mri_, *tri_, NewIndex); - HME.moveAllOperandsFrom(MI, OldIndex); + HME.moveAllRangesFrom(MI, OldIndex); +} + +void LiveIntervals::handleMoveIntoBundle(MachineInstr* MI, MachineInstr* BundleStart) { + SlotIndex NewIndex = indexes_->getInstructionIndex(BundleStart); + HMEditor HME(*this, *mri_, *tri_, NewIndex); + HME.moveAllRangesInto(MI, BundleStart); } From emenezes at codeaurora.org Tue Feb 21 17:29:16 2012 From: emenezes at codeaurora.org (Evandro Menezes) Date: Tue, 21 Feb 2012 17:29:16 -0600 Subject: [llvm-commits] Hexagon: Add pattern for truncated word store In-Reply-To: References: <4F3EC198.6070409@codeaurora.org> <4F43CD5B.4000100@codeaurora.org> Message-ID: <4F4428CC.5080407@codeaurora.org> Chad, I'm not sure that it applies to this patch, since it simplifies the specific InstrInfo.td and AsmPrinter.cpp without affecting the generated code. -- Evandro Menezes Austin, TX emenezes at codeaurora.org Qualcomm Innovation Center, Inc is a member of the Code Aurora Forum On 02/21/12 12:27, Chad Rosier wrote: > Testcase? :) > > On Feb 21, 2012, at 8:59 AM, Evandro Menezes wrote: > >> Resubmitting the patch to fix a typo. >> >> -- >> Evandro Menezes Austin, TX emenezes at codeaurora.org >> Qualcomm Innovation Center, Inc is a member of the Code Aurora Forum >> >> >> On 02/17/12 15:07, Evandro Menezes wrote: >>> This patch for Hexagon replaces an insn definition with a pattern for >>> truncated word stores. >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From mcrosier at apple.com Tue Feb 21 17:37:27 2012 From: mcrosier at apple.com (Chad Rosier) Date: Tue, 21 Feb 2012 15:37:27 -0800 Subject: [llvm-commits] Hexagon: Add pattern for truncated word store In-Reply-To: <4F4428CC.5080407@codeaurora.org> References: <4F3EC198.6070409@codeaurora.org> <4F43CD5B.4000100@codeaurora.org> <4F4428CC.5080407@codeaurora.org> Message-ID: <99804DD1-C30A-4111-8400-CB7EA0DA8F5D@apple.com> Ah, ok. On Feb 21, 2012, at 3:29 PM, Evandro Menezes wrote: > Chad, > > I'm not sure that it applies to this patch, since it simplifies the specific InstrInfo.td and AsmPrinter.cpp without affecting the generated code. > > -- > Evandro Menezes Austin, TX emenezes at codeaurora.org > Qualcomm Innovation Center, Inc is a member of the Code Aurora Forum > > > On 02/21/12 12:27, Chad Rosier wrote: >> Testcase? :) >> >> On Feb 21, 2012, at 8:59 AM, Evandro Menezes wrote: >> >>> Resubmitting the patch to fix a typo. >>> >>> -- >>> Evandro Menezes Austin, TX emenezes at codeaurora.org >>> Qualcomm Innovation Center, Inc is a member of the Code Aurora Forum >>> >>> >>> On 02/17/12 15:07, Evandro Menezes wrote: >>>> This patch for Hexagon replaces an insn definition with a pattern for >>>> truncated word stores. >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From bigcheesegs at gmail.com Tue Feb 21 17:38:03 2012 From: bigcheesegs at gmail.com (Michael Spencer) Date: Tue, 21 Feb 2012 15:38:03 -0800 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: On Tue, Feb 21, 2012 at 12:02 PM, Joe Groff wrote: > On Tue, Feb 21, 2012 at 5:10 AM, Anton Korobeynikov > wrote: >> Well... Do you have vcpp in hand? You can check in which conditions >> call to fltused is emitted. >> Typical cases: >> ?1. Ordinary floating point operand >> ?2. float* >> ?3. struct { float } >> ?4. struct { float } * > > It appears that VC generates a _fltused reference if a float type is > referenced in any context, even if the type isn't ever used as an > argument. Perhaps LLVM should be changed so that the "reference > _fltused" flag is enabled when a FloatType is instantiated, rather > than by checking CallInsts during instruction lowering. Is that a > sensible change? > > -Joe VC emits __fltused if you use the keyword float or double anywhere in your program. I wrote the original code to emit __fltused, and decided to restrict it to the places that the MSVCRT actually needs it, which is specifically format string functions. The reason it adds it for any vararg call passing a float is because of vararg forwarding functions which may eventually call a format string function. I would prefer we emit it in as few cases as possible. - Michael Spencer From stoklund at 2pi.dk Tue Feb 21 17:47:44 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 21 Feb 2012 23:47:44 -0000 Subject: [llvm-commits] [llvm] r151104 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Message-ID: <20120221234744.390302A6C12F@llvm.org> Author: stoklund Date: Tue Feb 21 17:47:43 2012 New Revision: 151104 URL: http://llvm.org/viewvc/llvm-project?rev=151104&view=rev Log: Calls don't really change the stack pointer. Even if a call instruction has %SP operands, it doesn't change the value of the stack pointer. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=151104&r1=151103&r2=151104&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Feb 21 17:47:43 2012 @@ -1400,7 +1400,8 @@ // saves compile time, because it doesn't require every single // stack slot reference to depend on the instruction that does the // modification. - if (MI->definesRegister(ARM::SP)) + // Calls don't actually change the stack pointer, even if they have imp-defs. + if (!MI->isCall() && MI->definesRegister(ARM::SP)) return true; return false; From stoklund at 2pi.dk Tue Feb 21 17:49:18 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 21 Feb 2012 23:49:18 -0000 Subject: [llvm-commits] [llvm] r151105 - /llvm/trunk/test/CodeGen/PowerPC/ppc32-vaarg.ll Message-ID: <20120221234918.589432A6C12F@llvm.org> Author: stoklund Date: Tue Feb 21 17:49:18 2012 New Revision: 151105 URL: http://llvm.org/viewvc/llvm-project?rev=151105&view=rev Log: Remove a bad PowerPC test. This test case was way too strict, matching the entire assembly output. Every non-trivial change to the ppc backend or -O0 pipeline required the test to be updated. It should be replaced with a test of the specific vaarg feature. Removed: llvm/trunk/test/CodeGen/PowerPC/ppc32-vaarg.ll Removed: llvm/trunk/test/CodeGen/PowerPC/ppc32-vaarg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc32-vaarg.ll?rev=151104&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/ppc32-vaarg.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/ppc32-vaarg.ll (removed) @@ -1,160 +0,0 @@ -; RUN: llc -O0 < %s | FileCheck %s -;ModuleID = 'test.c' -target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32" -target triple = "powerpc-unknown-freebsd9.0" - -%struct.__va_list_tag = type { i8, i8, i16, i8*, i8* } - - at var1 = common global i64 0, align 8 - at var2 = common global double 0.0, align 8 - at var3 = common global i32 0, align 4 - -define void @ppcvaargtest(%struct.__va_list_tag* %ap) nounwind { - entry: - %x = va_arg %struct.__va_list_tag* %ap, i64; Get from r5,r6 -; CHECK: addi 5, 4, 1 -; CHECK-NEXT: rlwinm 6, 4, 0, 31, 31 -; CHECK-NEXT: cmplwi 0, 6, 0 -; CHECK-NEXT: stw 3, -4(1) -; CHECK-NEXT: stw 5, -8(1) -; CHECK-NEXT: stw 4, -12(1) -; CHECK-NEXT: bne 0, .LBB0_2 -; CHECK-NEXT: # BB#1: # %entry -; CHECK-NEXT: lwz 3, -12(1) -; CHECK-NEXT: stw 3, -8(1) -; CHECK-NEXT: .LBB0_2: # %entry -; CHECK-NEXT: lwz 3, -8(1) -; CHECK-NEXT: addi 4, 3, 2 -; CHECK-NEXT: lwz 5, -4(1) -; CHECK-NEXT: lwz 6, 4(5) -; CHECK-NEXT: lwz 7, 8(5) -; CHECK-NEXT: stb 4, 0(5) -; CHECK-NEXT: cmpwi 0, 3, 8 -; CHECK-NEXT: addi 4, 6, 4 -; CHECK-NEXT: mr 8, 6 -; CHECK-NEXT: stw 7, -16(1) -; CHECK-NEXT: stw 4, -20(1) -; CHECK-NEXT: stw 3, -24(1) -; CHECK-NEXT: stw 8, -28(1) -; CHECK-NEXT: stw 6, -32(1) -; CHECK-NEXT: mfcr 0 # cr0 -; CHECK-NEXT: stw 0, -36(1) -; CHECK-NEXT: blt 0, .LBB0_4 -; CHECK-NEXT: # BB#3: # %entry -; CHECK-NEXT: lwz 3, -20(1) -; CHECK-NEXT: stw 3, -28(1) -; CHECK-NEXT: .LBB0_4: # %entry -; CHECK-NEXT: lwz 3, -28(1) -; CHECK-NEXT: lwz 4, -4(1) -; CHECK-NEXT: stw 3, 4(4) - store i64 %x, i64* @var1, align 8 -; CHECK-NEXT: lwz 3, -24(1) -; CHECK-NEXT: slwi 5, 3, 2 -; CHECK-NEXT: lwz 6, -16(1) -; CHECK-NEXT: add 5, 6, 5 -; CHECK-NEXT: lwz 0, -36(1) -; CHECK-NEXT: mtcrf 128, 0 -; CHECK-NEXT: stw 5, -40(1) -; CHECK-NEXT: blt 0, .LBB0_6 -; CHECK-NEXT: # BB#5: # %entry -; CHECK-NEXT: lwz 3, -32(1) -; CHECK-NEXT: stw 3, -40(1) -; CHECK-NEXT: .LBB0_6: # %entry -; CHECK-NEXT: lwz 3, -40(1) -; CHECK-NEXT: lwz 4, 0(3) -; CHECK-NEXT: lwz 3, 4(3) -; CHECK-NEXT: lis 5, var1 at ha -; CHECK-NEXT: la 6, var1 at l(5) -; CHECK-NEXT: stw 3, 4(6) -; CHECK-NEXT: stw 4, var1 at l(5) -; CHECK-NEXT: lwz 3, -4(1) - %y = va_arg %struct.__va_list_tag* %ap, double; From f1 -; CHECK-NEXT: lbz 4, 1(3) -; CHECK-NEXT: lwz 5, 4(3) -; CHECK-NEXT: lwz 6, 8(3) -; CHECK-NEXT: addi 7, 4, 1 -; CHECK-NEXT: stb 7, 1(3) -; CHECK-NEXT: cmpwi 0, 4, 8 -; CHECK-NEXT: addi 7, 5, 8 -; CHECK-NEXT: mr 8, 5 -; CHECK-NEXT: stw 5, -44(1) -; CHECK-NEXT: stw 7, -48(1) -; CHECK-NEXT: stw 4, -52(1) -; CHECK-NEXT: stw 6, -56(1) -; CHECK-NEXT: stw 8, -60(1) -; CHECK-NEXT: mfcr 0 # cr0 -; CHECK-NEXT: stw 0, -64(1) -; CHECK-NEXT: blt 0, .LBB0_8 -; CHECK-NEXT: # BB#7: # %entry -; CHECK-NEXT: lwz 3, -48(1) -; CHECK-NEXT: stw 3, -60(1) -; CHECK-NEXT: .LBB0_8: # %entry -; CHECK-NEXT: lwz 3, -60(1) -; CHECK-NEXT: lwz 4, -4(1) -; CHECK-NEXT: stw 3, 4(4) -; CHECK-NEXT: lwz 3, -52(1) -; CHECK-NEXT: slwi 5, 3, 3 -; CHECK-NEXT: lwz 6, -56(1) -; CHECK-NEXT: add 5, 6, 5 -; CHECK-NEXT: addi 5, 5, 32 -; CHECK-NEXT: lwz 0, -64(1) -; CHECK-NEXT: mtcrf 128, 0 -; CHECK-NEXT: stw 5, -68(1) -; CHECK-NEXT: blt 0, .LBB0_10 -; CHECK-NEXT: # BB#9: # %entry -; CHECK-NEXT: lwz 3, -44(1) -; CHECK-NEXT: stw 3, -68(1) -; CHECK-NEXT: .LBB0_10: # %entry -; CHECK-NEXT: lwz 3, -68(1) -; CHECK-NEXT: lfd 0, 0(3) - store double %y, double* @var2, align 8 -; CHECK-NEXT: lis 3, var2 at ha -; CHECK-NEXT: stfd 0, var2 at l(3) - %z = va_arg %struct.__va_list_tag* %ap, i32; From r7 -; CHECK-NEXT: lwz 3, -4(1) -; CHECK-NEXT: lbz 4, 0(3) -; CHECK-NEXT: lwz 5, 4(3) -; CHECK-NEXT: lwz 6, 8(3) -; CHECK-NEXT: addi 7, 4, 1 -; CHECK-NEXT: stb 7, 0(3) -; CHECK-NEXT: cmpwi 0, 4, 8 -; CHECK-NEXT: addi 7, 5, 4 -; CHECK-NEXT: mr 8, 5 -; CHECK-NEXT: stw 4, -72(1) -; CHECK-NEXT: stw 6, -76(1) -; CHECK-NEXT: mfcr 0 # cr0 -; CHECK-NEXT: stw 0, -80(1) -; CHECK-NEXT: stw 5, -84(1) -; CHECK-NEXT: stw 8, -88(1) -; CHECK-NEXT: stw 7, -92(1) -; CHECK-NEXT: blt 0, .LBB0_12 -; CHECK-NEXT: # BB#11: # %entry -; CHECK-NEXT: lwz 3, -92(1) -; CHECK-NEXT: stw 3, -88(1) -; CHECK-NEXT: .LBB0_12: # %entry -; CHECK-NEXT: lwz 3, -88(1) -; CHECK-NEXT: lwz 4, -4(1) -; CHECK-NEXT: stw 3, 4(4) -; CHECK-NEXT: lwz 3, -72(1) -; CHECK-NEXT: slwi 5, 3, 2 -; CHECK-NEXT: lwz 6, -76(1) -; CHECK-NEXT: add 5, 6, 5 -; CHECK-NEXT: lwz 0, -80(1) -; CHECK-NEXT: mtcrf 128, 0 -; CHECK-NEXT: stw 5, -96(1) -; CHECK-NEXT: blt 0, .LBB0_14 -; CHECK-NEXT: # BB#13: # %entry -; CHECK-NEXT: lwz 3, -84(1) -; CHECK-NEXT: stw 3, -96(1) -; CHECK-NEXT: .LBB0_14: # %entry -; CHECK-NEXT: lwz 3, -96(1) -; CHECK-NEXT: lwz 3, 0(3) - store i32 %z, i32* @var3, align 4 -; CHECK-NEXT: lis 4, var3 at ha -; CHECK-NEXT: stw 3, var3 at l(4) -; CHECK-NEXT: lwz 3, -4(1) - ret void -; CHECK-NEXT: stw 3, -100(1) -; CHECK-NEXT: blr -} - From jolesen at apple.com Tue Feb 21 17:57:26 2012 From: jolesen at apple.com (Jakob Stoklund Olesen) Date: Tue, 21 Feb 2012 15:57:26 -0800 Subject: [llvm-commits] LLVM test/CodeGen/PowerPC/ppc32-vaarg.ll Message-ID: <21DAD6FB-B396-4D87-AC6C-5574CDC42FD4@apple.com> Hi Roman, In r151105, I removed your ppc vaarg test case. It was much too restrictive and needed updating every time something in the code generator changed. Could you please replace it with a test case that only checks the vaarg functionality? Thanks, /jakob From eli.friedman at gmail.com Tue Feb 21 18:01:56 2012 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 21 Feb 2012 16:01:56 -0800 Subject: [llvm-commits] [llvm] r151104 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp In-Reply-To: <20120221234744.390302A6C12F@llvm.org> References: <20120221234744.390302A6C12F@llvm.org> Message-ID: On Tue, Feb 21, 2012 at 3:47 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Tue Feb 21 17:47:43 2012 > New Revision: 151104 > > URL: http://llvm.org/viewvc/llvm-project?rev=151104&view=rev > Log: > Calls don't really change the stack pointer. Doesn't that depend on the calling convention? Granted, I think it holds for all the calling conventions I know of on ARM, but it certainly isn't true in general. -Eli From stoklund at 2pi.dk Tue Feb 21 18:04:49 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 21 Feb 2012 16:04:49 -0800 Subject: [llvm-commits] [llvm] r151104 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp In-Reply-To: References: <20120221234744.390302A6C12F@llvm.org> Message-ID: On Feb 21, 2012, at 4:01 PM, Eli Friedman wrote: > On Tue, Feb 21, 2012 at 3:47 PM, Jakob Stoklund Olesen wrote: >> Author: stoklund >> Date: Tue Feb 21 17:47:43 2012 >> New Revision: 151104 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=151104&view=rev >> Log: >> Calls don't really change the stack pointer. > > Doesn't that depend on the calling convention? Yes, at least on x86. > Granted, I think it > holds for all the calling conventions I know of on ARM, but it > certainly isn't true in general. AFAIK, no ARM calling conventions change the stack pointer. /jakob From ahatanaka at mips.com Tue Feb 21 18:16:54 2012 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 22 Feb 2012 00:16:54 -0000 Subject: [llvm-commits] [llvm] r151107 - /llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp Message-ID: <20120222001654.BFFEA2A6C12F@llvm.org> Author: ahatanak Date: Tue Feb 21 18:16:54 2012 New Revision: 151107 URL: http://llvm.org/viewvc/llvm-project?rev=151107&view=rev Log: Use a function in MathExtras to do sign extension. Modified: llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp Modified: llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp?rev=151107&r1=151106&r2=151107&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsAnalyzeImmediate.cpp Tue Feb 21 18:16:54 2012 @@ -90,7 +90,7 @@ return; // Sign-extend and shift operand of ADDiu and see if it still fits in 16-bit. - int64_t Imm = (((int64_t)Seq[0].ImmOpnd) << 48) >> 48; + int64_t Imm = SignExtend64<16>(Seq[0].ImmOpnd); int64_t ShiftedImm = Imm << (Seq[1].ImmOpnd - 16); if (!isInt<16>(ShiftedImm)) From eli.friedman at gmail.com Tue Feb 21 18:29:22 2012 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 21 Feb 2012 16:29:22 -0800 Subject: [llvm-commits] [llvm] r151104 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp In-Reply-To: References: <20120221234744.390302A6C12F@llvm.org> Message-ID: On Tue, Feb 21, 2012 at 4:04 PM, Jakob Stoklund Olesen wrote: > > On Feb 21, 2012, at 4:01 PM, Eli Friedman wrote: > >> On Tue, Feb 21, 2012 at 3:47 PM, Jakob Stoklund Olesen wrote: >>> Author: stoklund >>> Date: Tue Feb 21 17:47:43 2012 >>> New Revision: 151104 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=151104&view=rev >>> Log: >>> Calls don't really change the stack pointer. >> >> Doesn't that depend on the calling convention? > > Yes, at least on x86. > >> ?Granted, I think it >> holds for all the calling conventions I know of on ARM, but it >> certainly isn't true in general. > > AFAIK, no ARM calling conventions change the stack pointer. Mind changing the comment to say that? -Eli From ahatanaka at mips.com Tue Feb 21 18:57:18 2012 From: ahatanaka at mips.com (Hatanaka, Akira) Date: Wed, 22 Feb 2012 00:57:18 +0000 Subject: [llvm-commits] [PATCH][Review request] fix bug in TargetLowering::getPICJumpTableRelocBase Message-ID: <95DD8BA8AA50B14BBFB86A1D541FA380F308AFC3@exchdb03.mips.com> This patch is needed to have TargetLowering::getPICJumpTableRelocBase return a GLOBAL_OFFSET_TABLE node when a jump table entry is encoded as a GPRel64BlockAddress. This should have been included in r149668, but somehow I missed it: http://article.gmane.org/gmane.comp.compilers.llvm.cvs/107188 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/0c735d1d/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: picjumptablerelocbase.patch Type: text/x-patch Size: 1618 bytes Desc: picjumptablerelocbase.patch Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/0c735d1d/attachment.bin From stoklund at 2pi.dk Tue Feb 21 18:56:08 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 22 Feb 2012 00:56:08 -0000 Subject: [llvm-commits] [llvm] r151110 - in /llvm/trunk: docs/ProgrammersManual.html include/llvm/ADT/SparseSet.h unittests/ADT/SparseSetTest.cpp unittests/CMakeLists.txt Message-ID: <20120222005608.78DB32A6C12F@llvm.org> Author: stoklund Date: Tue Feb 21 18:56:08 2012 New Revision: 151110 URL: http://llvm.org/viewvc/llvm-project?rev=151110&view=rev Log: Add a Briggs and Torczon sparse set implementation. For objects that can be identified by small unsigned keys, SparseSet provides constant time clear() and fast deterministic iteration. Insert, erase, and find operations are typically faster than hash tables. SparseSet is useful for keeping information about physical registers, virtual registers, or numbered basic blocks. Added: llvm/trunk/include/llvm/ADT/SparseSet.h llvm/trunk/unittests/ADT/SparseSetTest.cpp Modified: llvm/trunk/docs/ProgrammersManual.html llvm/trunk/unittests/CMakeLists.txt Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=151110&r1=151109&r2=151110&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Tue Feb 21 18:56:08 2012 @@ -81,6 +81,7 @@
    • "llvm/ADT/SmallSet.h"
    • "llvm/ADT/SmallPtrSet.h"
    • "llvm/ADT/DenseSet.h"
    • +
    • "llvm/ADT/SparseSet.h"
    • "llvm/ADT/FoldingSet.h"
    • <set>
    • "llvm/ADT/SetVector.h"
    • @@ -1490,6 +1491,24 @@

      + "llvm/ADT/SparseSet.h" +

      + +
      + +

      SparseSet holds a small number of objects identified by unsigned keys of +moderate size. It uses a lot of memory, but provides operations that are +almost as fast as a vector. Typical keys are physical registers, virtual +registers, or numbered basic blocks.

      + +

      SparseSet is useful for algorithms that need very fast clear/find/insert/erase +and fast iteration over small sets. It is not intended for building composite +data structures.

      + +
      + + +

      "llvm/ADT/FoldingSet.h"

      Added: llvm/trunk/include/llvm/ADT/SparseSet.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SparseSet.h?rev=151110&view=auto ============================================================================== --- llvm/trunk/include/llvm/ADT/SparseSet.h (added) +++ llvm/trunk/include/llvm/ADT/SparseSet.h Tue Feb 21 18:56:08 2012 @@ -0,0 +1,259 @@ +//===--- llvm/ADT/SparseSet.h - Sparse set ----------------------*- 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 the SparseSet class derived from the version described in +// Briggs, Torczon, "An efficient representation for sparse sets", ACM Letters +// on Programming Languages and Systems, Volume 2 Issue 1-4, March???Dec. 1993. +// +// A sparse set holds a small number of objects identified by integer keys from +// a moderately sized universe. The sparse set uses more memory than other +// containers in order to provide faster operations. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_SPARSESET_H +#define LLVM_ADT_SPARSESET_H + +#include "llvm/ADT/SmallVector.h" + +namespace llvm { + +/// SparseSetFunctor - Objects in a SparseSet are identified by small integer +/// keys. A functor object is used to compute the key of an object. The +/// functor's operator() must return an unsigned smaller than the universe. +/// +/// The default functor implementation forwards to a getSparseSetKey() method +/// on the object. It is intended for sparse sets holding ad-hoc structs. +/// +template +struct SparseSetFunctor { + unsigned operator()(const ValueT &Val) { + return Val.getSparseSetKey(); + } +}; + +/// SparseSetFunctor - Provide a trivial identity functor for +/// SparseSet. +/// +template<> struct SparseSetFunctor { + unsigned operator()(unsigned Val) { return Val; } +}; + +/// SparseSet - Fast set implementation for objects that can be identified by +/// small unsigned keys. +/// +/// SparseSet allocates memory proportional to the size of the key universe, so +/// it is not recommended for building composite data structures. It is useful +/// for algorithms that require a single set with fast operations. +/// +/// Compared to DenseSet and DenseMap, SparseSet provides constant-time fast +/// clear() and iteration as fast as a vector. The find(), insert(), and +/// erase() operations are all constant time, and typically faster than a hash +/// table. The iteration order doesn't depend on numerical key values, it only +/// depends on the order of insert() and erase() operations. When no elements +/// have been erased, the iteration order is the insertion order. +/// +/// Compared to BitVector, SparseSet uses 8x-40x more memory, but +/// offers constant-time clear() and size() operations as well as fast +/// iteration independent on the size of the universe. +/// +/// SparseSet contains a dense vector holding all the objects and a sparse +/// array holding indexes into the dense vector. Most of the memory is used by +/// the sparse array which is the size of the key universe. The SparseT +/// template parameter provides a space/speed tradeoff for sets holding many +/// elements. +/// +/// When SparseT is uint32_t, find() only touches 2 cache lines, but the sparse +/// array uses 4 x Universe bytes. +/// +/// When SparseT is uint8_t (the default), find() touches up to 2+[N/256] cache +/// lines, but the sparse array is 4x smaller. N is the number of elements in +/// the set. +/// +/// For sets that may grow to thousands of elements, SparseT should be set to +/// uint16_t or uint32_t. +/// +/// @param ValueT The type of objects in the set. +/// @param SparseT An unsigned integer type. See above. +/// @param KeyFunctorT A functor that computes the unsigned key of a ValueT. +/// +template > +class SparseSet { + typedef SmallVector DenseT; + DenseT Dense; + SparseT *Sparse; + unsigned Universe; + KeyFunctorT KeyOf; + + // Disable copy construction and assignment. + // This data structure is not meant to be used that way. + SparseSet(const SparseSet&); // DO NOT IMPLEMENT. + SparseSet &operator=(const SparseSet&); // DO NOT IMPLEMENT. + +public: + typedef ValueT value_type; + typedef ValueT &reference; + typedef const ValueT &const_reference; + typedef ValueT *pointer; + typedef const ValueT *const_pointer; + + SparseSet() : Sparse(0), Universe(0) {} + ~SparseSet() { free(Sparse); } + + /// setUniverse - Set the universe size which determines the largest key the + /// set can hold. The universe must be sized before any elements can be + /// added. + /// + /// @param U Universe size. All object keys must be less than U. + /// + void setUniverse(unsigned U) { + // It's not hard to resize the universe on a non-empty set, but it doesn't + // seem like a likely use case, so we can add that code when we need it. + assert(empty() && "Can only resize universe on an empty map"); + // Hysteresis prevents needless reallocations. + if (U >= Universe/4 && U <= Universe) + return; + free(Sparse); + // The Sparse array doesn't actually need to be initialized, so malloc + // would be enough here, but that will cause tools like valgrind to + // complain about branching on uninitialized data. + Sparse = reinterpret_cast(calloc(U, sizeof(SparseT))); + Universe = U; + } + + // Import trivial vector stuff from DenseT. + typedef typename DenseT::iterator iterator; + typedef typename DenseT::const_iterator const_iterator; + + const_iterator begin() const { return Dense.begin(); } + const_iterator end() const { return Dense.end(); } + iterator begin() { return Dense.begin(); } + iterator end() { return Dense.end(); } + + /// empty - Returns true if the set is empty. + /// + /// This is not the same as BitVector::empty(). + /// + bool empty() const { return Dense.empty(); } + + /// size - Returns the number of elements in the set. + /// + /// This is not the same as BitVector::size() which returns the size of the + /// universe. + /// + unsigned size() const { return Dense.size(); } + + /// clear - Clears the set. This is a very fast constant time operation. + /// + void clear() { + // Sparse does not need to be cleared, see find(). + Dense.clear(); + } + + /// find - Find an element by its key. + /// + /// @param Key A valid key to find. + /// @returns An iterator to the element identified by key, or end(). + /// + iterator find(unsigned Key) { + assert(Key < Universe && "Key out of range"); + assert(std::numeric_limits::is_integer && + !std::numeric_limits::is_signed && + "SparseT must be an unsigned integer type"); + const unsigned Stride = std::numeric_limits::max() + 1u; + for (unsigned i = Sparse[Key], e = size(); i < e; i += Stride) { + const unsigned FoundKey = KeyOf(Dense[i]); + assert(FoundKey < Universe && "Invalid key in set. Did object mutate?"); + if (Key == FoundKey) + return begin() + i; + // Stride is 0 when SparseT >= unsigned. We don't need to loop. + if (!Stride) + break; + } + return end(); + } + + const_iterator find(unsigned Key) const { + return const_cast(this)->find(Key); + } + + /// count - Returns true if this set contains an element identified by Key. + /// + bool count(unsigned Key) const { + return find(Key) != end(); + } + + /// insert - Attempts to insert a new element. + /// + /// If Val is successfully inserted, return (I, true), where I is an iterator + /// pointing to the newly inserted element. + /// + /// If the set already contains an element with the same key as Val, return + /// (I, false), where I is an iterator pointing to the existing element. + /// + /// Insertion invalidates all iterators. + /// + std::pair insert(const ValueT &Val) { + unsigned Key = KeyOf(Val); + iterator I = find(Key); + if (I != end()) + return std::make_pair(I, false); + Sparse[Key] = size(); + Dense.push_back(Val); + return std::make_pair(end() - 1, true); + } + + /// erase - Erases an existing element identified by a valid iterator. + /// + /// This invalidates all iterators, but erase() returns an iterator pointing + /// to the next element. This makes it possible to erase selected elements + /// while iterating over the set: + /// + /// for (SparseSet::iterator I = Set.begin(); I != Set.end();) + /// if (test(*I)) + /// I = Set.erase(I); + /// else + /// ++I; + /// + /// Note that end() changes when elements are erased, unlike std::list. + /// + iterator erase(iterator I) { + assert(I - begin() < size() && "Invalid iterator"); + if (I != end() - 1) { + *I = Dense.back(); + unsigned BackKey = KeyOf(Dense.back()); + assert(BackKey < Universe && "Invalid key in set. Did object mutate?"); + Sparse[BackKey] = I - begin(); + } + // This depends on SmallVector::pop_back() not invalidating iterators. + // std::vector::pop_back() doesn't give that guarantee. + Dense.pop_back(); + return I; + } + + /// erase - Erases an element identified by Key, if it exists. + /// + /// @param Key The key identifying the element to erase. + /// @returns True when an element was erased, false if no element was found. + /// + bool erase(unsigned Key) { + iterator I = find(Key); + if (I == end()) + return false; + erase(I); + return true; + } + +}; + +} // end namespace llvm + +#endif Added: llvm/trunk/unittests/ADT/SparseSetTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/SparseSetTest.cpp?rev=151110&view=auto ============================================================================== --- llvm/trunk/unittests/ADT/SparseSetTest.cpp (added) +++ llvm/trunk/unittests/ADT/SparseSetTest.cpp Tue Feb 21 18:56:08 2012 @@ -0,0 +1,186 @@ +//===------ ADT/SparseSetTest.cpp - SparseSet unit tests - -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/SparseSet.h" +#include "gtest/gtest.h" + +using namespace llvm; + +namespace { + +typedef SparseSet USet; + +// Empty set tests +TEST(SparseSetTest, EmptySet) { + USet Set; + EXPECT_TRUE(Set.empty()); + EXPECT_TRUE(Set.begin() == Set.end()); + EXPECT_EQ(0u, Set.size()); + + Set.setUniverse(10); + + // Lookups on empty set. + EXPECT_TRUE(Set.find(0) == Set.end()); + EXPECT_TRUE(Set.find(9) == Set.end()); + + // Same thing on a const reference. + const USet &CSet = Set; + EXPECT_TRUE(CSet.empty()); + EXPECT_TRUE(CSet.begin() == CSet.end()); + EXPECT_EQ(0u, CSet.size()); + EXPECT_TRUE(CSet.find(0) == CSet.end()); + USet::const_iterator I = CSet.find(5); + EXPECT_TRUE(I == CSet.end()); +} + +// Single entry set tests +TEST(SparseSetTest, SingleEntrySet) { + USet Set; + Set.setUniverse(10); + std::pair IP = Set.insert(5); + EXPECT_TRUE(IP.second); + EXPECT_TRUE(IP.first == Set.begin()); + + EXPECT_FALSE(Set.empty()); + EXPECT_FALSE(Set.begin() == Set.end()); + EXPECT_TRUE(Set.begin() + 1 == Set.end()); + EXPECT_EQ(1u, Set.size()); + + EXPECT_TRUE(Set.find(0) == Set.end()); + EXPECT_TRUE(Set.find(9) == Set.end()); + + EXPECT_FALSE(Set.count(0)); + EXPECT_TRUE(Set.count(5)); + + // Redundant insert. + IP = Set.insert(5); + EXPECT_FALSE(IP.second); + EXPECT_TRUE(IP.first == Set.begin()); + + // Erase non-existant element. + EXPECT_FALSE(Set.erase(1)); + EXPECT_EQ(1u, Set.size()); + EXPECT_EQ(5u, *Set.begin()); + + // Erase iterator. + USet::iterator I = Set.find(5); + EXPECT_TRUE(I == Set.begin()); + I = Set.erase(I); + EXPECT_TRUE(I == Set.end()); + EXPECT_TRUE(Set.empty()); +} + +// Multiple entry set tests +TEST(SparseSetTest, MultipleEntrySet) { + USet Set; + Set.setUniverse(10); + + Set.insert(5); + Set.insert(3); + Set.insert(2); + Set.insert(1); + Set.insert(4); + EXPECT_EQ(5u, Set.size()); + + // Without deletions, iteration order == insertion order. + USet::const_iterator I = Set.begin(); + EXPECT_EQ(5u, *I); + ++I; + EXPECT_EQ(3u, *I); + ++I; + EXPECT_EQ(2u, *I); + ++I; + EXPECT_EQ(1u, *I); + ++I; + EXPECT_EQ(4u, *I); + ++I; + EXPECT_TRUE(I == Set.end()); + + // Redundant insert. + std::pair IP = Set.insert(3); + EXPECT_FALSE(IP.second); + EXPECT_TRUE(IP.first == Set.begin() + 1); + + // Erase last element by key. + EXPECT_TRUE(Set.erase(4)); + EXPECT_EQ(4u, Set.size()); + EXPECT_FALSE(Set.count(4)); + EXPECT_FALSE(Set.erase(4)); + EXPECT_EQ(4u, Set.size()); + EXPECT_FALSE(Set.count(4)); + + // Erase first element by key. + EXPECT_TRUE(Set.count(5)); + EXPECT_TRUE(Set.find(5) == Set.begin()); + EXPECT_TRUE(Set.erase(5)); + EXPECT_EQ(3u, Set.size()); + EXPECT_FALSE(Set.count(5)); + EXPECT_FALSE(Set.erase(5)); + EXPECT_EQ(3u, Set.size()); + EXPECT_FALSE(Set.count(5)); + + Set.insert(6); + Set.insert(7); + EXPECT_EQ(5u, Set.size()); + + // Erase last element by iterator. + I = Set.erase(Set.end() - 1); + EXPECT_TRUE(I == Set.end()); + EXPECT_EQ(4u, Set.size()); + + // Erase second element by iterator. + I = Set.erase(Set.begin() + 1); + EXPECT_TRUE(I == Set.begin() + 1); + + // Clear and resize the universe. + Set.clear(); + EXPECT_FALSE(Set.count(5)); + Set.setUniverse(1000); + + // Add more than 256 elements. + for (unsigned i = 100; i != 800; ++i) + Set.insert(i); + + for (unsigned i = 0; i != 10; ++i) + Set.erase(i); + + for (unsigned i = 100; i != 800; ++i) + EXPECT_TRUE(Set.count(i)); + + EXPECT_FALSE(Set.count(99)); + EXPECT_FALSE(Set.count(800)); + EXPECT_EQ(700u, Set.size()); +} + +struct Alt { + unsigned Value; + explicit Alt(unsigned x) : Value(x) {} + unsigned getSparseSetKey() const { return Value - 1000; } +}; + +TEST(SparseSetTest, AltStructSet) { + typedef SparseSet ASet; + ASet Set; + Set.setUniverse(10); + Set.insert(Alt(1005)); + + ASet::iterator I = Set.find(5); + ASSERT_TRUE(I == Set.begin()); + EXPECT_EQ(1005u, I->Value); + + Set.insert(Alt(1006)); + Set.insert(Alt(1006)); + I = Set.erase(Set.begin()); + ASSERT_TRUE(I == Set.begin()); + EXPECT_EQ(1006u, I->Value); + + EXPECT_FALSE(Set.erase(5)); + EXPECT_TRUE(Set.erase(6)); +} +} // namespace Modified: llvm/trunk/unittests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CMakeLists.txt?rev=151110&r1=151109&r2=151110&view=diff ============================================================================== --- llvm/trunk/unittests/CMakeLists.txt (original) +++ llvm/trunk/unittests/CMakeLists.txt Tue Feb 21 18:56:08 2012 @@ -71,6 +71,7 @@ ADT/SmallStringTest.cpp ADT/SmallVectorTest.cpp ADT/SparseBitVectorTest.cpp + ADT/SparseSetTest.cpp ADT/StringMapTest.cpp ADT/StringRefTest.cpp ADT/TripleTest.cpp From stoklund at 2pi.dk Tue Feb 21 19:02:37 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 22 Feb 2012 01:02:37 -0000 Subject: [llvm-commits] [llvm] r151111 - /llvm/trunk/lib/CodeGen/RegAllocFast.cpp Message-ID: <20120222010237.A5D5F2A6C12F@llvm.org> Author: stoklund Date: Tue Feb 21 19:02:37 2012 New Revision: 151111 URL: http://llvm.org/viewvc/llvm-project?rev=151111&view=rev Log: Use SparseSet for the RAFast live virtual register map. This makes RAFast 4% faster, and it gets rid of the dodgy DenseMap iteration. This also revealed that RAFast would sometimes dereference DenseMap iterators after erasing other elements from the map. That does seem to work in the current DenseMap implementation, but SparseSet doesn't allow it. Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocFast.cpp?rev=151111&r1=151110&r2=151111&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocFast.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocFast.cpp Tue Feb 21 19:02:37 2012 @@ -32,6 +32,7 @@ #include "llvm/ADT/IndexedMap.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/SparseSet.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include @@ -68,16 +69,20 @@ // Everything we know about a live virtual register. struct LiveReg { MachineInstr *LastUse; // Last instr to use reg. + unsigned VirtReg; // Virtual register number. unsigned PhysReg; // Currently held here. unsigned short LastOpNum; // OpNum on LastUse. bool Dirty; // Register needs spill. - LiveReg(unsigned p=0) : LastUse(0), PhysReg(p), LastOpNum(0), - Dirty(false) {} + explicit LiveReg(unsigned v) + : LastUse(0), VirtReg(v), PhysReg(0), LastOpNum(0), Dirty(false) {} + + unsigned getSparseSetKey() const { + return TargetRegisterInfo::virtReg2Index(VirtReg); + } }; - typedef DenseMap LiveRegMap; - typedef LiveRegMap::value_type LiveRegEntry; + typedef SparseSet LiveRegMap; // LiveVirtRegs - This map contains entries for each virtual register // that is currently available in a physical register. @@ -154,8 +159,16 @@ void usePhysReg(MachineOperand&); void definePhysReg(MachineInstr *MI, unsigned PhysReg, RegState NewState); unsigned calcSpillCost(unsigned PhysReg) const; - void assignVirtToPhysReg(LiveRegEntry &LRE, unsigned PhysReg); - void allocVirtReg(MachineInstr *MI, LiveRegEntry &LRE, unsigned Hint); + void assignVirtToPhysReg(LiveReg&, unsigned PhysReg); + LiveRegMap::iterator findLiveVirtReg(unsigned VirtReg) { + return LiveVirtRegs.find(TargetRegisterInfo::virtReg2Index(VirtReg)); + } + LiveRegMap::const_iterator findLiveVirtReg(unsigned VirtReg) const { + return LiveVirtRegs.find(TargetRegisterInfo::virtReg2Index(VirtReg)); + } + LiveRegMap::iterator assignVirtToPhysReg(unsigned VReg, unsigned PhysReg); + LiveRegMap::iterator allocVirtReg(MachineInstr *MI, LiveRegMap::iterator, + unsigned Hint); LiveRegMap::iterator defineVirtReg(MachineInstr *MI, unsigned OpNum, unsigned VirtReg, unsigned Hint); LiveRegMap::iterator reloadVirtReg(MachineInstr *MI, unsigned OpNum, @@ -218,10 +231,9 @@ /// killVirtReg - Mark virtreg as no longer available. void RAFast::killVirtReg(LiveRegMap::iterator LRI) { - addKillFlag(LRI->second); - const LiveReg &LR = LRI->second; - assert(PhysRegState[LR.PhysReg] == LRI->first && "Broken RegState mapping"); - PhysRegState[LR.PhysReg] = regFree; + addKillFlag(*LRI); + assert(PhysRegState[LRI->PhysReg] == LRI->VirtReg && "Broken RegState mapping"); + PhysRegState[LRI->PhysReg] = regFree; // Erase from LiveVirtRegs unless we're spilling in bulk. if (!isBulkSpilling) LiveVirtRegs.erase(LRI); @@ -231,7 +243,7 @@ void RAFast::killVirtReg(unsigned VirtReg) { assert(TargetRegisterInfo::isVirtualRegister(VirtReg) && "killVirtReg needs a virtual register"); - LiveRegMap::iterator LRI = LiveVirtRegs.find(VirtReg); + LiveRegMap::iterator LRI = findLiveVirtReg(VirtReg); if (LRI != LiveVirtRegs.end()) killVirtReg(LRI); } @@ -241,7 +253,7 @@ void RAFast::spillVirtReg(MachineBasicBlock::iterator MI, unsigned VirtReg) { assert(TargetRegisterInfo::isVirtualRegister(VirtReg) && "Spilling a physical register is illegal!"); - LiveRegMap::iterator LRI = LiveVirtRegs.find(VirtReg); + LiveRegMap::iterator LRI = findLiveVirtReg(VirtReg); assert(LRI != LiveVirtRegs.end() && "Spilling unmapped virtual register"); spillVirtReg(MI, LRI); } @@ -249,18 +261,18 @@ /// spillVirtReg - Do the actual work of spilling. void RAFast::spillVirtReg(MachineBasicBlock::iterator MI, LiveRegMap::iterator LRI) { - LiveReg &LR = LRI->second; - assert(PhysRegState[LR.PhysReg] == LRI->first && "Broken RegState mapping"); + LiveReg &LR = *LRI; + assert(PhysRegState[LR.PhysReg] == LRI->VirtReg && "Broken RegState mapping"); if (LR.Dirty) { // If this physreg is used by the instruction, we want to kill it on the // instruction, not on the spill. bool SpillKill = LR.LastUse != MI; LR.Dirty = false; - DEBUG(dbgs() << "Spilling " << PrintReg(LRI->first, TRI) + DEBUG(dbgs() << "Spilling " << PrintReg(LRI->VirtReg, TRI) << " in " << PrintReg(LR.PhysReg, TRI)); - const TargetRegisterClass *RC = MRI->getRegClass(LRI->first); - int FI = getStackSpaceFor(LRI->first, RC); + const TargetRegisterClass *RC = MRI->getRegClass(LRI->VirtReg); + int FI = getStackSpaceFor(LRI->VirtReg, RC); DEBUG(dbgs() << " to stack slot #" << FI << "\n"); TII->storeRegToStackSlot(*MBB, MI, LR.PhysReg, SpillKill, FI, RC, TRI); ++NumStores; // Update statistics @@ -268,7 +280,8 @@ // If this register is used by DBG_VALUE then insert new DBG_VALUE to // identify spilled location as the place to find corresponding variable's // value. - SmallVector &LRIDbgValues = LiveDbgValueMap[LRI->first]; + SmallVector &LRIDbgValues = + LiveDbgValueMap[LRI->VirtReg]; for (unsigned li = 0, le = LRIDbgValues.size(); li != le; ++li) { MachineInstr *DBG = LRIDbgValues[li]; const MDNode *MDPtr = @@ -431,8 +444,11 @@ DEBUG(dbgs() << PrintReg(VirtReg, TRI) << " corresponding " << PrintReg(PhysReg, TRI) << " is reserved already.\n"); return spillImpossible; - default: - return LiveVirtRegs.lookup(VirtReg).Dirty ? spillDirty : spillClean; + default: { + LiveRegMap::const_iterator I = findLiveVirtReg(VirtReg); + assert(I != LiveVirtRegs.end() && "Missing VirtReg entry"); + return I->Dirty ? spillDirty : spillClean; + } } // This is a disabled register, add up cost of aliases. @@ -450,10 +466,13 @@ break; case regReserved: return spillImpossible; - default: - Cost += LiveVirtRegs.lookup(VirtReg).Dirty ? spillDirty : spillClean; + default: { + LiveRegMap::const_iterator I = findLiveVirtReg(VirtReg); + assert(I != LiveVirtRegs.end() && "Missing VirtReg entry"); + Cost += I->Dirty ? spillDirty : spillClean; break; } + } } return Cost; } @@ -463,17 +482,27 @@ /// that PhysReg is the proper container for VirtReg now. The physical /// register must not be used for anything else when this is called. /// -void RAFast::assignVirtToPhysReg(LiveRegEntry &LRE, unsigned PhysReg) { - DEBUG(dbgs() << "Assigning " << PrintReg(LRE.first, TRI) << " to " +void RAFast::assignVirtToPhysReg(LiveReg &LR, unsigned PhysReg) { + DEBUG(dbgs() << "Assigning " << PrintReg(LR.VirtReg, TRI) << " to " << PrintReg(PhysReg, TRI) << "\n"); - PhysRegState[PhysReg] = LRE.first; - assert(!LRE.second.PhysReg && "Already assigned a physreg"); - LRE.second.PhysReg = PhysReg; + PhysRegState[PhysReg] = LR.VirtReg; + assert(!LR.PhysReg && "Already assigned a physreg"); + LR.PhysReg = PhysReg; +} + +RAFast::LiveRegMap::iterator +RAFast::assignVirtToPhysReg(unsigned VirtReg, unsigned PhysReg) { + LiveRegMap::iterator LRI = findLiveVirtReg(VirtReg); + assert(LRI != LiveVirtRegs.end() && "VirtReg disappeared"); + assignVirtToPhysReg(*LRI, PhysReg); + return LRI; } /// allocVirtReg - Allocate a physical register for VirtReg. -void RAFast::allocVirtReg(MachineInstr *MI, LiveRegEntry &LRE, unsigned Hint) { - const unsigned VirtReg = LRE.first; +RAFast::LiveRegMap::iterator RAFast::allocVirtReg(MachineInstr *MI, + LiveRegMap::iterator LRI, + unsigned Hint) { + const unsigned VirtReg = LRI->VirtReg; assert(TargetRegisterInfo::isVirtualRegister(VirtReg) && "Can only allocate virtual registers"); @@ -492,7 +521,9 @@ if (Cost < spillDirty) { if (Cost) definePhysReg(MI, Hint, regFree); - return assignVirtToPhysReg(LRE, Hint); + // definePhysReg may kill virtual registers and modify LiveVirtRegs. + // That invalidates LRI, so run a new lookup for VirtReg. + return assignVirtToPhysReg(VirtReg, Hint); } } @@ -501,8 +532,10 @@ // First try to find a completely free register. for (ArrayRef::iterator I = AO.begin(), E = AO.end(); I != E; ++I) { unsigned PhysReg = *I; - if (PhysRegState[PhysReg] == regFree && !UsedInInstr.test(PhysReg)) - return assignVirtToPhysReg(LRE, PhysReg); + if (PhysRegState[PhysReg] == regFree && !UsedInInstr.test(PhysReg)) { + assignVirtToPhysReg(*LRI, PhysReg); + return LRI; + } } DEBUG(dbgs() << "Allocating " << PrintReg(VirtReg) << " from " @@ -515,21 +548,25 @@ DEBUG(dbgs() << "\tCost: " << Cost << "\n"); DEBUG(dbgs() << "\tBestCost: " << BestCost << "\n"); // Cost is 0 when all aliases are already disabled. - if (Cost == 0) - return assignVirtToPhysReg(LRE, *I); + if (Cost == 0) { + assignVirtToPhysReg(*LRI, *I); + return LRI; + } if (Cost < BestCost) BestReg = *I, BestCost = Cost; } if (BestReg) { definePhysReg(MI, BestReg, regFree); - return assignVirtToPhysReg(LRE, BestReg); + // definePhysReg may kill virtual registers and modify LiveVirtRegs. + // That invalidates LRI, so run a new lookup for VirtReg. + return assignVirtToPhysReg(VirtReg, BestReg); } // Nothing we can do. Report an error and keep going with a bad allocation. MI->emitError("ran out of registers during register allocation"); definePhysReg(MI, *AO.begin(), regFree); - assignVirtToPhysReg(LRE, *AO.begin()); + return assignVirtToPhysReg(VirtReg, *AO.begin()); } /// defineVirtReg - Allocate a register for VirtReg and mark it as dirty. @@ -540,8 +577,7 @@ "Not a virtual register"); LiveRegMap::iterator LRI; bool New; - tie(LRI, New) = LiveVirtRegs.insert(std::make_pair(VirtReg, LiveReg())); - LiveReg &LR = LRI->second; + tie(LRI, New) = LiveVirtRegs.insert(LiveReg(VirtReg)); if (New) { // If there is no hint, peek at the only use of this register. if ((!Hint || !TargetRegisterInfo::isPhysicalRegister(Hint)) && @@ -551,18 +587,18 @@ if (UseMI.isCopyLike()) Hint = UseMI.getOperand(0).getReg(); } - allocVirtReg(MI, *LRI, Hint); - } else if (LR.LastUse) { + LRI = allocVirtReg(MI, LRI, Hint); + } else if (LRI->LastUse) { // Redefining a live register - kill at the last use, unless it is this // instruction defining VirtReg multiple times. - if (LR.LastUse != MI || LR.LastUse->getOperand(LR.LastOpNum).isUse()) - addKillFlag(LR); + if (LRI->LastUse != MI || LRI->LastUse->getOperand(LRI->LastOpNum).isUse()) + addKillFlag(*LRI); } - assert(LR.PhysReg && "Register not assigned"); - LR.LastUse = MI; - LR.LastOpNum = OpNum; - LR.Dirty = true; - UsedInInstr.set(LR.PhysReg); + assert(LRI->PhysReg && "Register not assigned"); + LRI->LastUse = MI; + LRI->LastOpNum = OpNum; + LRI->Dirty = true; + UsedInInstr.set(LRI->PhysReg); return LRI; } @@ -574,18 +610,17 @@ "Not a virtual register"); LiveRegMap::iterator LRI; bool New; - tie(LRI, New) = LiveVirtRegs.insert(std::make_pair(VirtReg, LiveReg())); - LiveReg &LR = LRI->second; + tie(LRI, New) = LiveVirtRegs.insert(LiveReg(VirtReg)); MachineOperand &MO = MI->getOperand(OpNum); if (New) { - allocVirtReg(MI, *LRI, Hint); + LRI = allocVirtReg(MI, LRI, Hint); const TargetRegisterClass *RC = MRI->getRegClass(VirtReg); int FrameIndex = getStackSpaceFor(VirtReg, RC); DEBUG(dbgs() << "Reloading " << PrintReg(VirtReg, TRI) << " into " - << PrintReg(LR.PhysReg, TRI) << "\n"); - TII->loadRegFromStackSlot(*MBB, MI, LR.PhysReg, FrameIndex, RC, TRI); + << PrintReg(LRI->PhysReg, TRI) << "\n"); + TII->loadRegFromStackSlot(*MBB, MI, LRI->PhysReg, FrameIndex, RC, TRI); ++NumLoads; - } else if (LR.Dirty) { + } else if (LRI->Dirty) { if (isLastUseOfLocalReg(MO)) { DEBUG(dbgs() << "Killing last use: " << MO << "\n"); if (MO.isUse()) @@ -610,10 +645,10 @@ DEBUG(dbgs() << "Clearing clean dead: " << MO << "\n"); MO.setIsDead(false); } - assert(LR.PhysReg && "Register not assigned"); - LR.LastUse = MI; - LR.LastOpNum = OpNum; - UsedInInstr.set(LR.PhysReg); + assert(LRI->PhysReg && "Register not assigned"); + LRI->LastUse = MI; + LRI->LastOpNum = OpNum; + UsedInInstr.set(LRI->PhysReg); return LRI; } @@ -690,7 +725,7 @@ DEBUG(dbgs() << "Operand " << i << "("<< MO << ") is tied to operand " << DefIdx << ".\n"); LiveRegMap::iterator LRI = reloadVirtReg(MI, i, Reg, 0); - unsigned PhysReg = LRI->second.PhysReg; + unsigned PhysReg = LRI->PhysReg; setPhysReg(MI, i, PhysReg); // Note: we don't update the def operand yet. That would cause the normal // def-scan to attempt spilling. @@ -699,7 +734,7 @@ // Reload the register, but don't assign to the operand just yet. // That would confuse the later phys-def processing pass. LiveRegMap::iterator LRI = reloadVirtReg(MI, i, Reg, 0); - PartialDefs.push_back(LRI->second.PhysReg); + PartialDefs.push_back(LRI->PhysReg); } } @@ -713,7 +748,7 @@ continue; // Note: defineVirtReg may invalidate MO. LiveRegMap::iterator LRI = defineVirtReg(MI, i, Reg, 0); - unsigned PhysReg = LRI->second.PhysReg; + unsigned PhysReg = LRI->PhysReg; if (setPhysReg(MI, i, PhysReg)) VirtDead.push_back(Reg); } @@ -794,7 +829,7 @@ DEBUG(dbgs() << "\nAllocating " << *MBB); PhysRegState.assign(TRI->getNumRegs(), regDisabled); - assert(LiveVirtRegs.empty() && "Mapping not cleared form last block?"); + assert(LiveVirtRegs.empty() && "Mapping not cleared from last block?"); MachineBasicBlock::iterator MII = MBB->begin(); @@ -822,25 +857,26 @@ case regReserved: dbgs() << "*"; break; - default: + default: { dbgs() << '=' << PrintReg(PhysRegState[Reg]); - if (LiveVirtRegs[PhysRegState[Reg]].Dirty) + LiveRegMap::iterator I = findLiveVirtReg(PhysRegState[Reg]); + assert(I != LiveVirtRegs.end() && "Missing VirtReg entry"); + if (I->Dirty) dbgs() << "*"; - assert(LiveVirtRegs[PhysRegState[Reg]].PhysReg == Reg && - "Bad inverse map"); + assert(I->PhysReg == Reg && "Bad inverse map"); break; } + } } dbgs() << '\n'; // Check that LiveVirtRegs is the inverse. for (LiveRegMap::iterator i = LiveVirtRegs.begin(), e = LiveVirtRegs.end(); i != e; ++i) { - assert(TargetRegisterInfo::isVirtualRegister(i->first) && + assert(TargetRegisterInfo::isVirtualRegister(i->VirtReg) && "Bad map key"); - assert(TargetRegisterInfo::isPhysicalRegister(i->second.PhysReg) && + assert(TargetRegisterInfo::isPhysicalRegister(i->PhysReg) && "Bad map value"); - assert(PhysRegState[i->second.PhysReg] == i->first && - "Bad inverse map"); + assert(PhysRegState[i->PhysReg] == i->VirtReg && "Bad inverse map"); } }); @@ -854,9 +890,9 @@ if (!MO.isReg()) continue; unsigned Reg = MO.getReg(); if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue; - LiveRegMap::iterator LRI = LiveVirtRegs.find(Reg); + LiveRegMap::iterator LRI = findLiveVirtReg(Reg); if (LRI != LiveVirtRegs.end()) - setPhysReg(MI, i, LRI->second.PhysReg); + setPhysReg(MI, i, LRI->PhysReg); else { int SS = StackSlotForVirtReg[Reg]; if (SS == -1) { @@ -971,7 +1007,7 @@ if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue; if (MO.isUse()) { LiveRegMap::iterator LRI = reloadVirtReg(MI, i, Reg, CopyDst); - unsigned PhysReg = LRI->second.PhysReg; + unsigned PhysReg = LRI->PhysReg; CopySrc = (CopySrc == Reg || CopySrc == PhysReg) ? PhysReg : 0; if (setPhysReg(MI, i, PhysReg)) killVirtReg(LRI); @@ -1027,7 +1063,7 @@ continue; } LiveRegMap::iterator LRI = defineVirtReg(MI, i, Reg, CopySrc); - unsigned PhysReg = LRI->second.PhysReg; + unsigned PhysReg = LRI->PhysReg; if (setPhysReg(MI, i, PhysReg)) { VirtDead.push_back(Reg); CopyDst = 0; // cancel coalescing; @@ -1089,6 +1125,7 @@ // initialize the virtual->physical register map to have a 'null' // mapping for all virtual registers StackSlotForVirtReg.resize(MRI->getNumVirtRegs()); + LiveVirtRegs.setUniverse(MRI->getNumVirtRegs()); // Loop over all of the basic blocks, eliminating virtual register references for (MachineFunction::iterator MBBi = Fn.begin(), MBBe = Fn.end(); From stoklund at 2pi.dk Tue Feb 21 19:07:19 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 22 Feb 2012 01:07:19 -0000 Subject: [llvm-commits] [llvm] r151113 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Message-ID: <20120222010719.A2F292A6C12F@llvm.org> Author: stoklund Date: Tue Feb 21 19:07:19 2012 New Revision: 151113 URL: http://llvm.org/viewvc/llvm-project?rev=151113&view=rev Log: Clarify ARM calling conventions. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=151113&r1=151112&r2=151113&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Feb 21 19:07:19 2012 @@ -1401,6 +1401,8 @@ // stack slot reference to depend on the instruction that does the // modification. // Calls don't actually change the stack pointer, even if they have imp-defs. + // No ARM calling conventions change the stack pointer. (X86 calling + // conventions sometimes do). if (!MI->isCall() && MI->definesRegister(ARM::SP)) return true; From stoklund at 2pi.dk Tue Feb 21 19:12:32 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 21 Feb 2012 17:12:32 -0800 Subject: [llvm-commits] [llvm] r151104 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp In-Reply-To: References: <20120221234744.390302A6C12F@llvm.org> Message-ID: On Feb 21, 2012, at 4:29 PM, Eli Friedman wrote: > On Tue, Feb 21, 2012 at 4:04 PM, Jakob Stoklund Olesen wrote: >> >> On Feb 21, 2012, at 4:01 PM, Eli Friedman wrote: >> >>> On Tue, Feb 21, 2012 at 3:47 PM, Jakob Stoklund Olesen wrote: >>>> Author: stoklund >>>> Date: Tue Feb 21 17:47:43 2012 >>>> New Revision: 151104 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=151104&view=rev >>>> Log: >>>> Calls don't really change the stack pointer. >>> >>> Doesn't that depend on the calling convention? >> >> Yes, at least on x86. >> >>> Granted, I think it >>> holds for all the calling conventions I know of on ARM, but it >>> certainly isn't true in general. >> >> AFAIK, no ARM calling conventions change the stack pointer. > > Mind changing the comment to say that? Nope. r151113. /jakob From mcrosier at apple.com Tue Feb 21 19:18:58 2012 From: mcrosier at apple.com (Chad Rosier) Date: Tue, 21 Feb 2012 17:18:58 -0800 Subject: [llvm-commits] [llvm] r151111 - /llvm/trunk/lib/CodeGen/RegAllocFast.cpp In-Reply-To: <20120222010237.A5D5F2A6C12F@llvm.org> References: <20120222010237.A5D5F2A6C12F@llvm.org> Message-ID: On Feb 21, 2012, at 5:02 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Tue Feb 21 19:02:37 2012 > New Revision: 151111 > > URL: http://llvm.org/viewvc/llvm-project?rev=151111&view=rev > Log: > Use SparseSet for the RAFast live virtual register map. > > This makes RAFast 4% faster, and it gets rid of the dodgy DenseMap > iteration. Very nice!! What exactly were you testing to get the 4% estimate? Chad > This also revealed that RAFast would sometimes dereference DenseMap > iterators after erasing other elements from the map. That does seem to > work in the current DenseMap implementation, but SparseSet doesn't allow > it. > > Modified: > llvm/trunk/lib/CodeGen/RegAllocFast.cpp > > Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocFast.cpp?rev=151111&r1=151110&r2=151111&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/RegAllocFast.cpp (original) > +++ llvm/trunk/lib/CodeGen/RegAllocFast.cpp Tue Feb 21 19:02:37 2012 > @@ -32,6 +32,7 @@ > #include "llvm/ADT/IndexedMap.h" > #include "llvm/ADT/SmallSet.h" > #include "llvm/ADT/SmallVector.h" > +#include "llvm/ADT/SparseSet.h" > #include "llvm/ADT/Statistic.h" > #include "llvm/ADT/STLExtras.h" > #include > @@ -68,16 +69,20 @@ > // Everything we know about a live virtual register. > struct LiveReg { > MachineInstr *LastUse; // Last instr to use reg. > + unsigned VirtReg; // Virtual register number. > unsigned PhysReg; // Currently held here. > unsigned short LastOpNum; // OpNum on LastUse. > bool Dirty; // Register needs spill. > > - LiveReg(unsigned p=0) : LastUse(0), PhysReg(p), LastOpNum(0), > - Dirty(false) {} > + explicit LiveReg(unsigned v) > + : LastUse(0), VirtReg(v), PhysReg(0), LastOpNum(0), Dirty(false) {} > + > + unsigned getSparseSetKey() const { > + return TargetRegisterInfo::virtReg2Index(VirtReg); > + } > }; > > - typedef DenseMap LiveRegMap; > - typedef LiveRegMap::value_type LiveRegEntry; > + typedef SparseSet LiveRegMap; > > // LiveVirtRegs - This map contains entries for each virtual register > // that is currently available in a physical register. > @@ -154,8 +159,16 @@ > void usePhysReg(MachineOperand&); > void definePhysReg(MachineInstr *MI, unsigned PhysReg, RegState NewState); > unsigned calcSpillCost(unsigned PhysReg) const; > - void assignVirtToPhysReg(LiveRegEntry &LRE, unsigned PhysReg); > - void allocVirtReg(MachineInstr *MI, LiveRegEntry &LRE, unsigned Hint); > + void assignVirtToPhysReg(LiveReg&, unsigned PhysReg); > + LiveRegMap::iterator findLiveVirtReg(unsigned VirtReg) { > + return LiveVirtRegs.find(TargetRegisterInfo::virtReg2Index(VirtReg)); > + } > + LiveRegMap::const_iterator findLiveVirtReg(unsigned VirtReg) const { > + return LiveVirtRegs.find(TargetRegisterInfo::virtReg2Index(VirtReg)); > + } > + LiveRegMap::iterator assignVirtToPhysReg(unsigned VReg, unsigned PhysReg); > + LiveRegMap::iterator allocVirtReg(MachineInstr *MI, LiveRegMap::iterator, > + unsigned Hint); > LiveRegMap::iterator defineVirtReg(MachineInstr *MI, unsigned OpNum, > unsigned VirtReg, unsigned Hint); > LiveRegMap::iterator reloadVirtReg(MachineInstr *MI, unsigned OpNum, > @@ -218,10 +231,9 @@ > > /// killVirtReg - Mark virtreg as no longer available. > void RAFast::killVirtReg(LiveRegMap::iterator LRI) { > - addKillFlag(LRI->second); > - const LiveReg &LR = LRI->second; > - assert(PhysRegState[LR.PhysReg] == LRI->first && "Broken RegState mapping"); > - PhysRegState[LR.PhysReg] = regFree; > + addKillFlag(*LRI); > + assert(PhysRegState[LRI->PhysReg] == LRI->VirtReg && "Broken RegState mapping"); > + PhysRegState[LRI->PhysReg] = regFree; > // Erase from LiveVirtRegs unless we're spilling in bulk. > if (!isBulkSpilling) > LiveVirtRegs.erase(LRI); > @@ -231,7 +243,7 @@ > void RAFast::killVirtReg(unsigned VirtReg) { > assert(TargetRegisterInfo::isVirtualRegister(VirtReg) && > "killVirtReg needs a virtual register"); > - LiveRegMap::iterator LRI = LiveVirtRegs.find(VirtReg); > + LiveRegMap::iterator LRI = findLiveVirtReg(VirtReg); > if (LRI != LiveVirtRegs.end()) > killVirtReg(LRI); > } > @@ -241,7 +253,7 @@ > void RAFast::spillVirtReg(MachineBasicBlock::iterator MI, unsigned VirtReg) { > assert(TargetRegisterInfo::isVirtualRegister(VirtReg) && > "Spilling a physical register is illegal!"); > - LiveRegMap::iterator LRI = LiveVirtRegs.find(VirtReg); > + LiveRegMap::iterator LRI = findLiveVirtReg(VirtReg); > assert(LRI != LiveVirtRegs.end() && "Spilling unmapped virtual register"); > spillVirtReg(MI, LRI); > } > @@ -249,18 +261,18 @@ > /// spillVirtReg - Do the actual work of spilling. > void RAFast::spillVirtReg(MachineBasicBlock::iterator MI, > LiveRegMap::iterator LRI) { > - LiveReg &LR = LRI->second; > - assert(PhysRegState[LR.PhysReg] == LRI->first && "Broken RegState mapping"); > + LiveReg &LR = *LRI; > + assert(PhysRegState[LR.PhysReg] == LRI->VirtReg && "Broken RegState mapping"); > > if (LR.Dirty) { > // If this physreg is used by the instruction, we want to kill it on the > // instruction, not on the spill. > bool SpillKill = LR.LastUse != MI; > LR.Dirty = false; > - DEBUG(dbgs() << "Spilling " << PrintReg(LRI->first, TRI) > + DEBUG(dbgs() << "Spilling " << PrintReg(LRI->VirtReg, TRI) > << " in " << PrintReg(LR.PhysReg, TRI)); > - const TargetRegisterClass *RC = MRI->getRegClass(LRI->first); > - int FI = getStackSpaceFor(LRI->first, RC); > + const TargetRegisterClass *RC = MRI->getRegClass(LRI->VirtReg); > + int FI = getStackSpaceFor(LRI->VirtReg, RC); > DEBUG(dbgs() << " to stack slot #" << FI << "\n"); > TII->storeRegToStackSlot(*MBB, MI, LR.PhysReg, SpillKill, FI, RC, TRI); > ++NumStores; // Update statistics > @@ -268,7 +280,8 @@ > // If this register is used by DBG_VALUE then insert new DBG_VALUE to > // identify spilled location as the place to find corresponding variable's > // value. > - SmallVector &LRIDbgValues = LiveDbgValueMap[LRI->first]; > + SmallVector &LRIDbgValues = > + LiveDbgValueMap[LRI->VirtReg]; > for (unsigned li = 0, le = LRIDbgValues.size(); li != le; ++li) { > MachineInstr *DBG = LRIDbgValues[li]; > const MDNode *MDPtr = > @@ -431,8 +444,11 @@ > DEBUG(dbgs() << PrintReg(VirtReg, TRI) << " corresponding " > << PrintReg(PhysReg, TRI) << " is reserved already.\n"); > return spillImpossible; > - default: > - return LiveVirtRegs.lookup(VirtReg).Dirty ? spillDirty : spillClean; > + default: { > + LiveRegMap::const_iterator I = findLiveVirtReg(VirtReg); > + assert(I != LiveVirtRegs.end() && "Missing VirtReg entry"); > + return I->Dirty ? spillDirty : spillClean; > + } > } > > // This is a disabled register, add up cost of aliases. > @@ -450,10 +466,13 @@ > break; > case regReserved: > return spillImpossible; > - default: > - Cost += LiveVirtRegs.lookup(VirtReg).Dirty ? spillDirty : spillClean; > + default: { > + LiveRegMap::const_iterator I = findLiveVirtReg(VirtReg); > + assert(I != LiveVirtRegs.end() && "Missing VirtReg entry"); > + Cost += I->Dirty ? spillDirty : spillClean; > break; > } > + } > } > return Cost; > } > @@ -463,17 +482,27 @@ > /// that PhysReg is the proper container for VirtReg now. The physical > /// register must not be used for anything else when this is called. > /// > -void RAFast::assignVirtToPhysReg(LiveRegEntry &LRE, unsigned PhysReg) { > - DEBUG(dbgs() << "Assigning " << PrintReg(LRE.first, TRI) << " to " > +void RAFast::assignVirtToPhysReg(LiveReg &LR, unsigned PhysReg) { > + DEBUG(dbgs() << "Assigning " << PrintReg(LR.VirtReg, TRI) << " to " > << PrintReg(PhysReg, TRI) << "\n"); > - PhysRegState[PhysReg] = LRE.first; > - assert(!LRE.second.PhysReg && "Already assigned a physreg"); > - LRE.second.PhysReg = PhysReg; > + PhysRegState[PhysReg] = LR.VirtReg; > + assert(!LR.PhysReg && "Already assigned a physreg"); > + LR.PhysReg = PhysReg; > +} > + > +RAFast::LiveRegMap::iterator > +RAFast::assignVirtToPhysReg(unsigned VirtReg, unsigned PhysReg) { > + LiveRegMap::iterator LRI = findLiveVirtReg(VirtReg); > + assert(LRI != LiveVirtRegs.end() && "VirtReg disappeared"); > + assignVirtToPhysReg(*LRI, PhysReg); > + return LRI; > } > > /// allocVirtReg - Allocate a physical register for VirtReg. > -void RAFast::allocVirtReg(MachineInstr *MI, LiveRegEntry &LRE, unsigned Hint) { > - const unsigned VirtReg = LRE.first; > +RAFast::LiveRegMap::iterator RAFast::allocVirtReg(MachineInstr *MI, > + LiveRegMap::iterator LRI, > + unsigned Hint) { > + const unsigned VirtReg = LRI->VirtReg; > > assert(TargetRegisterInfo::isVirtualRegister(VirtReg) && > "Can only allocate virtual registers"); > @@ -492,7 +521,9 @@ > if (Cost < spillDirty) { > if (Cost) > definePhysReg(MI, Hint, regFree); > - return assignVirtToPhysReg(LRE, Hint); > + // definePhysReg may kill virtual registers and modify LiveVirtRegs. > + // That invalidates LRI, so run a new lookup for VirtReg. > + return assignVirtToPhysReg(VirtReg, Hint); > } > } > > @@ -501,8 +532,10 @@ > // First try to find a completely free register. > for (ArrayRef::iterator I = AO.begin(), E = AO.end(); I != E; ++I) { > unsigned PhysReg = *I; > - if (PhysRegState[PhysReg] == regFree && !UsedInInstr.test(PhysReg)) > - return assignVirtToPhysReg(LRE, PhysReg); > + if (PhysRegState[PhysReg] == regFree && !UsedInInstr.test(PhysReg)) { > + assignVirtToPhysReg(*LRI, PhysReg); > + return LRI; > + } > } > > DEBUG(dbgs() << "Allocating " << PrintReg(VirtReg) << " from " > @@ -515,21 +548,25 @@ > DEBUG(dbgs() << "\tCost: " << Cost << "\n"); > DEBUG(dbgs() << "\tBestCost: " << BestCost << "\n"); > // Cost is 0 when all aliases are already disabled. > - if (Cost == 0) > - return assignVirtToPhysReg(LRE, *I); > + if (Cost == 0) { > + assignVirtToPhysReg(*LRI, *I); > + return LRI; > + } > if (Cost < BestCost) > BestReg = *I, BestCost = Cost; > } > > if (BestReg) { > definePhysReg(MI, BestReg, regFree); > - return assignVirtToPhysReg(LRE, BestReg); > + // definePhysReg may kill virtual registers and modify LiveVirtRegs. > + // That invalidates LRI, so run a new lookup for VirtReg. > + return assignVirtToPhysReg(VirtReg, BestReg); > } > > // Nothing we can do. Report an error and keep going with a bad allocation. > MI->emitError("ran out of registers during register allocation"); > definePhysReg(MI, *AO.begin(), regFree); > - assignVirtToPhysReg(LRE, *AO.begin()); > + return assignVirtToPhysReg(VirtReg, *AO.begin()); > } > > /// defineVirtReg - Allocate a register for VirtReg and mark it as dirty. > @@ -540,8 +577,7 @@ > "Not a virtual register"); > LiveRegMap::iterator LRI; > bool New; > - tie(LRI, New) = LiveVirtRegs.insert(std::make_pair(VirtReg, LiveReg())); > - LiveReg &LR = LRI->second; > + tie(LRI, New) = LiveVirtRegs.insert(LiveReg(VirtReg)); > if (New) { > // If there is no hint, peek at the only use of this register. > if ((!Hint || !TargetRegisterInfo::isPhysicalRegister(Hint)) && > @@ -551,18 +587,18 @@ > if (UseMI.isCopyLike()) > Hint = UseMI.getOperand(0).getReg(); > } > - allocVirtReg(MI, *LRI, Hint); > - } else if (LR.LastUse) { > + LRI = allocVirtReg(MI, LRI, Hint); > + } else if (LRI->LastUse) { > // Redefining a live register - kill at the last use, unless it is this > // instruction defining VirtReg multiple times. > - if (LR.LastUse != MI || LR.LastUse->getOperand(LR.LastOpNum).isUse()) > - addKillFlag(LR); > + if (LRI->LastUse != MI || LRI->LastUse->getOperand(LRI->LastOpNum).isUse()) > + addKillFlag(*LRI); > } > - assert(LR.PhysReg && "Register not assigned"); > - LR.LastUse = MI; > - LR.LastOpNum = OpNum; > - LR.Dirty = true; > - UsedInInstr.set(LR.PhysReg); > + assert(LRI->PhysReg && "Register not assigned"); > + LRI->LastUse = MI; > + LRI->LastOpNum = OpNum; > + LRI->Dirty = true; > + UsedInInstr.set(LRI->PhysReg); > return LRI; > } > > @@ -574,18 +610,17 @@ > "Not a virtual register"); > LiveRegMap::iterator LRI; > bool New; > - tie(LRI, New) = LiveVirtRegs.insert(std::make_pair(VirtReg, LiveReg())); > - LiveReg &LR = LRI->second; > + tie(LRI, New) = LiveVirtRegs.insert(LiveReg(VirtReg)); > MachineOperand &MO = MI->getOperand(OpNum); > if (New) { > - allocVirtReg(MI, *LRI, Hint); > + LRI = allocVirtReg(MI, LRI, Hint); > const TargetRegisterClass *RC = MRI->getRegClass(VirtReg); > int FrameIndex = getStackSpaceFor(VirtReg, RC); > DEBUG(dbgs() << "Reloading " << PrintReg(VirtReg, TRI) << " into " > - << PrintReg(LR.PhysReg, TRI) << "\n"); > - TII->loadRegFromStackSlot(*MBB, MI, LR.PhysReg, FrameIndex, RC, TRI); > + << PrintReg(LRI->PhysReg, TRI) << "\n"); > + TII->loadRegFromStackSlot(*MBB, MI, LRI->PhysReg, FrameIndex, RC, TRI); > ++NumLoads; > - } else if (LR.Dirty) { > + } else if (LRI->Dirty) { > if (isLastUseOfLocalReg(MO)) { > DEBUG(dbgs() << "Killing last use: " << MO << "\n"); > if (MO.isUse()) > @@ -610,10 +645,10 @@ > DEBUG(dbgs() << "Clearing clean dead: " << MO << "\n"); > MO.setIsDead(false); > } > - assert(LR.PhysReg && "Register not assigned"); > - LR.LastUse = MI; > - LR.LastOpNum = OpNum; > - UsedInInstr.set(LR.PhysReg); > + assert(LRI->PhysReg && "Register not assigned"); > + LRI->LastUse = MI; > + LRI->LastOpNum = OpNum; > + UsedInInstr.set(LRI->PhysReg); > return LRI; > } > > @@ -690,7 +725,7 @@ > DEBUG(dbgs() << "Operand " << i << "("<< MO << ") is tied to operand " > << DefIdx << ".\n"); > LiveRegMap::iterator LRI = reloadVirtReg(MI, i, Reg, 0); > - unsigned PhysReg = LRI->second.PhysReg; > + unsigned PhysReg = LRI->PhysReg; > setPhysReg(MI, i, PhysReg); > // Note: we don't update the def operand yet. That would cause the normal > // def-scan to attempt spilling. > @@ -699,7 +734,7 @@ > // Reload the register, but don't assign to the operand just yet. > // That would confuse the later phys-def processing pass. > LiveRegMap::iterator LRI = reloadVirtReg(MI, i, Reg, 0); > - PartialDefs.push_back(LRI->second.PhysReg); > + PartialDefs.push_back(LRI->PhysReg); > } > } > > @@ -713,7 +748,7 @@ > continue; > // Note: defineVirtReg may invalidate MO. > LiveRegMap::iterator LRI = defineVirtReg(MI, i, Reg, 0); > - unsigned PhysReg = LRI->second.PhysReg; > + unsigned PhysReg = LRI->PhysReg; > if (setPhysReg(MI, i, PhysReg)) > VirtDead.push_back(Reg); > } > @@ -794,7 +829,7 @@ > DEBUG(dbgs() << "\nAllocating " << *MBB); > > PhysRegState.assign(TRI->getNumRegs(), regDisabled); > - assert(LiveVirtRegs.empty() && "Mapping not cleared form last block?"); > + assert(LiveVirtRegs.empty() && "Mapping not cleared from last block?"); > > MachineBasicBlock::iterator MII = MBB->begin(); > > @@ -822,25 +857,26 @@ > case regReserved: > dbgs() << "*"; > break; > - default: > + default: { > dbgs() << '=' << PrintReg(PhysRegState[Reg]); > - if (LiveVirtRegs[PhysRegState[Reg]].Dirty) > + LiveRegMap::iterator I = findLiveVirtReg(PhysRegState[Reg]); > + assert(I != LiveVirtRegs.end() && "Missing VirtReg entry"); > + if (I->Dirty) > dbgs() << "*"; > - assert(LiveVirtRegs[PhysRegState[Reg]].PhysReg == Reg && > - "Bad inverse map"); > + assert(I->PhysReg == Reg && "Bad inverse map"); > break; > } > + } > } > dbgs() << '\n'; > // Check that LiveVirtRegs is the inverse. > for (LiveRegMap::iterator i = LiveVirtRegs.begin(), > e = LiveVirtRegs.end(); i != e; ++i) { > - assert(TargetRegisterInfo::isVirtualRegister(i->first) && > + assert(TargetRegisterInfo::isVirtualRegister(i->VirtReg) && > "Bad map key"); > - assert(TargetRegisterInfo::isPhysicalRegister(i->second.PhysReg) && > + assert(TargetRegisterInfo::isPhysicalRegister(i->PhysReg) && > "Bad map value"); > - assert(PhysRegState[i->second.PhysReg] == i->first && > - "Bad inverse map"); > + assert(PhysRegState[i->PhysReg] == i->VirtReg && "Bad inverse map"); > } > }); > > @@ -854,9 +890,9 @@ > if (!MO.isReg()) continue; > unsigned Reg = MO.getReg(); > if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue; > - LiveRegMap::iterator LRI = LiveVirtRegs.find(Reg); > + LiveRegMap::iterator LRI = findLiveVirtReg(Reg); > if (LRI != LiveVirtRegs.end()) > - setPhysReg(MI, i, LRI->second.PhysReg); > + setPhysReg(MI, i, LRI->PhysReg); > else { > int SS = StackSlotForVirtReg[Reg]; > if (SS == -1) { > @@ -971,7 +1007,7 @@ > if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue; > if (MO.isUse()) { > LiveRegMap::iterator LRI = reloadVirtReg(MI, i, Reg, CopyDst); > - unsigned PhysReg = LRI->second.PhysReg; > + unsigned PhysReg = LRI->PhysReg; > CopySrc = (CopySrc == Reg || CopySrc == PhysReg) ? PhysReg : 0; > if (setPhysReg(MI, i, PhysReg)) > killVirtReg(LRI); > @@ -1027,7 +1063,7 @@ > continue; > } > LiveRegMap::iterator LRI = defineVirtReg(MI, i, Reg, CopySrc); > - unsigned PhysReg = LRI->second.PhysReg; > + unsigned PhysReg = LRI->PhysReg; > if (setPhysReg(MI, i, PhysReg)) { > VirtDead.push_back(Reg); > CopyDst = 0; // cancel coalescing; > @@ -1089,6 +1125,7 @@ > // initialize the virtual->physical register map to have a 'null' > // mapping for all virtual registers > StackSlotForVirtReg.resize(MRI->getNumVirtRegs()); > + LiveVirtRegs.setUniverse(MRI->getNumVirtRegs()); > > // Loop over all of the basic blocks, eliminating virtual register references > for (MachineFunction::iterator MBBi = Fn.begin(), MBBe = Fn.end(); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From geek4civic at gmail.com Tue Feb 21 19:19:35 2012 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Wed, 22 Feb 2012 01:19:35 -0000 Subject: [llvm-commits] [llvm] r151114 - /llvm/trunk/include/llvm/ADT/SparseSet.h Message-ID: <20120222011935.3EAA92A6C12F@llvm.org> Author: chapuni Date: Tue Feb 21 19:19:35 2012 New Revision: 151114 URL: http://llvm.org/viewvc/llvm-project?rev=151114&view=rev Log: ADT/SparseSet.h: Fix up header dependencies. Modified: llvm/trunk/include/llvm/ADT/SparseSet.h Modified: llvm/trunk/include/llvm/ADT/SparseSet.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SparseSet.h?rev=151114&r1=151113&r2=151114&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/SparseSet.h (original) +++ llvm/trunk/include/llvm/ADT/SparseSet.h Tue Feb 21 19:19:35 2012 @@ -21,6 +21,8 @@ #define LLVM_ADT_SPARSESET_H #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/DataTypes.h" +#include namespace llvm { From stoklund at 2pi.dk Tue Feb 21 19:38:03 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 21 Feb 2012 17:38:03 -0800 Subject: [llvm-commits] [llvm] r151111 - /llvm/trunk/lib/CodeGen/RegAllocFast.cpp In-Reply-To: References: <20120222010237.A5D5F2A6C12F@llvm.org> Message-ID: <4361459C-8F6A-49D3-88D8-DDCB5FAA2EB5@2pi.dk> On Feb 21, 2012, at 5:18 PM, Chad Rosier wrote: > > On Feb 21, 2012, at 5:02 PM, Jakob Stoklund Olesen wrote: > >> Author: stoklund >> Date: Tue Feb 21 19:02:37 2012 >> New Revision: 151111 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=151111&view=rev >> Log: >> Use SparseSet for the RAFast live virtual register map. >> >> This makes RAFast 4% faster, and it gets rid of the dodgy DenseMap >> iteration. > > Very nice!! What exactly were you testing to get the 4% estimate? I have a -O0 bitcode file for 464.h264ref / armv7. I ran llc -time-passes and checked the user time for the fast allocator. Note that RAFast is only 7% of codegen time at -O0, so the overall impact on clang -O0 is probably in the noise. /jakob From mcrosier at apple.com Tue Feb 21 19:44:27 2012 From: mcrosier at apple.com (Chad Rosier) Date: Tue, 21 Feb 2012 17:44:27 -0800 Subject: [llvm-commits] [llvm] r151111 - /llvm/trunk/lib/CodeGen/RegAllocFast.cpp In-Reply-To: <4361459C-8F6A-49D3-88D8-DDCB5FAA2EB5@2pi.dk> References: <20120222010237.A5D5F2A6C12F@llvm.org> <4361459C-8F6A-49D3-88D8-DDCB5FAA2EB5@2pi.dk> Message-ID: On Feb 21, 2012, at 5:38 PM, Jakob Stoklund Olesen wrote: > > On Feb 21, 2012, at 5:18 PM, Chad Rosier wrote: > >> >> On Feb 21, 2012, at 5:02 PM, Jakob Stoklund Olesen wrote: >> >>> Author: stoklund >>> Date: Tue Feb 21 19:02:37 2012 >>> New Revision: 151111 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=151111&view=rev >>> Log: >>> Use SparseSet for the RAFast live virtual register map. >>> >>> This makes RAFast 4% faster, and it gets rid of the dodgy DenseMap >>> iteration. >> >> Very nice!! What exactly were you testing to get the 4% estimate? > > I have a -O0 bitcode file for 464.h264ref / armv7. I ran llc -time-passes and checked the user time for the fast allocator. Ah, I was just wondering if this was a single test case or something larger like an aggregate number for the test-suite. > > Note that RAFast is only 7% of codegen time at -O0, so the overall impact on clang -O0 is probably in the noise. So you're telling me RAFast is fast. :) Every little bit counts! Thanks, Jakob. > > /jakob > From eli.friedman at gmail.com Tue Feb 21 19:45:14 2012 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 21 Feb 2012 17:45:14 -0800 Subject: [llvm-commits] [cfe-commits] [PATCH] Supporting thiscall compatibility with MSVC In-Reply-To: References: Message-ID: On Sat, Feb 18, 2012 at 9:36 AM, Aaron Ballman wrote: > On Fri, Feb 17, 2012 at 7:30 PM, Eli Friedman wrote: >> On Fri, Feb 17, 2012 at 3:41 PM, Aaron Ballman wrote: >>> On Thu, Feb 16, 2012 at 10:42 PM, Eli Friedman wrote: >>>> On Thu, Feb 16, 2012 at 8:39 PM, Aaron Ballman wrote: >>>>> On Thu, Feb 16, 2012 at 9:50 PM, Eli Friedman wrote: >>>>>> On Thu, Feb 16, 2012 at 7:38 PM, Aaron Ballman wrote: >>>>>>> On Thu, Feb 16, 2012 at 8:52 PM, Eli Friedman wrote: >>>>>>>> On Thu, Feb 16, 2012 at 6:25 PM, Aaron Ballman wrote: >>>>>>>>> Here's the next attempt at the MSVC thiscall support patch, this time >>>>>>>>> with test cases and an improved tablegen declaration. >>>>>>>>> >>>>>>>>> This is the first time I've done a test case for clang or llvm >>>>>>>>> codegen, so please pay special attention to the test cases and let me >>>>>>>>> know if I'm off-base (and what I should do differently). >>>>>>>> >>>>>>>> You might want to make the LLVM testcase a bit stronger by using CHECK-NEXT. >>>>>>> >>>>>>> Does CHECK-NEXT basically chain the checks together to check several >>>>>>> lines as a group? >>>>>> >>>>>> Basically, yes. >>>>> >>>>> The problem is that the assembly is different between O levels. ?So >>>>> -O0 does leal, leal, but -O1 does leal, movl. >>>>> >>>>> Is there a way for me to handle this in the test case, or should I >>>>> just be explicit about the O level and its behavior? >>>> >>>> We always run tests at the same -O level, so you shouldn't worry about >>>> that. ?That said, if you think splitting your testcase into multiple >>>> functions would make it more stable, please do that. >>> >>> Here's another shot at the patch -- this time, I am using the proper >>> way to test for the Win32 ABI, and I've updated the X86 codegen test >>> case so that it's a bit more clear. >> >> Your test somehow disappeared form the clang patch. >> >> Please rename IsWin32FloatStructABI if you're going to use it this >> way. ?I'm still not convinced it's necessary to behave differently >> when targeting MinGW, though. > > That was truly odd -- no idea how the test case got missed, but it's > back again. ?I've also removed the check for the Win32 ABI as it > appears this is used by gcc (4.6 and up) for MS compat as well. Both patches look good. -Eli From stoklund at 2pi.dk Tue Feb 21 19:46:59 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 21 Feb 2012 17:46:59 -0800 Subject: [llvm-commits] [llvm] r151111 - /llvm/trunk/lib/CodeGen/RegAllocFast.cpp In-Reply-To: References: <20120222010237.A5D5F2A6C12F@llvm.org> <4361459C-8F6A-49D3-88D8-DDCB5FAA2EB5@2pi.dk> Message-ID: <05A7B2BA-24E7-4CDF-9902-73A6A98A144D@2pi.dk> On Feb 21, 2012, at 5:44 PM, Chad Rosier wrote: > > On Feb 21, 2012, at 5:38 PM, Jakob Stoklund Olesen wrote: > >> >> On Feb 21, 2012, at 5:18 PM, Chad Rosier wrote: >> >>> >>> On Feb 21, 2012, at 5:02 PM, Jakob Stoklund Olesen wrote: >>> >>>> Author: stoklund >>>> Date: Tue Feb 21 19:02:37 2012 >>>> New Revision: 151111 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=151111&view=rev >>>> Log: >>>> Use SparseSet for the RAFast live virtual register map. >>>> >>>> This makes RAFast 4% faster, and it gets rid of the dodgy DenseMap >>>> iteration. >>> >>> Very nice!! What exactly were you testing to get the 4% estimate? >> >> I have a -O0 bitcode file for 464.h264ref / armv7. I ran llc -time-passes and checked the user time for the fast allocator. > > Ah, I was just wondering if this was a single test case or something larger like an aggregate number for the test-suite. I was lazy because I expect the improvement to be the same for all test cases. >> Note that RAFast is only 7% of codegen time at -O0, so the overall impact on clang -O0 is probably in the noise. > > So you're telling me RAFast is fast. :) Every little bit counts! If you make RAFast infinity faster, clang -O0 would be 2% faster. Diminishing returns? ;) /jakob From eli.friedman at gmail.com Tue Feb 21 19:43:48 2012 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 22 Feb 2012 01:43:48 -0000 Subject: [llvm-commits] [llvm] r151115 - /llvm/trunk/tools/bugpoint/ExtractFunction.cpp Message-ID: <20120222014348.0D54B2A6C12F@llvm.org> Author: efriedma Date: Tue Feb 21 19:43:47 2012 New Revision: 151115 URL: http://llvm.org/viewvc/llvm-project?rev=151115&view=rev Log: Improve handling of blockaddresses in bugpoint when splitting a module. Patch by Daniel Reynaud. Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=151115&r1=151114&r2=151115&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original) +++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Tue Feb 21 19:43:47 2012 @@ -47,7 +47,39 @@ cl::opt NoSCFG("disable-simplifycfg", cl::location(DisableSimplifyCFG), cl::desc("Do not use the -simplifycfg pass to reduce testcases")); -} + + Function* globalInitUsesExternalBA(GlobalVariable* GV) { + if (!GV->hasInitializer()) + return 0; + + Constant *I = GV->getInitializer(); + + // walk the values used by the initializer + // (and recurse into things like ConstantExpr) + std::vector Todo; + std::set Done; + Todo.push_back(I); + + while (!Todo.empty()) { + Constant* V = Todo.back(); + Todo.pop_back(); + Done.insert(V); + + if (BlockAddress *BA = dyn_cast(V)) { + Function *F = BA->getFunction(); + if (F->isDeclaration()) + return F; + } + + for (User::op_iterator i = V->op_begin(), e = V->op_end(); i != e; ++i) { + Constant *C = dyn_cast(*i); + if (C && !isa(C) && !Done.count(C)) + Todo.push_back(C); + } + } + return 0; + } +} // end anonymous namespace /// deleteInstructionFromProgram - This method clones the current Program and /// deletes the specified instruction from the cloned module. It then runs a @@ -272,11 +304,6 @@ ValueToValueMapTy NewVMap; Module *New = CloneModule(M, NewVMap); - // Make sure global initializers exist only in the safe module (CBE->.so) - for (Module::global_iterator I = New->global_begin(), E = New->global_end(); - I != E; ++I) - I->setInitializer(0); // Delete the initializer to make it external - // Remove the Test functions from the Safe module std::set TestFunctions; for (unsigned i = 0, e = F.size(); i != e; ++i) { @@ -295,6 +322,27 @@ DeleteFunctionBody(I); + // Try to split the global initializers evenly + for (Module::global_iterator I = M->global_begin(), E = M->global_end(); + I != E; ++I) { + GlobalVariable *GV = cast(NewVMap[I]); + if (Function *TestFn = globalInitUsesExternalBA(I)) { + if (Function *SafeFn = globalInitUsesExternalBA(GV)) { + errs() << "*** Error: when reducing functions, encountered " + "the global '"; + WriteAsOperand(errs(), GV, false); + errs() << "' with an initializer that references blockaddresses " + "from safe function '" << SafeFn->getName() + << "' and from test function '" << TestFn->getName() << "'.\n"; + exit(1); + } + I->setInitializer(0); // Delete the initializer to make it external + } else { + // If we keep it in the safe module, then delete it in the test module + GV->setInitializer(0); + } + } + // Make sure that there is a global ctor/dtor array in both halves of the // module if they both have static ctor/dtor functions. SplitStaticCtorDtor("llvm.global_ctors", M, New, NewVMap); From eli.friedman at gmail.com Tue Feb 21 19:48:28 2012 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 21 Feb 2012 17:48:28 -0800 Subject: [llvm-commits] Please review: make bugpoint aware of blockaddress constant in global initializers In-Reply-To: References: <14C08D85-E7F7-44DE-8260-706F4C9489D4@apple.com> Message-ID: On Wed, Feb 8, 2012 at 5:18 PM, Daniel Reynaud wrote: > > On Feb 8, 2012, at 3:05 PM, Eli Friedman wrote: > >> On Wed, Feb 8, 2012 at 2:56 PM, Daniel Reynaud wrote: >>> >>> On Feb 7, 2012, at 5:44 PM, Eli Friedman wrote: >>> >>>> On Tue, Feb 7, 2012 at 5:21 PM, Daniel Reynaud wrote: >>>>> Even better with the actual patch. >>>>> >>>>> >>>>> >>>>> On Feb 7, 2012, at 5:20 PM, Daniel Reynaud wrote: >>>>> >>>>> This is a patch for http://llvm.org/bugs/show_bug.cgi?id=11919 >>>>> >>>>> It seems to do the trick for me. When this particular configuration (a >>>>> global initializer references a blockaddress from a function that has been >>>>> sent to a different module) is not encountered, it should produce the same >>>>> initializer pattern as usual (i.e., everything in the safe module). >>>>> >>>>> thanks, >>>>> daniel >>>> >>>> + ?bool globalInitUsesExternalBA(GlobalVariable* GV) { >>>> + ? ? ?if (!GV->hasInitializer()) >>>> + ? ? ? ? ?return false; >>>> + >>>> + ? ? ?Constant *I = GV->getInitializer(); >>>> + >>>> + ? ? ?// walk the values used by the initializer >>>> + ? ? ?// (and recurse into things like ConstantExpr) >>>> + ? ? ?std::vector Worklist; >>>> + ? ? ?Worklist.push_back(I); >>>> + ? ? ?while(!Worklist.empty()) { >>>> + ? ? ? ?Constant* V = Worklist.back(); >>>> + ? ? ? ?Worklist.pop_back(); >>>> + >>>> + ? ? ? ?if (BlockAddress *BA = dyn_cast(V)) { >>>> + ? ? ? ? ?Function *F = BA->getFunction(); >>>> + ? ? ? ? ?if (F->isDeclaration()) >>>> + ? ? ? ? ? ?return true; >>>> + ? ? ? ?} >>>> + >>>> + ? ? ? ?for (User::op_iterator i = V->op_begin(), e = V->op_end(); i != e; ++i) >>>> + ? ? ? ? ?if (Constant *C = dyn_cast(*i)) >>>> + ? ? ? ? ? ?Worklist.push_back(C); >>>> + ? ? ?} >>>> + >>>> + ? ?return false; >>>> + ?} >>>> >>>> You need to make sure not to recurse into GlobalValues. >>> >>> ok >>> >>>> ?You also >>>> probably want a hashtable so you don't run into bad performance >>>> characteristics with ConstantExprs. >>> >>> ok. I tried putting various things in the cache (everything, nothing, just ConstantExpr), and it did not have any noticeable impact on my test case (76s to reduce 459 functions). >> >> I'm not really worried about the performance of normal cases; the >> issue is that there are some pathological cases which can cause the >> naive approach to to take exponential time. >> >>>> >>>> Also, weird indentation. >>>> >>>> >>>> + ?// Try to split the global initializers evenly >>>> + ?for (Module::global_iterator I = M->global_begin(), E = M->global_end(); >>>> + ? ? ? I != E; ++I) { >>>> + ? ?GlobalVariable *GV = cast(NewVMap[I]); >>>> + ? ?if (globalInitUsesExternalBA(I)) { >>>> + ? ? ?assert(!globalInitUsesExternalBA(GV) && "A global initializer references" >>>> + ? ? ? ? ?"functions in both the safe and the test module"); >>>> >>>> I don't see what prevents this assertion from triggering? >>> >>> nothing indeed. If a global initializer references blockaddresses across modules, I don't think we can split. >> >> True; we should at least give a proper error message, though. > > Now with a proper error message then. r151115; sorry about the delay. -Eli From arcata at gmail.com Tue Feb 21 19:50:34 2012 From: arcata at gmail.com (Joe Groff) Date: Tue, 21 Feb 2012 17:50:34 -0800 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: Here is a revised patch. I moved the logic into a toplevel function in FunctionLoweringInfo, and shortened the property name to 'usesVAFloatArgument'. I added a test for fltused with indirect calls that passes, so I believe the type logic is correct?the type of the callee should be a pointer-to-FunctionType whether direct or indirect. After discussing the issue with Bigcheese on IRC, we determined that checking only for top-level floating point types should be sufficient. Any other issues? -Joe -------------- next part -------------- A non-text attachment was scrubbed... Name: pr11798-4.diff Type: application/octet-stream Size: 9275 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120221/04f7a4b0/attachment.obj From stoklund at 2pi.dk Tue Feb 21 19:52:43 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 21 Feb 2012 17:52:43 -0800 Subject: [llvm-commits] [llvm] r151114 - /llvm/trunk/include/llvm/ADT/SparseSet.h In-Reply-To: <20120222011935.3EAA92A6C12F@llvm.org> References: <20120222011935.3EAA92A6C12F@llvm.org> Message-ID: <8261E8E7-0323-462E-9DEE-9801B441B2DE@2pi.dk> On Feb 21, 2012, at 5:19 PM, NAKAMURA Takumi wrote: > Author: chapuni > Date: Tue Feb 21 19:19:35 2012 > New Revision: 151114 > > URL: http://llvm.org/viewvc/llvm-project?rev=151114&view=rev > Log: > ADT/SparseSet.h: Fix up header dependencies. Thanks! /jakob From geek4civic at gmail.com Tue Feb 21 20:36:30 2012 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Wed, 22 Feb 2012 11:36:30 +0900 Subject: [llvm-commits] Bug in "call __chkstak" on 64 bit OS In-Reply-To: References: <7DE70FDACDE4CD4887C4278C12A2E30508F3E5@HASMSX104.ger.corp.intel.com> Message-ID: Marina, Please try my attached patch. It seeks predefined symbols before DLLs. IMO, tweaking only "chkstk" would be ad-hoc hack. I would be happier if entire calls/jmps could be resolved as indirect. Introducing large model is good thing, though! ;) ...Takumi -------------- next part -------------- diff --git a/llvm/lib/Support/Windows/DynamicLibrary.inc b/llvm/lib/Support/Windows/DynamicLibrary.inc index 83da82a..e858d74 100644 --- a/llvm/lib/Support/Windows/DynamicLibrary.inc +++ b/llvm/lib/Support/Windows/DynamicLibrary.inc @@ -124,17 +124,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { return i->second; } - // Now search the libraries. - if (OpenedHandles) { - for (DenseSet::iterator I = OpenedHandles->begin(), - E = OpenedHandles->end(); I != E; ++I) { - FARPROC ptr = GetProcAddress((HMODULE)*I, symbolName); - if (ptr) { - return (void *)(intptr_t)ptr; - } - } - } - + // Next, search predefined explicit symbols. #define EXPLICIT_SYMBOL(SYM) \ if (!strcmp(symbolName, #SYM)) return (void*)&SYM; #define EXPLICIT_SYMBOL2(SYMFROM, SYMTO) \ @@ -147,6 +137,17 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char* symbolName) { #undef EXPLICIT_SYMBOL #undef EXPLICIT_SYMBOL2 + // Now search the libraries. + if (OpenedHandles) { + for (DenseSet::iterator I = OpenedHandles->begin(), + E = OpenedHandles->end(); I != E; ++I) { + FARPROC ptr = GetProcAddress((HMODULE)*I, symbolName); + if (ptr) { + return (void *)(intptr_t)ptr; + } + } + } + return 0; } From aaron at aaronballman.com Tue Feb 21 21:04:40 2012 From: aaron at aaronballman.com (Aaron Ballman) Date: Wed, 22 Feb 2012 03:04:40 -0000 Subject: [llvm-commits] [llvm] r151123 - in /llvm/trunk: lib/Target/X86/X86CallingConv.td test/CodeGen/X86/thiscall-struct-return.ll Message-ID: <20120222030440.633412A6C12F@llvm.org> Author: aaronballman Date: Tue Feb 21 21:04:40 2012 New Revision: 151123 URL: http://llvm.org/viewvc/llvm-project?rev=151123&view=rev Log: Adding support for Microsoft's thiscall calling convention. LLVM side of the patch. Added: llvm/trunk/test/CodeGen/X86/thiscall-struct-return.ll Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=151123&r1=151122&r2=151123&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CallingConv.td (original) +++ llvm/trunk/lib/Target/X86/X86CallingConv.td Tue Feb 21 21:04:40 2012 @@ -331,8 +331,8 @@ // Promote i8/i16 arguments to i32. CCIfType<[i8, i16], CCPromoteToType>, - // The 'nest' parameter, if any, is passed in EAX. - CCIfNest>, + // Pass sret arguments indirectly through EAX + CCIfSRet>, // The first integer argument is passed in ECX CCIfType<[i32], CCAssignToReg<[ECX]>>, Added: llvm/trunk/test/CodeGen/X86/thiscall-struct-return.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/thiscall-struct-return.ll?rev=151123&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/thiscall-struct-return.ll (added) +++ llvm/trunk/test/CodeGen/X86/thiscall-struct-return.ll Tue Feb 21 21:04:40 2012 @@ -0,0 +1,47 @@ +; RUN: llc < %s -mtriple=i386-PC-Win32 | FileCheck %s + +%class.C = type { i8 } +%struct.S = type { i32 } +%struct.M = type { i32, i32 } + +declare void @_ZN1CC1Ev(%class.C* %this) unnamed_addr nounwind align 2 +declare x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* noalias sret %agg.result, %class.C* %this) nounwind align 2 +declare x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* noalias sret %agg.result, %class.C* %this) nounwind align 2 + +define void @testv() nounwind { +; CHECK: testv: +; CHECK: leal +; CHECK-NEXT: movl %esi, (%esp) +; CHECK-NEXT: calll _ZN1CC1Ev +; CHECK: leal 8(%esp), %eax +; CHECK-NEXT: movl %esi, %ecx +; CHECK-NEXT: calll _ZNK1C5SmallEv +entry: + %c = alloca %class.C, align 1 + %tmp = alloca %struct.S, align 4 + call void @_ZN1CC1Ev(%class.C* %c) + ; This call should put the return structure as a pointer + ; into EAX instead of returning directly in EAX. The this + ; pointer should go into ECX + call x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* sret %tmp, %class.C* %c) + ret void +} + +define void @test2v() nounwind { +; CHECK: test2v: +; CHECK: leal +; CHECK-NEXT: movl %esi, (%esp) +; CHECK-NEXT: calll _ZN1CC1Ev +; CHECK: leal 8(%esp), %eax +; CHECK-NEXT: movl %esi, %ecx +; CHECK-NEXT: calll _ZNK1C6MediumEv +entry: + %c = alloca %class.C, align 1 + %tmp = alloca %struct.M, align 4 + call void @_ZN1CC1Ev(%class.C* %c) + ; This call should put the return structure as a pointer + ; into EAX instead of returning directly in EAX/EDX. The this + ; pointer should go into ECX + call x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* sret %tmp, %class.C* %c) + ret void +} From rafael.espindola at gmail.com Tue Feb 21 21:21:39 2012 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 22 Feb 2012 03:21:39 -0000 Subject: [llvm-commits] [llvm] r151125 - in /llvm/trunk: lib/Analysis/ScalarEvolutionExpander.cpp test/Transforms/LoopStrengthReduce/pr12048.ll Message-ID: <20120222032139.B27242A6C130@llvm.org> Author: rafael Date: Tue Feb 21 21:21:39 2012 New Revision: 151125 URL: http://llvm.org/viewvc/llvm-project?rev=151125&view=rev Log: Semantically revert 151015. Add a comment on why we should be able to assert the dominance once the dominates method is fixed and why we can use the builder's insertion point. Fixes pr12048. Added: llvm/trunk/test/Transforms/LoopStrengthReduce/pr12048.ll Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=151125&r1=151124&r2=151125&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Tue Feb 21 21:21:39 2012 @@ -31,11 +31,20 @@ Value *SCEVExpander::ReuseOrCreateCast(Value *V, Type *Ty, Instruction::CastOps Op, BasicBlock::iterator IP) { - // All new or reused instructions must strictly dominate their uses. - // It would be nice to assert this here, but we don't always know where - // the next instructions will be added as the caller can move the - // Builder's InsertPt before creating them and we might be called with - // an invalid InsertPt. + // This function must be called with the builder having a valid insertion + // point. It doesn't need to be the actual IP where the uses of the returned + // cast will be added, but it must dominate such IP. + // We use this precondition to assert that we can produce a cast that will + // dominate all its uses. In particular, this is crussial for the case + // where the builder's insertion point *is* the point where we were asked + // to put the cast. + // Since we don't know the the builder's insertion point is actually + // where the uses will be added (only that it dominates it), we are + // not allowed to move it. + BasicBlock::iterator BIP = Builder.GetInsertPoint(); + + // FIXME: enable once our implementation of dominates is fixed. + // assert(BIP == IP || SE.DT->dominates(IP, BIP)); // Check to see if there is already a cast! for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); @@ -44,8 +53,9 @@ if (U->getType() == Ty) if (CastInst *CI = dyn_cast(U)) if (CI->getOpcode() == Op) { - // If the cast isn't where we want it, fix it. - if (BasicBlock::iterator(CI) != IP) { + // If the cast isn't where we want it or if it doesn't dominate + // a use in BIP, fix it. + if (BasicBlock::iterator(CI) != IP || BIP == IP) { // Create a new cast, and leave the old cast in place in case // it is being used as an insert point. Clear its operand // so that it doesn't hold anything live. Added: llvm/trunk/test/Transforms/LoopStrengthReduce/pr12048.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/pr12048.ll?rev=151125&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/pr12048.ll (added) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/pr12048.ll Tue Feb 21 21:21:39 2012 @@ -0,0 +1,38 @@ +; RUN: opt < %s -loop-reduce + +define void @resolve_name() nounwind uwtable ssp { + br label %while.cond40.preheader +while.cond132.while.cond.loopexit_crit_edge: + br label %while.cond40.preheader +while.cond40.preheader: + br label %while.cond40 +while.cond40: + %indvars.iv194 = phi i8* [ null, %while.cond40.preheader ], [ %scevgep, %while.body51 ] + %tmp.1 = phi i8* [ undef, %while.cond40.preheader ], [ %incdec.ptr, %while.body51 ] + switch i8 undef, label %while.body51 [ + i8 0, label %if.then59 + ] +while.body51: ; preds = %land.end50 + %incdec.ptr = getelementptr inbounds i8* %tmp.1, i64 1 + %scevgep = getelementptr i8* %indvars.iv194, i64 1 + br label %while.cond40 +if.then59: ; preds = %while.end + br i1 undef, label %if.then64, label %if.end113 +if.then64: ; preds = %if.then59 + %incdec.ptr88.tmp.2 = select i1 undef, i8* undef, i8* undef + br label %if.end113 +if.end113: ; preds = %if.then64, %if.then59 + %tmp.4 = phi i8* [ %incdec.ptr88.tmp.2, %if.then64 ], [ undef, %if.then59 ] + %tmp.4195 = ptrtoint i8* %tmp.4 to i64 + br label %while.cond132.preheader +while.cond132.preheader: ; preds = %if.end113 + %cmp133173 = icmp eq i8* %tmp.1, %tmp.4 + br i1 %cmp133173, label %while.cond40.preheader, label %while.body139.lr.ph +while.body139.lr.ph: ; preds = %while.cond132.preheader + %scevgep198 = getelementptr i8* %indvars.iv194, i64 0 + %scevgep198199 = ptrtoint i8* %scevgep198 to i64 + br label %while.body139 +while.body139: ; preds = %while.body139, %while.body139.lr.ph + %start_of_var.0177 = phi i8* [ %tmp.1, %while.body139.lr.ph ], [ null, %while.body139 ] + br i1 undef, label %while.cond132.while.cond.loopexit_crit_edge, label %while.body139 +} From atrick at apple.com Tue Feb 21 21:40:01 2012 From: atrick at apple.com (Andrew Trick) Date: Tue, 21 Feb 2012 19:40:01 -0800 Subject: [llvm-commits] [llvm] r151125 - in /llvm/trunk: lib/Analysis/ScalarEvolutionExpander.cpp test/Transforms/LoopStrengthReduce/pr12048.ll In-Reply-To: <20120222032139.B27242A6C130@llvm.org> References: <20120222032139.B27242A6C130@llvm.org> Message-ID: On Feb 21, 2012, at 7:21 PM, Rafael Espindola wrote: > > - // If the cast isn't where we want it, fix it. > - if (BasicBlock::iterator(CI) != IP) { > + // If the cast isn't where we want it or if it doesn't dominate > + // a use in BIP, fix it. > + if (BasicBlock::iterator(CI) != IP || BIP == IP) { > // Create a new cast, and leave the old cast in place in case > // it is being used as an insert point. Clear its operand > // so that it doesn't hold anything live. Great! Given the amount of time I spent during review trying to remember why I originally added that check. We should probably be more explicit in the comments. Something like: "If the cast isn't where we want it, create a new, earlier cast at IP. Likewise, do not reuse a cast at BIP because it must dominate instructions that will be inserted before BIP." -Andy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120221/6ee19b67/attachment.html From rafael.espindola at gmail.com Tue Feb 21 21:44:46 2012 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 22 Feb 2012 03:44:46 -0000 Subject: [llvm-commits] [llvm] r151127 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Message-ID: <20120222034447.0692B2A6C12F@llvm.org> Author: rafael Date: Tue Feb 21 21:44:46 2012 New Revision: 151127 URL: http://llvm.org/viewvc/llvm-project?rev=151127&view=rev Log: Improve comment. Thanks for Andrew for the suggestion. Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=151127&r1=151126&r2=151127&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Tue Feb 21 21:44:46 2012 @@ -53,8 +53,9 @@ if (U->getType() == Ty) if (CastInst *CI = dyn_cast(U)) if (CI->getOpcode() == Op) { - // If the cast isn't where we want it or if it doesn't dominate - // a use in BIP, fix it. + // If the cast isn't where we want it, create a new cast at IP. + // Likewise, do not reuse a cast at BIP because it must dominate + // instructions that might be inserted before BIP. if (BasicBlock::iterator(CI) != IP || BIP == IP) { // Create a new cast, and leave the old cast in place in case // it is being used as an insert point. Clear its operand From clattner at apple.com Tue Feb 21 22:15:38 2012 From: clattner at apple.com (Chris Lattner) Date: Tue, 21 Feb 2012 20:15:38 -0800 Subject: [llvm-commits] [PATCH] Handle negative values in StringRef::getAsInteger(unsigned Radix, APInt &). In-Reply-To: References: <7A0EF93B-7C20-490F-AF3E-1FAB42D28536@apple.com> Message-ID: <326B5F89-3A09-4DB6-811C-6C025D3B39E5@apple.com> On Feb 16, 2012, at 2:45 PM, Michael Spencer wrote: > On Thu, Feb 16, 2012 at 8:20 AM, Chris Lattner wrote: >> >> On Feb 15, 2012, at 4:25 PM, Michael Spencer wrote: >> >>> I have a use case for this in lld. >> >> >> This is sorta strange to me, how about adding an APSInt overload that allows negative (also weird) or a new getAsSignedInteger method (probably better)? >> >> -Chris > > There is already precedent in the other StringRef::getAsInteger > functions to accept negative values. I believe the interface should be > uniform. > > All I actually need is uint64_t and int64_t, however, these are > unsigned long and long on my platform (x86-64 Linux), and thus don't > match any of the overloads. > > Would it be better for me to just cleanup the overload set? I'd prefer you to clean up the overload set, but do what you think is best. Thanks! -Chris From clattner at apple.com Tue Feb 21 22:17:32 2012 From: clattner at apple.com (Chris Lattner) Date: Tue, 21 Feb 2012 20:17:32 -0800 Subject: [llvm-commits] [llvm] r151093 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/constantfold-initializers.ll In-Reply-To: <20120221220806.ED6AD2A6C12F@llvm.org> References: <20120221220806.ED6AD2A6C12F@llvm.org> Message-ID: <1D190D19-E8E3-4D63-A46B-DF6EA8D8D2A1@apple.com> On Feb 21, 2012, at 2:08 PM, Nick Lewycky wrote: > Author: nicholas > Date: Tue Feb 21 16:08:06 2012 > New Revision: 151093 > > URL: http://llvm.org/viewvc/llvm-project?rev=151093&view=rev > Log: > Use the target-aware constant folder on expressions to improve the chance > they'll be simple enough to simulate, and to reduce the chance we'll encounter > equal but different simple pointer constants. > > This removes the symptoms from PR11352 but is not a full fix. A proper fix would > either require a guarantee that two constant objects we simulate are folded > when equal, or a different way of handling equal pointers (ie., trying a > constantexpr icmp on them to see whether we know they're equal or non-equal or > unsure). I think it should be enough to consider two constants the same if they are pointer equal and neither is a ConstantExpr. -Chris > > Modified: > llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp > llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll > > Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=151093&r1=151092&r2=151093&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Feb 21 16:08:06 2012 > @@ -2388,6 +2388,8 @@ > if (StoreInst *SI = dyn_cast(CurInst)) { > if (!SI->isSimple()) return false; // no volatile/atomic accesses. > Constant *Ptr = getVal(SI->getOperand(1)); > + if (ConstantExpr *CE = dyn_cast(Ptr)) > + Ptr = ConstantFoldConstantExpression(CE, TD, TLI); > if (!isSimpleEnoughPointerToCommit(Ptr)) > // If this is too complex for us to commit, reject it. > return false; > @@ -2423,7 +2425,9 @@ > Constant * const IdxList[] = {IdxZero, IdxZero}; > > Ptr = ConstantExpr::getGetElementPtr(Ptr, IdxList); > - > + if (ConstantExpr *CE = dyn_cast(Ptr)) > + Ptr = ConstantFoldConstantExpression(CE, TD, TLI); > + > // If we can't improve the situation by introspecting NewTy, > // we have to give up. > } else { > @@ -2464,7 +2468,10 @@ > cast(GEP)->isInBounds()); > } else if (LoadInst *LI = dyn_cast(CurInst)) { > if (!LI->isSimple()) return false; // no volatile/atomic accesses. > - InstResult = ComputeLoadResult(getVal(LI->getOperand(0))); > + Constant *Ptr = getVal(LI->getOperand(0)); > + if (ConstantExpr *CE = dyn_cast(Ptr)) > + Ptr = ConstantFoldConstantExpression(CE, TD, TLI); > + InstResult = ComputeLoadResult(Ptr); > if (InstResult == 0) return false; // Could not evaluate load. > } else if (AllocaInst *AI = dyn_cast(CurInst)) { > if (AI->isArrayAllocation()) return false; // Cannot handle array allocs. > > Modified: llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll?rev=151093&r1=151092&r2=151093&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll (original) > +++ llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll Tue Feb 21 16:08:06 2012 > @@ -6,3 +6,46 @@ > > ; CHECK: @A = global i1 false > @A = global i1 icmp ne (i64 sub nsw (i64 ptrtoint (i8* getelementptr inbounds ([3 x i8]* @.str91250, i64 0, i64 1) to i64), i64 ptrtoint ([3 x i8]* @.str91250 to i64)), i64 1) > + > +; PR11352 > + > + at xs = global [2 x i32] zeroinitializer, align 4 > +; CHECK: @xs = global [2 x i32] [i32 1, i32 1] > + > +define internal void @test1() { > +entry: > + store i32 1, i32* getelementptr inbounds ([2 x i32]* @xs, i64 0, i64 0) > + %0 = load i32* getelementptr inbounds ([2 x i32]* @xs, i32 0, i64 0), align 4 > + store i32 %0, i32* getelementptr inbounds ([2 x i32]* @xs, i64 0, i64 1) > + ret void > +} > + > +; PR12060 > + > +%closure = type { i32 } > + > + at f = internal global %closure zeroinitializer, align 4 > + at m = global i32 0, align 4 > +; CHECK-NOT: @f > +; CHECK: @m = global i32 13 > + > +define internal i32 @test2_helper(%closure* %this, i32 %b) { > +entry: > + %0 = getelementptr inbounds %closure* %this, i32 0, i32 0 > + %1 = load i32* %0, align 4 > + %add = add nsw i32 %1, %b > + ret i32 %add > +} > + > +define internal void @test2() { > +entry: > + store i32 4, i32* getelementptr inbounds (%closure* @f, i32 0, i32 0) > + %call = call i32 @test2_helper(%closure* @f, i32 9) > + store i32 %call, i32* @m, align 4 > + ret void > +} > + > + at llvm.global_ctors = appending constant > + [2 x { i32, void ()* }] > + [{ i32, void ()* } { i32 65535, void ()* @test1 }, > + { i32, void ()* } { i32 65535, void ()* @test2 }] > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Tue Feb 21 22:16:24 2012 From: clattner at apple.com (Chris Lattner) Date: Tue, 21 Feb 2012 20:16:24 -0800 Subject: [llvm-commits] [llvm] r150939 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp In-Reply-To: <4F41BE64.8000201@mxc.ca> References: <20120219232627.8F3991BE003@llvm.org> <4F41BE64.8000201@mxc.ca> Message-ID: <59264080-AFB8-40D1-82B2-70D6CB5FEE02@apple.com> On Feb 19, 2012, at 7:30 PM, Nick Lewycky wrote: > Chris Lattner wrote: >> >> On Feb 19, 2012, at 4:37 PM, NAKAMURA Takumi wrote: >> >>> 2012/2/20 Chris Lattner: >>>> Nice! It's probably best to rename the "Evaluate" class to "Evaluator". Also, it can be put into an anon namespace. Thanks Nick! >>> >>> Rather, could we integrate the evaluators in globalopt, >>> constantfolding (and EE/Interpreter)? >> >> They all do different things (and the interpreter should be killed :), so I don't think it makes sense. > > I think it would make sense. They share a design where they visit each an instruction/constant-expression with some mapping applied to the operands such as building a Constant* or computing a ConstantRange or using a SCEV object. This sounds like InstVisitor. A patch to kill off the interpreter is heartily appreciated. -Chris From atrick at apple.com Tue Feb 21 22:52:52 2012 From: atrick at apple.com (Andrew Trick) Date: Tue, 21 Feb 2012 20:52:52 -0800 Subject: [llvm-commits] [llvm] r150885 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp In-Reply-To: <4F432A21.5060208@gmail.com> References: <20120218175143.39EC02A6C12F@llvm.org> <4F400451.9030203@gmail.com> <4F402019.3020805@gmail.com> <4F40C8EE.9070003@free.fr> <4F415BC7.5090408@gmail.com> <4F4217AC.6010204@free.fr> <4F432A21.5060208@gmail.com> Message-ID: <86393DD4-9EBF-4098-98A3-7EC429B1A324@apple.com> On Feb 20, 2012, at 9:22 PM, Rafael ?vila de Esp?ndola wrote: >> By the way, if you move this logic into the dominates routine, then I >> guess the >> verifier can be simplified by removing all the current logic and just >> replacing >> by a call to the improved dominator routine. > > Thanks again for the review. Exactly what these functions do was a bit > fuzzy in my head. > > I really like the idea of sharing as much code as possible. The attached > patches do that, but unfortunately they cannot fully replace the logic > in the verifier. The interface doesn't provide which edge of a phi to > consider, so they have to be conservative and check all. Please remove properlyDominates(Instruction, Instruction). I created it for the same reason as your dominatesUse(). I like the idea of using dominatesUse() everywhere. Just beware that it's not semantically equivalent to the old dominates(). Can you prove to yourself that dominatesUse does what the client expects in each instance that you replaced? I don't think anything was wrong with the original implementation except for one missing check. Can you just do this: // If A is an invoke instruction, its value is only available in this normal // successor block. if (const InvokeInst *II = dyn_cast(A)) { BBA = II->getNormalDest(); + if (BBA == BBB) return true; } So you don't need patch #2 at all. -Andy From craig.topper at gmail.com Tue Feb 21 23:59:10 2012 From: craig.topper at gmail.com (Craig Topper) Date: Wed, 22 Feb 2012 05:59:10 -0000 Subject: [llvm-commits] [llvm] r151134 - in /llvm/trunk: include/llvm/Target/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/MBlaze/ lib/Target/Mips/ lib/Target/PTX/ lib/Target/PowerPC/ lib/Target/X86/ utils/TableGen/ Message-ID: <20120222055911.527612A6C12F@llvm.org> Author: ctopper Date: Tue Feb 21 23:59:10 2012 New Revision: 151134 URL: http://llvm.org/viewvc/llvm-project?rev=151134&view=rev Log: Make all pointers to TargetRegisterClass const since they are all pointers to static data that should not be modified. Modified: llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/include/llvm/Target/TargetSubtargetInfo.h llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/Target/ARM/ARMFastISel.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86VZeroUpper.cpp llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Tue Feb 21 23:59:10 2012 @@ -201,9 +201,9 @@ /// getRegClassFor - Return the register class that should be used for the /// specified value type. - virtual TargetRegisterClass *getRegClassFor(EVT VT) const { + virtual const TargetRegisterClass *getRegClassFor(EVT VT) const { assert(VT.isSimple() && "getRegClassFor called on illegal type!"); - TargetRegisterClass *RC = RegClassForVT[VT.getSimpleVT().SimpleTy]; + const TargetRegisterClass *RC = RegClassForVT[VT.getSimpleVT().SimpleTy]; assert(RC && "This value type is not natively supported!"); return RC; } @@ -1043,7 +1043,7 @@ /// addRegisterClass - Add the specified register class as an available /// regclass for the specified value type. This indicates the selector can /// handle values of that class natively. - void addRegisterClass(EVT VT, TargetRegisterClass *RC) { + void addRegisterClass(EVT VT, const TargetRegisterClass *RC) { assert((unsigned)VT.getSimpleVT().SimpleTy < array_lengthof(RegClassForVT)); AvailableRegClasses.push_back(std::make_pair(VT, RC)); RegClassForVT[VT.getSimpleVT().SimpleTy] = RC; @@ -1760,7 +1760,7 @@ /// RegClassForVT - This indicates the default register class to use for /// each ValueType the target supports natively. - TargetRegisterClass *RegClassForVT[MVT::LAST_VALUETYPE]; + const TargetRegisterClass *RegClassForVT[MVT::LAST_VALUETYPE]; unsigned char NumRegistersForVT[MVT::LAST_VALUETYPE]; EVT RegisterTypeForVT[MVT::LAST_VALUETYPE]; @@ -1934,7 +1934,7 @@ return LegalizeKind(TypeSplitVector, NVT); } - std::vector > AvailableRegClasses; + std::vector > AvailableRegClasses; /// TargetDAGCombineArray - Targets can specify ISD nodes that they would /// like PerformDAGCombine callbacks for by calling setTargetDAGCombine(), Modified: llvm/trunk/include/llvm/Target/TargetSubtargetInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSubtargetInfo.h?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetSubtargetInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetSubtargetInfo.h Tue Feb 21 23:59:10 2012 @@ -39,7 +39,7 @@ // AntiDepBreakMode - Type of anti-dependence breaking that should // be performed before post-RA scheduling. typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } AntiDepBreakMode; - typedef SmallVectorImpl RegClassVector; + typedef SmallVectorImpl RegClassVector; virtual ~TargetSubtargetInfo(); Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Tue Feb 21 23:59:10 2012 @@ -134,7 +134,7 @@ MachineFunction &MF, MachineLoopInfo &MLI, MachineDominatorTree &MDT, AliasAnalysis *AA, const RegisterClassInfo&, TargetSubtargetInfo::AntiDepBreakMode AntiDepMode, - SmallVectorImpl &CriticalPathRCs); + SmallVectorImpl &CriticalPathRCs); ~SchedulePostRATDList(); @@ -184,7 +184,7 @@ MachineFunction &MF, MachineLoopInfo &MLI, MachineDominatorTree &MDT, AliasAnalysis *AA, const RegisterClassInfo &RCI, TargetSubtargetInfo::AntiDepBreakMode AntiDepMode, - SmallVectorImpl &CriticalPathRCs) + SmallVectorImpl &CriticalPathRCs) : ScheduleDAGInstrs(MF, MLI, MDT, /*IsPostRA=*/true), Topo(SUnits), AA(AA), KillIndices(TRI->getNumRegs()) { @@ -216,7 +216,7 @@ // Check for explicit enable/disable of post-ra scheduling. TargetSubtargetInfo::AntiDepBreakMode AntiDepMode = TargetSubtargetInfo::ANTIDEP_NONE; - SmallVector CriticalPathRCs; + SmallVector CriticalPathRCs; if (EnablePostRAScheduler.getPosition() > 0) { if (!EnablePostRAScheduler) return false; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Feb 21 23:59:10 2012 @@ -725,8 +725,8 @@ // First, try to perform the bitcast by inserting a reg-reg copy. unsigned ResultReg = 0; if (SrcVT.getSimpleVT() == DstVT.getSimpleVT()) { - TargetRegisterClass* SrcClass = TLI.getRegClassFor(SrcVT); - TargetRegisterClass* DstClass = TLI.getRegClassFor(DstVT); + const TargetRegisterClass* SrcClass = TLI.getRegClassFor(SrcVT); + const TargetRegisterClass* DstClass = TLI.getRegClassFor(DstVT); // Don't attempt a cross-class copy. It will likely fail. if (SrcClass == DstClass) { ResultReg = createResultReg(DstClass); Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Tue Feb 21 23:59:10 2012 @@ -728,7 +728,7 @@ // This will get lowered later into the correct offsets and registers // via rewriteXFrameIndex. if (SI != FuncInfo.StaticAllocaMap.end()) { - TargetRegisterClass* RC = TLI.getRegClassFor(VT); + const TargetRegisterClass* RC = TLI.getRegClassFor(VT); unsigned ResultReg = createResultReg(RC); unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri; AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, @@ -911,8 +911,8 @@ // put the alloca address into a register, set the base type back to // register and continue. This should almost never happen. if (needsLowering && Addr.BaseType == Address::FrameIndexBase) { - TargetRegisterClass *RC = isThumb2 ? ARM::tGPRRegisterClass : - ARM::GPRRegisterClass; + const TargetRegisterClass *RC = isThumb2 ? ARM::tGPRRegisterClass + : ARM::GPRRegisterClass; unsigned ResultReg = createResultReg(RC); unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri; AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, @@ -987,7 +987,7 @@ unsigned Opc; bool useAM3 = false; bool needVMOV = false; - TargetRegisterClass *RC; + const TargetRegisterClass *RC; switch (VT.getSimpleVT().SimpleTy) { // This is mostly going to be Neon/vector support. default: return false; @@ -1490,8 +1490,8 @@ // Now set a register based on the comparison. Explicitly set the predicates // here. unsigned MovCCOpc = isThumb2 ? ARM::t2MOVCCi : ARM::MOVCCi; - TargetRegisterClass *RC = isThumb2 ? ARM::rGPRRegisterClass - : ARM::GPRRegisterClass; + const TargetRegisterClass *RC = isThumb2 ? ARM::rGPRRegisterClass + : ARM::GPRRegisterClass; unsigned DestReg = createResultReg(RC); Constant *Zero = ConstantInt::get(Type::getInt32Ty(*Context), 0); unsigned ZeroReg = TargetMaterializeConstant(Zero); @@ -1955,7 +1955,7 @@ // For this move we copy into two registers and then move into the // double fp reg we want. EVT DestVT = RVLocs[0].getValVT(); - TargetRegisterClass* DstRC = TLI.getRegClassFor(DestVT); + const TargetRegisterClass* DstRC = TLI.getRegClassFor(DestVT); unsigned ResultReg = createResultReg(DstRC); AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(ARM::VMOVDRR), ResultReg) @@ -1975,7 +1975,7 @@ if (RetVT == MVT::i1 || RetVT == MVT::i8 || RetVT == MVT::i16) CopyVT = MVT::i32; - TargetRegisterClass* DstRC = TLI.getRegClassFor(CopyVT); + const TargetRegisterClass* DstRC = TLI.getRegClassFor(CopyVT); unsigned ResultReg = createResultReg(DstRC); BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY), Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Feb 21 23:59:10 2012 @@ -1011,7 +1011,7 @@ /// getRegClassFor - Return the register class that should be used for the /// specified value type. -TargetRegisterClass *ARMTargetLowering::getRegClassFor(EVT VT) const { +const TargetRegisterClass *ARMTargetLowering::getRegClassFor(EVT VT) const { // Map v4i64 to QQ registers but do not make the type legal. Similarly map // v8i64 to QQQQ registers. v4i64 and v8i64 are only used for REG_SEQUENCE to // load / store 4 to 8 consecutive D registers. @@ -2422,7 +2422,7 @@ MachineFunction &MF = DAG.getMachineFunction(); ARMFunctionInfo *AFI = MF.getInfo(); - TargetRegisterClass *RC; + const TargetRegisterClass *RC; if (AFI->isThumb1OnlyFunction()) RC = ARM::tGPRRegisterClass; else @@ -2508,7 +2508,7 @@ SmallVector MemOps; for (; firstRegToSaveIndex < 4; ++firstRegToSaveIndex) { - TargetRegisterClass *RC; + const TargetRegisterClass *RC; if (AFI->isThumb1OnlyFunction()) RC = ARM::tGPRRegisterClass; else @@ -2591,7 +2591,7 @@ ArgValue = GetF64FormalArgument(VA, ArgLocs[++i], Chain, DAG, dl); } else { - TargetRegisterClass *RC; + const TargetRegisterClass *RC; if (RegVT == MVT::f32) RC = ARM::SPRRegisterClass; @@ -5299,7 +5299,7 @@ BB->end()); exitMBB->transferSuccessorsAndUpdatePHIs(BB); - TargetRegisterClass *TRC = + const TargetRegisterClass *TRC = isThumb2 ? ARM::tGPRRegisterClass : ARM::GPRRegisterClass; unsigned scratch = MRI.createVirtualRegister(TRC); unsigned scratch2 = (!BinOpcode) ? incr : MRI.createVirtualRegister(TRC); @@ -5409,7 +5409,7 @@ BB->end()); exitMBB->transferSuccessorsAndUpdatePHIs(BB); - TargetRegisterClass *TRC = + const TargetRegisterClass *TRC = isThumb2 ? ARM::tGPRRegisterClass : ARM::GPRRegisterClass; unsigned scratch = MRI.createVirtualRegister(TRC); unsigned scratch2 = MRI.createVirtualRegister(TRC); @@ -5519,7 +5519,7 @@ BB->end()); exitMBB->transferSuccessorsAndUpdatePHIs(BB); - TargetRegisterClass *TRC = + const TargetRegisterClass *TRC = isThumb2 ? ARM::tGPRRegisterClass : ARM::GPRRegisterClass; unsigned storesuccess = MRI.createVirtualRegister(TRC); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Tue Feb 21 23:59:10 2012 @@ -345,7 +345,7 @@ /// getRegClassFor - Return the register class that should be used for the /// specified value type. - virtual TargetRegisterClass *getRegClassFor(EVT VT) const; + virtual const TargetRegisterClass *getRegClassFor(EVT VT) const; /// getMaximalGlobalOffset - Returns the maximal possible offset which can /// be used for loads / stores from the global. Modified: llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp Tue Feb 21 23:59:10 2012 @@ -896,7 +896,7 @@ if (VA.isRegLoc()) { MVT RegVT = VA.getLocVT(); ArgRegEnd = VA.getLocReg(); - TargetRegisterClass *RC = 0; + const TargetRegisterClass *RC; if (RegVT == MVT::i32) RC = MBlaze::GPRRegisterClass; @@ -964,7 +964,7 @@ StackPtr = DAG.getRegister(StackReg, getPointerTy()); // The last register argument that must be saved is MBlaze::R10 - TargetRegisterClass *RC = MBlaze::GPRRegisterClass; + const TargetRegisterClass *RC = MBlaze::GPRRegisterClass; unsigned Begin = getMBlazeRegisterNumbering(MBlaze::R5); unsigned Start = getMBlazeRegisterNumbering(ArgRegEnd+1); Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Tue Feb 21 23:59:10 2012 @@ -710,7 +710,7 @@ // MachineFunction as a live in value. It also creates a corresponding // virtual register for it. static unsigned -AddLiveIn(MachineFunction &MF, unsigned PReg, TargetRegisterClass *RC) +AddLiveIn(MachineFunction &MF, unsigned PReg, const TargetRegisterClass *RC) { assert(RC->contains(PReg) && "Not the correct regclass!"); unsigned VReg = MF.getRegInfo().createVirtualRegister(RC); @@ -2601,7 +2601,7 @@ if (IsRegLoc) { EVT RegVT = VA.getLocVT(); unsigned ArgReg = VA.getLocReg(); - TargetRegisterClass *RC = 0; + const TargetRegisterClass *RC; if (RegVT == MVT::i32) RC = Mips::CPURegsRegisterClass; @@ -2684,7 +2684,7 @@ const unsigned *ArgRegs = IsO32 ? O32IntRegs : Mips64IntRegs; unsigned Idx = CCInfo.getFirstUnallocated(ArgRegs, NumOfRegs); int FirstRegSlotOffset = IsO32 ? 0 : -64 ; // offset of $a0's slot. - TargetRegisterClass *RC + const TargetRegisterClass *RC = IsO32 ? Mips::CPURegsRegisterClass : Mips::CPU64RegsRegisterClass; unsigned RegSize = RC->getSize(); int RegSlotOffset = FirstRegSlotOffset + Idx * RegSize; Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Tue Feb 21 23:59:10 2012 @@ -240,32 +240,25 @@ } else { for (unsigned i = 0, e = Ins.size(); i != e; ++i) { - EVT RegVT = Ins[i].VT; - TargetRegisterClass* TRC = getRegClassFor(RegVT); - unsigned RegType; + EVT RegVT = Ins[i].VT; + const TargetRegisterClass* TRC = getRegClassFor(RegVT); + unsigned RegType; // Determine which register class we need - if (RegVT == MVT::i1) { + if (RegVT == MVT::i1) RegType = PTXRegisterType::Pred; - } - else if (RegVT == MVT::i16) { + else if (RegVT == MVT::i16) RegType = PTXRegisterType::B16; - } - else if (RegVT == MVT::i32) { + else if (RegVT == MVT::i32) RegType = PTXRegisterType::B32; - } - else if (RegVT == MVT::i64) { + else if (RegVT == MVT::i64) RegType = PTXRegisterType::B64; - } - else if (RegVT == MVT::f32) { + else if (RegVT == MVT::f32) RegType = PTXRegisterType::F32; - } - else if (RegVT == MVT::f64) { + else if (RegVT == MVT::f64) RegType = PTXRegisterType::F64; - } - else { + else llvm_unreachable("Unknown parameter type"); - } // Use a unique index in the instruction to prevent instruction folding. // Yes, this is a hack. @@ -326,7 +319,7 @@ } else { for (unsigned i = 0, e = Outs.size(); i != e; ++i) { EVT RegVT = Outs[i].VT; - TargetRegisterClass* TRC = 0; + const TargetRegisterClass* TRC; unsigned RegType; // Determine which register class we need Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Tue Feb 21 23:59:10 2012 @@ -1698,7 +1698,7 @@ // Arguments stored in registers. if (VA.isRegLoc()) { - TargetRegisterClass *RC; + const TargetRegisterClass *RC; EVT ValVT = VA.getValVT(); switch (ValVT.getSimpleVT().SimpleTy) { Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Tue Feb 21 23:59:10 2012 @@ -2104,7 +2104,7 @@ if (!X86SelectAddress(C, AM)) return 0; unsigned Opc = Subtarget->is64Bit() ? X86::LEA64r : X86::LEA32r; - TargetRegisterClass* RC = TLI.getRegClassFor(TLI.getPointerTy()); + const TargetRegisterClass* RC = TLI.getRegClassFor(TLI.getPointerTy()); unsigned ResultReg = createResultReg(RC); addFullAddress(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(Opc), ResultReg), AM); Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Feb 21 23:59:10 2012 @@ -1829,7 +1829,7 @@ if (VA.isRegLoc()) { EVT RegVT = VA.getLocVT(); - TargetRegisterClass *RC = NULL; + const TargetRegisterClass *RC; if (RegVT == MVT::i32) RC = X86::GR32RegisterClass; else if (Is64Bit && RegVT == MVT::i64) @@ -11209,7 +11209,7 @@ unsigned CXchgOpc, unsigned notOpc, unsigned EAXreg, - TargetRegisterClass *RC, + const TargetRegisterClass *RC, bool invSrc) const { // For the atomic bitwise operator, we generate // thisMBB: Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Tue Feb 21 23:59:10 2012 @@ -832,7 +832,7 @@ unsigned cxchgOpc, unsigned notOpc, unsigned EAXreg, - TargetRegisterClass *RC, + const TargetRegisterClass *RC, bool invSrc = false) const; MachineBasicBlock *EmitAtomicBit6432WithCustomInserter( Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Tue Feb 21 23:59:10 2012 @@ -1835,7 +1835,7 @@ case X86::ADD32rr_DB: { assert(MI->getNumOperands() >= 3 && "Unknown add instruction!"); unsigned Opc; - TargetRegisterClass *RC; + const TargetRegisterClass *RC; if (MIOpc == X86::ADD64rr || MIOpc == X86::ADD64rr_DB) { Opc = X86::LEA64r; RC = X86::GR64_NOSPRegisterClass; Modified: llvm/trunk/lib/Target/X86/X86VZeroUpper.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86VZeroUpper.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86VZeroUpper.cpp (original) +++ llvm/trunk/lib/Target/X86/X86VZeroUpper.cpp Tue Feb 21 23:59:10 2012 @@ -145,7 +145,7 @@ // to insert any VZEROUPPER instructions. This is constant-time, so it is // cheap in the common case of no ymm use. bool YMMUsed = false; - TargetRegisterClass *RC = X86::VR256RegisterClass; + const TargetRegisterClass *RC = X86::VR256RegisterClass; for (TargetRegisterClass::iterator i = RC->begin(), e = RC->end(); i != e; i++) { if (MRI.isPhysRegUsed(*i)) { Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=151134&r1=151133&r2=151134&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Tue Feb 21 23:59:10 2012 @@ -482,8 +482,8 @@ // Output the extern for the instance. OS << " extern " << Name << "Class\t" << Name << "RegClass;\n"; // Output the extern for the pointer to the instance (should remove). - OS << " static TargetRegisterClass * const "<< Name <<"RegisterClass = &" - << Name << "RegClass;\n"; + OS << " static const TargetRegisterClass * const " << Name + << "RegisterClass = &" << Name << "RegClass;\n"; } OS << "} // end of namespace " << TargetName << "\n\n"; } From atrick at apple.com Wed Feb 22 00:08:11 2012 From: atrick at apple.com (Andrew Trick) Date: Wed, 22 Feb 2012 06:08:11 -0000 Subject: [llvm-commits] [llvm] r151135 - in /llvm/trunk: include/llvm/CodeGen/ScheduleDAG.h lib/CodeGen/CriticalAntiDepBreaker.cpp lib/CodeGen/LatencyPriorityQueue.cpp lib/CodeGen/MachineScheduler.cpp lib/CodeGen/ScheduleDAGInstrs.cpp lib/CodeGen/ScheduleDAGInstrs.h Message-ID: <20120222060811.767512A6C12F@llvm.org> Author: atrick Date: Wed Feb 22 00:08:11 2012 New Revision: 151135 URL: http://llvm.org/viewvc/llvm-project?rev=151135&view=rev Log: Initialize SUnits before DAG building. Affect on SD scheduling and postRA scheduling: Printing the DAG will display the nodes in top-down topological order. This matches the order within the MBB and makes my life much easier in general. Affect on misched: We don't need to track virtual register uses at all. This is awesome. I also intend to rely on the SUnit ID as a topo-sort index. So if A < B then we cannot have an edge B -> A. Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp llvm/trunk/lib/CodeGen/MachineScheduler.cpp llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=151135&r1=151134&r2=151135&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Wed Feb 22 00:08:11 2012 @@ -231,6 +231,7 @@ public: SUnit *OrigNode; // If not this, the node from which // this node was cloned. + // (SD scheduling only) // Preds/Succs - The SUnits before/after us in the graph. SmallVector Preds; // All sunit predecessors. Modified: llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp?rev=151135&r1=151134&r2=151135&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp (original) +++ llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp Wed Feb 22 00:08:11 2012 @@ -427,6 +427,8 @@ // Keep a map of the MachineInstr*'s back to the SUnit representing them. // This is used for updating debug information. + // + // FIXME: Replace this with the existing map in ScheduleDAGInstrs::MISUnitMap DenseMap MISUnitMap; // Find the node at the bottom of the critical path. Modified: llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp?rev=151135&r1=151134&r2=151135&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp (original) +++ llvm/trunk/lib/CodeGen/LatencyPriorityQueue.cpp Wed Feb 22 00:08:11 2012 @@ -46,7 +46,7 @@ // Finally, just to provide a stable ordering, use the node number as a // deciding factor. - return LHSNum < RHSNum; + return RHSNum < LHSNum; } Modified: llvm/trunk/lib/CodeGen/MachineScheduler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineScheduler.cpp?rev=151135&r1=151134&r2=151135&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineScheduler.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineScheduler.cpp Wed Feb 22 00:08:11 2012 @@ -149,7 +149,8 @@ MachineScheduler *Pass; public: ScheduleTopDownLive(MachineScheduler *P): - ScheduleDAGInstrs(*P->MF, *P->MLI, *P->MDT, /*IsPostRA=*/false), Pass(P) {} + ScheduleDAGInstrs(*P->MF, *P->MLI, *P->MDT, /*IsPostRA=*/false, P->LIS), + Pass(P) {} /// ScheduleDAGInstrs callback. void Schedule(); @@ -310,7 +311,8 @@ MachineScheduler *Pass; public: DefaultMachineScheduler(MachineScheduler *P): - ScheduleDAGInstrs(*P->MF, *P->MLI, *P->MDT, /*IsPostRA=*/false), Pass(P) {} + ScheduleDAGInstrs(*P->MF, *P->MLI, *P->MDT, /*IsPostRA=*/false, P->LIS), + Pass(P) {} /// Schedule - This is called back from ScheduleDAGInstrs::Run() when it's /// time to do some work. @@ -348,15 +350,14 @@ #ifndef NDEBUG namespace { -// Nodes with a higher number have lower priority. This way we attempt to +// Nodes with a higher number have higher priority. This way we attempt to // schedule the latest instructions earliest. // // TODO: Relies on the property of the BuildSchedGraph that results in SUnits -// being ordered in sequence bottom-up. This will be formalized, probably be -// constructing SUnits in a prepass. +// being ordered in sequence top-down. struct ShuffleSUnitOrder { bool operator()(SUnit *A, SUnit *B) const { - return A->NodeNum > B->NodeNum; + return A->NodeNum < B->NodeNum; } }; Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=151135&r1=151134&r2=151135&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Wed Feb 22 00:08:11 2012 @@ -17,6 +17,7 @@ #include "llvm/Operator.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/ValueTracking.h" +#include "llvm/CodeGen/LiveIntervalAnalysis.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineMemOperand.h" #include "llvm/CodeGen/MachineRegisterInfo.h" @@ -34,11 +35,14 @@ ScheduleDAGInstrs::ScheduleDAGInstrs(MachineFunction &mf, const MachineLoopInfo &mli, const MachineDominatorTree &mdt, - bool IsPostRAFlag) + bool IsPostRAFlag, + LiveIntervals *lis) : ScheduleDAG(mf), MLI(mli), MDT(mdt), MFI(mf.getFrameInfo()), InstrItins(mf.getTarget().getInstrItineraryData()), IsPostRA(IsPostRAFlag), - UnitLatencies(false), Defs(TRI->getNumRegs()), Uses(TRI->getNumRegs()), + LIS(lis), UnitLatencies(false), + Defs(TRI->getNumRegs()), Uses(TRI->getNumRegs()), LoopRegs(MLI, MDT), FirstDbgValue(0) { + assert((IsPostRA || LIS) && "PreRA scheduling requires LiveIntervals"); DbgValues.clear(); assert(!(IsPostRA && MF.getRegInfo().getNumVirtRegs()) && "Virtual registers must be removed prior to PostRA scheduling"); @@ -357,8 +361,6 @@ const MachineInstr *MI = SU->getInstr(); unsigned Reg = MI->getOperand(OperIdx).getReg(); - const TargetSubtargetInfo &ST = TM.getSubtarget(); - // Add output dependence to the next nearest def of this vreg. // // Unless this definition is dead, the output dependence should be @@ -366,60 +368,94 @@ // uses. We're conservative for now until we have a way to guarantee the uses // are not eliminated sometime during scheduling. The output dependence edge // is also useful if output latency exceeds def-use latency. - SUnit *DefSU = VRegDefs[Reg]; + SUnit *&DefSU = VRegDefs[Reg]; if (DefSU && DefSU != SU && DefSU != &ExitSU) { unsigned OutLatency = TII->getOutputLatency(InstrItins, MI, OperIdx, DefSU->getInstr()); DefSU->addPred(SDep(SU, SDep::Output, OutLatency, Reg)); } - VRegDefs[Reg] = SU; + DefSU = SU; +} - // Add data dependence to any uses of this vreg before the next nearest def. - // - // TODO: Handle ExitSU properly. - // - // TODO: Data dependence could be handled more efficiently at the use-side. - std::vector &UseList = VRegUses[Reg]; - for (std::vector::const_iterator UI = UseList.begin(), - UE = UseList.end(); UI != UE; ++UI) { - SUnit *UseSU = *UI; - if (UseSU == SU) continue; - - // TODO: Handle "special" address latencies cleanly. - const SDep& dep = SDep(SU, SDep::Data, SU->Latency, Reg); - if (!UnitLatencies) { - // Adjust the dependence latency using operand def/use information, then - // allow the target to perform its own adjustments. - ComputeOperandLatency(SU, UseSU, const_cast(dep)); - ST.adjustSchedDependency(SU, UseSU, const_cast(dep)); - } - UseSU->addPred(dep); - } - UseList.clear(); -} - -/// addVRegUseDeps - Add register antidependencies from this SUnit to -/// instructions that occur later in the same scheduling region if they -/// write the virtual register referenced at OperIdx. +/// addVRegUseDeps - Add a register data dependency if the instruction that +/// defines the virtual register used at OperIdx is mapped to an SUnit. Add a +/// register antidependency from this SUnit to instructions that occur later in +/// the same scheduling region if they write the virtual register. +/// +/// TODO: Handle ExitSU "uses" properly. void ScheduleDAGInstrs::addVRegUseDeps(SUnit *SU, unsigned OperIdx) { - unsigned Reg = SU->getInstr()->getOperand(OperIdx).getReg(); + MachineInstr *MI = SU->getInstr(); + unsigned Reg = MI->getOperand(OperIdx).getReg(); + + // Lookup this operand's reaching definition. + assert(LIS && "vreg dependencies requires LiveIntervals"); + SlotIndex UseIdx = LIS->getSlotIndexes()->getInstructionIndex(MI); + LiveInterval *LI = &LIS->getInterval(Reg); + VNInfo *VNI = LI->getVNInfoAt(UseIdx); + MachineInstr *Def = LIS->getInstructionFromIndex(VNI->def); + if (Def) { + SUnit *DefSU = getSUnit(Def); + if (DefSU) { + // The reaching Def lives within this scheduling region. + // Create a data dependence. + // + // TODO: Handle "special" address latencies cleanly. + const SDep &dep = SDep(DefSU, SDep::Data, DefSU->Latency, Reg); + if (!UnitLatencies) { + // Adjust the dependence latency using operand def/use information, then + // allow the target to perform its own adjustments. + ComputeOperandLatency(DefSU, SU, const_cast(dep)); + const TargetSubtargetInfo &ST = TM.getSubtarget(); + ST.adjustSchedDependency(DefSU, SU, const_cast(dep)); + } + SU->addPred(dep); + } + } // Add antidependence to the following def of the vreg it uses. - SUnit *DefSU = VRegDefs[Reg]; - if (DefSU && DefSU != SU) - DefSU->addPred(SDep(SU, SDep::Anti, 0, Reg)); + DenseMap::const_iterator I = VRegDefs.find(Reg); + if (I != VRegDefs.end()) { + SUnit *DefSU = I->second; + if (DefSU != SU) + DefSU->addPred(SDep(SU, SDep::Anti, 0, Reg)); + } +} - // Add this SUnit to the use list of the vreg it uses. - // - // TODO: pinch the DAG before we see too many uses to avoid quadratic - // behavior. Limiting the scheduling window can accomplish the same thing. - VRegUses[Reg].push_back(SU); +/// Create an SUnit for each real instruction, numbered in top-down toplological +/// order. The instruction order A < B, implies that no edge exists from B to A. +/// +/// Map each real instruction to its SUnit. +/// +/// After initSUnits, the SUnits vector is cannot be resized and the scheduler +/// may hang onto SUnit pointers. We may relax this in the future by using SUnit +/// IDs instead of pointers. +void ScheduleDAGInstrs::initSUnits() { + // We'll be allocating one SUnit for each real instruction in the region, + // which is contained within a basic block. + SUnits.reserve(BB->size()); + + for (MachineBasicBlock::iterator I = Begin; I != InsertPos; ++I) { + MachineInstr *MI = I; + if (MI->isDebugValue()) + continue; + + SUnit *SU = NewSUnit(MI); + MISUnitMap[MI] = SU; + + SU->isCall = MI->isCall(); + SU->isCommutable = MI->isCommutable(); + + // Assign the Latency field of SU using target-provided information. + if (UnitLatencies) + SU->Latency = 1; + else + ComputeLatency(SU); + } } void ScheduleDAGInstrs::BuildSchedGraph(AliasAnalysis *AA) { - // We'll be allocating one SUnit for each instruction, plus one for - // the region exit node. - SUnits.reserve(BB->size()); + // Create an SUnit for each real instruction. + initSUnits(); // We build scheduling units by walking a block's instruction list from bottom // to top. @@ -447,14 +483,7 @@ assert(Defs[i].empty() && "Only BuildGraph should push/pop Defs"); } - // Reinitialize the large VReg vectors, while reusing the memory. - // - // Note: this can be an expensive part of DAG building. We may want to be more - // clever. Reevaluate after VRegUses goes away. - assert(VRegDefs.size() == 0 && VRegUses.size() == 0 && - "Only BuildSchedGraph should access VRegDefs/Uses"); - VRegDefs.resize(MF.getRegInfo().getNumVirtRegs()); - VRegUses.resize(MF.getRegInfo().getNumVirtRegs()); + assert(VRegDefs.size() == 0 && "Only BuildSchedGraph may access VRegDefs"); // Walk the list of instructions, from bottom moving up. MachineInstr *PrevMI = NULL; @@ -473,16 +502,9 @@ assert(!MI->isTerminator() && !MI->isLabel() && "Cannot schedule terminators or labels!"); - // Create the SUnit for this MI. - SUnit *SU = NewSUnit(MI); - SU->isCall = MI->isCall(); - SU->isCommutable = MI->isCommutable(); - // Assign the Latency field of SU using target-provided information. - if (UnitLatencies) - SU->Latency = 1; - else - ComputeLatency(SU); + SUnit *SU = MISUnitMap[MI]; + assert(SU && "No SUnit mapped to this MI"); // Add register-based dependencies (data, anti, and output). for (unsigned j = 0, n = MI->getNumOperands(); j != n; ++j) { @@ -657,8 +679,8 @@ Uses[i].clear(); } VRegDefs.clear(); - VRegUses.clear(); PendingLoads.clear(); + MISUnitMap.clear(); } void ScheduleDAGInstrs::FinishBlock() { Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h?rev=151135&r1=151134&r2=151135&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h Wed Feb 22 00:08:11 2012 @@ -27,6 +27,7 @@ namespace llvm { class MachineLoopInfo; class MachineDominatorTree; + class LiveIntervals; /// LoopDependencies - This class analyzes loop-oriented register /// dependencies, which are used to guide scheduling decisions. @@ -108,6 +109,11 @@ /// isPostRA flag indicates vregs cannot be present. bool IsPostRA; + /// Live Intervals provides reaching defs in preRA scheduling. + LiveIntervals *LIS; + + DenseMap MISUnitMap; + /// UnitLatencies (misnamed) flag avoids computing def-use latencies, using /// the def-side latency only. bool UnitLatencies; @@ -119,12 +125,9 @@ std::vector > Defs; std::vector > Uses; - // Virtual register Defs and Uses. - // - // TODO: Eliminate VRegUses by creating SUnits in a prepass and looking up - // the live range's reaching def. - IndexedMap VRegDefs; - IndexedMap, VirtReg2IndexFunctor> VRegUses; + // Track the last instructon in this region defining each virtual register. + // FIXME: turn this into a sparse set with constant time clear(). + DenseMap VRegDefs; /// PendingLoads - Remember where unknown loads are after the most recent /// unknown store, as we iterate. As with Defs and Uses, this is here @@ -152,7 +155,8 @@ explicit ScheduleDAGInstrs(MachineFunction &mf, const MachineLoopInfo &mli, const MachineDominatorTree &mdt, - bool IsPostRAFlag); + bool IsPostRAFlag, + LiveIntervals *LIS = 0); virtual ~ScheduleDAGInstrs() {} @@ -169,6 +173,7 @@ return &SUnits.back(); } + /// Run - perform scheduling. /// void Run(MachineBasicBlock *bb, @@ -219,6 +224,14 @@ virtual std::string getGraphNodeLabel(const SUnit *SU) const; protected: + SUnit *getSUnit(MachineInstr *MI) const { + DenseMap::const_iterator I = MISUnitMap.find(MI); + if (I == MISUnitMap.end()) + return 0; + return I->second; + } + + void initSUnits(); void addPhysRegDeps(SUnit *SU, unsigned OperIdx); void addVRegDefDeps(SUnit *SU, unsigned OperIdx); void addVRegUseDeps(SUnit *SU, unsigned OperIdx); From atrick at apple.com Wed Feb 22 00:08:13 2012 From: atrick at apple.com (Andrew Trick) Date: Wed, 22 Feb 2012 06:08:13 -0000 Subject: [llvm-commits] [llvm] r151136 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Message-ID: <20120222060813.A68F92A6C12F@llvm.org> Author: atrick Date: Wed Feb 22 00:08:13 2012 New Revision: 151136 URL: http://llvm.org/viewvc/llvm-project?rev=151136&view=rev Log: misched: DAG builder should not track dependencies for SSA defs. The vast majority of virtual register definitions don't need an entry in the DAG builder's VRegDefs set. Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=151136&r1=151135&r2=151136&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Wed Feb 22 00:08:13 2012 @@ -44,7 +44,7 @@ LoopRegs(MLI, MDT), FirstDbgValue(0) { assert((IsPostRA || LIS) && "PreRA scheduling requires LiveIntervals"); DbgValues.clear(); - assert(!(IsPostRA && MF.getRegInfo().getNumVirtRegs()) && + assert(!(IsPostRA && MRI.getNumVirtRegs()) && "Virtual registers must be removed prior to PostRA scheduling"); } @@ -361,6 +361,10 @@ const MachineInstr *MI = SU->getInstr(); unsigned Reg = MI->getOperand(OperIdx).getReg(); + // SSA defs do not have output/anti dependencies. + if (llvm::next(MRI.def_begin(Reg)) == MRI.def_end()) + return; + // Add output dependence to the next nearest def of this vreg. // // Unless this definition is dead, the output dependence should be From nicholas at mxc.ca Wed Feb 22 00:25:23 2012 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 21 Feb 2012 22:25:23 -0800 Subject: [llvm-commits] [llvm] r151093 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/constantfold-initializers.ll In-Reply-To: <1D190D19-E8E3-4D63-A46B-DF6EA8D8D2A1@apple.com> References: <20120221220806.ED6AD2A6C12F@llvm.org> <1D190D19-E8E3-4D63-A46B-DF6EA8D8D2A1@apple.com> Message-ID: <4F448A53.8060507@mxc.ca> Chris Lattner wrote: > > On Feb 21, 2012, at 2:08 PM, Nick Lewycky wrote: > >> Author: nicholas >> Date: Tue Feb 21 16:08:06 2012 >> New Revision: 151093 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=151093&view=rev >> Log: >> Use the target-aware constant folder on expressions to improve the chance >> they'll be simple enough to simulate, and to reduce the chance we'll encounter >> equal but different simple pointer constants. >> >> This removes the symptoms from PR11352 but is not a full fix. A proper fix would >> either require a guarantee that two constant objects we simulate are folded >> when equal, or a different way of handling equal pointers (ie., trying a >> constantexpr icmp on them to see whether we know they're equal or non-equal or >> unsure). > > I think it should be enough to consider two constants the same if they are pointer equal and neither is a ConstantExpr. Sure that's sufficient, but we'd like to handle ConstantExpr's, such as an all-zero GEP. Yep, the non-TD constant folder can't pick one of: getelementptr inbounds (%closure* @f, i32 0, i32 0) getelementptr inbounds (%closure* @f, i64 0, i32 0) . Oops, and that breaks GlobalOpt. Double-oops. Really, I'd rather figure out some way to constant fold those into the same Constant* rather than teach globalopt anything new. Nick > > -Chris > >> >> Modified: >> llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp >> llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll >> >> Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=151093&r1=151092&r2=151093&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) >> +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Feb 21 16:08:06 2012 >> @@ -2388,6 +2388,8 @@ >> if (StoreInst *SI = dyn_cast(CurInst)) { >> if (!SI->isSimple()) return false; // no volatile/atomic accesses. >> Constant *Ptr = getVal(SI->getOperand(1)); >> + if (ConstantExpr *CE = dyn_cast(Ptr)) >> + Ptr = ConstantFoldConstantExpression(CE, TD, TLI); >> if (!isSimpleEnoughPointerToCommit(Ptr)) >> // If this is too complex for us to commit, reject it. >> return false; >> @@ -2423,7 +2425,9 @@ >> Constant * const IdxList[] = {IdxZero, IdxZero}; >> >> Ptr = ConstantExpr::getGetElementPtr(Ptr, IdxList); >> - >> + if (ConstantExpr *CE = dyn_cast(Ptr)) >> + Ptr = ConstantFoldConstantExpression(CE, TD, TLI); >> + >> // If we can't improve the situation by introspecting NewTy, >> // we have to give up. >> } else { >> @@ -2464,7 +2468,10 @@ >> cast(GEP)->isInBounds()); >> } else if (LoadInst *LI = dyn_cast(CurInst)) { >> if (!LI->isSimple()) return false; // no volatile/atomic accesses. >> - InstResult = ComputeLoadResult(getVal(LI->getOperand(0))); >> + Constant *Ptr = getVal(LI->getOperand(0)); >> + if (ConstantExpr *CE = dyn_cast(Ptr)) >> + Ptr = ConstantFoldConstantExpression(CE, TD, TLI); >> + InstResult = ComputeLoadResult(Ptr); >> if (InstResult == 0) return false; // Could not evaluate load. >> } else if (AllocaInst *AI = dyn_cast(CurInst)) { >> if (AI->isArrayAllocation()) return false; // Cannot handle array allocs. >> >> Modified: llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll?rev=151093&r1=151092&r2=151093&view=diff >> ============================================================================== >> --- llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll (original) >> +++ llvm/trunk/test/Transforms/GlobalOpt/constantfold-initializers.ll Tue Feb 21 16:08:06 2012 >> @@ -6,3 +6,46 @@ >> >> ; CHECK: @A = global i1 false >> @A = global i1 icmp ne (i64 sub nsw (i64 ptrtoint (i8* getelementptr inbounds ([3 x i8]* @.str91250, i64 0, i64 1) to i64), i64 ptrtoint ([3 x i8]* @.str91250 to i64)), i64 1) >> + >> +; PR11352 >> + >> + at xs = global [2 x i32] zeroinitializer, align 4 >> +; CHECK: @xs = global [2 x i32] [i32 1, i32 1] >> + >> +define internal void @test1() { >> +entry: >> + store i32 1, i32* getelementptr inbounds ([2 x i32]* @xs, i64 0, i64 0) >> + %0 = load i32* getelementptr inbounds ([2 x i32]* @xs, i32 0, i64 0), align 4 >> + store i32 %0, i32* getelementptr inbounds ([2 x i32]* @xs, i64 0, i64 1) >> + ret void >> +} >> + >> +; PR12060 >> + >> +%closure = type { i32 } >> + >> + at f = internal global %closure zeroinitializer, align 4 >> + at m = global i32 0, align 4 >> +; CHECK-NOT: @f >> +; CHECK: @m = global i32 13 >> + >> +define internal i32 @test2_helper(%closure* %this, i32 %b) { >> +entry: >> + %0 = getelementptr inbounds %closure* %this, i32 0, i32 0 >> + %1 = load i32* %0, align 4 >> + %add = add nsw i32 %1, %b >> + ret i32 %add >> +} >> + >> +define internal void @test2() { >> +entry: >> + store i32 4, i32* getelementptr inbounds (%closure* @f, i32 0, i32 0) >> + %call = call i32 @test2_helper(%closure* @f, i32 9) >> + store i32 %call, i32* @m, align 4 >> + ret void >> +} >> + >> + at llvm.global_ctors = appending constant >> + [2 x { i32, void ()* }] >> + [{ i32, void ()* } { i32 65535, void ()* @test1 }, >> + { i32, void ()* } { i32 65535, void ()* @test2 }] >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From nicholas at mxc.ca Wed Feb 22 00:28:38 2012 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 21 Feb 2012 22:28:38 -0800 Subject: [llvm-commits] [llvm] r150978 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp In-Reply-To: <95A6D725-0D4A-4D10-9D2F-6928E3383F8C@googlemail.com> References: <20120220184510.419FC2A6C12F@llvm.org> <4F435182.8040109@free.fr> <4F437BFD.70102@free.fr> <95A6D725-0D4A-4D10-9D2F-6928E3383F8C@googlemail.com> Message-ID: <4F448B16.3030403@mxc.ca> Benjamin Kramer wrote: > > On 21.02.2012, at 12:11, Duncan Sands wrote: > >> Hi Benjamin, >> >>>>> InstCombine: Removing the base from the address calculation is only safe when the GEPs are inbounds. >>>> >>>> since GEP is implicitly a signed computation, isn't this only true for signed >>>> comparisons? I.e. mightn't an inbounds GEP overflow when viewed as an unsigned >>>> computation, leading to wrongness for unsigned comparisons? >>> >>> Not sure if I understand. We're folding this to an index compare so the resulting icmp will always be signed. Also, overflow on inbounds GEPs is undefined behavior. >> >> what does "overflow" mean? Suppose a pointer has 8 bits, so the values are: >> >> -128, -127, ..., -1, 0, 1, ..., 127 >> >> Can I have an object that spans addresses -1, 0, 1? Can I have an object that >> occupies addresses 127 and -128? If either of these is yes, then we had better >> be allowing inbounds GEP that (in the first case) has an unsigned overflow, and >> (if the second case is allowed) signed overflow. Hold up. My understanding was no object can lie across -1,0 or 127,-128 in LLVM. Am I mistaken? Is there documentation on this point? If not, could this please be documented? > After some discussion on IRC it became clear that this transformation is not valid for signed ICMPs. > I added a check for them and some explanation in r151055. > > Thanks Duncan! > > - Ben > >> >> Ciao, Duncan. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From nicholas at mxc.ca Wed Feb 22 00:50:21 2012 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 21 Feb 2012 22:50:21 -0800 Subject: [llvm-commits] [llvm] r151110 - in /llvm/trunk: docs/ProgrammersManual.html include/llvm/ADT/SparseSet.h unittests/ADT/SparseSetTest.cpp unittests/CMakeLists.txt In-Reply-To: <20120222005608.78DB32A6C12F@llvm.org> References: <20120222005608.78DB32A6C12F@llvm.org> Message-ID: <4F44902D.7070003@mxc.ca> Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Tue Feb 21 18:56:08 2012 > New Revision: 151110 > > URL: http://llvm.org/viewvc/llvm-project?rev=151110&view=rev > Log: > Add a Briggs and Torczon sparse set implementation. > > For objects that can be identified by small unsigned keys, SparseSet > provides constant time clear() and fast deterministic iteration. Insert, > erase, and find operations are typically faster than hash tables. > > SparseSet is useful for keeping information about physical registers, > virtual registers, or numbered basic blocks. > Added: llvm/trunk/include/llvm/ADT/SparseSet.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SparseSet.h?rev=151110&view=auto > ============================================================================== > --- llvm/trunk/include/llvm/ADT/SparseSet.h (added) > +++ llvm/trunk/include/llvm/ADT/SparseSet.h Tue Feb 21 18:56:08 2012 > @@ -0,0 +1,259 @@ > +//===--- llvm/ADT/SparseSet.h - Sparse set ----------------------*- 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 the SparseSet class derived from the version described in > +// Briggs, Torczon, "An efficient representation for sparse sets", ACM Letters > +// on Programming Languages and Systems, Volume 2 Issue 1-4, March???Dec. 1993. Non-ASCII bytes between "March" and "Dec"? > +// Single entry set tests > +TEST(SparseSetTest, SingleEntrySet) { > + USet Set; > + Set.setUniverse(10); > + std::pair IP = Set.insert(5); > + EXPECT_TRUE(IP.second); > + EXPECT_TRUE(IP.first == Set.begin()); > + > + EXPECT_FALSE(Set.empty()); > + EXPECT_FALSE(Set.begin() == Set.end()); > + EXPECT_TRUE(Set.begin() + 1 == Set.end()); > + EXPECT_EQ(1u, Set.size()); > + > + EXPECT_TRUE(Set.find(0) == Set.end()); > + EXPECT_TRUE(Set.find(9) == Set.end()); > + > + EXPECT_FALSE(Set.count(0)); > + EXPECT_TRUE(Set.count(5)); > + > + // Redundant insert. > + IP = Set.insert(5); > + EXPECT_FALSE(IP.second); > + EXPECT_TRUE(IP.first == Set.begin()); > + > + // Erase non-existant element. "existent" Nick From craig.topper at gmail.com Wed Feb 22 01:28:11 2012 From: craig.topper at gmail.com (Craig Topper) Date: Wed, 22 Feb 2012 07:28:11 -0000 Subject: [llvm-commits] [llvm] r151138 - in /llvm/trunk: lib/Target/X86/X86ISelDAGToDAG.cpp utils/TableGen/RegisterInfoEmitter.cpp Message-ID: <20120222072811.702F72A6C12F@llvm.org> Author: ctopper Date: Wed Feb 22 01:28:11 2012 New Revision: 151138 URL: http://llvm.org/viewvc/llvm-project?rev=151138&view=rev Log: Declare register classes as const. Fix a couple pointers to register classes that weren't already const. Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=151138&r1=151137&r2=151138&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Wed Feb 22 01:28:11 2012 @@ -2269,7 +2269,7 @@ // On x86-32, only the ABCD registers have 8-bit subregisters. if (!Subtarget->is64Bit()) { - TargetRegisterClass *TRC = 0; + const TargetRegisterClass *TRC; switch (N0.getValueType().getSimpleVT().SimpleTy) { case MVT::i32: TRC = &X86::GR32_ABCDRegClass; break; case MVT::i16: TRC = &X86::GR16_ABCDRegClass; break; @@ -2298,7 +2298,7 @@ SDValue Reg = N0.getNode()->getOperand(0); // Put the value in an ABCD register. - TargetRegisterClass *TRC = 0; + const TargetRegisterClass *TRC; switch (N0.getValueType().getSimpleVT().SimpleTy) { case MVT::i64: TRC = &X86::GR64_ABCDRegClass; break; case MVT::i32: TRC = &X86::GR32_ABCDRegClass; break; Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=151138&r1=151137&r2=151138&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Wed Feb 22 01:28:11 2012 @@ -480,7 +480,7 @@ OS << " };\n"; // Output the extern for the instance. - OS << " extern " << Name << "Class\t" << Name << "RegClass;\n"; + OS << " extern const " << Name << "Class " << Name << "RegClass;\n"; // Output the extern for the pointer to the instance (should remove). OS << " static const TargetRegisterClass * const " << Name << "RegisterClass = &" << Name << "RegClass;\n"; @@ -548,8 +548,9 @@ OS << "namespace " << RegisterClasses[0]->Namespace << " { // Register class instances\n"; for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) - OS << " " << RegisterClasses[i]->getName() << "Class\t" - << RegisterClasses[i]->getName() << "RegClass;\n"; + OS << " extern const " << RegisterClasses[i]->getName() << "Class " + << RegisterClasses[i]->getName() << "RegClass = " + << RegisterClasses[i]->getName() << "Class();\n"; std::map > SuperRegClassMap; From baldrick at free.fr Wed Feb 22 01:56:40 2012 From: baldrick at free.fr (Duncan Sands) Date: Wed, 22 Feb 2012 08:56:40 +0100 Subject: [llvm-commits] [llvm] r150885 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp In-Reply-To: <86393DD4-9EBF-4098-98A3-7EC429B1A324@apple.com> References: <20120218175143.39EC02A6C12F@llvm.org> <4F400451.9030203@gmail.com> <4F402019.3020805@gmail.com> <4F40C8EE.9070003@free.fr> <4F415BC7.5090408@gmail.com> <4F4217AC.6010204@free.fr> <4F432A21.5060208@gmail.com> <86393DD4-9EBF-4098-98A3-7EC429B1A324@apple.com> Message-ID: <4F449FB8.1060506@free.fr> Hi Andrew, > // If A is an invoke instruction, its value is only available in this normal > // successor block. > if (const InvokeInst *II = dyn_cast(A)) { > BBA = II->getNormalDest(); > + if (BBA == BBB) return true; > } why is this correct? The normal destination of an invoke could have other predecessors (in that case the only possible uses of the invoke value are in phi nodes). For a routine of this generality, I think it is important to handle all cases without assuming anything about where the instructions in question came from (e.g. in Rafael's use case the logic could probably be simplified, but those special features can't be assumed here, at least not without auditing all uses of this method and documenting [and checking with assertions] the assumptions). By the way, I think the name dominatesUse is a bit confusing. After all, instructions always dominates their uses, so it sounds like it should just return "true" :) How about leaving the name "dominates" and explaining more in the comment describing the method (note that the comment in the header already doesn't match the comment here). Or just call it: dominatesInTheAppropriateWayForThisToBeAUseOfTheOther :) Ciao, Duncan. From baldrick at free.fr Wed Feb 22 02:11:42 2012 From: baldrick at free.fr (Duncan Sands) Date: Wed, 22 Feb 2012 09:11:42 +0100 Subject: [llvm-commits] [llvm] r150978 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp In-Reply-To: <4F448B16.3030403@mxc.ca> References: <20120220184510.419FC2A6C12F@llvm.org> <4F435182.8040109@free.fr> <4F437BFD.70102@free.fr> <95A6D725-0D4A-4D10-9D2F-6928E3383F8C@googlemail.com> <4F448B16.3030403@mxc.ca> Message-ID: <4F44A33E.70108@free.fr> Hi Nick, >>> what does "overflow" mean? Suppose a pointer has 8 bits, so the values are: >>> >>> -128, -127, ..., -1, 0, 1, ..., 127 >>> >>> Can I have an object that spans addresses -1, 0, 1? Can I have an object that >>> occupies addresses 127 and -128? If either of these is yes, then we had better >>> be allowing inbounds GEP that (in the first case) has an unsigned overflow, and >>> (if the second case is allowed) signed overflow. > > Hold up. My understanding was no object can lie across -1,0 or 127,-128 in LLVM. > Am I mistaken? Is there documentation on this point? If not, could this please > be documented? as a side-note, the GCC developers seem to believe that 127,-128 is possible. It came up in this thread: http://gcc.gnu.org/ml/gcc/2011-08/msg00220.html Personally I also don't see what's wrong with this. Ciao, Duncan. From glider at google.com Wed Feb 22 02:13:47 2012 From: glider at google.com (Alexander Potapenko) Date: Wed, 22 Feb 2012 08:13:47 -0000 Subject: [llvm-commits] [compiler-rt] r151139 - /compiler-rt/trunk/lib/asan/asan_procmaps.h Message-ID: <20120222081347.6AB562A6C12F@llvm.org> Author: glider Date: Wed Feb 22 02:13:47 2012 New Revision: 151139 URL: http://llvm.org/viewvc/llvm-project?rev=151139&view=rev Log: Add AsanProcMaps::Dump() Modified: compiler-rt/trunk/lib/asan/asan_procmaps.h Modified: compiler-rt/trunk/lib/asan/asan_procmaps.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_procmaps.h?rev=151139&r1=151138&r2=151139&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_procmaps.h (original) +++ compiler-rt/trunk/lib/asan/asan_procmaps.h Wed Feb 22 02:13:47 2012 @@ -28,6 +28,19 @@ // address 'addr'. Returns true on success. bool GetObjectNameAndOffset(uintptr_t addr, uintptr_t *offset, char filename[], size_t filename_size); + void Dump() { + Reset(); + uintptr_t start, end; + const intptr_t kBufSize = 4095; + char filename[kBufSize]; + Report("Process memory map follows:\n"); + while (Next(&start, &end, /* file_offset */NULL, + filename, kBufSize)) { + Printf("\t%p-%p\t%s\n", (void*)start, (void*)end, filename); + } + Report("End of process memory map.\n"); + } + ~AsanProcMaps(); private: // Default implementation of GetObjectNameAndOffset. From glider at google.com Wed Feb 22 02:27:32 2012 From: glider at google.com (Alexander Potapenko) Date: Wed, 22 Feb 2012 08:27:32 -0000 Subject: [llvm-commits] [compiler-rt] r151141 - /compiler-rt/trunk/lib/asan/asan_rtl.cc Message-ID: <20120222082732.D32162A6C12F@llvm.org> Author: glider Date: Wed Feb 22 02:27:32 2012 New Revision: 151141 URL: http://llvm.org/viewvc/llvm-project?rev=151141&view=rev Log: Dump the process memory map if any of the mappings interleaves with the shadow. Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=151141&r1=151140&r2=151141&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_rtl.cc (original) +++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Feb 22 02:27:32 2012 @@ -490,6 +490,8 @@ } else { Report("Shadow memory range interleaves with an existing memory mapping. " "ASan cannot proceed correctly. ABORTING.\n"); + AsanProcMaps proc_maps; + proc_maps.Dump(); AsanDie(); } From baldrick at free.fr Wed Feb 22 02:32:00 2012 From: baldrick at free.fr (Duncan Sands) Date: Wed, 22 Feb 2012 09:32:00 +0100 Subject: [llvm-commits] [llvm] r151125 - in /llvm/trunk: lib/Analysis/ScalarEvolutionExpander.cpp test/Transforms/LoopStrengthReduce/pr12048.ll In-Reply-To: <20120222032139.B27242A6C130@llvm.org> References: <20120222032139.B27242A6C130@llvm.org> Message-ID: <4F44A800.9050209@free.fr> Hi Rafael, > --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) > +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Tue Feb 21 21:21:39 2012 > @@ -31,11 +31,20 @@ > Value *SCEVExpander::ReuseOrCreateCast(Value *V, Type *Ty, > Instruction::CastOps Op, > BasicBlock::iterator IP) { > - // All new or reused instructions must strictly dominate their uses. > - // It would be nice to assert this here, but we don't always know where > - // the next instructions will be added as the caller can move the > - // Builder's InsertPt before creating them and we might be called with > - // an invalid InsertPt. > + // This function must be called with the builder having a valid insertion > + // point. It doesn't need to be the actual IP where the uses of the returned > + // cast will be added, but it must dominate such IP. > + // We use this precondition to assert that we can produce a cast that will > + // dominate all its uses. In particular, this is crussial for the case crussial -> crucial Ciao, Duncan. From echristo at apple.com Wed Feb 22 02:46:02 2012 From: echristo at apple.com (Eric Christopher) Date: Wed, 22 Feb 2012 08:46:02 -0000 Subject: [llvm-commits] [llvm] r151142 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Message-ID: <20120222084603.451932A6C130@llvm.org> Author: echristo Date: Wed Feb 22 02:46:02 2012 New Revision: 151142 URL: http://llvm.org/viewvc/llvm-project?rev=151142&view=rev Log: Remove extra semi-colon. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=151142&r1=151141&r2=151142&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Wed Feb 22 02:46:02 2012 @@ -616,7 +616,7 @@ // A runtime language of 0 actually means C/C++ and that any // non-negative value is some version of Objective-C/C++. IsImplementation = (CT.getRunTimeLang() == 0) || - CT.isObjcClassComplete();; + CT.isObjcClassComplete(); } unsigned Flags = IsImplementation ? DwarfAccelTable::eTypeFlagClassIsImplementation : 0; From echristo at apple.com Wed Feb 22 02:46:14 2012 From: echristo at apple.com (Eric Christopher) Date: Wed, 22 Feb 2012 08:46:14 -0000 Subject: [llvm-commits] [llvm] r151143 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfCompileUnit.cpp DwarfCompileUnit.h DwarfDebug.cpp Message-ID: <20120222084614.736A52A6C130@llvm.org> Author: echristo Date: Wed Feb 22 02:46:13 2012 New Revision: 151143 URL: http://llvm.org/viewvc/llvm-project?rev=151143&view=rev Log: Add the source language into the compile unit. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=151143&r1=151142&r2=151143&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Wed Feb 22 02:46:13 2012 @@ -32,8 +32,9 @@ using namespace llvm; /// CompileUnit - Compile unit constructor. -CompileUnit::CompileUnit(unsigned I, DIE *D, AsmPrinter *A, DwarfDebug *DW) - : ID(I), CUDie(D), Asm(A), DD(DW), IndexTyDie(0) { +CompileUnit::CompileUnit(unsigned I, unsigned L, DIE *D, AsmPrinter *A, + DwarfDebug *DW) + : ID(I), Language(L), CUDie(D), Asm(A), DD(DW), IndexTyDie(0) { DIEIntegerOne = new (DIEValueAllocator) DIEInteger(1); } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=151143&r1=151142&r2=151143&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Wed Feb 22 02:46:13 2012 @@ -36,6 +36,10 @@ /// unsigned ID; + /// Language - The DW_AT_language of the compile unit + /// + unsigned Language; + /// Die - Compile unit debug information entry. /// const OwningPtr CUDie; @@ -76,11 +80,12 @@ DenseMap ContainingTypeMap; public: - CompileUnit(unsigned I, DIE *D, AsmPrinter *A, DwarfDebug *DW); + CompileUnit(unsigned I, unsigned L, DIE *D, AsmPrinter *A, DwarfDebug *DW); ~CompileUnit(); // Accessors. unsigned getID() const { return ID; } + unsigned getLanguage() const { return Language; } DIE* getCUDie() const { return CUDie.get(); } const StringMap &getGlobalTypes() const { return GlobalTypes; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=151143&r1=151142&r2=151143&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Feb 22 02:46:13 2012 @@ -550,7 +550,7 @@ unsigned ID = GetOrCreateSourceID(FN, CompilationDir); DIE *Die = new DIE(dwarf::DW_TAG_compile_unit); - CompileUnit *NewCU = new CompileUnit(ID, Die, Asm, this); + CompileUnit *NewCU = new CompileUnit(ID, DIUnit.getLanguage(), Die, Asm, this); NewCU->addString(Die, dwarf::DW_AT_producer, DIUnit.getProducer()); NewCU->addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2, DIUnit.getLanguage()); From echristo at apple.com Wed Feb 22 02:46:21 2012 From: echristo at apple.com (Eric Christopher) Date: Wed, 22 Feb 2012 08:46:21 -0000 Subject: [llvm-commits] [llvm] r151144 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp test/DebugInfo/X86/DW_AT_specification.ll test/DebugInfo/X86/concrete_out_of_line.ll test/DebugInfo/X86/pr11300.ll Message-ID: <20120222084622.707321BE003@llvm.org> Author: echristo Date: Wed Feb 22 02:46:21 2012 New Revision: 151144 URL: http://llvm.org/viewvc/llvm-project?rev=151144&view=rev Log: Only add DW_AT_prototyped if we're working with a C-like language. Worth another 45k (1%) off of a large C++ testcase. rdar://10909458 Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll llvm/trunk/test/DebugInfo/X86/pr11300.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=151144&r1=151143&r2=151144&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Wed Feb 22 02:46:21 2012 @@ -780,8 +780,12 @@ Buffer.addChild(Arg); } } - // Add prototype flag. - if (isPrototyped) + // Add prototype flag if we're dealing with a C language and the + // function has been prototyped. + if (isPrototyped && + (Language == dwarf::DW_LANG_C89 || + Language == dwarf::DW_LANG_C99 || + Language == dwarf::DW_LANG_ObjC)) addUInt(&Buffer, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1); } break; @@ -1023,7 +1027,12 @@ addSourceLine(SPDie, SP); - if (SP.isPrototyped()) + // Add the prototype if we have a prototype and we have a C like + // language. + if (SP.isPrototyped() && + (Language == dwarf::DW_LANG_C89 || + Language == dwarf::DW_LANG_C99 || + Language == dwarf::DW_LANG_ObjC)) addUInt(SPDie, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1); // Add Return Type. Modified: llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll?rev=151144&r1=151143&r2=151144&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll (original) +++ llvm/trunk/test/DebugInfo/X86/DW_AT_specification.ll Wed Feb 22 02:46:21 2012 @@ -4,7 +4,7 @@ ; test that the DW_AT_specification is a back edge in the file. ; CHECK: 0x00000038: DW_TAG_subprogram [5] * -; CHECK: 0x0000005f: DW_AT_specification [DW_FORM_ref4] (cu + 0x0038 => {0x00000038}) +; CHECK: 0x0000005e: DW_AT_specification [DW_FORM_ref4] (cu + 0x0038 => {0x00000038}) @_ZZN3foo3barEvE1x = constant i32 0, align 4 Modified: llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll?rev=151144&r1=151143&r2=151144&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll (original) +++ llvm/trunk/test/DebugInfo/X86/concrete_out_of_line.ll Wed Feb 22 02:46:21 2012 @@ -7,7 +7,7 @@ ; first check that we have a TAG_subprogram at a given offset and it has ; AT_inline. -; CHECK: 0x00000134: DW_TAG_subprogram +; CHECK: 0x00000130: DW_TAG_subprogram [18] ; CHECK-NEXT: DW_AT_MIPS_linkage_name ; CHECK-NEXT: DW_AT_specification ; CHECK-NEXT: DW_AT_inline @@ -15,8 +15,8 @@ ; and then that a TAG_subprogram refers to it with AT_abstract_origin. -; CHECK: 0x00000184: DW_TAG_subprogram -; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x0134 => {0x00000134}) +; CHECK: 0x00000180: DW_TAG_subprogram [20] +; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x0130 => {0x00000130}) define i32 @_ZN17nsAutoRefCnt7ReleaseEv() { entry: Modified: llvm/trunk/test/DebugInfo/X86/pr11300.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/pr11300.ll?rev=151144&r1=151143&r2=151144&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/X86/pr11300.ll (original) +++ llvm/trunk/test/DebugInfo/X86/pr11300.ll Wed Feb 22 02:46:21 2012 @@ -3,8 +3,8 @@ ; test that the DW_AT_specification is a back edge in the file. -; CHECK: 0x0000005b: DW_TAG_subprogram [5] -; CHECK: 0x0000007c: DW_AT_specification [DW_FORM_ref4] (cu + 0x005b => {0x0000005b}) +; CHECK: 0x0000005a: DW_TAG_subprogram [5] +; CHECK: 0x0000007a: DW_AT_specification [DW_FORM_ref4] (cu + 0x005a => {0x0000005a}) %struct.foo = type { i8 } From timurrrr at google.com Wed Feb 22 02:56:25 2012 From: timurrrr at google.com (Timur Iskhodzhanov) Date: Wed, 22 Feb 2012 08:56:25 -0000 Subject: [llvm-commits] [compiler-rt] r151145 - /compiler-rt/trunk/lib/asan/interception/interception_linux.h Message-ID: <20120222085625.9420F2A6C12F@llvm.org> Author: timurrrr Date: Wed Feb 22 02:56:25 2012 New Revision: 151145 URL: http://llvm.org/viewvc/llvm-project?rev=151145&view=rev Log: [ASan] Fix a wrong filename mentioned in a comment Modified: compiler-rt/trunk/lib/asan/interception/interception_linux.h Modified: compiler-rt/trunk/lib/asan/interception/interception_linux.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/interception/interception_linux.h?rev=151145&r1=151144&r2=151145&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/interception/interception_linux.h (original) +++ compiler-rt/trunk/lib/asan/interception/interception_linux.h Wed Feb 22 02:56:25 2012 @@ -15,7 +15,7 @@ #ifdef __linux__ #if !defined(INCLUDED_FROM_INTERCEPTION_LIB) -# error "interception_mac.h should be included from interception library only" +# error "interception_linux.h should be included from interception library only" #endif #ifndef INTERCEPTION_LINUX_H From glider at google.com Wed Feb 22 03:11:55 2012 From: glider at google.com (Alexander Potapenko) Date: Wed, 22 Feb 2012 09:11:55 -0000 Subject: [llvm-commits] [compiler-rt] r151147 - in /compiler-rt/trunk/lib/asan: asan_internal.h asan_posix.cc asan_procmaps.h asan_rtl.cc asan_win.cc Message-ID: <20120222091155.BB0042A6C12F@llvm.org> Author: glider Date: Wed Feb 22 03:11:55 2012 New Revision: 151147 URL: http://llvm.org/viewvc/llvm-project?rev=151147&view=rev Log: Move the contents of AsanProcMaps::Dump() into AsanDumpProcessMaps() for Posix systems. Define AsanDumpProcessMaps as unimplemented on Windows. This should fix the Windows build. Modified: compiler-rt/trunk/lib/asan/asan_internal.h compiler-rt/trunk/lib/asan/asan_posix.cc compiler-rt/trunk/lib/asan/asan_procmaps.h compiler-rt/trunk/lib/asan/asan_rtl.cc compiler-rt/trunk/lib/asan/asan_win.cc Modified: compiler-rt/trunk/lib/asan/asan_internal.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=151147&r1=151146&r2=151147&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_internal.h (original) +++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Feb 22 03:11:55 2012 @@ -130,6 +130,7 @@ bool AsanShadowRangeIsAvailable(); int AsanOpenReadonly(const char* filename); const char *AsanGetEnv(const char *name); +void AsanDumpProcessMap(); void *AsanMmapFixedNoReserve(uintptr_t fixed_addr, size_t size); void *AsanMmapFixedReserve(uintptr_t fixed_addr, size_t size); Modified: compiler-rt/trunk/lib/asan/asan_posix.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_posix.cc?rev=151147&r1=151146&r2=151147&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_posix.cc (original) +++ compiler-rt/trunk/lib/asan/asan_posix.cc Wed Feb 22 03:11:55 2012 @@ -15,6 +15,7 @@ #include "asan_internal.h" #include "asan_interceptors.h" +#include "asan_procmaps.h" #include "asan_stack.h" #include "asan_thread_registry.h" @@ -69,6 +70,19 @@ setrlimit(RLIMIT_CORE, &nocore); } +void AsanDumpProcessMap() { + AsanProcMaps proc_maps; + uintptr_t start, end; + const intptr_t kBufSize = 4095; + char filename[kBufSize]; + Report("Process memory map follows:\n"); + while (proc_maps.Next(&start, &end, /* file_offset */NULL, + filename, kBufSize)) { + Printf("\t%p-%p\t%s\n", (void*)start, (void*)end, filename); + } + Report("End of process memory map.\n"); +} + int GetPid() { return getpid(); } Modified: compiler-rt/trunk/lib/asan/asan_procmaps.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_procmaps.h?rev=151147&r1=151146&r2=151147&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_procmaps.h (original) +++ compiler-rt/trunk/lib/asan/asan_procmaps.h Wed Feb 22 03:11:55 2012 @@ -28,19 +28,6 @@ // address 'addr'. Returns true on success. bool GetObjectNameAndOffset(uintptr_t addr, uintptr_t *offset, char filename[], size_t filename_size); - void Dump() { - Reset(); - uintptr_t start, end; - const intptr_t kBufSize = 4095; - char filename[kBufSize]; - Report("Process memory map follows:\n"); - while (Next(&start, &end, /* file_offset */NULL, - filename, kBufSize)) { - Printf("\t%p-%p\t%s\n", (void*)start, (void*)end, filename); - } - Report("End of process memory map.\n"); - } - ~AsanProcMaps(); private: // Default implementation of GetObjectNameAndOffset. Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=151147&r1=151146&r2=151147&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_rtl.cc (original) +++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Feb 22 03:11:55 2012 @@ -17,7 +17,6 @@ #include "asan_internal.h" #include "asan_lock.h" #include "asan_mapping.h" -#include "asan_procmaps.h" #include "asan_stack.h" #include "asan_stats.h" #include "asan_thread.h" @@ -490,8 +489,7 @@ } else { Report("Shadow memory range interleaves with an existing memory mapping. " "ASan cannot proceed correctly. ABORTING.\n"); - AsanProcMaps proc_maps; - proc_maps.Dump(); + AsanDumpProcessMap(); AsanDie(); } Modified: compiler-rt/trunk/lib/asan/asan_win.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=151147&r1=151146&r2=151147&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_win.cc (original) +++ compiler-rt/trunk/lib/asan/asan_win.cc Wed Feb 22 03:11:55 2012 @@ -232,6 +232,10 @@ return NULL; } +void AsanDumpProcessMap() { + UNIMPLEMENTED(); +} + int GetPid() { return GetProcessId(GetCurrentProcess()); } From eugeni.stepanov at gmail.com Wed Feb 22 03:21:02 2012 From: eugeni.stepanov at gmail.com (Evgeniy Stepanov) Date: Wed, 22 Feb 2012 09:21:02 -0000 Subject: [llvm-commits] [compiler-rt] r151148 - /compiler-rt/trunk/LICENSE.TXT Message-ID: <20120222092102.5AFD42A6C12F@llvm.org> Author: eugenis Date: Wed Feb 22 03:21:02 2012 New Revision: 151148 URL: http://llvm.org/viewvc/llvm-project?rev=151148&view=rev Log: Update source code links in LICENSE.TXT. mach_override has been moved to a different path. sysinfo is gone. Modified: compiler-rt/trunk/LICENSE.TXT Modified: compiler-rt/trunk/LICENSE.TXT URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/LICENSE.TXT?rev=151148&r1=151147&r2=151148&view=diff ============================================================================== --- compiler-rt/trunk/LICENSE.TXT (original) +++ compiler-rt/trunk/LICENSE.TXT Wed Feb 22 03:21:02 2012 @@ -94,5 +94,4 @@ Program Directory ------- --------- -sysinfo lib/asan/sysinfo -mach_override lib/asan/mach_override +mach_override lib/asan/interception/mach_override From timurrrr at google.com Wed Feb 22 03:28:15 2012 From: timurrrr at google.com (Timur Iskhodzhanov) Date: Wed, 22 Feb 2012 09:28:15 -0000 Subject: [llvm-commits] [compiler-rt] r151149 - /compiler-rt/trunk/lib/asan/asan_rtl.cc Message-ID: <20120222092815.30C512A6C12F@llvm.org> Author: timurrrr Date: Wed Feb 22 03:28:14 2012 New Revision: 151149 URL: http://llvm.org/viewvc/llvm-project?rev=151149&view=rev Log: [ASan] Fix style + suppress 'long' lint warnings Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=151149&r1=151148&r2=151149&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_rtl.cc (original) +++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Feb 22 03:28:14 2012 @@ -517,6 +517,6 @@ // On Windows, when using dynamic CRT (/MD), we can put a pointer // to __asan_init into the global list of C initializers. // See crt0dat.c in the CRT sources for the details. - #pragma section(".CRT$XIB",long,read) + #pragma section(".CRT$XIB", long, read) // NOLINT __declspec(allocate(".CRT$XIB")) void (*__asan_preinit)() = __asan_init; #endif From chandlerc at gmail.com Wed Feb 22 05:32:55 2012 From: chandlerc at gmail.com (Chandler Carruth) Date: Wed, 22 Feb 2012 11:32:55 -0000 Subject: [llvm-commits] [llvm] r151156 - in /llvm/trunk: include/llvm/ADT/Triple.h lib/Support/Triple.cpp unittests/ADT/TripleTest.cpp Message-ID: <20120222113255.3BA402A6C12F@llvm.org> Author: chandlerc Date: Wed Feb 22 05:32:54 2012 New Revision: 151156 URL: http://llvm.org/viewvc/llvm-project?rev=151156&view=rev Log: Support was removed from LLVM's MIPS backend for the PSP variant of that chip in r139383, and the PSP components of the triple are really annoying to parse. Let's leave this chapter behind. There is no reason to expect LLVM to see a PSP-related triple these days, and so no reasonable motivation to support them. It might be reasonable to prune a few of the older MIPS triple forms in general, but as those at least cause no burden on parsing (they aren't both a chip and an OS!), I'm happy to leave them in for now. Modified: llvm/trunk/include/llvm/ADT/Triple.h llvm/trunk/lib/Support/Triple.cpp llvm/trunk/unittests/ADT/TripleTest.cpp Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=151156&r1=151155&r2=151156&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Wed Feb 22 05:32:54 2012 @@ -47,7 +47,7 @@ cellspu, // CellSPU: spu, cellspu hexagon, // Hexagon: hexagon mips, // MIPS: mips, mipsallegrex - mipsel, // MIPSEL: mipsel, mipsallegrexel, psp + mipsel, // MIPSEL: mipsel, mipsallegrexel mips64, // MIPS64: mips64 mips64el,// MIPS64EL: mips64el msp430, // MSP430: msp430 @@ -89,7 +89,6 @@ MinGW32, // i*86-pc-mingw32, *-w64-mingw32 NetBSD, OpenBSD, - Psp, Solaris, Win32, Haiku, Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=151156&r1=151155&r2=151156&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Wed Feb 22 05:32:54 2012 @@ -107,7 +107,6 @@ case MinGW32: return "mingw32"; case NetBSD: return "netbsd"; case OpenBSD: return "openbsd"; - case Psp: return "psp"; case Solaris: return "solaris"; case Win32: return "win32"; case Haiku: return "haiku"; @@ -232,7 +231,7 @@ .Cases("spu", "cellspu", Triple::cellspu) .Case("msp430", Triple::msp430) .Cases("mips", "mipseb", "mipsallegrex", Triple::mips) - .Cases("mipsel", "mipsallegrexel", "psp", Triple::mipsel) + .Cases("mipsel", "mipsallegrexel", Triple::mipsel) .Cases("mips64", "mips64eb", Triple::mips64) .Case("mips64el", Triple::mips64el) .Case("hexagon", Triple::hexagon) @@ -270,7 +269,6 @@ .StartsWith("mingw32", Triple::MinGW32) .StartsWith("netbsd", Triple::NetBSD) .StartsWith("openbsd", Triple::OpenBSD) - .StartsWith("psp", Triple::Psp) .StartsWith("solaris", Triple::Solaris) .StartsWith("win32", Triple::Win32) .StartsWith("haiku", Triple::Haiku) Modified: llvm/trunk/unittests/ADT/TripleTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/TripleTest.cpp?rev=151156&r1=151155&r2=151156&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/TripleTest.cpp (original) +++ llvm/trunk/unittests/ADT/TripleTest.cpp Wed Feb 22 05:32:54 2012 @@ -162,12 +162,6 @@ for (int OS = 1+Triple::UnknownOS; OS <= Triple::Minix; ++OS) { C[2] = Triple::getOSTypeName(Triple::OSType(OS)); - // If a value has multiple interpretations, then the permutation - // test will inevitably fail. Currently this is only the case for - // "psp" which parses as both an architecture and an O/S. - if (OS == Triple::Psp) - continue; - std::string E = Join(C[0], C[1], C[2]); EXPECT_EQ(E, Triple::normalize(Join(C[0], C[1], C[2]))); @@ -212,9 +206,6 @@ } } - EXPECT_EQ("a-b-psp", Triple::normalize("a-b-psp")); - EXPECT_EQ("psp-b-c", Triple::normalize("psp-b-c")); - // Various real-world funky triples. The value returned by GCC's config.sub // is given in the comment. EXPECT_EQ("i386--mingw32", Triple::normalize("i386-mingw32")); // i386-pc-mingw32 From samsonov at google.com Wed Feb 22 05:59:44 2012 From: samsonov at google.com (Alexey Samsonov) Date: Wed, 22 Feb 2012 11:59:44 -0000 Subject: [llvm-commits] [compiler-rt] r151157 - /compiler-rt/trunk/lib/asan/Makefile.old Message-ID: <20120222115944.94B322A6C12F@llvm.org> Author: samsonov Date: Wed Feb 22 05:59:44 2012 New Revision: 151157 URL: http://llvm.org/viewvc/llvm-project?rev=151157&view=rev Log: AddressSanitizer: fix Makefile.old - gtest should depend on libasan Modified: compiler-rt/trunk/lib/asan/Makefile.old Modified: compiler-rt/trunk/lib/asan/Makefile.old URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/Makefile.old?rev=151157&r1=151156&r2=151157&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/Makefile.old (original) +++ compiler-rt/trunk/lib/asan/Makefile.old Wed Feb 22 05:59:44 2012 @@ -320,7 +320,7 @@ asan_benchmarks: $(BIN)/asan_benchmarks$(SUFF) # for now, build gtest with clang/asan even if we use a different compiler. -$(GTEST_LIB): +$(GTEST_LIB): $(LIBASAN_A) mkdir -p $(GTEST_MAKE_DIR) && \ cd $(GTEST_MAKE_DIR) && \ $(MAKE) -f ../make/Makefile CXXFLAGS="$(PIE) $(CFLAGS) -g -w" \ From jay.foad at gmail.com Wed Feb 22 06:15:10 2012 From: jay.foad at gmail.com (Jay Foad) Date: Wed, 22 Feb 2012 12:15:10 +0000 Subject: [llvm-commits] [PATCH] RFC: fix some problems in GeneralHash Message-ID: What do you think of the attached patch? It: 1. Fixes the theoretical problem with GeneralHash::addUnaligned returning varying results on big-endian hosts. 2. Fixes the strict aliasing problems that foiled my attempt to apply Meador's patch to improve uniquing of struct and function types. 3. Moves GeneralHash::finish and GeneralHash::mix out of line. This is just a matter of taste, but the inlined code looked a bit long-winded to me. It also simplifies and combines addAligned and addUnaligned into a single inline function addBytes that covers all cases, and relies on the compiler to optimise away the calls to memcpy. This mostly seems to work, except that GCC doesn't seem to be clever enough to optimise away the whole of: if (I != E) { Data = 0; std::memcpy(&Data, I, E - I); mix(Data); } ... when addBits is called with a type which is known to be at least 4-aligned. Can I change the code a bit to help the compiler out? Tested with "make check-all", llvm + clang, on a Release+Asserts build built with GCC 4.4.6-11ubuntu2 on Ubuntu 11.10 x86_64. Thanks, Jay. -------------- next part -------------- A non-text attachment was scrubbed... Name: hashing.patch Type: text/x-patch Size: 3952 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/777fde3c/attachment.bin From chandlerc at gmail.com Wed Feb 22 06:15:27 2012 From: chandlerc at gmail.com (Chandler Carruth) Date: Wed, 22 Feb 2012 04:15:27 -0800 Subject: [llvm-commits] PATCH: Refactor LLVM's triple normalization Message-ID: Latest patch in the series re-working llvm::Triple to be more suitable for use inside of a cross-compiling FE. I think this version is easier to read. It burns most of the lines of code on asserts and an enum now. It is however much less efficient. ;] Let me know if there is some concern with that. It at least shouldn't need the heap for any sane inputs. The variable names are lame. Let me know if you have better ideas. If you see any ways to simplify further, please point them out. More details in the commit log.... Commit Log: Rewrite the normalization logic to be a bit simpler, and to take advantage of the fact that a triplet cannot parse as more than a single kind. The primary shift is to do less permuting of the triplets as they are parsed, and to do the parse is phases. One of the benefits is that this structure lends itself to further refactorings I'm working on for the Triple, to allow it to parse an un-normalized triple non-destructively. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/20eb91e0/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: triple-normalize-refactor.patch Type: text/x-patch Size: 11422 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/20eb91e0/attachment.bin From chandlerc at google.com Wed Feb 22 06:27:50 2012 From: chandlerc at google.com (Chandler Carruth) Date: Wed, 22 Feb 2012 04:27:50 -0800 Subject: [llvm-commits] [PATCH] RFC: fix some problems in GeneralHash In-Reply-To: References: Message-ID: On Wed, Feb 22, 2012 at 4:15 AM, Jay Foad wrote: > What do you think of the attached patch? It: > > 1. Fixes the theoretical problem with GeneralHash::addUnaligned > returning varying results on big-endian hosts. > 2. Fixes the strict aliasing problems that foiled my attempt to apply > Meador's patch to improve uniquing of struct and function types. > This is definitely the way to go. memcpy is the only safe technique here, and compilers should optimize it harder. > 3. Moves GeneralHash::finish and GeneralHash::mix out of line. This is > just a matter of taste, but the inlined code looked a bit long-winded > to me. > Please leave these inline. They seem quite good candidates for inlining. Feel free to define them out of the class body, but still in the header file... It also simplifies and combines addAligned and addUnaligned into a > single inline function addBytes that covers all cases, and relies on > the compiler to optimise away the calls to memcpy. This mostly seems > to work, except that GCC doesn't seem to be clever enough to optimise > away the whole of: > > if (I != E) { > Data = 0; > std::memcpy(&Data, I, E - I); > mix(Data); > } > > ... when addBits is called with a type which is known to be at least 4-aligned. Can I change the code a bit to help the compiler out? > No, the compiler should handle this. I completely agree with the decision to let the compile deduce and figure out alignment optimizations. A few comments on the patch: - template - struct addBitsImpl { - static void add(GeneralHash &Hash, const T *I, const T *E) { - Hash.addUnaligned( - reinterpret_cast(I), - reinterpret_cast(E)); + // Add a range of bytes from I to E. + void addBytes(const char *I, const char *E) { + uint32_t Data; + // Use memcpy to work around strict aliasing rules. Not work around, this is simply required by the standard... I don't think you need this comment at all actually. + for (; E - I >= ptrdiff_t(sizeof Data); I += sizeof Data) { + // A clever compiler should be able to turn this memcpy into a single + // aligned or unaligned load (depending on the alignment of the type T + // that was used in the call to addBits). + std::memcpy(&Data, I, sizeof Data); + mix(Data); } - }; - - template - struct addBitsImpl { - static void add(GeneralHash &Hash, const T *I, const T *E) { - Hash.addAligned( - reinterpret_cast(I), - reinterpret_cast(E)); + if (I != E) { + Data = 0; + std::memcpy(&Data, I, E - I); + mix(Data); } - }; + } // Add a range of bits from I to E. template void addBits(const T *I, const T *E) { - addBitsImpl::Alignment_GreaterEqual_4Bytes>::add(*this, I, E); + addBytes(reinterpret_cast(I), + reinterpret_cast(E)); Can we get rid of these reinterpret casts and retain the exact type all the way through? I don't see any real benefit to changing the types, and I think it'll make it more obvious to the reader. It may also fix some of the alignment issues by forcing an instantiation with a particular type pointer for which the compiler knows more about the alignment. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/6fea8366/attachment.html From eugeni.stepanov at gmail.com Wed Feb 22 06:31:25 2012 From: eugeni.stepanov at gmail.com (Evgeniy Stepanov) Date: Wed, 22 Feb 2012 12:31:25 -0000 Subject: [llvm-commits] [compiler-rt] r151158 - /compiler-rt/trunk/lib/asan/asan_interceptors.cc Message-ID: <20120222123125.CCEC52A6C12F@llvm.org> Author: eugenis Date: Wed Feb 22 06:31:25 2012 New Revision: 151158 URL: http://llvm.org/viewvc/llvm-project?rev=151158&view=rev Log: [asan] Remove mentions of pthread*_t from interceptors. Some platforms do not define pthread_t in stdlib.h. Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=151158&r1=151157&r2=151158&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original) +++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Wed Feb 22 06:31:25 2012 @@ -268,9 +268,8 @@ } #ifndef _WIN32 -INTERCEPTOR(int, pthread_create, pthread_t *thread, - const pthread_attr_t *attr, - void *(*start_routine)(void*), void *arg) { +INTERCEPTOR(int, pthread_create, void *thread, + void *attr, void *(*start_routine)(void*), void *arg) { GET_STACK_TRACE_HERE(kStackTraceMax); int current_tid = asanThreadRegistry().GetCurrentTidOrMinusOne(); AsanThread *t = AsanThread::Create(current_tid, start_routine, arg, &stack); From jay.foad at gmail.com Wed Feb 22 06:39:43 2012 From: jay.foad at gmail.com (Jay Foad) Date: Wed, 22 Feb 2012 12:39:43 +0000 Subject: [llvm-commits] [PATCH] RFC: fix some problems in GeneralHash In-Reply-To: References: Message-ID: On 22 February 2012 12:27, Chandler Carruth wrote: > Please leave these inline. They seem quite good candidates for inlining. > Feel free to define them out of the class body, but still in the header > file... Fair enough. (I suppose my complaint is that GCC seemed to be inlining too much, but that's not a good reason to change the source code.) >> It also simplifies and combines addAligned and addUnaligned into a >> single inline function addBytes that covers all cases, and relies on >> the compiler to optimise away the calls to memcpy. This mostly seems >> to work, except that GCC doesn't seem to be clever enough to optimise >> away the whole of: >> >> ? ?if (I != E) { >> ? ? ?Data = 0; >> ? ? ?std::memcpy(&Data, I, E - I); >> ? ? ?mix(Data); >> ? ?} >> >> ... when addBits is called with a type which is known to be at least >> >> 4-aligned. Can I change the code a bit to help the compiler out? > > > No, the compiler should handle this. I think maybe it can't remove the "if (I != E)" because it has to cope with the possibility that I > E. But I'm not sure, and changing the condition to "if (I < E)" didn't seem to help. > + ? ?// Use memcpy to work around strict aliasing rules. > > Not work around, this is simply required by the standard... I don't think > you need this comment at all actually. Well, I didn't say it was working around a *bug*, it's just working around some rules in the standard that got in the way of a more obvious coding. > ? ?// Add a range of bits from I to E. > ? ?template > ? ?void addBits(const T *I, const T *E) { > - ? ?addBitsImpl::Alignment_GreaterEqual_4Bytes>::add(*this, > I, E); > + ? ?addBytes(reinterpret_cast(I), > + ? ? ? ? ? ? reinterpret_cast(E)); > > Can we get rid of these reinterpret casts and retain the exact type all the > way through? I don't see any real benefit to changing the types, and I think > it'll make it more obvious to the reader. > > It may also fix some of the alignment issues by forcing an instantiation > with a particular type pointer for which the compiler knows more about the > alignment. At some point I need to convert to char* so I can do byte-based pointer arithmetic, specifically in these two lines: + for (; E - I >= ptrdiff_t(sizeof Data); I += sizeof Data) { + std::memcpy(&Data, I, E - I); Do you have a better way of writing this? Thanks, Jay. From samsonov at google.com Wed Feb 22 06:54:05 2012 From: samsonov at google.com (Alexey Samsonov) Date: Wed, 22 Feb 2012 12:54:05 -0000 Subject: [llvm-commits] [compiler-rt] r151159 - in /compiler-rt/trunk/lib/asan: asan_interceptors.cc asan_internal.h Message-ID: <20120222125405.340172A6C12F@llvm.org> Author: samsonov Date: Wed Feb 22 06:54:04 2012 New Revision: 151159 URL: http://llvm.org/viewvc/llvm-project?rev=151159&view=rev Log: AddressSanitizer: get rid of limits.h, use constants for fixed size integral types instead. Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc compiler-rt/trunk/lib/asan/asan_internal.h Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=151159&r1=151158&r2=151159&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original) +++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Wed Feb 22 06:54:04 2012 @@ -24,7 +24,6 @@ #include "interception/interception.h" #include -#include #if defined(_WIN32) // FIXME: remove when we start intercepting on Windows. Currently it's needed to @@ -132,9 +131,9 @@ nptr++; } while (IsDigit(*nptr)) { - res = (res <= ULLONG_MAX / 10) ? res * 10 : ULLONG_MAX; + res = (res <= UINT64_MAX / 10) ? res * 10 : UINT64_MAX; int digit = ((*nptr) - '0'); - res = (res <= ULLONG_MAX - digit) ? res + digit : ULLONG_MAX; + res = (res <= UINT64_MAX - digit) ? res + digit : UINT64_MAX; have_digits = true; nptr++; } @@ -142,9 +141,9 @@ *endptr = (have_digits) ? (char*)nptr : old_nptr; } if (sgn > 0) { - return (int64_t)(Min((uint64_t)LLONG_MAX, res)); + return (int64_t)(Min((uint64_t)INT64_MAX, res)); } else { - return (res > LLONG_MAX) ? LLONG_MIN : ((int64_t)res * -1); + return (res > INT64_MAX) ? INT64_MIN : ((int64_t)res * -1); } } Modified: compiler-rt/trunk/lib/asan/asan_internal.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=151159&r1=151158&r2=151159&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_internal.h (original) +++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Feb 22 06:54:04 2012 @@ -59,6 +59,22 @@ #endif #endif +// Limits for integral types. We have to redefine it in case we don't +// have stdint.h (like in Visual Studio 9). +#if __WORDSIZE == 64 +# define __INT64_C(c) c ## L +# define __UINT64_C(c) c ## UL +#else +# define __INT64_C(c) c ## LL +# define __UINT64_C(c) c ## ULL +#endif // __WORDSIZE == 64 +# define INT32_MIN (-2147483647-1) +# define INT32_MAX (2147483647) +# define UINT32_MAX (4294967295U) +# define INT64_MIN (-__INT64_C(9223372036854775807)-1) +# define INT64_MAX (__INT64_C(9223372036854775807)) +# define UINT64_MAX (__UINT64_C(18446744073709551615)) + #if defined(__linux__) # define ASAN_LINUX 1 #else From timurrrr at google.com Wed Feb 22 07:04:16 2012 From: timurrrr at google.com (timurrrr at google.com) Date: Wed, 22 Feb 2012 13:04:16 +0000 Subject: [llvm-commits] [ASan] Intercept functions on Windows - first version (issue 5690065) Message-ID: <001636ed73513923a104b98d2a22@google.com> Reviewers: glider, Evgeniy Stepanov, Message: Hi Alexander, Evgeniy, Can you please review this patch? It adds some basic support for function interception on Windows. Thanks, Timur Description: [ASan] Intercept functions on Windows - first version Please review this at http://codereview.appspot.com/5690065/ Affected files: M lib/asan/asan_interceptors.cc M lib/asan/asan_malloc_win.cc M lib/asan/asan_win.cc M lib/asan/interception/interception.h A lib/asan/interception/interception_win.cc A lib/asan/interception/interception_win.h From samsonov at google.com Wed Feb 22 07:16:05 2012 From: samsonov at google.com (samsonov at google.com) Date: Wed, 22 Feb 2012 13:16:05 +0000 Subject: [llvm-commits] [ASan] Intercept functions on Windows - first version (issue 5690065) Message-ID: <20cf305e24e77aa0d004b98d54cc@google.com> On 2012/02/22 13:04:16, timurrrr_at_google_com wrote: > Hi Alexander, Evgeniy, > Can you please review this patch? > It adds some basic support for function interception on Windows. IMO InitializeAllInterceptors() really does look horrible now :) I think we need to use functions like: InitializeSignalInterceptors() InitializePthreadInterceptors() InitializeGCDInterceptors() and so on. Probably these functions can be defined in their own .cc file, but even now they may simplify things. Also, what about using if (ASAN_WINDOWS)? > Thanks, > Timur http://codereview.appspot.com/5690065/ From eugeni.stepanov at gmail.com Wed Feb 22 07:16:46 2012 From: eugeni.stepanov at gmail.com (Evgeniy Stepanov) Date: Wed, 22 Feb 2012 17:16:46 +0400 Subject: [llvm-commits] [PATCH] [asan] Code style fixup Message-ID: Hi, #ifdef is evil, so this patch replaces several #ifdef with plain if(). As a result, the code contains less #ifdefs, but more if()s, than before. Please review. -------------- next part -------------- A non-text attachment was scrubbed... Name: ifdef-is-evil.patch Type: text/x-patch Size: 4145 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/a894f6c6/attachment.bin From samsonov at google.com Wed Feb 22 07:40:10 2012 From: samsonov at google.com (Alexey Samsonov) Date: Wed, 22 Feb 2012 17:40:10 +0400 Subject: [llvm-commits] [ASan] Intercept functions on Windows - first version (issue 5690065) In-Reply-To: <20cf305e24e77aa0d004b98d54cc@google.com> References: <20cf305e24e77aa0d004b98d54cc@google.com> Message-ID: On Wed, Feb 22, 2012 at 5:16 PM, wrote: > On 2012/02/22 13:04:16, timurrrr_at_google_com wrote: > >> Hi Alexander, Evgeniy, >> > > Can you please review this patch? >> It adds some basic support for function interception on Windows. >> > > IMO InitializeAllInterceptors() really does look horrible now :) > I think we need to use functions like: > InitializeSignalInterceptors() > InitializePthreadInterceptors(**) > InitializeGCDInterceptors() > and so on. Probably these functions can be defined in their own .cc > file, but even now they may simplify things. > > Also, what about using if (ASAN_WINDOWS)? > omg, if (ASAN_WINDOWS) can be a problem as we'll still need to resolve symbols that can be undefined on a given os. > > Thanks, >> Timur >> > > > > http://codereview.appspot.com/**5690065/ > -- Alexey Samsonov Software Engineer, Moscow samsonov at google.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/5d319ad8/attachment.html From samsonov at google.com Wed Feb 22 07:45:24 2012 From: samsonov at google.com (samsonov at google.com) Date: Wed, 22 Feb 2012 13:45:24 +0000 Subject: [llvm-commits] PATCH: AddressSanitizer: get rid of stdlib.h, leave (smaller) stddef.h instead. (issue 5689069) Message-ID: <20cf303bfd22536e3704b98dbdf6@google.com> Reviewers: ramosian.glider, timurrrr_at_google_com, Evgeniy Stepanov, Please review this at http://codereview.appspot.com/5689069/ Affected files: M asan_interface.h M asan_internal.h M asan_posix.cc M asan_rtl.cc M asan_win.cc -------------- next part -------------- Index: asan_rtl.cc =================================================================== --- asan_rtl.cc (revision 151158) +++ asan_rtl.cc (working copy) @@ -44,7 +44,7 @@ bool FLAG_replace_cfallocator; // Used on Mac only. size_t FLAG_max_malloc_fill_size = 0; bool FLAG_use_fake_stack; -int FLAG_exitcode = EXIT_FAILURE; +int FLAG_exitcode = ASAN_DEFAULT_FAILURE_EXITCODE; bool FLAG_allow_user_poisoning; int FLAG_sleep_before_dying; @@ -433,13 +433,14 @@ FLAG_replace_str = IntFlagValue(options, "replace_str=", 1); FLAG_replace_intrin = IntFlagValue(options, "replace_intrin=", 1); FLAG_use_fake_stack = IntFlagValue(options, "use_fake_stack=", 1); - FLAG_exitcode = IntFlagValue(options, "exitcode=", EXIT_FAILURE); + FLAG_exitcode = IntFlagValue(options, "exitcode=", + ASAN_DEFAULT_FAILURE_EXITCODE); FLAG_allow_user_poisoning = IntFlagValue(options, "allow_user_poisoning=", 1); FLAG_sleep_before_dying = IntFlagValue(options, "sleep_before_dying=", 0); if (FLAG_atexit) { - atexit(asan_atexit); + Atexit(asan_atexit); } // interceptors Index: asan_posix.cc =================================================================== --- asan_posix.cc (revision 151158) +++ asan_posix.cc (working copy) @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -99,6 +100,10 @@ return _exit(exitcode); } +int Atexit(void (*function)(void)) { + return atexit(function); +} + int AtomicInc(int *a) { #ifdef ANDROID return __atomic_inc(a) + 1; Index: asan_internal.h =================================================================== --- asan_internal.h (revision 151159) +++ asan_internal.h (working copy) @@ -18,7 +18,7 @@ # error "This operating system is not supported by AddressSanitizer" #endif -#include // for size_t, uintptr_t, etc. +#include // for size_t, uintptr_t, etc. #if defined(_WIN32) // There's no in Visual Studio 9, so we have to define [u]int*_t. @@ -75,6 +75,8 @@ # define INT64_MAX (__INT64_C(9223372036854775807)) # define UINT64_MAX (__UINT64_C(18446744073709551615)) +#define ASAN_DEFAULT_FAILURE_EXITCODE 1 + #if defined(__linux__) # define ASAN_LINUX 1 #else @@ -229,6 +231,7 @@ void AsanDie(); void SleepForSeconds(int seconds); void Exit(int exitcode); +int Atexit(void (*function)(void)); #define CHECK(cond) do { if (!(cond)) { \ CheckFailed(#cond, __FILE__, __LINE__); \ Index: asan_win.cc =================================================================== --- asan_win.cc (revision 151158) +++ asan_win.cc (working copy) @@ -16,6 +16,7 @@ #include #include // FIXME: get rid of this. +#include #include // FIXME: temporarily needed for placement new in AsanLock. @@ -260,6 +261,10 @@ _exit(exitcode); } +int Atexit(void (*function)(void)) { + return atexit(function); +} + } // namespace __asan #endif // _WIN32 Index: asan_interface.h =================================================================== --- asan_interface.h (revision 151158) +++ asan_interface.h (working copy) @@ -15,6 +15,10 @@ #ifndef ASAN_INTERFACE_H #define ASAN_INTERFACE_H +// ----------- ATTENTION ------------- +// This header should NOT include any other headers from ASan runtime. +// All functions in this header are extern "C" and start with __asan_. + #if !defined(_WIN32) #include // for uintptr_t #define ASAN_INTERFACE_FUNCTION_ATTRIBUTE __attribute__((visibility("default"))) @@ -22,11 +26,8 @@ // TODO(timurrrr): find out what we need on Windows. __declspec(dllexport) ? #define ASAN_INTERFACE_FUNCTION_ATTRIBUTE #endif -#include // for size_t +#include // for size_t -// This header should NOT include any other headers from ASan runtime. -// All functions in this header are extern "C" and start with __asan_. - extern "C" { // This function should be called at the very beginning of the process, // before any instrumented code is executed and before any call to malloc. From benny.kra at googlemail.com Wed Feb 22 07:42:11 2012 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Wed, 22 Feb 2012 13:42:11 -0000 Subject: [llvm-commits] [llvm] r151160 - /llvm/trunk/lib/Object/Archive.cpp Message-ID: <20120222134211.90EA22A6C12F@llvm.org> Author: d0k Date: Wed Feb 22 07:42:11 2012 New Revision: 151160 URL: http://llvm.org/viewvc/llvm-project?rev=151160&view=rev Log: Remove static ctor. Modified: llvm/trunk/lib/Object/Archive.cpp Modified: llvm/trunk/lib/Object/Archive.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=151160&r1=151159&r2=151160&view=diff ============================================================================== --- llvm/trunk/lib/Object/Archive.cpp (original) +++ llvm/trunk/lib/Object/Archive.cpp Wed Feb 22 07:42:11 2012 @@ -19,7 +19,7 @@ using namespace llvm; using namespace object; -static const StringRef Magic = "!\n"; +static const char *Magic = "!\n"; namespace { struct ArchiveMemberHeader { @@ -200,7 +200,7 @@ } Archive::child_iterator Archive::begin_children(bool skip_internal) const { - const char *Loc = Data->getBufferStart() + Magic.size(); + const char *Loc = Data->getBufferStart() + strlen(Magic); size_t Size = sizeof(ArchiveMemberHeader) + ToHeader(Loc)->getSize(); Child c(this, StringRef(Loc, Size)); From glider at google.com Wed Feb 22 07:55:41 2012 From: glider at google.com (glider at google.com) Date: Wed, 22 Feb 2012 13:55:41 +0000 Subject: [llvm-commits] [ASan] Intercept functions on Windows - first version (issue 5690065) Message-ID: <001636ed754512102304b98de2b8@google.com> LGTM http://codereview.appspot.com/5690065/ From eugenis at google.com Wed Feb 22 07:56:13 2012 From: eugenis at google.com (eugenis at google.com) Date: Wed, 22 Feb 2012 13:56:13 +0000 Subject: [llvm-commits] [ASan] Intercept functions on Windows - first version (issue 5690065) Message-ID: <0016369201f001313004b98de496@google.com> lgtm http://codereview.appspot.com/5690065/ From eugenis at google.com Wed Feb 22 08:01:01 2012 From: eugenis at google.com (eugenis at google.com) Date: Wed, 22 Feb 2012 14:01:01 +0000 Subject: [llvm-commits] AddressSanitizer: get rid of stdlib.h, leave (smaller) stddef.h instead. (issue 5689069) Message-ID: <20cf303bfc802644f704b98df5e9@google.com> lgtm, thanks http://codereview.appspot.com/5689069/ From timurrrr at google.com Wed Feb 22 08:01:40 2012 From: timurrrr at google.com (timurrrr at google.com) Date: Wed, 22 Feb 2012 14:01:40 +0000 Subject: [llvm-commits] [ASan] Intercept functions on Windows - first version (issue 5690065) Message-ID: <0016e68f9e9178a3ec04b98df795@google.com> On 2012/02/22 13:16:05, samsonov wrote: > IMO InitializeAllInterceptors() really does look horrible now :) It's less than 100LOC now > I think we need to use functions like: > InitializeSignalInterceptors() > InitializePthreadInterceptors() > InitializeGCDInterceptors() > and so on. Probably these functions can be defined in their own .cc file, but > even now they may simplify things. I agree, but not clear how to do this, especially since we plan to introduce something like asan_interceptors_{win,posix}.cc later. Since these functions you suggest will be around 10-20LOC each I'd rather wait a bit until it's clear how we do platform-specific interceptors in the future. > Also, what about using if (ASAN_WINDOWS)? [per offline chat] We'll need to compile non-Windows interceptors then, otherwise real_X will not be defined. I don't want to inject pthread_create just for a bit of extra code readability :) > > Thanks, > > Timur http://codereview.appspot.com/5690065/ From timurrrr at google.com Wed Feb 22 07:59:50 2012 From: timurrrr at google.com (Timur Iskhodzhanov) Date: Wed, 22 Feb 2012 13:59:50 -0000 Subject: [llvm-commits] [compiler-rt] r151161 - in /compiler-rt/trunk/lib/asan: asan_interceptors.cc asan_malloc_win.cc asan_win.cc interception/interception.h interception/interception_win.cc interception/interception_win.h Message-ID: <20120222135950.3E4542A6C131@llvm.org> Author: timurrrr Date: Wed Feb 22 07:59:49 2012 New Revision: 151161 URL: http://llvm.org/viewvc/llvm-project?rev=151161&view=rev Log: [ASan] Intercept functions on Windows - first version Added: compiler-rt/trunk/lib/asan/interception/interception_win.cc (with props) compiler-rt/trunk/lib/asan/interception/interception_win.h (with props) Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc compiler-rt/trunk/lib/asan/asan_malloc_win.cc compiler-rt/trunk/lib/asan/asan_win.cc compiler-rt/trunk/lib/asan/interception/interception.h Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=151161&r1=151160&r2=151161&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original) +++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Wed Feb 22 07:59:49 2012 @@ -25,12 +25,6 @@ #include -#if defined(_WIN32) -// FIXME: remove when we start intercepting on Windows. Currently it's needed to -// define memset/memcpy intrinsics. -# include -#endif // _WIN32 - #if defined(__APPLE__) // FIXME(samsonov): Gradually replace system headers with declarations of // intercepted functions. @@ -299,6 +293,7 @@ REAL(longjmp)(env, val); } +#if !defined(_WIN32) INTERCEPTOR(void, _longjmp, void *env, int val) { __asan_handle_no_return(); REAL(_longjmp)(env, val); @@ -308,6 +303,7 @@ __asan_handle_no_return(); REAL(siglongjmp)(env, val); } +#endif #if ASAN_HAS_EXCEPTIONS == 1 #ifdef __APPLE__ @@ -586,13 +582,10 @@ // ---------------------- InitializeAsanInterceptors ---------------- {{{1 namespace __asan { void InitializeAsanInterceptors() { -#ifndef __APPLE__ - CHECK(INTERCEPT_FUNCTION(index)); -#else - CHECK(OVERRIDE_FUNCTION(index, WRAP(strchr))); -#endif + // Intercept mem* functions. CHECK(INTERCEPT_FUNCTION(memcmp)); CHECK(INTERCEPT_FUNCTION(memmove)); + CHECK(INTERCEPT_FUNCTION(memset)); #ifdef __APPLE__ // Wrap memcpy() on OS X 10.6 only, because on 10.7 memcpy() and memmove() // are resolved into memmove$VARIANT$sse42. @@ -608,47 +601,67 @@ // Always wrap memcpy() on non-Darwin platforms. CHECK(INTERCEPT_FUNCTION(memcpy)); #endif - CHECK(INTERCEPT_FUNCTION(memset)); - CHECK(INTERCEPT_FUNCTION(strcasecmp)); + + // Intercept str* functions. CHECK(INTERCEPT_FUNCTION(strcat)); // NOLINT CHECK(INTERCEPT_FUNCTION(strchr)); CHECK(INTERCEPT_FUNCTION(strcmp)); CHECK(INTERCEPT_FUNCTION(strcpy)); // NOLINT - CHECK(INTERCEPT_FUNCTION(strdup)); CHECK(INTERCEPT_FUNCTION(strlen)); - CHECK(INTERCEPT_FUNCTION(strncasecmp)); CHECK(INTERCEPT_FUNCTION(strncmp)); CHECK(INTERCEPT_FUNCTION(strncpy)); +#if !defined(_WIN32) + CHECK(INTERCEPT_FUNCTION(strcasecmp)); + CHECK(INTERCEPT_FUNCTION(strdup)); + CHECK(INTERCEPT_FUNCTION(strncasecmp)); +# ifndef __APPLE__ + CHECK(INTERCEPT_FUNCTION(index)); +# else + CHECK(OVERRIDE_FUNCTION(index, WRAP(strchr))); +# endif +#endif +#if !defined(__APPLE__) + CHECK(INTERCEPT_FUNCTION(strnlen)); +#endif -#ifndef ANDROID + // Intecept signal- and jump-related functions. + CHECK(INTERCEPT_FUNCTION(longjmp)); +#if !defined(ANDROID) && !defined(_WIN32) CHECK(INTERCEPT_FUNCTION(sigaction)); CHECK(INTERCEPT_FUNCTION(signal)); #endif - CHECK(INTERCEPT_FUNCTION(longjmp)); +#if !defined(_WIN32) CHECK(INTERCEPT_FUNCTION(_longjmp)); INTERCEPT_FUNCTION(__cxa_throw); - CHECK(INTERCEPT_FUNCTION(pthread_create)); - -#ifdef _WIN32 - // FIXME: We don't intercept properly on Windows yet, so use the original - // functions for now. - REAL(memcpy) = memcpy; - REAL(memset) = memset; +# if !defined(__APPLE__) + // On Darwin siglongjmp tailcalls longjmp, so we don't want to intercept it + // there. + CHECK(INTERCEPT_FUNCTION(siglongjmp)); +# endif #endif -#ifdef __APPLE__ - CHECK(INTERCEPT_FUNCTION(dispatch_async_f)); - CHECK(INTERCEPT_FUNCTION(dispatch_sync_f)); - CHECK(INTERCEPT_FUNCTION(dispatch_after_f)); - CHECK(INTERCEPT_FUNCTION(dispatch_barrier_async_f)); - CHECK(INTERCEPT_FUNCTION(dispatch_group_async_f)); + // Intercept threading-related functions +#if !defined(_WIN32) + CHECK(INTERCEPT_FUNCTION(pthread_create)); +# if defined(__APPLE__) // We don't need to intercept pthread_workqueue_additem_np() to support the // libdispatch API, but it helps us to debug the unsupported functions. Let's // intercept it only during verbose runs. if (FLAG_v >= 2) { CHECK(INTERCEPT_FUNCTION(pthread_workqueue_additem_np)); } +# endif +#endif + + // Some Mac-specific interceptors. +#if defined(__APPLE__) + CHECK(INTERCEPT_FUNCTION(dispatch_async_f)); + CHECK(INTERCEPT_FUNCTION(dispatch_sync_f)); + CHECK(INTERCEPT_FUNCTION(dispatch_after_f)); + CHECK(INTERCEPT_FUNCTION(dispatch_barrier_async_f)); + CHECK(INTERCEPT_FUNCTION(dispatch_group_async_f)); + // Normally CFStringCreateCopy should not copy constant CF strings. // Replacing the default CFAllocator causes constant strings to be copied // rather than just returned, which leads to bugs in big applications like @@ -657,15 +670,8 @@ // Until this problem is fixed we need to check that the string is // non-constant before calling CFStringCreateCopy. CHECK(INTERCEPT_FUNCTION(CFStringCreateCopy)); -#else - // On Darwin siglongjmp tailcalls longjmp, so we don't want to intercept it - // there. - CHECK(INTERCEPT_FUNCTION(siglongjmp)); #endif -#ifndef __APPLE__ - CHECK(INTERCEPT_FUNCTION(strnlen)); -#endif if (FLAG_v > 0) { Printf("AddressSanitizer: libc interceptors initialized\n"); } Modified: compiler-rt/trunk/lib/asan/asan_malloc_win.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_malloc_win.cc?rev=151161&r1=151160&r2=151161&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_malloc_win.cc (original) +++ compiler-rt/trunk/lib/asan/asan_malloc_win.cc Wed Feb 22 07:59:49 2012 @@ -21,6 +21,7 @@ namespace __asan { void ReplaceSystemMalloc() { // FIXME: investigate whether any action is needed. + // Currenlty, we fail to intercept malloc() called from intercepted _strdup(). } } // namespace __asan Modified: compiler-rt/trunk/lib/asan/asan_win.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=151161&r1=151160&r2=151161&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_win.cc (original) +++ compiler-rt/trunk/lib/asan/asan_win.cc Wed Feb 22 07:59:49 2012 @@ -214,7 +214,9 @@ // ---------------------- Various stuff ---------------- {{{1 void *AsanDoesNotSupportStaticLinkage() { - // FIXME: shall we do anything here on Windows? +#if !defined(_DLL) || defined(_DEBUG) +#error Please build the runtime with /MD +#endif return NULL; } Modified: compiler-rt/trunk/lib/asan/interception/interception.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/interception/interception.h?rev=151161&r1=151160&r2=151161&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/interception/interception.h (original) +++ compiler-rt/trunk/lib/asan/interception/interception.h Wed Feb 22 07:59:49 2012 @@ -77,7 +77,7 @@ # define INTERCEPTOR_ATTRIBUTE #elif defined(_WIN32) // TODO(timurrrr): we're likely to use something else later on Windows. -# define WRAP(x) wrap_##x +# define WRAP(x) x # define WRAPPER_NAME(x) #x # define INTERCEPTOR_ATTRIBUTE #else @@ -128,7 +128,8 @@ # define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_MAC(func) #else // defined(_WIN32) // FIXME: deal with interception on Win. -# define INTERCEPT_FUNCTION(func) true +# include "interception_win.h" +# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_WIN(func) #endif #undef INCLUDED_FROM_INTERCEPTION_LIB Added: compiler-rt/trunk/lib/asan/interception/interception_win.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/interception/interception_win.cc?rev=151161&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/interception/interception_win.cc (added) +++ compiler-rt/trunk/lib/asan/interception/interception_win.cc Wed Feb 22 07:59:49 2012 @@ -0,0 +1,36 @@ +//===-- interception_linux.cc -----------------------------------*- C++ -*-===// +// +// 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 part of AddressSanitizer, an address sanity checker. +// +// Windows-specific interception methods. +//===----------------------------------------------------------------------===// + +#ifdef _WIN32 + +#include + +namespace __interception { + +bool GetRealFunctionAddress(const char *func_name, void **func_addr) { + const char *DLLS[] = { + "msvcr80.dll", + "msvcr90.dll", + "kernel32.dll", + NULL + }; + *func_addr = NULL; + for (size_t i = 0; *func_addr == NULL && DLLS[i]; ++i) { + *func_addr = GetProcAddress(GetModuleHandleA(DLLS[i]), func_name); + } + return (*func_addr != NULL); +} +} // namespace __interception + +#endif // _WIN32 Propchange: compiler-rt/trunk/lib/asan/interception/interception_win.cc ------------------------------------------------------------------------------ svn:eol-style = LF Added: compiler-rt/trunk/lib/asan/interception/interception_win.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/interception/interception_win.h?rev=151161&view=auto ============================================================================== --- compiler-rt/trunk/lib/asan/interception/interception_win.h (added) +++ compiler-rt/trunk/lib/asan/interception/interception_win.h Wed Feb 22 07:59:49 2012 @@ -0,0 +1,33 @@ +//===-- interception_linux.h ------------------------------------*- C++ -*-===// +// +// 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 part of AddressSanitizer, an address sanity checker. +// +// Windows-specific interception methods. +//===----------------------------------------------------------------------===// + +#ifdef _WIN32 + +#if !defined(INCLUDED_FROM_INTERCEPTION_LIB) +# error "interception_win.h should be included from interception library only" +#endif + +#ifndef INTERCEPTION_WIN_H +#define INTERCEPTION_WIN_H + +namespace __interception { +// returns true if a function with the given name was found. +bool GetRealFunctionAddress(const char *func_name, void **func_addr); +} // namespace __interception + +#define INTERCEPT_FUNCTION_WIN(func) \ + ::__interception::GetRealFunctionAddress(#func, (void**)&REAL(func)) + +#endif // INTERCEPTION_WIN_H +#endif // _WIN32 Propchange: compiler-rt/trunk/lib/asan/interception/interception_win.h ------------------------------------------------------------------------------ svn:eol-style = LF From timurrrr at google.com Wed Feb 22 08:04:38 2012 From: timurrrr at google.com (timurrrr at google.com) Date: Wed, 22 Feb 2012 14:04:38 +0000 Subject: [llvm-commits] [ASan] Intercept functions on Windows - first version (issue 5690065) Message-ID: <0016e68ef45719958f04b98e02fb@google.com> > LGTM r151161, thanks! http://codereview.appspot.com/5690065/ From samsonov at google.com Wed Feb 22 08:07:06 2012 From: samsonov at google.com (Alexey Samsonov) Date: Wed, 22 Feb 2012 14:07:06 -0000 Subject: [llvm-commits] [compiler-rt] r151162 - in /compiler-rt/trunk/lib/asan: asan_interface.h asan_internal.h asan_posix.cc asan_rtl.cc asan_win.cc Message-ID: <20120222140706.B56ED2A6C131@llvm.org> Author: samsonov Date: Wed Feb 22 08:07:06 2012 New Revision: 151162 URL: http://llvm.org/viewvc/llvm-project?rev=151162&view=rev Log: AddressSanitizer: get rid of stdlib.h and add (smaller) stddef.h instead Modified: compiler-rt/trunk/lib/asan/asan_interface.h compiler-rt/trunk/lib/asan/asan_internal.h compiler-rt/trunk/lib/asan/asan_posix.cc compiler-rt/trunk/lib/asan/asan_rtl.cc compiler-rt/trunk/lib/asan/asan_win.cc Modified: compiler-rt/trunk/lib/asan/asan_interface.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interface.h?rev=151162&r1=151161&r2=151162&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_interface.h (original) +++ compiler-rt/trunk/lib/asan/asan_interface.h Wed Feb 22 08:07:06 2012 @@ -15,6 +15,10 @@ #ifndef ASAN_INTERFACE_H #define ASAN_INTERFACE_H +// ----------- ATTENTION ------------- +// This header should NOT include any other headers from ASan runtime. +// All functions in this header are extern "C" and start with __asan_. + #if !defined(_WIN32) #include // for uintptr_t #define ASAN_INTERFACE_FUNCTION_ATTRIBUTE __attribute__((visibility("default"))) @@ -22,10 +26,7 @@ // TODO(timurrrr): find out what we need on Windows. __declspec(dllexport) ? #define ASAN_INTERFACE_FUNCTION_ATTRIBUTE #endif -#include // for size_t - -// This header should NOT include any other headers from ASan runtime. -// All functions in this header are extern "C" and start with __asan_. +#include // for size_t extern "C" { // This function should be called at the very beginning of the process, Modified: compiler-rt/trunk/lib/asan/asan_internal.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=151162&r1=151161&r2=151162&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_internal.h (original) +++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Feb 22 08:07:06 2012 @@ -18,7 +18,7 @@ # error "This operating system is not supported by AddressSanitizer" #endif -#include // for size_t, uintptr_t, etc. +#include // for size_t, uintptr_t, etc. #if defined(_WIN32) // There's no in Visual Studio 9, so we have to define [u]int*_t. @@ -75,6 +75,8 @@ # define INT64_MAX (__INT64_C(9223372036854775807)) # define UINT64_MAX (__UINT64_C(18446744073709551615)) +#define ASAN_DEFAULT_FAILURE_EXITCODE 1 + #if defined(__linux__) # define ASAN_LINUX 1 #else @@ -229,6 +231,7 @@ void AsanDie(); void SleepForSeconds(int seconds); void Exit(int exitcode); +int Atexit(void (*function)(void)); #define CHECK(cond) do { if (!(cond)) { \ CheckFailed(#cond, __FILE__, __LINE__); \ Modified: compiler-rt/trunk/lib/asan/asan_posix.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_posix.cc?rev=151162&r1=151161&r2=151162&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_posix.cc (original) +++ compiler-rt/trunk/lib/asan/asan_posix.cc Wed Feb 22 08:07:06 2012 @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -99,6 +100,10 @@ return _exit(exitcode); } +int Atexit(void (*function)(void)) { + return atexit(function); +} + int AtomicInc(int *a) { #ifdef ANDROID return __atomic_inc(a) + 1; Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=151162&r1=151161&r2=151162&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_rtl.cc (original) +++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Feb 22 08:07:06 2012 @@ -44,7 +44,7 @@ bool FLAG_replace_cfallocator; // Used on Mac only. size_t FLAG_max_malloc_fill_size = 0; bool FLAG_use_fake_stack; -int FLAG_exitcode = EXIT_FAILURE; +int FLAG_exitcode = ASAN_DEFAULT_FAILURE_EXITCODE; bool FLAG_allow_user_poisoning; int FLAG_sleep_before_dying; @@ -433,13 +433,14 @@ FLAG_replace_str = IntFlagValue(options, "replace_str=", 1); FLAG_replace_intrin = IntFlagValue(options, "replace_intrin=", 1); FLAG_use_fake_stack = IntFlagValue(options, "use_fake_stack=", 1); - FLAG_exitcode = IntFlagValue(options, "exitcode=", EXIT_FAILURE); + FLAG_exitcode = IntFlagValue(options, "exitcode=", + ASAN_DEFAULT_FAILURE_EXITCODE); FLAG_allow_user_poisoning = IntFlagValue(options, "allow_user_poisoning=", 1); FLAG_sleep_before_dying = IntFlagValue(options, "sleep_before_dying=", 0); if (FLAG_atexit) { - atexit(asan_atexit); + Atexit(asan_atexit); } // interceptors Modified: compiler-rt/trunk/lib/asan/asan_win.cc URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=151162&r1=151161&r2=151162&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_win.cc (original) +++ compiler-rt/trunk/lib/asan/asan_win.cc Wed Feb 22 08:07:06 2012 @@ -16,6 +16,7 @@ #include #include // FIXME: get rid of this. +#include #include // FIXME: temporarily needed for placement new in AsanLock. @@ -262,6 +263,10 @@ _exit(exitcode); } +int Atexit(void (*function)(void)) { + return atexit(function); +} + } // namespace __asan #endif // _WIN32 From samsonov at google.com Wed Feb 22 08:13:14 2012 From: samsonov at google.com (samsonov at google.com) Date: Wed, 22 Feb 2012 14:13:14 +0000 Subject: [llvm-commits] AddressSanitizer: get rid of stdlib.h, leave (smaller) stddef.h instead. (issue 5689069) Message-ID: <20cf302d4892dafd0004b98e20b1@google.com> On 2012/02/22 14:01:01, Evgeniy Stepanov wrote: > lgtm, thanks r151162 http://codereview.appspot.com/5689069/ From meadori at gmail.com Wed Feb 22 09:07:16 2012 From: meadori at gmail.com (Meador Inge) Date: Wed, 22 Feb 2012 09:07:16 -0600 Subject: [llvm-commits] [PATCH] RFC: fix some problems in GeneralHash In-Reply-To: References: Message-ID: On Wed, Feb 22, 2012 at 6:15 AM, Jay Foad wrote: > What do you think of the attached patch? It: > > 1. Fixes the theoretical problem with GeneralHash::addUnaligned > returning varying results on big-endian hosts. > 2. Fixes the strict aliasing problems that foiled my attempt to apply > Meador's patch to improve uniquing of struct and function types. I tested my patch plus this one on Fedora 16 with GCC 4.4.6 and it worked fine. The memcpy method looks like the way to go. > 3. Moves GeneralHash::finish and GeneralHash::mix out of line. This is > just a matter of taste, but the inlined code looked a bit long-winded > to me. I would keep them inline. Even if we outlined them that would be a separate patch (the outlining made this one harder to review). Any new unit tests? I tried to construct one to reproduce this bug, but I didn't have much luck. I might be worth adding a more few tests hashing data of various sizes and alignment. -- # Meador From meadori at gmail.com Wed Feb 22 09:15:34 2012 From: meadori at gmail.com (Meador Inge) Date: Wed, 22 Feb 2012 09:15:34 -0600 Subject: [llvm-commits] [PATCH] RFC: fix some problems in GeneralHash In-Reply-To: References: Message-ID: On Wed, Feb 22, 2012 at 6:39 AM, Jay Foad wrote: > On 22 February 2012 12:27, Chandler Carruth wrote: >> + ? ?// Use memcpy to work around strict aliasing rules. >> >> Not work around, this is simply required by the standard... I don't think >> you need this comment at all actually. > > Well, I didn't say it was working around a *bug*, it's just working > around some rules in the standard that got in the way of a more > obvious coding. I agree with Chandler on the contents of the comment, but I think the comment itself is useful. "work around" sounds like the strict aliasing rules are wrong and we are working around their brokenness. When, in fact, we are trying to keep from violating them. Also, I think some folks might wonder why the 'memcpy' is used instead of a cast or something (it does look a little odd at first glance). -- # Meador From ojab at ojab.ru Wed Feb 22 06:04:45 2012 From: ojab at ojab.ru (ojab) Date: Wed, 22 Feb 2012 15:04:45 +0300 Subject: [llvm-commits] [PATCH] Add InitializeNativeTargetDisassembler function In-Reply-To: References: Message-ID: Chandler, any feedback? //wbr ojab On Fri, Feb 17, 2012 at 11:21 PM, Eric Christopher wrote: > If it works I have no objections. Chandler? > > -eric > > On Feb 16, 2012, at 9:56 AM, ojab wrote: > > > ook! In the attached file, updated to r150707. > > > > //wbr ojab > > > > > > On Thu, Feb 16, 2012 at 9:48 PM, Eric Christopher > wrote: > > When you ping a patch it's useful to have it attached again :) > > > > -eric > > > > On Feb 16, 2012, at 7:48 AM, ojab wrote: > > > >> Any feedback? > >> > >> //wbr ojab > >> > >> > >> On Mon, Feb 13, 2012 at 6:06 PM, ojab wrote: > >> Updated patch (to LLVM r150383), please review. > >> > >> //wbr ojab > >> > >> > >> On Tue, Feb 7, 2012 at 2:50 PM, ojab wrote: > >> Hello, > >> > >> can I have review? > >> > >> //wbr ojab > >> > >> > >> On Wed, Feb 1, 2012 at 9:48 AM, ojab wrote: > >> Hello, > >> > >> I would be useful to have InitializeNativeTargetDisassembler() function > to initialize the native target disassembler, similar to > InitializeNativeTargetAsmPrinter/InitializeNativeTargetAsmParser/etc, patch > in the attached file. > >> > >> //wbr ojab > >> > >> > >> > >> _______________________________________________ > >> 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/20120222/af59b3da/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: InitializeNativeTargetDisassembler.patch Type: application/octet-stream Size: 8431 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/af59b3da/attachment.obj From baldrick at free.fr Wed Feb 22 09:34:46 2012 From: baldrick at free.fr (Duncan Sands) Date: Wed, 22 Feb 2012 16:34:46 +0100 Subject: [llvm-commits] PATCH: Refactor LLVM's triple normalization In-Reply-To: References: Message-ID: <4F450B16.3060706@free.fr> Hi Chandler, > Latest patch in the series re-working llvm::Triple to be more suitable for use > inside of a cross-compiling FE. can't you easily get the desired effect with the existing logic by changing the Components array from an array of StringRefs to an array of (StringRef, unsigned) pairs, where the second component tells you what the original position was. I.e. when you initialize Components, you initialize the i'th element to (Whatever_String_Ref, i). At places where you insert an empty component (i.e. something which didn't have an original position) you can insert a ("", ~0U) pair rather than "". Then at the end you automatically get the permutation as well as the permuted strings. > I think this version is easier to read. It burns most of the lines of code on > asserts and an enum now. It is however much less efficient. ;] Indeed. I have to ask: is there really any point to this rewrite? I think your motivation was to make it easier to extract the permutation, but as far as I can see that's trivial (see above). So that leaves the goodness of producing nicer, more understandable and more maintainable code. I agree that the arch/vendor/etc parsing parts of the existing code could probably be cleaner and factorized out. I mean these bits: ArchType Arch = UnknownArch; if (Components.size() > 0) Arch = ParseArch(Components[0]); ... if (Components.size() > 3) Environment = ParseEnvironment(Components[3]); and case 0: Arch = ParseArch(Comp); Valid = Arch != UnknownArch; break; ... case 3: Environment = ParseEnvironment(Comp); Valid = Environment != UnknownEnvironment; break; Ignoring these bits, what's left is pretty short and clean. I'm not sure that what you are proposing is any better (and it loses a feature: being able to handle strings which parse as more than one thing, which was useful in the past and maybe in the future). Ciao, Duncan. From jay.foad at gmail.com Wed Feb 22 09:50:29 2012 From: jay.foad at gmail.com (Jay Foad) Date: Wed, 22 Feb 2012 15:50:29 +0000 Subject: [llvm-commits] [PATCH] RFC: fix some problems in GeneralHash In-Reply-To: References: Message-ID: Here's an updated patch. I've rewritten the contentious comment, and re-inlined finish() and mix(). Jay. -------------- next part -------------- A non-text attachment was scrubbed... Name: hashing2.patch Type: text/x-patch Size: 3673 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/bf963fd8/attachment.bin From baldrick at free.fr Wed Feb 22 09:53:17 2012 From: baldrick at free.fr (Duncan Sands) Date: Wed, 22 Feb 2012 16:53:17 +0100 Subject: [llvm-commits] [PATCH] RFC: fix some problems in GeneralHash In-Reply-To: References: Message-ID: <4F450F6D.6020600@free.fr> Hi Jay, On 22/02/12 16:50, Jay Foad wrote: > Here's an updated patch. I've rewritten the contentious comment, and > re-inlined finish() and mix(). > --- include/llvm/ADT/Hashing.h (revision 151155) > +++ include/llvm/ADT/Hashing.h (working copy) > @@ -14,6 +14,7 @@ > #ifndef LLVM_ADT_HASHING_H > #define LLVM_ADT_HASHING_H > > +#include > #include "llvm/ADT/ArrayRef.h" > #include "llvm/ADT/StringRef.h" usually system headers are listed last (style). Ciao, Duncan. From jay.foad at gmail.com Wed Feb 22 09:59:10 2012 From: jay.foad at gmail.com (Jay Foad) Date: Wed, 22 Feb 2012 15:59:10 +0000 Subject: [llvm-commits] [PATCH] RFC: fix some problems in GeneralHash In-Reply-To: <4F450F6D.6020600@free.fr> References: <4F450F6D.6020600@free.fr> Message-ID: On 22 February 2012 15:53, Duncan Sands wrote: > usually system headers are listed last (style). Oh yeah. Seems backwards to me, but I'll fix it anyway. Jay. From stoklund at 2pi.dk Wed Feb 22 10:01:54 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 22 Feb 2012 16:01:54 -0000 Subject: [llvm-commits] [llvm] r151163 - in /llvm/trunk: include/llvm/ADT/SparseSet.h unittests/ADT/SparseSetTest.cpp Message-ID: <20120222160154.5B0222A6C12F@llvm.org> Author: stoklund Date: Wed Feb 22 10:01:54 2012 New Revision: 151163 URL: http://llvm.org/viewvc/llvm-project?rev=151163&view=rev Log: Fix typos. Modified: llvm/trunk/include/llvm/ADT/SparseSet.h llvm/trunk/unittests/ADT/SparseSetTest.cpp Modified: llvm/trunk/include/llvm/ADT/SparseSet.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SparseSet.h?rev=151163&r1=151162&r2=151163&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/SparseSet.h (original) +++ llvm/trunk/include/llvm/ADT/SparseSet.h Wed Feb 22 10:01:54 2012 @@ -9,7 +9,7 @@ // // This file defines the SparseSet class derived from the version described in // Briggs, Torczon, "An efficient representation for sparse sets", ACM Letters -// on Programming Languages and Systems, Volume 2 Issue 1-4, March???Dec. 1993. +// on Programming Languages and Systems, Volume 2 Issue 1-4, March-Dec. 1993. // // A sparse set holds a small number of objects identified by integer keys from // a moderately sized universe. The sparse set uses more memory than other Modified: llvm/trunk/unittests/ADT/SparseSetTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/SparseSetTest.cpp?rev=151163&r1=151162&r2=151163&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/SparseSetTest.cpp (original) +++ llvm/trunk/unittests/ADT/SparseSetTest.cpp Wed Feb 22 10:01:54 2012 @@ -16,7 +16,7 @@ typedef SparseSet USet; -// Empty set tests +// Empty set tests. TEST(SparseSetTest, EmptySet) { USet Set; EXPECT_TRUE(Set.empty()); @@ -39,7 +39,7 @@ EXPECT_TRUE(I == CSet.end()); } -// Single entry set tests +// Single entry set tests. TEST(SparseSetTest, SingleEntrySet) { USet Set; Set.setUniverse(10); @@ -63,7 +63,7 @@ EXPECT_FALSE(IP.second); EXPECT_TRUE(IP.first == Set.begin()); - // Erase non-existant element. + // Erase non-existent element. EXPECT_FALSE(Set.erase(1)); EXPECT_EQ(1u, Set.size()); EXPECT_EQ(5u, *Set.begin()); @@ -76,7 +76,7 @@ EXPECT_TRUE(Set.empty()); } -// Multiple entry set tests +// Multiple entry set tests. TEST(SparseSetTest, MultipleEntrySet) { USet Set; Set.setUniverse(10); From greened at obbligato.org Wed Feb 22 10:09:42 2012 From: greened at obbligato.org (David Greene) Date: Wed, 22 Feb 2012 16:09:42 -0000 Subject: [llvm-commits] [llvm] r151164 - in /llvm/trunk: docs/TableGenFundamentals.html include/llvm/TableGen/Record.h lib/TableGen/TGLexer.cpp lib/TableGen/TGLexer.h lib/TableGen/TGParser.cpp lib/TableGen/TGParser.h test/TableGen/ForeachList.td test/TableGen/ForeachLoop.td test/TableGen/NestedForeach.td test/TableGen/SiblingForeach.td utils/emacs/tablegen-mode.el utils/vim/tablegen.vim Message-ID: <20120222160942.B60542A6C12F@llvm.org> Author: greened Date: Wed Feb 22 10:09:41 2012 New Revision: 151164 URL: http://llvm.org/viewvc/llvm-project?rev=151164&view=rev Log: Add Foreach Loop Add some data structures to represent for loops. These will be referenced during object processing to do any needed iteration and instantiation. Add foreach keyword support to the lexer. Add a mode to indicate that we're parsing a foreach loop. This allows the value parser to early-out when processing the foreach value list. Add a routine to parse foreach iteration declarations. This is separate from ParseDeclaration because the type of the named value (the iterator) doesn't match the type of the initializer value (the value list). It also needs to add two values to the foreach record: the iterator and the value list. Add parsing support for foreach. Add the code to process foreach loops and create defs based on iterator values. Allow foreach loops to be matched at the top level. When parsing an IDValue check if it is a foreach loop iterator for one of the active loops. If so, return a VarInit for it. Add Emacs keyword support for foreach. Add VIM keyword support for foreach. Add tests to check foreach operation. Add TableGen documentation for foreach. Support foreach with multiple objects. Support non-braced foreach body with one object. Do not require types for the foreach declaration. Assume the iterator type from the iteration list element type. Added: llvm/trunk/test/TableGen/ForeachList.td llvm/trunk/test/TableGen/ForeachLoop.td llvm/trunk/test/TableGen/NestedForeach.td llvm/trunk/test/TableGen/SiblingForeach.td Modified: llvm/trunk/docs/TableGenFundamentals.html llvm/trunk/include/llvm/TableGen/Record.h llvm/trunk/lib/TableGen/TGLexer.cpp llvm/trunk/lib/TableGen/TGLexer.h llvm/trunk/lib/TableGen/TGParser.cpp llvm/trunk/lib/TableGen/TGParser.h llvm/trunk/utils/emacs/tablegen-mode.el llvm/trunk/utils/vim/tablegen.vim Modified: llvm/trunk/docs/TableGenFundamentals.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/TableGenFundamentals.html?rev=151164&r1=151163&r2=151164&view=diff ============================================================================== --- llvm/trunk/docs/TableGenFundamentals.html (original) +++ llvm/trunk/docs/TableGenFundamentals.html Wed Feb 22 10:09:41 2012 @@ -37,6 +37,7 @@
      1. File inclusion
      2. 'let' expressions
      3. +
      4. 'foreach' blocks
    • TableGen backends @@ -401,6 +402,14 @@
      list[4-7,17,2-3]
      A slice of the 'list' list, including elements 4,5,6,7,17,2, and 3 from it. Elements may be included multiple times.
      +
      foreach <var> = <list> in { <body> }
      +
      foreach <var> = <list> in <def>
      +
      Replicate <body> or <def>, replacing instances of + <var> with each value in <list>. <var> is scoped at the + level of the foreach loop and must not conflict with any other object + introduced in <body> or <def>. Currently only defs are + expanded within <body>. +
      (DEF a, b)
      a dag value. The first element is required to be a record definition, the remaining elements in the list may be arbitrary other values, including nested @@ -880,6 +889,39 @@ + +

      + Looping +

      + +
      +

      TableGen supports the 'foreach' block, which textually replicates +the loop body, substituting iterator values for iterator references in the +body. Example:

      + +
      +
      +foreach i = [0, 1, 2, 3] in {
      +  def R#i : Register<...>;
      +  def F#i : Register<...>;
      +}
      +
      +
      + +

      This will create objects R0, R1, R2 and +R3. foreach blocks may be nested. If there is only +one item in the body the braces may be elided:

      + +
      +
      +foreach i = [0, 1, 2, 3] in
      +  def R#i : Register<...>;
      +
      +
      +
      + +
      + Modified: llvm/trunk/include/llvm/TableGen/Record.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=151164&r1=151163&r2=151164&view=diff ============================================================================== --- llvm/trunk/include/llvm/TableGen/Record.h (original) +++ llvm/trunk/include/llvm/TableGen/Record.h Wed Feb 22 10:09:41 2012 @@ -1535,6 +1535,7 @@ class RecordKeeper { std::map Classes, Defs; + public: ~RecordKeeper() { for (std::map::iterator I = Classes.begin(), Modified: llvm/trunk/lib/TableGen/TGLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGLexer.cpp?rev=151164&r1=151163&r2=151164&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGLexer.cpp (original) +++ llvm/trunk/lib/TableGen/TGLexer.cpp Wed Feb 22 10:09:41 2012 @@ -274,6 +274,7 @@ .Case("dag", tgtok::Dag) .Case("class", tgtok::Class) .Case("def", tgtok::Def) + .Case("foreach", tgtok::Foreach) .Case("defm", tgtok::Defm) .Case("multiclass", tgtok::MultiClass) .Case("field", tgtok::Field) Modified: llvm/trunk/lib/TableGen/TGLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGLexer.h?rev=151164&r1=151163&r2=151164&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGLexer.h (original) +++ llvm/trunk/lib/TableGen/TGLexer.h Wed Feb 22 10:09:41 2012 @@ -42,7 +42,7 @@ paste, // # // Keywords. - Bit, Bits, Class, Code, Dag, Def, Defm, Field, In, Int, Let, List, + Bit, Bits, Class, Code, Dag, Def, Foreach, Defm, Field, In, Int, Let, List, MultiClass, String, // !keywords. Modified: llvm/trunk/lib/TableGen/TGParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=151164&r1=151163&r2=151164&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGParser.cpp (original) +++ llvm/trunk/lib/TableGen/TGParser.cpp Wed Feb 22 10:09:41 2012 @@ -289,6 +289,113 @@ return false; } +/// ProcessForeachDefs - Given a record, apply all of the variable +/// values in all surrounding foreach loops, creating new records for +/// each combination of values. +bool TGParser::ProcessForeachDefs(Record *CurRec, MultiClass *CurMultiClass, + SMLoc Loc) { + // We want to instantiate a new copy of CurRec for each combination + // of nested loop iterator values. We don't want top instantiate + // any copies until we have values for each loop iterator. + IterSet IterVals; + for (LoopVector::iterator Loop = Loops.begin(), LoopEnd = Loops.end(); + Loop != LoopEnd; + ++Loop) { + // Process this loop. + if (ProcessForeachDefs(CurRec, CurMultiClass, Loc, + IterVals, *Loop, Loop+1)) { + Error(Loc, + "Could not process loops for def " + CurRec->getNameInitAsString()); + return true; + } + } + + return false; +} + +/// ProcessForeachDefs - Given a record, a loop and a loop iterator, +/// apply each of the variable values in this loop and then process +/// subloops. +bool TGParser::ProcessForeachDefs(Record *CurRec, MultiClass *CurMultiClass, + SMLoc Loc, IterSet &IterVals, + ForeachLoop &CurLoop, + LoopVector::iterator NextLoop) { + Init *IterVar = CurLoop.IterVar; + ListInit *List = dynamic_cast(CurLoop.ListValue); + + if (List == 0) { + Error(Loc, "Loop list is not a list"); + return true; + } + + // Process each value. + for (int64_t i = 0; i < List->getSize(); ++i) { + Init *ItemVal = List->resolveListElementReference(*CurRec, 0, i); + IterVals.push_back(IterRecord(IterVar, ItemVal)); + + if (IterVals.size() == Loops.size()) { + // Ok, we have all of the iterator values for this point in the + // iteration space. Instantiate a new record to reflect this + // combination of values. + Record *IterRec = new Record(*CurRec); + + // Set the iterator values now. + for (IterSet::iterator i = IterVals.begin(), iend = IterVals.end(); + i != iend; + ++i) { + VarInit *IterVar = dynamic_cast(i->IterVar); + if (IterVar == 0) { + Error(Loc, "foreach iterator is unresolved"); + return true; + } + + TypedInit *IVal = dynamic_cast(i->IterValue); + if (IVal == 0) { + Error(Loc, "foreach iterator value is untyped"); + return true; + } + + IterRec->addValue(RecordVal(IterVar->getName(), IVal->getType(), false)); + + if (SetValue(IterRec, Loc, IterVar->getName(), + std::vector(), IVal)) { + Error(Loc, "when instantiating this def"); + return true; + } + + // Resolve it next. + IterRec->resolveReferencesTo(IterRec->getValue(IterVar->getName())); + + // Remove it. + IterRec->removeValue(IterVar->getName()); + } + + if (Records.getDef(IterRec->getNameInitAsString())) { + Error(Loc, "def already exists: " + IterRec->getNameInitAsString()); + return true; + } + + Records.addDef(IterRec); + IterRec->resolveReferences(); + } + + if (NextLoop != Loops.end()) { + // Process nested loops. + if (ProcessForeachDefs(CurRec, CurMultiClass, Loc, IterVals, *NextLoop, + NextLoop+1)) { + Error(Loc, + "Could not process loops for def " + + CurRec->getNameInitAsString()); + return true; + } + } + + // We're done with this iterator. + IterVals.pop_back(); + } + return false; +} + //===----------------------------------------------------------------------===// // Parser Code //===----------------------------------------------------------------------===// @@ -296,7 +403,8 @@ /// isObjectStart - Return true if this is a valid first token for an Object. static bool isObjectStart(tgtok::TokKind K) { return K == tgtok::Class || K == tgtok::Def || - K == tgtok::Defm || K == tgtok::Let || K == tgtok::MultiClass; + K == tgtok::Defm || K == tgtok::Let || + K == tgtok::MultiClass || K == tgtok::Foreach; } static std::string GetNewAnonymousName() { @@ -698,6 +806,15 @@ } } + // If this is in a foreach loop, make sure it's not a loop iterator + for (LoopVector::iterator i = Loops.begin(), iend = Loops.end(); + i != iend; + ++i) { + VarInit *IterVar = dynamic_cast(i->IterVar); + if (IterVar && IterVar->getName() == Name) + return IterVar; + } + if (Mode == ParseNameMode) return StringInit::get(Name); @@ -1353,7 +1470,7 @@ switch (Lex.getCode()) { default: return Result; case tgtok::l_brace: { - if (Mode == ParseNameMode) + if (Mode == ParseNameMode || Mode == ParseForeachMode) // This is the beginning of the object body. return Result; @@ -1605,6 +1722,50 @@ return DeclName; } +/// ParseForeachDeclaration - Read a foreach declaration, returning +/// the name of the declared object or a NULL Init on error. Return +/// the name of the parsed initializer list through ForeachListName. +/// +/// ForeachDeclaration ::= ID '=' Value +/// +Init *TGParser::ParseForeachDeclaration(Init *&ForeachListValue) { + if (Lex.getCode() != tgtok::Id) { + TokError("Expected identifier in foreach declaration"); + return 0; + } + + Init *DeclName = StringInit::get(Lex.getCurStrVal()); + Lex.Lex(); + + // If a value is present, parse it. + if (Lex.getCode() != tgtok::equal) { + TokError("Expected '=' in foreach declaration"); + return 0; + } + Lex.Lex(); // Eat the '=' + + // Expect a list initializer. + ForeachListValue = ParseValue(0, 0, ParseForeachMode); + + TypedInit *TypedList = dynamic_cast(ForeachListValue); + if (TypedList == 0) { + TokError("Value list is untyped"); + return 0; + } + + RecTy *ValueType = TypedList->getType(); + ListRecTy *ListType = dynamic_cast(ValueType); + if (ListType == 0) { + TokError("Value list is not of list type"); + return 0; + } + + RecTy *IterType = ListType->getElementType(); + VarInit *IterVar = VarInit::get(DeclName, IterType); + + return IterVar; +} + /// ParseTemplateArgList - Read a template argument list, which is a non-empty /// sequence of template-declarations in <>'s. If CurRec is non-null, these are /// template args for a def, which may or may not be in a multiclass. If null, @@ -1817,6 +1978,63 @@ } } + if (ProcessForeachDefs(CurRec, CurMultiClass, DefLoc)) { + Error(DefLoc, + "Could not process loops for def" + CurRec->getNameInitAsString()); + return true; + } + + return false; +} + +/// ParseForeach - Parse a for statement. Return the record corresponding +/// to it. This returns true on error. +/// +/// Foreach ::= FOREACH Declaration IN '{ ObjectList '}' +/// Foreach ::= FOREACH Declaration IN Object +/// +bool TGParser::ParseForeach(MultiClass *CurMultiClass) { + assert(Lex.getCode() == tgtok::Foreach && "Unknown tok"); + Lex.Lex(); // Eat the 'for' token. + + // Make a temporary object to record items associated with the for + // loop. + Init *ListValue = 0; + Init *IterName = ParseForeachDeclaration(ListValue); + if (IterName == 0) + return TokError("expected declaration in for"); + + if (Lex.getCode() != tgtok::In) + return TokError("Unknown tok"); + Lex.Lex(); // Eat the in + + // Create a loop object and remember it. + Loops.push_back(ForeachLoop(IterName, ListValue)); + + if (Lex.getCode() != tgtok::l_brace) { + // FOREACH Declaration IN Object + if (ParseObject(CurMultiClass)) + return true; + } + else { + SMLoc BraceLoc = Lex.getLoc(); + // Otherwise, this is a group foreach. + Lex.Lex(); // eat the '{'. + + // Parse the object list. + if (ParseObjectList(CurMultiClass)) + return true; + + if (Lex.getCode() != tgtok::r_brace) { + TokError("expected '}' at end of foreach command"); + return Error(BraceLoc, "to match this '{'"); + } + Lex.Lex(); // Eat the } + } + + // We've processed everything in this loop. + Loops.pop_back(); + return false; } @@ -2010,6 +2228,7 @@ case tgtok::Let: case tgtok::Def: case tgtok::Defm: + case tgtok::Foreach: if (ParseObject(CurMultiClass)) return true; break; @@ -2305,6 +2524,7 @@ return TokError("Expected class, def, defm, multiclass or let definition"); case tgtok::Let: return ParseTopLevelLet(MC); case tgtok::Def: return ParseDef(MC); + case tgtok::Foreach: return ParseForeach(MC); case tgtok::Defm: return ParseDefm(MC); case tgtok::Class: return ParseClass(); case tgtok::MultiClass: return ParseMultiClass(); Modified: llvm/trunk/lib/TableGen/TGParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.h?rev=151164&r1=151163&r2=151164&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGParser.h (original) +++ llvm/trunk/lib/TableGen/TGParser.h Wed Feb 22 10:09:41 2012 @@ -42,11 +42,25 @@ } }; + /// ForeachLoop - Record the iteration state associated with a for loop. + /// This is used to instantiate items in the loop body. + struct ForeachLoop { + Init *IterVar; + Init *ListValue; + + ForeachLoop(Init *IVar, Init *LValue) : IterVar(IVar), ListValue(LValue) {}; + }; + class TGParser { TGLexer Lex; std::vector > LetStack; std::map MultiClasses; + /// Loops - Keep track of any foreach loops we are within. + /// + typedef std::vector LoopVector; + LoopVector Loops; + /// CurMultiClass - If we are parsing a 'multiclass' definition, this is the /// current value. MultiClass *CurMultiClass; @@ -60,8 +74,10 @@ // in the middle of creating in. For those situations, allow the // parser to ignore missing object errors. enum IDParseMode { - ParseValueMode, // We are parsing a value we expect to look up. - ParseNameMode // We are parsing a name of an object that does not yet exist. + ParseValueMode, // We are parsing a value we expect to look up. + ParseNameMode, // We are parsing a name of an object that does not yet + // exist. + ParseForeachMode // We are parsing a foreach init. }; public: @@ -82,6 +98,7 @@ const std::vector &getDependencies() const { return Lex.getDependencies(); } + private: // Semantic analysis methods. bool AddValue(Record *TheRec, SMLoc Loc, const RecordVal &RV); bool SetValue(Record *TheRec, SMLoc Loc, Init *ValName, @@ -94,6 +111,23 @@ bool AddSubMultiClass(MultiClass *CurMC, SubMultiClassReference &SubMultiClass); + // IterRecord: Map an iterator name to a value. + struct IterRecord { + Init *IterVar; + Init *IterValue; + IterRecord(Init *Var, Init *Val) : IterVar(Var), IterValue(Val) {} + }; + + // IterSet: The set of all iterator values at some point in the + // iteration space. + typedef std::vector IterSet; + + bool ProcessForeachDefs(Record *CurRec, MultiClass *CurMultiClass, + SMLoc Loc); + bool ProcessForeachDefs(Record *CurRec, MultiClass *CurMultiClass, + SMLoc Loc, IterSet &IterVals, ForeachLoop &CurLoop, + LoopVector::iterator NextLoop); + private: // Parser methods. bool ParseObjectList(MultiClass *MC = 0); bool ParseObject(MultiClass *MC); @@ -116,6 +150,7 @@ SMLoc DefmPrefixLoc); bool ParseDefm(MultiClass *CurMultiClass); bool ParseDef(MultiClass *CurMultiClass); + bool ParseForeach(MultiClass *CurMultiClass); bool ParseTopLevelLet(MultiClass *CurMultiClass); std::vector ParseLetList(); @@ -125,6 +160,7 @@ bool ParseTemplateArgList(Record *CurRec); Init *ParseDeclaration(Record *CurRec, bool ParsingTemplateArgs); + Init *ParseForeachDeclaration(Init *&ForeachListValue); SubClassReference ParseSubClassReference(Record *CurRec, bool isDefm); SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC); Added: llvm/trunk/test/TableGen/ForeachList.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ForeachList.td?rev=151164&view=auto ============================================================================== --- llvm/trunk/test/TableGen/ForeachList.td (added) +++ llvm/trunk/test/TableGen/ForeachList.td Wed Feb 22 10:09:41 2012 @@ -0,0 +1,76 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +class Register { + string Name = name; + int Index = idx; +} + +foreach i = [0, 1, 2, 3, 4, 5, 6, 7] in { + def R#i : Register<"R"#i, i>; + def F#i : Register<"F"#i, i>; +} + +// CHECK: def F0 +// CHECK: string Name = "F0"; +// CHECK: int Index = 0; + +// CHECK: def F1 +// CHECK: string Name = "F1"; +// CHECK: int Index = 1; + +// CHECK: def F2 +// CHECK: string Name = "F2"; +// CHECK: int Index = 2; + +// CHECK: def F3 +// CHECK: string Name = "F3"; +// CHECK: int Index = 3; + +// CHECK: def F4 +// CHECK: string Name = "F4"; +// CHECK: int Index = 4; + +// CHECK: def F5 +// CHECK: string Name = "F5"; +// CHECK: int Index = 5; + +// CHECK: def F6 +// CHECK: string Name = "F6"; +// CHECK: int Index = 6; + +// CHECK: def F7 +// CHECK: string Name = "F7"; +// CHECK: int Index = 7; + +// CHECK: def R0 +// CHECK: string Name = "R0"; +// CHECK: int Index = 0; + +// CHECK: def R1 +// CHECK: string Name = "R1"; +// CHECK: int Index = 1; + +// CHECK: def R2 +// CHECK: string Name = "R2"; +// CHECK: int Index = 2; + +// CHECK: def R3 +// CHECK: string Name = "R3"; +// CHECK: int Index = 3; + +// CHECK: def R4 +// CHECK: string Name = "R4"; +// CHECK: int Index = 4; + +// CHECK: def R5 +// CHECK: string Name = "R5"; +// CHECK: int Index = 5; + +// CHECK: def R6 +// CHECK: string Name = "R6"; +// CHECK: int Index = 6; + +// CHECK: def R7 +// CHECK: string Name = "R7"; +// CHECK: int Index = 7; Added: llvm/trunk/test/TableGen/ForeachLoop.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ForeachLoop.td?rev=151164&view=auto ============================================================================== --- llvm/trunk/test/TableGen/ForeachLoop.td (added) +++ llvm/trunk/test/TableGen/ForeachLoop.td Wed Feb 22 10:09:41 2012 @@ -0,0 +1,43 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +class Register { + string Name = name; + int Index = idx; +} + +foreach i = [0, 1, 2, 3, 4, 5, 6, 7] in + def R#i : Register<"R"#i, i>; + + +// CHECK: def R0 +// CHECK: string Name = "R0"; +// CHECK: int Index = 0; + +// CHECK: def R1 +// CHECK: string Name = "R1"; +// CHECK: int Index = 1; + +// CHECK: def R2 +// CHECK: string Name = "R2"; +// CHECK: int Index = 2; + +// CHECK: def R3 +// CHECK: string Name = "R3"; +// CHECK: int Index = 3; + +// CHECK: def R4 +// CHECK: string Name = "R4"; +// CHECK: int Index = 4; + +// CHECK: def R5 +// CHECK: string Name = "R5"; +// CHECK: int Index = 5; + +// CHECK: def R6 +// CHECK: string Name = "R6"; +// CHECK: int Index = 6; + +// CHECK: def R7 +// CHECK: string Name = "R7"; +// CHECK: int Index = 7; Added: llvm/trunk/test/TableGen/NestedForeach.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/NestedForeach.td?rev=151164&view=auto ============================================================================== --- llvm/trunk/test/TableGen/NestedForeach.td (added) +++ llvm/trunk/test/TableGen/NestedForeach.td Wed Feb 22 10:09:41 2012 @@ -0,0 +1,74 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +class Droid { + string Series = series; + int Release = release; + string Model = model; + int Patchlevel = patchlevel; +} + +foreach S = ["R", "C"] in { + foreach R = [2, 3, 4] in { + foreach M = ["D", "P", "Q"] in { + foreach P = [0, 2, 4] in { + def S#R#M#P : Droid; + } + } + } +} + +// CHECK: def C2D0 +// CHECK: def C2D2 +// CHECK: def C2D4 +// CHECK: def C2P0 +// CHECK: def C2P2 +// CHECK: def C2P4 +// CHECK: def C2Q0 +// CHECK: def C2Q2 +// CHECK: def C2Q4 +// CHECK: def C3D0 +// CHECK: def C3D2 +// CHECK: def C3D4 +// CHECK: def C3P0 +// CHECK: def C3P2 +// CHECK: def C3P4 +// CHECK: def C3Q0 +// CHECK: def C3Q2 +// CHECK: def C3Q4 +// CHECK: def C4D0 +// CHECK: def C4D2 +// CHECK: def C4D4 +// CHECK: def C4P0 +// CHECK: def C4P2 +// CHECK: def C4P4 +// CHECK: def C4Q0 +// CHECK: def C4Q2 +// CHECK: def C4Q4 +// CHECK: def R2D0 +// CHECK: def R2D2 +// CHECK: def R2D4 +// CHECK: def R2P0 +// CHECK: def R2P2 +// CHECK: def R2P4 +// CHECK: def R2Q0 +// CHECK: def R2Q2 +// CHECK: def R2Q4 +// CHECK: def R3D0 +// CHECK: def R3D2 +// CHECK: def R3D4 +// CHECK: def R3P0 +// CHECK: def R3P2 +// CHECK: def R3P4 +// CHECK: def R3Q0 +// CHECK: def R3Q2 +// CHECK: def R3Q4 +// CHECK: def R4D0 +// CHECK: def R4D2 +// CHECK: def R4D4 +// CHECK: def R4P0 +// CHECK: def R4P2 +// CHECK: def R4P4 +// CHECK: def R4Q0 +// CHECK: def R4Q2 +// CHECK: def R4Q4 Added: llvm/trunk/test/TableGen/SiblingForeach.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/SiblingForeach.td?rev=151164&view=auto ============================================================================== --- llvm/trunk/test/TableGen/SiblingForeach.td (added) +++ llvm/trunk/test/TableGen/SiblingForeach.td Wed Feb 22 10:09:41 2012 @@ -0,0 +1,277 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +class Set { + int I = i; + int J = j; + int K = k; +} + +foreach i = [1, 2, 3] in { + def I1_#i : Set; + foreach j = [1, 2, 3] in { + def I1_#i#_J1_#j : Set; + } + def I2_#i : Set; + foreach j = [4, 5, 6] in { + foreach k = [1, 2, 3] in { + def I3_#i#_J2_#j#_K1_#k : Set; + } + def I4_#i#_J3_#j : Set; + } +} + +// CHECK: def I1_1 +// CHECK: int I = 1; +// CHECK: int J = 0; +// CHECK: int K = 0; + +// CHECK: def I1_1_J1_1 +// CHECK: int I = 1; +// CHECK: int J = 1; +// CHECK: int K = 0; + +// CHECK: def I1_1_J1_2 +// CHECK: int I = 1; +// CHECK: int J = 2; +// CHECK: int K = 0; + +// CHECK: def I1_1_J1_3 +// CHECK: int I = 1; +// CHECK: int J = 3; +// CHECK: int K = 0; + +// CHECK: def I1_2 +// CHECK: int I = 2; +// CHECK: int J = 0; +// CHECK: int K = 0; + +// CHECK: def I1_2_J1_1 +// CHECK: int I = 2; +// CHECK: int J = 1; +// CHECK: int K = 0; + +// CHECK: def I1_2_J1_2 +// CHECK: int I = 2; +// CHECK: int J = 2; +// CHECK: int K = 0; + +// CHECK: def I1_2_J1_3 +// CHECK: int I = 2; +// CHECK: int J = 3; +// CHECK: int K = 0; + +// CHECK: def I1_3 +// CHECK: int I = 3; +// CHECK: int J = 0; +// CHECK: int K = 0; + +// CHECK: def I1_3_J1_1 +// CHECK: int I = 3; +// CHECK: int J = 1; +// CHECK: int K = 0; + +// CHECK: def I1_3_J1_2 +// CHECK: int I = 3; +// CHECK: int J = 2; +// CHECK: int K = 0; + +// CHECK: def I1_3_J1_3 +// CHECK: int I = 3; +// CHECK: int J = 3; +// CHECK: int K = 0; + +// CHECK: def I2_1 +// CHECK: int I = 1; +// CHECK: int J = 0; +// CHECK: int K = 0; + +// CHECK: def I2_2 +// CHECK: int I = 2; +// CHECK: int J = 0; +// CHECK: int K = 0; + +// CHECK: def I2_3 +// CHECK: int I = 3; +// CHECK: int J = 0; +// CHECK: int K = 0; + +// CHECK: def I3_1_J2_4_K1_1 +// CHECK: int I = 1; +// CHECK: int J = 4; +// CHECK: int K = 1; + +// CHECK: def I3_1_J2_4_K1_2 +// CHECK: int I = 1; +// CHECK: int J = 4; +// CHECK: int K = 2; + +// CHECK: def I3_1_J2_4_K1_3 +// CHECK: int I = 1; +// CHECK: int J = 4; +// CHECK: int K = 3; + +// CHECK: def I3_1_J2_5_K1_1 +// CHECK: int I = 1; +// CHECK: int J = 5; +// CHECK: int K = 1; + +// CHECK: def I3_1_J2_5_K1_2 +// CHECK: int I = 1; +// CHECK: int J = 5; +// CHECK: int K = 2; + +// CHECK: def I3_1_J2_5_K1_3 +// CHECK: int I = 1; +// CHECK: int J = 5; +// CHECK: int K = 3; + +// CHECK: def I3_1_J2_6_K1_1 +// CHECK: int I = 1; +// CHECK: int J = 6; +// CHECK: int K = 1; + +// CHECK: def I3_1_J2_6_K1_2 +// CHECK: int I = 1; +// CHECK: int J = 6; +// CHECK: int K = 2; + +// CHECK: def I3_1_J2_6_K1_3 +// CHECK: int I = 1; +// CHECK: int J = 6; +// CHECK: int K = 3; + +// CHECK: def I3_2_J2_4_K1_1 +// CHECK: int I = 2; +// CHECK: int J = 4; +// CHECK: int K = 1; + +// CHECK: def I3_2_J2_4_K1_2 +// CHECK: int I = 2; +// CHECK: int J = 4; +// CHECK: int K = 2; + +// CHECK: def I3_2_J2_4_K1_3 +// CHECK: int I = 2; +// CHECK: int J = 4; +// CHECK: int K = 3; + +// CHECK: def I3_2_J2_5_K1_1 +// CHECK: int I = 2; +// CHECK: int J = 5; +// CHECK: int K = 1; + +// CHECK: def I3_2_J2_5_K1_2 +// CHECK: int I = 2; +// CHECK: int J = 5; +// CHECK: int K = 2; + +// CHECK: def I3_2_J2_5_K1_3 +// CHECK: int I = 2; +// CHECK: int J = 5; +// CHECK: int K = 3; + +// CHECK: def I3_2_J2_6_K1_1 +// CHECK: int I = 2; +// CHECK: int J = 6; +// CHECK: int K = 1; + +// CHECK: def I3_2_J2_6_K1_2 +// CHECK: int I = 2; +// CHECK: int J = 6; +// CHECK: int K = 2; + +// CHECK: def I3_2_J2_6_K1_3 +// CHECK: int I = 2; +// CHECK: int J = 6; +// CHECK: int K = 3; + +// CHECK: def I3_3_J2_4_K1_1 +// CHECK: int I = 3; +// CHECK: int J = 4; +// CHECK: int K = 1; + +// CHECK: def I3_3_J2_4_K1_2 +// CHECK: int I = 3; +// CHECK: int J = 4; +// CHECK: int K = 2; + +// CHECK: def I3_3_J2_4_K1_3 +// CHECK: int I = 3; +// CHECK: int J = 4; +// CHECK: int K = 3; + +// CHECK: def I3_3_J2_5_K1_1 +// CHECK: int I = 3; +// CHECK: int J = 5; +// CHECK: int K = 1; + +// CHECK: def I3_3_J2_5_K1_2 +// CHECK: int I = 3; +// CHECK: int J = 5; +// CHECK: int K = 2; + +// CHECK: def I3_3_J2_5_K1_3 +// CHECK: int I = 3; +// CHECK: int J = 5; +// CHECK: int K = 3; + +// CHECK: def I3_3_J2_6_K1_1 +// CHECK: int I = 3; +// CHECK: int J = 6; +// CHECK: int K = 1; + +// CHECK: def I3_3_J2_6_K1_2 +// CHECK: int I = 3; +// CHECK: int J = 6; +// CHECK: int K = 2; + +// CHECK: def I3_3_J2_6_K1_3 +// CHECK: int I = 3; +// CHECK: int J = 6; +// CHECK: int K = 3; + +// CHECK: def I4_1_J3_4 +// CHECK: int I = 1; +// CHECK: int J = 4; +// CHECK: int K = 0; + +// CHECK: def I4_1_J3_5 +// CHECK: int I = 1; +// CHECK: int J = 5; +// CHECK: int K = 0; + +// CHECK: def I4_1_J3_6 +// CHECK: int I = 1; +// CHECK: int J = 6; +// CHECK: int K = 0; + +// CHECK: def I4_2_J3_4 +// CHECK: int I = 2; +// CHECK: int J = 4; +// CHECK: int K = 0; + +// CHECK: def I4_2_J3_5 +// CHECK: int I = 2; +// CHECK: int J = 5; +// CHECK: int K = 0; + +// CHECK: def I4_2_J3_6 +// CHECK: int I = 2; +// CHECK: int J = 6; +// CHECK: int K = 0; + +// CHECK: def I4_3_J3_4 +// CHECK: int I = 3; +// CHECK: int J = 4; +// CHECK: int K = 0; + +// CHECK: def I4_3_J3_5 +// CHECK: int I = 3; +// CHECK: int J = 5; +// CHECK: int K = 0; + +// CHECK: def I4_3_J3_6 +// CHECK: int I = 3; +// CHECK: int J = 6; +// CHECK: int K = 0; Modified: llvm/trunk/utils/emacs/tablegen-mode.el URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/emacs/tablegen-mode.el?rev=151164&r1=151163&r2=151164&view=diff ============================================================================== --- llvm/trunk/utils/emacs/tablegen-mode.el (original) +++ llvm/trunk/utils/emacs/tablegen-mode.el Wed Feb 22 10:09:41 2012 @@ -13,7 +13,7 @@ (defvar tablegen-font-lock-keywords (let ((kw (regexp-opt '("class" "defm" "def" "field" "include" "in" - "let" "multiclass") + "let" "multiclass", "foreach") 'words)) (type-kw (regexp-opt '("bit" "bits" "code" "dag" "int" "list" "string") 'words)) Modified: llvm/trunk/utils/vim/tablegen.vim URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/vim/tablegen.vim?rev=151164&r1=151163&r2=151164&view=diff ============================================================================== --- llvm/trunk/utils/vim/tablegen.vim (original) +++ llvm/trunk/utils/vim/tablegen.vim Wed Feb 22 10:09:41 2012 @@ -14,7 +14,7 @@ syn case match -syn keyword tgKeyword def let in code dag field include defm +syn keyword tgKeyword def let in code dag field include defm foreach syn keyword tgType class int string list bit bits multiclass syn match tgNumber /\<\d\+\>/ From stoklund at 2pi.dk Wed Feb 22 10:14:47 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 22 Feb 2012 08:14:47 -0800 Subject: [llvm-commits] [llvm] r151110 - in /llvm/trunk: docs/ProgrammersManual.html include/llvm/ADT/SparseSet.h unittests/ADT/SparseSetTest.cpp unittests/CMakeLists.txt In-Reply-To: <4F44902D.7070003@mxc.ca> References: <20120222005608.78DB32A6C12F@llvm.org> <4F44902D.7070003@mxc.ca> Message-ID: <7C3BA6E6-B020-4770-BEF2-1D61C91A790F@2pi.dk> On Feb 21, 2012, at 10:50 PM, Nick Lewycky wrote: > Jakob Stoklund Olesen wrote: >> +// on Programming Languages and Systems, Volume 2 Issue 1-4, March???Dec. 1993. > > Non-ASCII bytes between "March" and "Dec"? Thanks. That en dash looked like a hyphen on my screen. r151163. /jakob From samsonov at google.com Wed Feb 22 10:12:46 2012 From: samsonov at google.com (Alexey Samsonov) Date: Wed, 22 Feb 2012 16:12:46 -0000 Subject: [llvm-commits] [compiler-rt] r151165 - /compiler-rt/trunk/lib/asan/asan_internal.h Message-ID: <20120222161246.4A7AD2A6C12F@llvm.org> Author: samsonov Date: Wed Feb 22 10:12:46 2012 New Revision: 151165 URL: http://llvm.org/viewvc/llvm-project?rev=151165&view=rev Log: AddressSanitizer: quick fix - undef INT32_MIN etc to avoid macro redefinition Modified: compiler-rt/trunk/lib/asan/asan_internal.h Modified: compiler-rt/trunk/lib/asan/asan_internal.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=151165&r1=151164&r2=151165&view=diff ============================================================================== --- compiler-rt/trunk/lib/asan/asan_internal.h (original) +++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Feb 22 10:12:46 2012 @@ -68,12 +68,18 @@ # define __INT64_C(c) c ## LL # define __UINT64_C(c) c ## ULL #endif // __WORDSIZE == 64 -# define INT32_MIN (-2147483647-1) -# define INT32_MAX (2147483647) -# define UINT32_MAX (4294967295U) -# define INT64_MIN (-__INT64_C(9223372036854775807)-1) -# define INT64_MAX (__INT64_C(9223372036854775807)) -# define UINT64_MAX (__UINT64_C(18446744073709551615)) +#undef INT32_MIN +#define INT32_MIN (-2147483647-1) +#undef INT32_MAX +#define INT32_MAX (2147483647) +#undef UINT32_MAX +#define UINT32_MAX (4294967295U) +#undef INT64_MIN +#define INT64_MIN (-__INT64_C(9223372036854775807)-1) +#undef INT64_MAX +#define INT64_MAX (__INT64_C(9223372036854775807)) +#undef UINT64_MAX +#define UINT64_MAX (__UINT64_C(18446744073709551615)) #define ASAN_DEFAULT_FAILURE_EXITCODE 1 From timurrrr at google.com Wed Feb 22 10:25:16 2012 From: timurrrr at google.com (Timur Iskhodzhanov) Date: Wed, 22 Feb 2012 20:25:16 +0400 Subject: [llvm-commits] [compiler-rt] r151165 - /compiler-rt/trunk/lib/asan/asan_internal.h In-Reply-To: <20120222161246.4A7AD2A6C12F@llvm.org> References: <20120222161246.4A7AD2A6C12F@llvm.org> Message-ID: why not #ifndef INT32_MIN # define INT32_MIN ... #endif instead? On Wed, Feb 22, 2012 at 8:12 PM, Alexey Samsonov wrote: > Author: samsonov > Date: Wed Feb 22 10:12:46 2012 > New Revision: 151165 > > URL: http://llvm.org/viewvc/llvm-project?rev=151165&view=rev > Log: > AddressSanitizer: quick fix - undef INT32_MIN etc to avoid macro redefinition > > Modified: > ? ?compiler-rt/trunk/lib/asan/asan_internal.h > > Modified: compiler-rt/trunk/lib/asan/asan_internal.h > URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=151165&r1=151164&r2=151165&view=diff > ============================================================================== > --- compiler-rt/trunk/lib/asan/asan_internal.h (original) > +++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Feb 22 10:12:46 2012 > @@ -68,12 +68,18 @@ > ?# define __INT64_C(c) ?c ## LL > ?# define __UINT64_C(c) c ## ULL > ?#endif ?// __WORDSIZE == 64 > -# define INT32_MIN ? ? ? ? ? ? ?(-2147483647-1) > -# define INT32_MAX ? ? ? ? ? ? ?(2147483647) > -# define UINT32_MAX ? ? ? ? ? ? (4294967295U) > -# define INT64_MIN ? ? ? ? ? ? ?(-__INT64_C(9223372036854775807)-1) > -# define INT64_MAX ? ? ? ? ? ? ?(__INT64_C(9223372036854775807)) > -# define UINT64_MAX ? ? ? ? ? ? (__UINT64_C(18446744073709551615)) > +#undef INT32_MIN > +#define INT32_MIN ? ? ? ? ? ? ?(-2147483647-1) > +#undef INT32_MAX > +#define INT32_MAX ? ? ? ? ? ? ?(2147483647) > +#undef UINT32_MAX > +#define UINT32_MAX ? ? ? ? ? ? (4294967295U) > +#undef INT64_MIN > +#define INT64_MIN ? ? ? ? ? ? ?(-__INT64_C(9223372036854775807)-1) > +#undef INT64_MAX > +#define INT64_MAX ? ? ? ? ? ? ?(__INT64_C(9223372036854775807)) > +#undef UINT64_MAX > +#define UINT64_MAX ? ? ? ? ? ? (__UINT64_C(18446744073709551615)) > > ?#define ASAN_DEFAULT_FAILURE_EXITCODE 1 > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From spande at codeaurora.org Wed Feb 22 10:45:10 2012 From: spande at codeaurora.org (Sirish Pande) Date: Wed, 22 Feb 2012 16:45:10 -0000 Subject: [llvm-commits] [llvm] r151166 - in /llvm/trunk/lib/Target/Hexagon: HexagonAsmPrinter.cpp HexagonInstrInfo.cpp HexagonInstrInfo.td HexagonRegisterInfo.cpp Message-ID: <20120222164510.5B05B2A6C12F@llvm.org> Author: sirish Date: Wed Feb 22 10:45:10 2012 New Revision: 151166 URL: http://llvm.org/viewvc/llvm-project?rev=151166&view=rev Log: Efficient pattern for store truncate. Patch by Evandro Menezes. Modified: llvm/trunk/lib/Target/Hexagon/HexagonAsmPrinter.cpp llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.td llvm/trunk/lib/Target/Hexagon/HexagonRegisterInfo.cpp Modified: llvm/trunk/lib/Target/Hexagon/HexagonAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonAsmPrinter.cpp?rev=151166&r1=151165&r2=151166&view=diff ============================================================================== --- llvm/trunk/lib/Target/Hexagon/HexagonAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Hexagon/HexagonAsmPrinter.cpp Wed Feb 22 10:45:10 2012 @@ -374,19 +374,6 @@ O << "}"; } printInstruction(MI, O); - } else if (MI->getOpcode() == Hexagon::STriwt) { - // - // Handle truncated store on Hexagon. - // - O << "\tmemw("; - printHexagonMEMriOperand(MI, 0, O); - - O << ") = "; - unsigned SubRegNum = - TM.getRegisterInfo()->getSubReg(MI->getOperand(2) - .getReg(), Hexagon::subreg_loreg); - const char *SubRegName = getRegisterName(SubRegNum); - O << SubRegName << '\n'; } else if (MI->getOpcode() == Hexagon::MPYI_rin) { // Handle multipy with -ve constant on Hexagon: // "$dst =- mpyi($src1, #$src2)" Modified: llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp?rev=151166&r1=151165&r2=151166&view=diff ============================================================================== --- llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp Wed Feb 22 10:45:10 2012 @@ -1397,7 +1397,6 @@ case Hexagon::LDriw: case Hexagon::STriw: - case Hexagon::STriwt: assert((Offset % 4 == 0) && "Offset has incorrect alignment"); return (Offset >= Hexagon_MEMW_OFFSET_MIN) && (Offset <= Hexagon_MEMW_OFFSET_MAX); Modified: llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.td?rev=151166&r1=151165&r2=151166&view=diff ============================================================================== --- llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.td (original) +++ llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.td Wed Feb 22 10:45:10 2012 @@ -1999,11 +1999,6 @@ "memw($src1+#$src2) = $src3", [(store IntRegs:$src3, (add IntRegs:$src1, s11_2ImmPred:$src2))]>; -def STriwt : STInst<(outs), - (ins MEMri:$addr, DoubleRegs:$src1), - "memw($addr) = $src1", - [(truncstorei32 DoubleRegs:$src1, ADDRriS11_2:$addr)]>; - let mayStore = 1, neverHasSideEffects = 1 in def STriw_GP : STInst<(outs), (ins globaladdress:$global, u16Imm:$offset, IntRegs:$src), @@ -2745,7 +2740,7 @@ def : Pat<(i1 (trunc DoubleRegs:$src)), (i1 (TFR_PdRs (i32(EXTRACT_SUBREG DoubleRegs:$src, subreg_loreg))))>; -// Map memw(Rs) = Rdd -> memw(Rs) = Rt. +// Map memb(Rs) = Rdd -> memb(Rs) = Rt. def : Pat<(truncstorei8 DoubleRegs:$src, ADDRriS11_0:$addr), (STrib ADDRriS11_0:$addr, (i32 (EXTRACT_SUBREG DoubleRegs:$src, subreg_loreg)))>; @@ -2755,6 +2750,11 @@ (STrih ADDRriS11_0:$addr, (i32 (EXTRACT_SUBREG DoubleRegs:$src, subreg_loreg)))>; +// Map memw(Rs) = Rdd -> memw(Rs) = Rt. +def : Pat<(truncstorei32 DoubleRegs:$src, ADDRriS11_0:$addr), + (STriw ADDRriS11_0:$addr, (i32 (EXTRACT_SUBREG DoubleRegs:$src, + subreg_loreg)))>; + // Map from i1 = constant<-1>; memw(addr) = i1 -> r0 = 1; memw(addr) = r0. def : Pat<(store (i1 -1), ADDRriS11_2:$addr), (STrib ADDRriS11_2:$addr, (TFRI 1))>; Modified: llvm/trunk/lib/Target/Hexagon/HexagonRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonRegisterInfo.cpp?rev=151166&r1=151165&r2=151166&view=diff ============================================================================== --- llvm/trunk/lib/Target/Hexagon/HexagonRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Hexagon/HexagonRegisterInfo.cpp Wed Feb 22 10:45:10 2012 @@ -206,8 +206,7 @@ } else if ((MI.getOpcode() == Hexagon::STriw) || (MI.getOpcode() == Hexagon::STrid) || (MI.getOpcode() == Hexagon::STrih) || - (MI.getOpcode() == Hexagon::STrib) || - (MI.getOpcode() == Hexagon::STriwt)) { + (MI.getOpcode() == Hexagon::STrib)) { // For stores, we need a reserved register. Change // memw(r30 + #10000) = r0 to: // From stoklund at 2pi.dk Wed Feb 22 10:50:46 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 22 Feb 2012 16:50:46 -0000 Subject: [llvm-commits] [llvm] r151167 - /llvm/trunk/lib/CodeGen/RegAllocFast.cpp Message-ID: <20120222165046.E77C82A6C12F@llvm.org> Author: stoklund Date: Wed Feb 22 10:50:46 2012 New Revision: 151167 URL: http://llvm.org/viewvc/llvm-project?rev=151167&view=rev Log: 80 col. Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocFast.cpp?rev=151167&r1=151166&r2=151167&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocFast.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocFast.cpp Wed Feb 22 10:50:46 2012 @@ -232,7 +232,8 @@ /// killVirtReg - Mark virtreg as no longer available. void RAFast::killVirtReg(LiveRegMap::iterator LRI) { addKillFlag(*LRI); - assert(PhysRegState[LRI->PhysReg] == LRI->VirtReg && "Broken RegState mapping"); + assert(PhysRegState[LRI->PhysReg] == LRI->VirtReg && + "Broken RegState mapping"); PhysRegState[LRI->PhysReg] = regFree; // Erase from LiveVirtRegs unless we're spilling in bulk. if (!isBulkSpilling) @@ -304,8 +305,9 @@ DEBUG(dbgs() << "Inserting debug info due to spill:" << "\n" << *NewDV); } } - // Now this register is spilled there is should not be any DBG_VALUE pointing - // to this register because they are all pointing to spilled value now. + // Now this register is spilled there is should not be any DBG_VALUE + // pointing to this register because they are all pointing to spilled value + // now. LRIDbgValues.clear(); if (SpillKill) LR.LastUse = 0; // Don't kill register again From kcc at google.com Wed Feb 22 11:06:27 2012 From: kcc at google.com (Kostya Serebryany) Date: Wed, 22 Feb 2012 09:06:27 -0800 Subject: [llvm-commits] [compiler-rt] r151157 - /compiler-rt/trunk/lib/asan/Makefile.old In-Reply-To: <20120222115944.94B322A6C12F@llvm.org> References: <20120222115944.94B322A6C12F@llvm.org> Message-ID: Why? This will cause gtest to be rebuilt on every change? On Wed, Feb 22, 2012 at 3:59 AM, Alexey Samsonov wrote: > Author: samsonov > Date: Wed Feb 22 05:59:44 2012 > New Revision: 151157 > > URL: http://llvm.org/viewvc/llvm-project?rev=151157&view=rev > Log: > AddressSanitizer: fix Makefile.old - gtest should depend on libasan > > Modified: > compiler-rt/trunk/lib/asan/Makefile.old > > Modified: compiler-rt/trunk/lib/asan/Makefile.old > URL: > http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/Makefile.old?rev=151157&r1=151156&r2=151157&view=diff > > ============================================================================== > --- compiler-rt/trunk/lib/asan/Makefile.old (original) > +++ compiler-rt/trunk/lib/asan/Makefile.old Wed Feb 22 05:59:44 2012 > @@ -320,7 +320,7 @@ > asan_benchmarks: $(BIN)/asan_benchmarks$(SUFF) > > # for now, build gtest with clang/asan even if we use a different > compiler. > -$(GTEST_LIB): > +$(GTEST_LIB): $(LIBASAN_A) > mkdir -p $(GTEST_MAKE_DIR) && \ > cd $(GTEST_MAKE_DIR) && \ > $(MAKE) -f ../make/Makefile CXXFLAGS="$(PIE) $(CFLAGS) -g -w" \ > > > _______________________________________________ > 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/20120222/efff586b/attachment.html From kcc at google.com Wed Feb 22 11:11:52 2012 From: kcc at google.com (Kostya Serebryany) Date: Wed, 22 Feb 2012 09:11:52 -0800 Subject: [llvm-commits] [PATCH] [asan] Code style fixup In-Reply-To: References: Message-ID: LGTM, thanks! Much nicer now. --kcc On Wed, Feb 22, 2012 at 5:16 AM, Evgeniy Stepanov wrote: > Hi, > > #ifdef is evil, so this patch replaces several #ifdef with plain if(). > As a result, the code contains less #ifdefs, but more if()s, than > before. > > Please review. > > _______________________________________________ > 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/20120222/46151083/attachment.html From mcrosier at apple.com Wed Feb 22 11:25:00 2012 From: mcrosier at apple.com (Chad Rosier) Date: Wed, 22 Feb 2012 17:25:00 -0000 Subject: [llvm-commits] [llvm] r151169 - in /llvm/trunk/lib: Analysis/RegionInfo.cpp CodeGen/BranchFolding.cpp Support/DataExtractor.cpp Target/ARM/ARMBaseRegisterInfo.cpp Target/MSP430/MSP430ISelLowering.cpp Target/X86/X86Subtarget.cpp VMCore/GCOV.cpp Message-ID: <20120222172500.9202D2A6C12F@llvm.org> Author: mcrosier Date: Wed Feb 22 11:25:00 2012 New Revision: 151169 URL: http://llvm.org/viewvc/llvm-project?rev=151169&view=rev Log: Remove extra semi-colons. Modified: llvm/trunk/lib/Analysis/RegionInfo.cpp llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/Support/DataExtractor.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/X86/X86Subtarget.cpp llvm/trunk/lib/VMCore/GCOV.cpp Modified: llvm/trunk/lib/Analysis/RegionInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/RegionInfo.cpp?rev=151169&r1=151168&r2=151169&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/RegionInfo.cpp (original) +++ llvm/trunk/lib/Analysis/RegionInfo.cpp Wed Feb 22 11:25:00 2012 @@ -650,7 +650,7 @@ // This basic block is a start block of a region. It is already in the // BBtoRegion relation. Only the child basic blocks have to be updated. if (it != BBtoRegion.end()) { - Region *newRegion = it->second;; + Region *newRegion = it->second; region->addSubRegion(getTopMostParent(newRegion)); region = newRegion; } else { Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=151169&r1=151168&r2=151169&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Feb 22 11:25:00 2012 @@ -1111,7 +1111,7 @@ } } PrevBB.splice(PrevBB.end(), MBB, MBB->begin(), MBB->end()); - PrevBB.removeSuccessor(PrevBB.succ_begin());; + PrevBB.removeSuccessor(PrevBB.succ_begin()); assert(PrevBB.succ_empty()); PrevBB.transferSuccessors(MBB); MadeChange = true; @@ -1670,7 +1670,7 @@ LocalDefsSet.insert(*OR); } - HasDups = true;; + HasDups = true; ++TIB; ++FIB; } Modified: llvm/trunk/lib/Support/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DataExtractor.cpp?rev=151169&r1=151168&r2=151169&view=diff ============================================================================== --- llvm/trunk/lib/Support/DataExtractor.cpp (original) +++ llvm/trunk/lib/Support/DataExtractor.cpp Wed Feb 22 11:25:00 2012 @@ -75,7 +75,7 @@ uint32_t *DataExtractor::getU32(uint32_t *offset_ptr, uint32_t *dst, uint32_t count) const { return getUs(offset_ptr, dst, count, this, IsLittleEndian, - Data.data());; + Data.data()); } uint64_t DataExtractor::getU64(uint32_t *offset_ptr) const { Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=151169&r1=151168&r2=151169&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Feb 22 11:25:00 2012 @@ -779,7 +779,7 @@ getFrameIndexInstrOffset(const MachineInstr *MI, int Idx) const { const MCInstrDesc &Desc = MI->getDesc(); unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask); - int64_t InstrOffs = 0;; + int64_t InstrOffs = 0; int Scale = 1; unsigned ImmIdx = 0; switch (AddrMode) { Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=151169&r1=151168&r2=151169&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Wed Feb 22 11:25:00 2012 @@ -644,7 +644,7 @@ const char *Sym = cast(Op)->getSymbol(); SDValue Result = DAG.getTargetExternalSymbol(Sym, getPointerTy()); - return DAG.getNode(MSP430ISD::Wrapper, dl, getPointerTy(), Result);; + return DAG.getNode(MSP430ISD::Wrapper, dl, getPointerTy(), Result); } SDValue MSP430TargetLowering::LowerBlockAddress(SDValue Op, @@ -653,7 +653,7 @@ const BlockAddress *BA = cast(Op)->getBlockAddress(); SDValue Result = DAG.getBlockAddress(BA, getPointerTy(), /*isTarget=*/true); - return DAG.getNode(MSP430ISD::Wrapper, dl, getPointerTy(), Result);; + return DAG.getNode(MSP430ISD::Wrapper, dl, getPointerTy(), Result); } static SDValue EmitCMP(SDValue &LHS, SDValue &RHS, SDValue &TargetCC, Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=151169&r1=151168&r2=151169&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Wed Feb 22 11:25:00 2012 @@ -302,7 +302,7 @@ } // FIXME: AVX2 codegen support is not ready. //if ((EBX >> 5) & 0x1) { - // X86SSELevel = AVX2;; + // X86SSELevel = AVX2; // ToggleFeature(X86::FeatureAVX2); //} if ((EBX >> 8) & 0x1) { Modified: llvm/trunk/lib/VMCore/GCOV.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/GCOV.cpp?rev=151169&r1=151168&r2=151169&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/GCOV.cpp (original) +++ llvm/trunk/lib/VMCore/GCOV.cpp Wed Feb 22 11:25:00 2012 @@ -107,7 +107,7 @@ for (unsigned i = 0, e = Count; i != e; ++i) { Blocks[i]->addCount(Buff.readInt64()); } - return true;; + return true; } LineNumber = Buff.readInt(); From samsonov at google.com Wed Feb 22 11:34:20 2012 From: samsonov at google.com (Alexey Samsonov) Date: Wed, 22 Feb 2012 21:34:20 +0400 Subject: [llvm-commits] [compiler-rt] r151157 - /compiler-rt/trunk/lib/asan/Makefile.old In-Reply-To: References: <20120222115944.94B322A6C12F@llvm.org> Message-ID: Looks like our linux bot was red today because of this. Gtest needs libasan.a in clang lib dir, but w/o this dependency makefile could start building gtest before libasan and failed. Why? > This will cause gtest to be rebuilt on every change? > > On Wed, Feb 22, 2012 at 3:59 AM, Alexey Samsonov wrote: > >> Author: samsonov >> Date: Wed Feb 22 05:59:44 2012 >> New Revision: 151157 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=151157&view=rev >> Log: >> AddressSanitizer: fix Makefile.old - gtest should depend on libasan >> >> Modified: >> compiler-rt/trunk/lib/asan/Makefile.old >> >> Modified: compiler-rt/trunk/lib/asan/Makefile.old >> URL: >> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/Makefile.old?rev=151157&r1=151156&r2=151157&view=diff >> >> ============================================================================== >> --- compiler-rt/trunk/lib/asan/Makefile.old (original) >> +++ compiler-rt/trunk/lib/asan/Makefile.old Wed Feb 22 05:59:44 2012 >> @@ -320,7 +320,7 @@ >> asan_benchmarks: $(BIN)/asan_benchmarks$(SUFF) >> >> # for now, build gtest with clang/asan even if we use a different >> compiler. >> -$(GTEST_LIB): >> +$(GTEST_LIB): $(LIBASAN_A) >> mkdir -p $(GTEST_MAKE_DIR) && \ >> cd $(GTEST_MAKE_DIR) && \ >> $(MAKE) -f ../make/Makefile CXXFLAGS="$(PIE) $(CFLAGS) -g -w" \ >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > -- Alexey Samsonov Software Engineer, Moscow samsonov at google.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/5c1e1281/attachment.html From samsonov at google.com Wed Feb 22 11:36:09 2012 From: samsonov at google.com (Alexey Samsonov) Date: Wed, 22 Feb 2012 21:36:09 +0400 Subject: [llvm-commits] [compiler-rt] r151165 - /compiler-rt/trunk/lib/asan/asan_internal.h In-Reply-To: References: <20120222161246.4A7AD2A6C12F@llvm.org> Message-ID: Why do you think it's better here? On Wed, Feb 22, 2012 at 8:25 PM, Timur Iskhodzhanov wrote: > why not > #ifndef INT32_MIN > # define INT32_MIN ... > #endif > instead? > > > On Wed, Feb 22, 2012 at 8:12 PM, Alexey Samsonov > wrote: > > Author: samsonov > > Date: Wed Feb 22 10:12:46 2012 > > New Revision: 151165 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=151165&view=rev > > Log: > > AddressSanitizer: quick fix - undef INT32_MIN etc to avoid macro > redefinition > > > > Modified: > > compiler-rt/trunk/lib/asan/asan_internal.h > > > > Modified: compiler-rt/trunk/lib/asan/asan_internal.h > > URL: > http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=151165&r1=151164&r2=151165&view=diff > > > ============================================================================== > > --- compiler-rt/trunk/lib/asan/asan_internal.h (original) > > +++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Feb 22 10:12:46 2012 > > @@ -68,12 +68,18 @@ > > # define __INT64_C(c) c ## LL > > # define __UINT64_C(c) c ## ULL > > #endif // __WORDSIZE == 64 > > -# define INT32_MIN (-2147483647-1) > > -# define INT32_MAX (2147483647) > > -# define UINT32_MAX (4294967295U) > > -# define INT64_MIN (-__INT64_C(9223372036854775807)-1) > > -# define INT64_MAX (__INT64_C(9223372036854775807)) > > -# define UINT64_MAX (__UINT64_C(18446744073709551615)) > > +#undef INT32_MIN > > +#define INT32_MIN (-2147483647-1) > > +#undef INT32_MAX > > +#define INT32_MAX (2147483647) > > +#undef UINT32_MAX > > +#define UINT32_MAX (4294967295U) > > +#undef INT64_MIN > > +#define INT64_MIN (-__INT64_C(9223372036854775807)-1) > > +#undef INT64_MAX > > +#define INT64_MAX (__INT64_C(9223372036854775807)) > > +#undef UINT64_MAX > > +#define UINT64_MAX (__UINT64_C(18446744073709551615)) > > > > #define ASAN_DEFAULT_FAILURE_EXITCODE 1 > > > > > > > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- Alexey Samsonov Software Engineer, Moscow samsonov at google.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/4a4370e7/attachment.html From kcc at google.com Wed Feb 22 11:57:32 2012 From: kcc at google.com (Kostya Serebryany) Date: Wed, 22 Feb 2012 09:57:32 -0800 Subject: [llvm-commits] [compiler-rt] r151157 - /compiler-rt/trunk/lib/asan/Makefile.old In-Reply-To: References: <20120222115944.94B322A6C12F@llvm.org> Message-ID: You solved wrong problem with this change. Instead, we need to build gtest w/o asan (and allow linking a pre-built system gtest). It did not work last time I tried (gtest uses static CTORs which call some functions we intercept). But we need to fix this. --kcc On Wed, Feb 22, 2012 at 9:34 AM, Alexey Samsonov wrote: > Looks like our linux bot was red today because of this. > Gtest needs libasan.a in clang lib dir, but w/o this dependency > makefile could start building gtest before libasan and failed. > > Why? >> This will cause gtest to be rebuilt on every change? >> >> On Wed, Feb 22, 2012 at 3:59 AM, Alexey Samsonov wrote: >> >>> Author: samsonov >>> Date: Wed Feb 22 05:59:44 2012 >>> New Revision: 151157 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=151157&view=rev >>> Log: >>> AddressSanitizer: fix Makefile.old - gtest should depend on libasan >>> >>> Modified: >>> compiler-rt/trunk/lib/asan/Makefile.old >>> >>> Modified: compiler-rt/trunk/lib/asan/Makefile.old >>> URL: >>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/Makefile.old?rev=151157&r1=151156&r2=151157&view=diff >>> >>> ============================================================================== >>> --- compiler-rt/trunk/lib/asan/Makefile.old (original) >>> +++ compiler-rt/trunk/lib/asan/Makefile.old Wed Feb 22 05:59:44 2012 >>> @@ -320,7 +320,7 @@ >>> asan_benchmarks: $(BIN)/asan_benchmarks$(SUFF) >>> >>> # for now, build gtest with clang/asan even if we use a different >>> compiler. >>> -$(GTEST_LIB): >>> +$(GTEST_LIB): $(LIBASAN_A) >>> mkdir -p $(GTEST_MAKE_DIR) && \ >>> cd $(GTEST_MAKE_DIR) && \ >>> $(MAKE) -f ../make/Makefile CXXFLAGS="$(PIE) $(CFLAGS) -g -w" \ >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >> >> > > > -- > Alexey Samsonov > Software Engineer, Moscow > samsonov at google.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/818624ef/attachment.html From kcc at google.com Wed Feb 22 12:00:57 2012 From: kcc at google.com (Kostya Serebryany) Date: Wed, 22 Feb 2012 10:00:57 -0800 Subject: [llvm-commits] [compiler-rt] r151165 - /compiler-rt/trunk/lib/asan/asan_internal.h In-Reply-To: References: <20120222161246.4A7AD2A6C12F@llvm.org> Message-ID: Why do you need this macro at all if you are not using it? I would actually ask to define const uint64_t kMaxInt64 = ... inside the module (or function) where you need it and get rid of all these macros completely. --kcc On Wed, Feb 22, 2012 at 9:36 AM, Alexey Samsonov wrote: > Why do you think it's better here? > > > On Wed, Feb 22, 2012 at 8:25 PM, Timur Iskhodzhanov wrote: > >> why not >> #ifndef INT32_MIN >> # define INT32_MIN ... >> #endif >> instead? >> >> >> On Wed, Feb 22, 2012 at 8:12 PM, Alexey Samsonov >> wrote: >> > Author: samsonov >> > Date: Wed Feb 22 10:12:46 2012 >> > New Revision: 151165 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=151165&view=rev >> > Log: >> > AddressSanitizer: quick fix - undef INT32_MIN etc to avoid macro >> redefinition >> > >> > Modified: >> > compiler-rt/trunk/lib/asan/asan_internal.h >> > >> > Modified: compiler-rt/trunk/lib/asan/asan_internal.h >> > URL: >> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=151165&r1=151164&r2=151165&view=diff >> > >> ============================================================================== >> > --- compiler-rt/trunk/lib/asan/asan_internal.h (original) >> > +++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Feb 22 10:12:46 2012 >> > @@ -68,12 +68,18 @@ >> > # define __INT64_C(c) c ## LL >> > # define __UINT64_C(c) c ## ULL >> > #endif // __WORDSIZE == 64 >> > -# define INT32_MIN (-2147483647-1) >> > -# define INT32_MAX (2147483647) >> > -# define UINT32_MAX (4294967295U) >> > -# define INT64_MIN (-__INT64_C(9223372036854775807)-1) >> > -# define INT64_MAX (__INT64_C(9223372036854775807)) >> > -# define UINT64_MAX (__UINT64_C(18446744073709551615)) >> > +#undef INT32_MIN >> > +#define INT32_MIN (-2147483647-1) >> > +#undef INT32_MAX >> > +#define INT32_MAX (2147483647) >> > +#undef UINT32_MAX >> > +#define UINT32_MAX (4294967295U) >> > +#undef INT64_MIN >> > +#define INT64_MIN (-__INT64_C(9223372036854775807)-1) >> > +#undef INT64_MAX >> > +#define INT64_MAX (__INT64_C(9223372036854775807)) >> > +#undef UINT64_MAX >> > +#define UINT64_MAX (__UINT64_C(18446744073709551615)) >> > >> > #define ASAN_DEFAULT_FAILURE_EXITCODE 1 >> > >> > >> > >> > _______________________________________________ >> > llvm-commits mailing list >> > llvm-commits at cs.uiuc.edu >> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > > > -- > Alexey Samsonov > Software Engineer, Moscow > samsonov at google.com > > > _______________________________________________ > 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/20120222/20a50381/attachment.html From stoklund at 2pi.dk Wed Feb 22 12:09:01 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 22 Feb 2012 10:09:01 -0800 Subject: [llvm-commits] [llvm] r151136 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp In-Reply-To: <20120222060813.A68F92A6C12F@llvm.org> References: <20120222060813.A68F92A6C12F@llvm.org> Message-ID: <36ABA142-FAF1-4474-8AA9-FD0645F6CA2B@2pi.dk> On Feb 21, 2012, at 10:08 PM, Andrew Trick wrote: > > + // SSA defs do not have output/anti dependencies. > + if (llvm::next(MRI.def_begin(Reg)) == MRI.def_end()) > + return; > + Note that after ProcessImplicitDefs, virtual registers may not have a def, and next(def_begin) is not allowed. (It's fine in this case because the code is explicitly handling a def of Reg). Should this be a method on MRI, like MRI::hasOneUse? /jakob From samsonov at google.com Wed Feb 22 12:12:29 2012 From: samsonov at google.com (Alexey Samsonov) Date: Wed, 22 Feb 2012 22:12:29 +0400 Subject: [llvm-commits] [compiler-rt] r151157 - /compiler-rt/trunk/lib/asan/Makefile.old In-Reply-To: References: <20120222115944.94B322A6C12F@llvm.org> Message-ID: Got it. You solved wrong problem with this change. > > Instead, we need to build gtest w/o asan (and allow linking a pre-built > system gtest). > It did not work last time I tried (gtest uses static CTORs which call some > functions we intercept). > But we need to fix this. > > --kcc > > > On Wed, Feb 22, 2012 at 9:34 AM, Alexey Samsonov wrote: > >> Looks like our linux bot was red today because of this. >> Gtest needs libasan.a in clang lib dir, but w/o this dependency >> makefile could start building gtest before libasan and failed. >> >> Why? >>> This will cause gtest to be rebuilt on every change? >>> >>> On Wed, Feb 22, 2012 at 3:59 AM, Alexey Samsonov wrote: >>> >>>> Author: samsonov >>>> Date: Wed Feb 22 05:59:44 2012 >>>> New Revision: 151157 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=151157&view=rev >>>> Log: >>>> AddressSanitizer: fix Makefile.old - gtest should depend on libasan >>>> >>>> Modified: >>>> compiler-rt/trunk/lib/asan/Makefile.old >>>> >>>> Modified: compiler-rt/trunk/lib/asan/Makefile.old >>>> URL: >>>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/Makefile.old?rev=151157&r1=151156&r2=151157&view=diff >>>> >>>> ============================================================================== >>>> --- compiler-rt/trunk/lib/asan/Makefile.old (original) >>>> +++ compiler-rt/trunk/lib/asan/Makefile.old Wed Feb 22 05:59:44 2012 >>>> @@ -320,7 +320,7 @@ >>>> asan_benchmarks: $(BIN)/asan_benchmarks$(SUFF) >>>> >>>> # for now, build gtest with clang/asan even if we use a different >>>> compiler. >>>> -$(GTEST_LIB): >>>> +$(GTEST_LIB): $(LIBASAN_A) >>>> mkdir -p $(GTEST_MAKE_DIR) && \ >>>> cd $(GTEST_MAKE_DIR) && \ >>>> $(MAKE) -f ../make/Makefile CXXFLAGS="$(PIE) $(CFLAGS) -g -w" \ >>>> >>>> >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>>> >>> >>> >> >> >> -- >> Alexey Samsonov >> Software Engineer, Moscow >> samsonov at google.com >> >> > -- Alexey Samsonov Software Engineer, Moscow samsonov at google.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/0b975f6e/attachment.html From samsonov at google.com Wed Feb 22 12:13:58 2012 From: samsonov at google.com (Alexey Samsonov) Date: Wed, 22 Feb 2012 22:13:58 +0400 Subject: [llvm-commits] [compiler-rt] r151165 - /compiler-rt/trunk/lib/asan/asan_internal.h In-Reply-To: References: <20120222161246.4A7AD2A6C12F@llvm.org> Message-ID: Ok. On Wed, Feb 22, 2012 at 10:00 PM, Kostya Serebryany wrote: > Why do you need this macro at all if you are not using it? > I would actually ask to define > const uint64_t kMaxInt64 = ... > inside the module (or function) where you need it and get rid of all these > macros completely. > > --kcc > > > On Wed, Feb 22, 2012 at 9:36 AM, Alexey Samsonov wrote: > >> Why do you think it's better here? >> >> >> On Wed, Feb 22, 2012 at 8:25 PM, Timur Iskhodzhanov wrote: >> >>> why not >>> #ifndef INT32_MIN >>> # define INT32_MIN ... >>> #endif >>> instead? >>> >>> >>> On Wed, Feb 22, 2012 at 8:12 PM, Alexey Samsonov >>> wrote: >>> > Author: samsonov >>> > Date: Wed Feb 22 10:12:46 2012 >>> > New Revision: 151165 >>> > >>> > URL: http://llvm.org/viewvc/llvm-project?rev=151165&view=rev >>> > Log: >>> > AddressSanitizer: quick fix - undef INT32_MIN etc to avoid macro >>> redefinition >>> > >>> > Modified: >>> > compiler-rt/trunk/lib/asan/asan_internal.h >>> > >>> > Modified: compiler-rt/trunk/lib/asan/asan_internal.h >>> > URL: >>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=151165&r1=151164&r2=151165&view=diff >>> > >>> ============================================================================== >>> > --- compiler-rt/trunk/lib/asan/asan_internal.h (original) >>> > +++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Feb 22 10:12:46 2012 >>> > @@ -68,12 +68,18 @@ >>> > # define __INT64_C(c) c ## LL >>> > # define __UINT64_C(c) c ## ULL >>> > #endif // __WORDSIZE == 64 >>> > -# define INT32_MIN (-2147483647-1) >>> > -# define INT32_MAX (2147483647) >>> > -# define UINT32_MAX (4294967295U) >>> > -# define INT64_MIN (-__INT64_C(9223372036854775807)-1) >>> > -# define INT64_MAX (__INT64_C(9223372036854775807)) >>> > -# define UINT64_MAX (__UINT64_C(18446744073709551615)) >>> > +#undef INT32_MIN >>> > +#define INT32_MIN (-2147483647-1) >>> > +#undef INT32_MAX >>> > +#define INT32_MAX (2147483647) >>> > +#undef UINT32_MAX >>> > +#define UINT32_MAX (4294967295U) >>> > +#undef INT64_MIN >>> > +#define INT64_MIN (-__INT64_C(9223372036854775807)-1) >>> > +#undef INT64_MAX >>> > +#define INT64_MAX (__INT64_C(9223372036854775807)) >>> > +#undef UINT64_MAX >>> > +#define UINT64_MAX (__UINT64_C(18446744073709551615)) >>> > >>> > #define ASAN_DEFAULT_FAILURE_EXITCODE 1 >>> > >>> > >>> > >>> > _______________________________________________ >>> > llvm-commits mailing list >>> > llvm-commits at cs.uiuc.edu >>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >> >> >> >> -- >> Alexey Samsonov >> Software Engineer, Moscow >> samsonov at google.com >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> > -- Alexey Samsonov Software Engineer, Moscow samsonov at google.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/1faf8aed/attachment.html From atrick at apple.com Wed Feb 22 12:27:46 2012 From: atrick at apple.com (Andrew Trick) Date: Wed, 22 Feb 2012 10:27:46 -0800 Subject: [llvm-commits] [llvm] r150885 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp In-Reply-To: <4F449FB8.1060506@free.fr> References: <20120218175143.39EC02A6C12F@llvm.org> <4F400451.9030203@gmail.com> <4F402019.3020805@gmail.com> <4F40C8EE.9070003@free.fr> <4F415BC7.5090408@gmail.com> <4F4217AC.6010204@free.fr> <4F432A21.5060208@gmail.com> <86393DD4-9EBF-4098-98A3-7EC429B1A324@apple.com> <4F449FB8.1060506@free.fr> Message-ID: On Feb 21, 2012, at 11:56 PM, Duncan Sands wrote: > Hi Andrew, > >> // If A is an invoke instruction, its value is only available in this normal >> // successor block. >> if (const InvokeInst *II = dyn_cast(A)) { >> BBA = II->getNormalDest(); >> + if (BBA == BBB) return true; >> } > > why is this correct? The normal destination of an invoke could have other > predecessors (in that case the only possible uses of the invoke value are > in phi nodes). For a routine of this generality, I think it is important > to handle all cases without assuming anything about where the instructions > in question came from (e.g. in Rafael's use case the logic could probably be > simplified, but those special features can't be assumed here, at least not > without auditing all uses of this method and documenting [and checking with > assertions] the assumptions). Sorry I missed that discussion. You do additionally need to check that Invoke.BB dominates BBB. The point is that the current implementation is correct apart from invoke dominance. I don't think we want to rewrite it. I vote for: if (const InvokeInst *II = dyn_cast(A)) { // Invoke cannot dominate anything in its block. if (!properlyDominates(BBA, BBB)) return false; // An invoke's value is only available in its normal successor. // A critcal edge to the normal successor is ruled out by the // properlyDomintes check above. BBA = II->getNormalDest(); return dominates(BBA, BBB); } For extra credit, you could avoid calling dominates twice by directly checking for a critical edge. > By the way, I think the name dominatesUse is a bit confusing. After all, > instructions always dominates their uses, so it sounds like it should just > return "true" :) How about leaving the name "dominates" and explaining more > in the comment describing the method (note that the comment in the header > already doesn't match the comment here). Or just call it: > dominatesInTheAppropriateWayForThisToBeAUseOfTheOther :) Agreed. -Andy From atrick at apple.com Wed Feb 22 12:35:53 2012 From: atrick at apple.com (Andrew Trick) Date: Wed, 22 Feb 2012 10:35:53 -0800 Subject: [llvm-commits] [llvm] r151136 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp In-Reply-To: <36ABA142-FAF1-4474-8AA9-FD0645F6CA2B@2pi.dk> References: <20120222060813.A68F92A6C12F@llvm.org> <36ABA142-FAF1-4474-8AA9-FD0645F6CA2B@2pi.dk> Message-ID: On Feb 22, 2012, at 10:09 AM, Jakob Stoklund Olesen wrote: > > On Feb 21, 2012, at 10:08 PM, Andrew Trick wrote: > >> >> + // SSA defs do not have output/anti dependencies. >> + if (llvm::next(MRI.def_begin(Reg)) == MRI.def_end()) >> + return; >> + > > Note that after ProcessImplicitDefs, virtual registers may not have a def, and next(def_begin) is not allowed. (It's fine in this case because the code is explicitly handling a def of Reg). > > Should this be a method on MRI, like MRI::hasOneUse? I'm the only client for now, and was taking advantage of the fact that we're already explicitly processing a def of the reg. More comments on the way. -Andy From atrick at apple.com Wed Feb 22 12:34:50 2012 From: atrick at apple.com (Andrew Trick) Date: Wed, 22 Feb 2012 18:34:50 -0000 Subject: [llvm-commits] [llvm] r151178 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Message-ID: <20120222183450.1F3E92A6C12F@llvm.org> Author: atrick Date: Wed Feb 22 12:34:49 2012 New Revision: 151178 URL: http://llvm.org/viewvc/llvm-project?rev=151178&view=rev Log: Comment from code review Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=151178&r1=151177&r2=151178&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Wed Feb 22 12:34:49 2012 @@ -362,6 +362,7 @@ unsigned Reg = MI->getOperand(OperIdx).getReg(); // SSA defs do not have output/anti dependencies. + // The current operand is a def, so we have at least one. if (llvm::next(MRI.def_begin(Reg)) == MRI.def_end()) return; From bigcheesegs at gmail.com Wed Feb 22 13:06:14 2012 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Wed, 22 Feb 2012 19:06:14 -0000 Subject: [llvm-commits] [llvm] r151183 - in /llvm/trunk: include/llvm/CodeGen/FunctionLoweringInfo.h include/llvm/CodeGen/MachineModuleInfo.h lib/CodeGen/MachineModuleInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp lib/Target/X86/X86AsmPrinter.cpp test/CodeGen/X86/fltused.ll test/CodeGen/X86/fltused_function_pointer.ll Message-ID: <20120222190614.DAECF2A6C12F@llvm.org> Author: mspencer Date: Wed Feb 22 13:06:13 2012 New Revision: 151183 URL: http://llvm.org/viewvc/llvm-project?rev=151183&view=rev Log: Properly emit _fltused with FastISel. Refactor to share code with SDAG. Patch by Joe Groff! Added: llvm/trunk/test/CodeGen/X86/fltused_function_pointer.ll - copied, changed from r151178, llvm/trunk/test/CodeGen/X86/fltused.ll Modified: llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp llvm/trunk/test/CodeGen/X86/fltused.ll Modified: llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h?rev=151183&r1=151182&r2=151183&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/FunctionLoweringInfo.h Wed Feb 22 13:06:13 2012 @@ -202,7 +202,7 @@ /// setArgumentFrameIndex - Record frame index for the byval /// argument. void setArgumentFrameIndex(const Argument *A, int FI); - + /// getArgumentFrameIndex - Get frame index for the byval argument. int getArgumentFrameIndex(const Argument *A); @@ -211,6 +211,13 @@ IndexedMap LiveOutRegInfo; }; +/// ComputeUsesVAFloatArgument - Determine if any floating-point values are +/// being passed to this variadic function, and set the MachineModuleInfo's +/// usesVAFloatArgument flag if so. This flag is used to emit an undefined +/// reference to _fltused on Windows, which will link in MSVCRT's +/// floating-point support. +void ComputeUsesVAFloatArgument(const CallInst &I, MachineModuleInfo *MMI); + /// AddCatchInfo - Extract the personality and type infos from an eh.selector /// call, and add them to the specified machine basic block. void AddCatchInfo(const CallInst &I, Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=151183&r1=151182&r2=151183&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Wed Feb 22 13:06:13 2012 @@ -161,10 +161,10 @@ /// in this module. bool DbgInfoAvailable; - /// CallsExternalVAFunctionWithFloatingPointArguments - True if this module - /// calls VarArg function with floating point arguments. This is used to emit - /// an undefined reference to fltused on Windows targets. - bool CallsExternalVAFunctionWithFloatingPointArguments; + /// UsesVAFloatArgument - True if this module calls VarArg function with + /// floating-point arguments. This is used to emit an undefined reference + /// to _fltused on Windows targets. + bool UsesVAFloatArgument; public: static char ID; // Pass identification, replacement for typeid @@ -223,12 +223,12 @@ bool callsUnwindInit() const { return CallsUnwindInit; } void setCallsUnwindInit(bool b) { CallsUnwindInit = b; } - bool callsExternalVAFunctionWithFloatingPointArguments() const { - return CallsExternalVAFunctionWithFloatingPointArguments; + bool usesVAFloatArgument() const { + return UsesVAFloatArgument; } - void setCallsExternalVAFunctionWithFloatingPointArguments(bool b) { - CallsExternalVAFunctionWithFloatingPointArguments = b; + void setUsesVAFloatArgument(bool b) { + UsesVAFloatArgument = b; } /// getFrameMoves - Returns a reference to a list of moves done in the current Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=151183&r1=151182&r2=151183&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Wed Feb 22 13:06:13 2012 @@ -257,7 +257,7 @@ : ImmutablePass(ID), Context(MAI, MRI, MOFI), ObjFileMMI(0), CompactUnwindEncoding(0), CurCallSite(0), CallsEHReturn(0), CallsUnwindInit(0), DbgInfoAvailable(false), - CallsExternalVAFunctionWithFloatingPointArguments(false) { + UsesVAFloatArgument(false) { initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry()); // Always emit some info, by default "no personality" info. Personalities.push_back(NULL); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=151183&r1=151182&r2=151183&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Wed Feb 22 13:06:13 2012 @@ -561,6 +561,9 @@ return true; } + MachineModuleInfo &MMI = FuncInfo.MF->getMMI(); + ComputeUsesVAFloatArgument(*Call, &MMI); + const Function *F = Call->getCalledFunction(); if (!F) return false; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=151183&r1=151182&r2=151183&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Wed Feb 22 13:06:13 2012 @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "function-lowering-info" +#include "llvm/ADT/PostOrderIterator.h" #include "llvm/CodeGen/FunctionLoweringInfo.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" @@ -371,6 +372,30 @@ return 0; } +/// ComputeUsesVAFloatArgument - Determine if any floating-point values are +/// being passed to this variadic function, and set the MachineModuleInfo's +/// usesVAFloatArgument flag if so. This flag is used to emit an undefined +/// reference to _fltused on Windows, which will link in MSVCRT's +/// floating-point support. +void llvm::ComputeUsesVAFloatArgument(const CallInst &I, + MachineModuleInfo *MMI) +{ + FunctionType *FT = cast( + I.getCalledValue()->getType()->getContainedType(0)); + if (FT->isVarArg() && !MMI->usesVAFloatArgument()) { + for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i) { + Type* T = I.getArgOperand(i)->getType(); + for (po_iterator i = po_begin(T), e = po_end(T); + i != e; ++i) { + if (i->isFloatingPointTy()) { + MMI->setUsesVAFloatArgument(true); + return; + } + } + } + } +} + /// AddCatchInfo - Extract the personality and type infos from an eh.selector /// call, and add them to the specified machine basic block. void llvm::AddCatchInfo(const CallInst &I, MachineModuleInfo *MMI, Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=151183&r1=151182&r2=151183&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Feb 22 13:06:13 2012 @@ -5454,23 +5454,8 @@ return; } - // See if any floating point values are being passed to this function. This is - // used to emit an undefined reference to fltused on Windows. - FunctionType *FT = - cast(I.getCalledValue()->getType()->getContainedType(0)); MachineModuleInfo &MMI = DAG.getMachineFunction().getMMI(); - if (FT->isVarArg() && - !MMI.callsExternalVAFunctionWithFloatingPointArguments()) { - for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i) { - Type* T = I.getArgOperand(i)->getType(); - for (po_iterator i = po_begin(T), e = po_end(T); - i != e; ++i) { - if (!i->isFloatingPointTy()) continue; - MMI.setCallsExternalVAFunctionWithFloatingPointArguments(true); - break; - } - } - } + ComputeUsesVAFloatArgument(I, &MMI); const char *RenameFn = 0; if (Function *F = I.getCalledFunction()) { Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=151183&r1=151182&r2=151183&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Wed Feb 22 13:06:13 2012 @@ -600,7 +600,7 @@ } if (Subtarget->isTargetWindows() && !Subtarget->isTargetCygMing() && - MMI->callsExternalVAFunctionWithFloatingPointArguments()) { + MMI->usesVAFloatArgument()) { StringRef SymbolName = Subtarget->is64Bit() ? "_fltused" : "__fltused"; MCSymbol *S = MMI->getContext().GetOrCreateSymbol(SymbolName); OutStreamer.EmitSymbolAttribute(S, MCSA_Global); Modified: llvm/trunk/test/CodeGen/X86/fltused.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fltused.ll?rev=151183&r1=151182&r2=151183&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fltused.ll (original) +++ llvm/trunk/test/CodeGen/X86/fltused.ll Wed Feb 22 13:06:13 2012 @@ -4,6 +4,8 @@ ; RUN: llc < %s -mtriple i686-pc-win32 | FileCheck %s --check-prefix WIN32 ; RUN: llc < %s -mtriple x86_64-pc-win32 | FileCheck %s --check-prefix WIN64 +; RUN: llc < %s -O0 -mtriple i686-pc-win32 | FileCheck %s --check-prefix WIN32 +; RUN: llc < %s -O0 -mtriple x86_64-pc-win32 | FileCheck %s --check-prefix WIN64 @.str = private constant [4 x i8] c"%f\0A\00" Copied: llvm/trunk/test/CodeGen/X86/fltused_function_pointer.ll (from r151178, llvm/trunk/test/CodeGen/X86/fltused.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fltused_function_pointer.ll?p2=llvm/trunk/test/CodeGen/X86/fltused_function_pointer.ll&p1=llvm/trunk/test/CodeGen/X86/fltused.ll&r1=151178&r2=151183&rev=151183&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fltused.ll (original) +++ llvm/trunk/test/CodeGen/X86/fltused_function_pointer.ll Wed Feb 22 13:06:13 2012 @@ -4,16 +4,16 @@ ; RUN: llc < %s -mtriple i686-pc-win32 | FileCheck %s --check-prefix WIN32 ; RUN: llc < %s -mtriple x86_64-pc-win32 | FileCheck %s --check-prefix WIN64 +; RUN: llc < %s -O0 -mtriple i686-pc-win32 | FileCheck %s --check-prefix WIN32 +; RUN: llc < %s -O0 -mtriple x86_64-pc-win32 | FileCheck %s --check-prefix WIN64 @.str = private constant [4 x i8] c"%f\0A\00" -define i32 @main() nounwind { +define i32 @foo(i32 (i8*, ...)* %f) nounwind { entry: - %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), double 1.000000e+000) nounwind + %call = tail call i32 (i8*, ...)* %f(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), double 1.000000e+000) nounwind ret i32 0 } -declare i32 @printf(i8* nocapture, ...) nounwind - ; WIN32: .globl __fltused ; WIN64: .globl _fltused From bigcheesegs at gmail.com Wed Feb 22 13:11:42 2012 From: bigcheesegs at gmail.com (Michael Spencer) Date: Wed, 22 Feb 2012 11:11:42 -0800 Subject: [llvm-commits] Patch for pr11798: Emit _fltused during FastISel In-Reply-To: References: Message-ID: On Tue, Feb 21, 2012 at 5:50 PM, Joe Groff wrote: > Here is a revised patch. I moved the logic into a toplevel function in > FunctionLoweringInfo, and shortened the property name to > 'usesVAFloatArgument'. I added a test for fltused with indirect calls > that passes, so I believe the type logic is correct?the type of the > callee should be a pointer-to-FunctionType whether direct or indirect. > After discussing the issue with Bigcheese on IRC, we determined that > checking only for top-level floating point types should be sufficient. > Any other issues? > > -Joe Committed in r151183. - Michael Spencer From sabre at nondot.org Wed Feb 22 13:17:20 2012 From: sabre at nondot.org (Chris Lattner) Date: Wed, 22 Feb 2012 19:17:20 -0000 Subject: [llvm-commits] [llvm] r151186 - /llvm/trunk/docs/DeveloperPolicy.html Message-ID: <20120222191720.877FE2A6C12F@llvm.org> Author: lattner Date: Wed Feb 22 13:17:20 2012 New Revision: 151186 URL: http://llvm.org/viewvc/llvm-project?rev=151186&view=rev Log: libclc is now dual licensed, Tobias and Peter own their respective subprojects. Modified: llvm/trunk/docs/DeveloperPolicy.html Modified: llvm/trunk/docs/DeveloperPolicy.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/DeveloperPolicy.html?rev=151186&r1=151185&r2=151186&view=diff ============================================================================== --- llvm/trunk/docs/DeveloperPolicy.html (original) +++ llvm/trunk/docs/DeveloperPolicy.html Wed Feb 22 13:17:20 2012 @@ -215,6 +215,10 @@
    • Jakob Olesen: Register allocators and TableGen.
    • Duncan Sands: dragonegg and llvm-gcc 4.2.
    • + +
    • Peter Collingbourne: libclc.
    • + +
    • Tobias Grosser: polly.
    • Note that code ownership is completely different than reviewers: anyone can @@ -566,7 +570,7 @@ if further clarification is needed.

      In addition to the UIUC license, the runtime library components of LLVM - (compiler_rt and libc++) are also licensed under the compiler_rt, libc++, and libclc) are also licensed under the MIT license, which does not contain the binary redistribution clause. As a user of these runtime libraries, it means that you can choose to use the code under either From stoklund at 2pi.dk Wed Feb 22 13:24:34 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 22 Feb 2012 11:24:34 -0800 Subject: [llvm-commits] [llvm] r151038 - /llvm/trunk/include/llvm/MC/MCRegisterInfo.h In-Reply-To: <20120221062236.D87A82A6C12F@llvm.org> References: <20120221062236.D87A82A6C12F@llvm.org> Message-ID: <2E4788DF-315A-4232-8450-252053092D55@2pi.dk> On Feb 20, 2012, at 10:22 PM, Craig Topper wrote: > Author: ctopper > Date: Tue Feb 21 00:22:36 2012 > New Revision: 151038 > > URL: http://llvm.org/viewvc/llvm-project?rev=151038&view=rev > Log: > Merge some tables in generated RegisterInfo file. Store indices into larger table instead of pointers to reduce relocations and shrink table size on 64-bit builds. Shaves ~24K off X86MCTargetDesc.o These functions are extremely hot. How does this affect compile times? > const unsigned *getAliasSet(unsigned RegNo) const { > // The Overlaps set always begins with Reg itself. > - return get(RegNo).Overlaps + 1; > + if (get(RegNo).Overlaps < 0) return 0; > + return Overlaps + get(RegNo).Overlaps + 1; > } Please don't add conditional code to these functions. They should never return NULL anyway. It's probably easiest to give NOREG a dummy empty set. /jakob From emenezes at codeaurora.org Wed Feb 22 13:36:07 2012 From: emenezes at codeaurora.org (Evandro Menezes) Date: Wed, 22 Feb 2012 13:36:07 -0600 Subject: [llvm-commits] Hexagon: Fix registers numbering Message-ID: <4F4543A7.3090901@codeaurora.org> This patch for Hexagon fixes the numbering of some registers and reclassifies a couple of them. -- Evandro Menezes Austin, TX emenezes at codeaurora.org Qualcomm Innovation Center, Inc is a member of the Code Aurora Forum -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: bug6133.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/af696d69/attachment.txt From isanbard at gmail.com Wed Feb 22 13:38:03 2012 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 22 Feb 2012 19:38:03 -0000 Subject: [llvm-commits] [llvm] r151189 - /llvm/trunk/utils/emacs/tablegen-mode.el Message-ID: <20120222193803.679182A6C12F@llvm.org> Author: void Date: Wed Feb 22 13:38:03 2012 New Revision: 151189 URL: http://llvm.org/viewvc/llvm-project?rev=151189&view=rev Log: Remove bad comma from .el file. Modified: llvm/trunk/utils/emacs/tablegen-mode.el Modified: llvm/trunk/utils/emacs/tablegen-mode.el URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/emacs/tablegen-mode.el?rev=151189&r1=151188&r2=151189&view=diff ============================================================================== --- llvm/trunk/utils/emacs/tablegen-mode.el (original) +++ llvm/trunk/utils/emacs/tablegen-mode.el Wed Feb 22 13:38:03 2012 @@ -13,7 +13,7 @@ (defvar tablegen-font-lock-keywords (let ((kw (regexp-opt '("class" "defm" "def" "field" "include" "in" - "let" "multiclass", "foreach") + "let" "multiclass" "foreach") 'words)) (type-kw (regexp-opt '("bit" "bits" "code" "dag" "int" "list" "string") 'words)) From daniel at zuster.org Wed Feb 22 14:37:09 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 22 Feb 2012 20:37:09 -0000 Subject: [llvm-commits] [zorg] r151194 - in /zorg/trunk/lnt/lnt/server/ui: templates/v4_run.html views.py Message-ID: <20120222203709.7E4072A6C130@llvm.org> Author: ddunbar Date: Wed Feb 22 14:37:09 2012 New Revision: 151194 URL: http://llvm.org/viewvc/llvm-project?rev=151194&view=rev Log: [lnt] lnt.server.ui.views/run overview: Factor out a V4RequestInfo helper object. - This also makes text_report and html_report functions handle the compare_to request. Modified: zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html?rev=151194&r1=151193&r2=151194&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html Wed Feb 22 14:37:09 2012 @@ -1,6 +1,9 @@ {% import "v4_utils.html" as v4_utils %} {% import "utils.html" as utils %} +{% set run = request_info.run %} +{% set compare_to = request_info.compare_to %} +{% set ts = request_info.ts %} {% set machine = run.machine %} {% extends "layout.html" %} @@ -72,8 +75,9 @@ {% endmacro %} -{% call v4_utils.v4_run_page(ts, machine, run, compare_to, neighboring_runs, - comparison_neighboring_runs) %} +{% call v4_utils.v4_run_page(ts, machine, run, compare_to, + request_info.neighboring_runs, + request_info.comparison_neighboring_runs) %} {{ utils.render_popup_begin('view_options', 'View Options', true) }}

      @@ -139,12 +143,12 @@ {{ utils.render_popup_end() }} {{ utils.render_popup_begin('text_report', 'Report (Text)', true) }} -
      {{ text_report }}
      +
      {{ request_info.text_report }}
      {{ utils.render_popup_end() }} {{ utils.render_popup_begin('html_report', 'Report (HTML)', options.hide_report_by_default) }} -{{html_report|safe}} +{{request_info.html_report|safe}} {{ utils.render_popup_end() }}

      Tests

      Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=151194&r1=151193&r2=151194&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Wed Feb 22 14:37:09 2012 @@ -747,71 +747,66 @@ testsuite_name=g.testsuite_name, id=id, associated_runs=associated_runs) +class V4RequestInfo(object): + def __init__(self, run_id, only_html_body=True): + self.db = request.get_db() + self.ts = ts = request.get_testsuite() + self.run = run = ts.query(ts.Run).filter_by(id=run_id).first() + if run is None: + abort(404) + + # Find the neighboring runs, by order. + prev_runs = list(ts.get_previous_runs_on_machine(run, N = 3)) + next_runs = list(ts.get_next_runs_on_machine(run, N = 3)) + self.neighboring_runs = next_runs[::-1] + [self.run] + prev_runs + + # Select the comparison run as either the previous run, or a user + # specified comparison run. + compare_to_str = request.args.get('compare_to') + if compare_to_str: + compare_to_id = int(compare_to_str) + self.compare_to = ts.query(ts.Run).\ + filter_by(id=compare_to_id).first() + if self.compare_to is None: + # FIXME: Need better way to report this error. + abort(404) + + self.comparison_neighboring_runs = ( + list(ts.get_next_runs_on_machine(self.compare_to, N=3))[::-1] + + [self.compare_to] + + list(ts.get_previous_runs_on_machine(self.compare_to, N=3))) + else: + if prev_runs: + self.compare_to = prev_runs[0] + else: + self.compare_to = None + self.comparison_neighboring_runs = self.neighboring_runs + + _, self.text_report, self.html_report = NTEmailReport.getReport( + result=None, db=self.db, run=self.run, + baseurl=db_url_for('index', _external=True), + was_added=True, will_commit=True, only_html_body=only_html_body, + compare_to=self.compare_to) + @v4_route("//report") def v4_report(id): - db = request.get_db() - ts = request.get_testsuite() - run = ts.query(ts.Run).filter_by(id=id).first() - if run is None: - abort(404) - - _, _, html_report = NTEmailReport.getReport( - result=None, db=db, run=run, - baseurl=db_url_for('index', _external=True), - was_added=True, will_commit=True, only_html_body=False) + info = V4RequestInfo(id, only_html_body=False) - return make_response(html_report) + return make_response(info.html_report) @v4_route("//text_report") def v4_text_report(id): - db = request.get_db() - ts = request.get_testsuite() - run = ts.query(ts.Run).filter_by(id=id).first() - if run is None: - abort(404) + info = V4RequestInfo(id, only_html_body=False) - _, text_report, _ = NTEmailReport.getReport( - result=None, db=db, run=run, - baseurl=db_url_for('index', _external=True), - was_added=True, will_commit=True, only_html_body=True) - - response = make_response(text_report) + response = make_response(info.text_report) response.mimetype = "text/plain" return response @v4_route("/") def v4_run(id): - db = request.get_db() - ts = request.get_testsuite() - run = ts.query(ts.Run).filter_by(id=id).first() - if run is None: - abort(404) - - # Find the neighboring runs, by order. - prev_runs = list(ts.get_previous_runs_on_machine(run, N = 3)) - next_runs = list(ts.get_next_runs_on_machine(run, N = 3)) - neighboring_runs = next_runs[::-1] + [run] + prev_runs - - # Select the comparison run as either the previous run, or a user specified - # comparison run. - compare_to_str = request.args.get('compare_to') - if compare_to_str: - compare_to_id = int(compare_to_str) - compare_to = ts.query(ts.Run).filter_by(id = compare_to_id).first() - if compare_to is None: - return render_template("error.html", message="""\ -Invalid compare_to ID %r""" % compare_to_str) - - comparison_neighboring_runs = ( - list(ts.get_next_runs_on_machine(compare_to, N=3))[::-1] + - [compare_to] + - list(ts.get_previous_runs_on_machine(compare_to, N=3))) - else: - if prev_runs: - compare_to = prev_runs[0] - else: - compare_to = None - comparison_neighboring_runs = neighboring_runs + info = V4RequestInfo(id) + ts = info.ts + run = info.run # Parse the view options. options = {} @@ -844,16 +839,6 @@ test_min_value_filter = float(test_min_value_filter_str) else: test_min_value_filter = 0.0 - - # Generate the report for inclusion in the run page. - # - # FIXME: This is a crummy implementation of the concept that we want the - # webapp UI to be easy to correlate with the email reports. - _, text_report, html_report = NTEmailReport.getReport( - result=None, db=db, run=run, - baseurl=db_url_for('index', _external=True), - was_added=True, will_commit=True, only_html_body=True, - compare_to=compare_to) # Gather the runs to use for statistical data. comparison_window = list(ts.get_previous_runs_on_machine( @@ -872,14 +857,12 @@ if test_filter_re.search(test[0])] return render_template( - "v4_run.html", ts=ts, run=run, compare_to=compare_to, - options=options, neighboring_runs=neighboring_runs, - comparison_neighboring_runs=comparison_neighboring_runs, - text_report=text_report, html_report=html_report, + "v4_run.html", ts=ts, options=options, primary_fields=list(ts.Sample.get_primary_fields()), comparison_window=comparison_window, sri=sri, test_info=test_info, runinfo=runinfo, - test_min_value_filter=test_min_value_filter) + test_min_value_filter=test_min_value_filter, + request_info=info) @v4_route("/order/") def v4_order(id): From daniel at zuster.org Wed Feb 22 14:37:17 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 22 Feb 2012 20:37:17 -0000 Subject: [llvm-commits] [zorg] r151197 - in /zorg/trunk/lnt/lnt/server/reporting: analysis.py runs.py Message-ID: <20120222203717.98F872A6C132@llvm.org> Author: ddunbar Date: Wed Feb 22 14:37:17 2012 New Revision: 151197 URL: http://llvm.org/viewvc/llvm-project?rev=151197&view=rev Log: [lnt] lnt.server.reporting.runs: Change RunInfo to load runs up front. - Good for ~10% improvement speedup in report generation. Modified: zorg/trunk/lnt/lnt/server/reporting/analysis.py zorg/trunk/lnt/lnt/server/reporting/runs.py Modified: zorg/trunk/lnt/lnt/server/reporting/analysis.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/reporting/analysis.py?rev=151197&r1=151196&r2=151197&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/reporting/analysis.py (original) +++ zorg/trunk/lnt/lnt/server/reporting/analysis.py Wed Feb 22 14:37:17 2012 @@ -8,12 +8,14 @@ from lnt.testing import PASS, FAIL, XFAIL class RunInfo(object): - def __init__(self, testsuite): + def __init__(self, testsuite, runs_to_load): self.testsuite = testsuite self.sample_map = util.multidict() self.loaded_run_ids = set() + self._load_samples_for_runs(runs_to_load) + def get_run_comparison_result(self, run, compare_to, test_id, field, comparison_window=[]): # Get the field which indicates the requested field's status. @@ -25,11 +27,6 @@ compare_id = None else: compare_id = compare_to.id - runs_to_load = set([r.id for r in comparison_window]) - runs_to_load.add(run.id) - if compare_id is not None: - runs_to_load.add(compare_id) - self._load_samples_for_runs(runs_to_load) # Lookup the current and previous samples. run_samples = self.sample_map.get((run.id, test_id), ()) Modified: zorg/trunk/lnt/lnt/server/reporting/runs.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/reporting/runs.py?rev=151197&r1=151196&r2=151197&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/reporting/runs.py (original) +++ zorg/trunk/lnt/lnt/server/reporting/runs.py Wed Feb 22 14:37:17 2012 @@ -29,7 +29,6 @@ ts = run.testsuite machine = run.machine machine_parameters = machine.parameters - sri = lnt.server.reporting.analysis.RunInfo(ts) # Gather the runs to use for statistical data. comparison_window = list(ts.get_previous_runs_on_machine( @@ -42,6 +41,13 @@ # Get the test names. test_names = ts.query(ts.Test.name, ts.Test.id).order_by(ts.Test.name).all() + # Create the run info analysis object. + runs_to_load = set(r.id for r in comparison_window) + runs_to_load.add(run.id) + if compare_to: + runs_to_load.add(compare_to.id) + sri = lnt.server.reporting.analysis.RunInfo(ts, runs_to_load) + # Gather the changes to report, organized by field and then collated by # change type. primary_fields = list(ts.Sample.get_primary_fields()) From daniel at zuster.org Wed Feb 22 14:37:06 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 22 Feb 2012 20:37:06 -0000 Subject: [llvm-commits] [zorg] r151193 - /zorg/trunk/lnt/lnt/server/ui/views.py Message-ID: <20120222203706.C7E602A6C12F@llvm.org> Author: ddunbar Date: Wed Feb 22 14:37:06 2012 New Revision: 151193 URL: http://llvm.org/viewvc/llvm-project?rev=151193&view=rev Log: [lnt/v0.4] lnt.server.ui.views/run overview: Fix test filter regexp and delete some dead code. Modified: zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=151193&r1=151192&r2=151193&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Wed Feb 22 14:37:06 2012 @@ -860,14 +860,6 @@ run, num_comparison_runs)) # Get the test names. - test_names = ts.query(ts.Test.name, ts.Test.id).order_by(ts.Test.name).all() - - # Gather all the samples for the runs we are interested in. - if compare_to: - run_ids = (run.id, compare_to.id) - else: - run_ids = (run.id,) - test_info = ts.query(ts.Test.name, ts.Test.id).\ order_by(ts.Test.name).all() @@ -875,9 +867,9 @@ # Filter the list of tests by name, if requested. if test_filter_re: - test_names = [test - for test in test_names - if test_filter_re.search(test)] + test_info = [test + for test in test_info + if test_filter_re.search(test[0])] return render_template( "v4_run.html", ts=ts, run=run, compare_to=compare_to, From daniel at zuster.org Wed Feb 22 14:37:11 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 22 Feb 2012 20:37:11 -0000 Subject: [llvm-commits] [zorg] r151195 - /zorg/trunk/lnt/lnt/server/ui/views.py Message-ID: <20120222203711.BFB012A6C130@llvm.org> Author: ddunbar Date: Wed Feb 22 14:37:11 2012 New Revision: 151195 URL: http://llvm.org/viewvc/llvm-project?rev=151195&view=rev Log: [lnt] lnt.server.ui.views/run overview: Bypass pointless routing through old NTEmailReport module. Modified: zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=151195&r1=151194&r2=151195&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Wed Feb 22 14:37:11 2012 @@ -782,11 +782,11 @@ self.compare_to = None self.comparison_neighboring_runs = self.neighboring_runs - _, self.text_report, self.html_report = NTEmailReport.getReport( - result=None, db=self.db, run=self.run, - baseurl=db_url_for('index', _external=True), - was_added=True, will_commit=True, only_html_body=only_html_body, - compare_to=self.compare_to) + reports = lnt.server.reporting.runs.generate_run_report( + self.run, baseurl=db_url_for('index', _external=True), + only_html_body=only_html_body, + result=None, compare_to=self.compare_to) + _, self.text_report, self.html_report = reports @v4_route("//report") def v4_report(id): From daniel at zuster.org Wed Feb 22 14:37:15 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 22 Feb 2012 20:37:15 -0000 Subject: [llvm-commits] [zorg] r151196 - in /zorg/trunk/lnt/lnt: server/reporting/runs.py server/ui/templates/v4_run.html server/ui/views.py util/NTEmailReport.py Message-ID: <20120222203715.247EC2A6C131@llvm.org> Author: ddunbar Date: Wed Feb 22 14:37:14 2012 New Revision: 151196 URL: http://llvm.org/viewvc/llvm-project?rev=151196&view=rev Log: [lnt] lnt.server.ui.views/run overview: Share the RunInfo analysis object created by the report generation. Modified: zorg/trunk/lnt/lnt/server/reporting/runs.py zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html zorg/trunk/lnt/lnt/server/ui/views.py zorg/trunk/lnt/lnt/util/NTEmailReport.py Modified: zorg/trunk/lnt/lnt/server/reporting/runs.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/reporting/runs.py?rev=151196&r1=151195&r2=151196&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/reporting/runs.py (original) +++ zorg/trunk/lnt/lnt/server/reporting/runs.py Wed Feb 22 14:37:14 2012 @@ -252,7 +252,7 @@ """ % locals() - return subject, report.getvalue(), html_report + return subject, report.getvalue(), html_report, sri def _add_report_changes_detail(ts, test_results, report, html_report, report_url): Modified: zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html?rev=151196&r1=151195&r2=151196&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html Wed Feb 22 14:37:14 2012 @@ -190,7 +190,7 @@ {% for test_name,test_id in test_info %} -{% set cr = sri.get_run_comparison_result( +{% set cr = request_info.sri.get_run_comparison_result( run, compare_to, test_id, field, comparison_window) %} {% if cr.previous is not none or cr.current is not none %} {% if cr.current is none or cr.current >= test_min_value_filter %} @@ -227,7 +227,7 @@ }}{% for field in primary_fields %}{% - set cr = sri.get_run_comparison_result( + set cr = request_info.sri.get_run_comparison_result( run, compare_to, test_id, field, comparison_window) %} {{cr.previous}} {{cr.current}} {{cr.pct_delta}}{% endfor %} Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=151196&r1=151195&r2=151196&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Wed Feb 22 14:37:14 2012 @@ -786,7 +786,7 @@ self.run, baseurl=db_url_for('index', _external=True), only_html_body=only_html_body, result=None, compare_to=self.compare_to) - _, self.text_report, self.html_report = reports + _, self.text_report, self.html_report, self.sri = reports @v4_route("//report") def v4_report(id): @@ -848,8 +848,6 @@ test_info = ts.query(ts.Test.name, ts.Test.id).\ order_by(ts.Test.name).all() - sri = lnt.server.reporting.analysis.RunInfo(ts) - # Filter the list of tests by name, if requested. if test_filter_re: test_info = [test @@ -860,7 +858,7 @@ "v4_run.html", ts=ts, options=options, primary_fields=list(ts.Sample.get_primary_fields()), comparison_window=comparison_window, - sri=sri, test_info=test_info, runinfo=runinfo, + test_info=test_info, runinfo=runinfo, test_min_value_filter=test_min_value_filter, request_info=info) Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=151196&r1=151195&r2=151196&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Wed Feb 22 14:37:14 2012 @@ -445,9 +445,10 @@ # We haven't implemented V4DB support yet in reports. if isinstance(db, lnt.server.db.v4db.V4DB): - return lnt.server.reporting.runs.generate_run_report( + reports = lnt.server.reporting.runs.generate_run_report( run, baseurl=baseurl, only_html_body=only_html_body, result=result, compare_to=compare_to) + return reports[:2] # Use a simple report unless the tag indicates this is an old style nightly # test run. From hfinkel at anl.gov Wed Feb 22 15:06:57 2012 From: hfinkel at anl.gov (Hal Finkel) Date: Wed, 22 Feb 2012 15:06:57 -0600 Subject: [llvm-commits] [PATCH] Use an alternate symbol for function-size calc In-Reply-To: <4EFDF51F.4000609@gmail.com> References: <1325190024.13080.2848.camel@sapling> <4EFD1D73.5070407@gmail.com> <1325217175.13080.2933.camel@sapling> <4EFDCBB3.4070207@gmail.com> <1325257121.13080.2963.camel@sapling> <4EFDE8C4.7080500@gmail.com> <1325264011.13080.2985.camel@sapling> <4EFDF51F.4000609@gmail.com> Message-ID: <20120222150657.5994f05d@sapling2> On Fri, 30 Dec 2011 12:30:07 -0500 Rafael ?vila de Esp?ndola wrote: > > I am not sure, but that seems to be what gcc does: > > > .section ".opd","aw" > ... > > test1: > ... > > .previous > > .L.test1: > ... > > .size test1,.-.L.test1 > > Same behavior, interesting. I think you original patch is OK then. > This is needed because of a particularity of how ppc64 works. It seems that I dropped the ball on actually committing this; I'll do that in a few minutes. To Joerg's point, I think that we can certainly make this use more modern directives, etc., but I'd like to commit a baseline working functionality that matches gcc's output and then improve from there. -Hal > > > -Hal > > > > Cheers, > Rafael -- Hal Finkel Postdoctoral Appointee Leadership Computing Facility Argonne National Laboratory From dmalyshev at accesssoftek.com Wed Feb 22 15:07:06 2012 From: dmalyshev at accesssoftek.com (Danil Malyshev) Date: Wed, 22 Feb 2012 13:07:06 -0800 Subject: [llvm-commits] RuntimeDyLd new features In-Reply-To: <0983E6C011D2DC4188F8761B533492DE066602@ORSMSX105.amr.corp.intel.com> References: <6AE1604EE3EC5F4296C096518C6B77EE1AA5238F8A@mail.accesssoftek.com> <0983E6C011D2DC4188F8761B533492DE04EA17@ORSMSX105.amr.corp.intel.com> <6AE1604EE3EC5F4296C096518C6B77EE1AA53541E7@mail.accesssoftek.com> <0983E6C011D2DC4188F8761B533492DE066602@ORSMSX105.amr.corp.intel.com> Message-ID: <6AE1604EE3EC5F4296C096518C6B77EE1AA5354B3F@mail.accesssoftek.com> Hi Andrew, Sorry for delay, I was unavailable last several days. Thank you for your research and your work. I made some quick fixes of problems that you have found (Section alignment; SectionEntry.LoadAddress; wrong check "SectionID == 0"). The new patch is attached as 01-RuntimeDyLd-02.patch I moved the tests to a separate patch 02-MCJIT_tests-01.patch for better readability. To explain why I moved MCJIT tests to a separate folder instead of run each test in JIT and MCJIT. Some platforms may supports only JIT and some supports only MCJIT, so common tests will always fail for these platform. I checked all the ExecutionEngine tests with MCJIT on three platforms: Ubuntu x86_64, Mac OS 64 and Ubuntu ARMv7. Unfortunately, three tests didn't validate: stubs.ll, test-common-symbols.ll and test-global.ll because of the problems that you describe in your mail. I just removed those three tests from the MCJIT tests, until the problems not be solved. Now on the remaining issues. > Similarly, your code does not handle symbols which are marked as relative to the SHN_COMMON > section. Fixing this is a bit more complicated. I think we can probably build a table of these symbols in > the RuntimeDyldImpl class by adding a new member to SectionRef, but we'll need deeper access to > the format-specific classes to update the symbol addresses. I'm working on an implementation of this > for ELF. I'll look about its implementation for MachO and COFF. > I think it would be worthwhile adding an function to SectionRef to query whether or not a > section contains code rather than the current algorithmic method you are using. Sounds good, I'll do it. > A related problem is that your code does not properly handle sections which are only represented by a > header in the ELF image (that is, SHT_NOBITS sections) or sections which need to be zero-initialized. I > worked around these problems using the existing isBSS() member in SectionRef, but it would probably > be better to split these two concepts. Sounds good, I'll add isNobits() to the SectionRef. Regards, Danil ________________________________ From: Kaylor, Andrew [mailto:andrew.kaylor at intel.com] Sent: Wednesday, February 15, 2012 4:53 AM To: Danil Malyshev; llvm-commits at cs.uiuc.edu Cc: Jim Grosbach Subject: RE: RuntimeDyLd new features Hi Danil, I've been working with your patch also. Mostly, it looks pretty good. I've been able to layer most of our added functionality on top of it, and I have GDB integration working and our integration tests passing. There are a few issues I'd like to bring up, however. The first thing I saw with your patch is that I had problems loading images that were generated with debug information included. In particular, applying relocations to debug sections using the actual addresses of the debug sections causes problems. This is really a small issue because, as you mentioned, debug sections don't need to be loaded. I worked around this problem by adding a new member function to SectionRef to query whether or not the section is required for execution. This is fairly trivial for ELF. A related problem is that your code does not properly handle sections which are only represented by a header in the ELF image (that is, SHT_NOBITS sections) or sections which need to be zero-initialized. I worked around these problems using the existing isBSS() member in SectionRef, but it would probably be better to split these two concepts. Similarly, your code does not handle symbols which are marked as relative to the SHN_COMMON section. Fixing this is a bit more complicated. I think we can probably build a table of these symbols in the RuntimeDyldImpl class by adding a new member to SectionRef, but we'll need deeper access to the format-specific classes to update the symbol addresses. I'm working on an implementation of this for ELF. The code which loads the sections is currently assuming pointer-sized alignment for all sections. I ran into a case using floating point numbers where 16-byte alignment was required. This is a fairly simple fix as the alignment value is accessible through SectionRef. I think it would be worthwhile adding an function to SectionRef to query whether or not a section contains code rather than the current algorithmic method you are using. In a few places you are using uintptr_t or uint8_t* in places that will restrict cross-architecture JITing. The TargetAddr in the SectionEntry structure is an example that comes to mind. The distinction between code and data for memory allocation will be important going forward. I think it would be better to fix the existing bug that to disable the specific allocations. In RuntimeDyld::loadObject, in the "parse and process relocations loop" "SectionID == 0" is used to identify sections that need to be looked up, but zero is a valid SectionID. For that section, it goes into the lookup for every relocation. I'm continuing to work on integrating our code, including some that hasn't yet been submitted to the list for review, with your changes. I need to go over what I've done with the rest of my co-workers, but I wanted to give you a progress update now. -Andy From: Danil Malyshev [mailto:dmalyshev at accesssoftek.com] Sent: Tuesday, February 14, 2012 10:30 AM To: Kaylor, Andrew; llvm-commits at cs.uiuc.edu Cc: Jim Grosbach Subject: RE: RuntimeDyLd new features Hi Andrew, Thank you for the detailed explanation. I have carefully studied your patch and DyldELFObject. A gdb support is very important and it's actually a big step for MCJIT. I like your patch, its loadObject() looks faster than my. But I see one big conceptual problem. The RuntimeDyLd was developed as a linker, which is able to prepare data for running on another platform. The RuntimeDyldMachO largely implements it. In the RuntimeDyldELF you went the other way. Now it is very far from remote execution. And even if the object file will be emitted with RTDyldMemoryManager, it is not a good idea: (1) remote execution doesn't need many parts of object file, such as debugging information, headers, section table and etc, (2) some sections is code and must has execution permit, some sections is data without execution permit, so the best way is use a different methods for emits different type of sections. If your patch will be committed, we obtain a RuntimeDyldMachO and RuntimeDyldELF, which different principles and a different results. And most likely, for ELF will never be fully realization for remote execution. I think another ways will be better, just for instance, two possible solutions: 1. Always emits the sections required to execution with a RTDyldMemoryManager. Resolve relocation in these sections. And if the isDebugging flag is set, then in addition, DyldELFObject::rebaseObject make his job, except that for the sections stored by the RTDyldMemoryManager write the correct address. 2. Check the debug flag at first, before load object file. If it set, just use your realization of loadObject, otherwise - use normal way with RTDyldMemoryManager. Both alternatives have their shortcomings, perhaps you find another solution. Also, I would be glad to hear that Jim thinks about it. Now I trying to merge your patch with my. Regards, Danil ________________________________ From: Kaylor, Andrew [mailto:andrew.kaylor at intel.com] Sent: Thursday, February 09, 2012 4:56 AM To: Danil Malyshev; llvm-commits at cs.uiuc.edu Subject: RE: RuntimeDyLd new features Hi Danil, Thanks for your efforts in this area. As Eli Bendersky mentioned, we have a patch out for review in this area also. I'm hopeful that we can find a convergence between our code, your code and the code that Jim Grosbach has put in place. Unfortunately, we have been submitting our code in small chunks for ease of review and to keep things stable, and it may not be obvious from what we've put out for review what our intentions were or our intended solutions to the problems that were left open. I'd like to take this opportunity to discuss the direction we we're heading and see how it might align with what you and Jim have done. Let me first explain what we have done, and then I'll offer specific comments on your code and possible next steps. We have had two primary goals: (1) to get MCJIT generated code to work correctly on Intel architecture and help pave the way for other implementations and (2) enable source-level debugging of JITed code with GDB. This second goal seems to be dropping from view, but it places a few constraints on the eventual implementation. We've had GDB integration working, BTW. In order to get GDB to handle JITed code, we need to register an ELF object image through an interface GDB defines. As you might expect, GDB has some peculiar expectations for what this ELF object image should look like. In particular, we need to set a flag in the ELF header and update the sh_addr members in the section headers to reflect the address where the section contents reside in memory. Our most recent patch (http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120130/135997.html, not yet committed) begins by copying the entire ELF image emitted by the MC code generator into an executable buffer. This was intended as a temporary step toward our eventual solution. It enabled us to perform relocations in-place on the object and execute functions in place (thus eliminating an extra copy that was previously being done). We were in the process of implementing a smarter section-based approach, but Jim Grosbach was implementing a similar approach in parallel and our submission ended up appearing out of step in this regard. So that's our background. Now, returning to your patch.... I like the idea of combining as much common code as possible into the RuntimeDyldImpl class. I'm interested to hear from users of the MachO loader if your implementation has lost any of the specialization that they need. I think it's a promising approach. There are some ELF-specific details that we will need to have incorporated to re-enable GDB integration, but I expect that we'll be able to find a way to work that in with a few well-placed overloaded function calls. I have some reservations about the use of the basic ObjectFile interface, which has some serious limitations. We've been working toward exposing the ELFObjectFile template for use in the runtime loading process (as well as other unrelated uses). It may be that this is something that can be generalized enough to fit with your approach. My main concern in this regard is that we need to be able to update specific entries in the ELF image, as described above. A related issue is that section loading can be refined with some ELF-specific details. Some sections need to have memory allocated for their contents. Other sections can be left in place in the originally generated image. There is a good bit of unnecessary copying going on in the existing implementation, and I'm not clear to what extent your patch addresses that. Before the object is loaded, it is copied into a new buffer and then the contents of each section are copied again as we go. What I'd like is for the runtime loaders to use the buffer into which the object is originally generated and only make copies where it is strictly necessary. This isn't necessarily something you need to do for your work to be acceptable, but I mention it as a likely next step. Over the next few days I intend to apply your patch locally and try to merge our work into it. I'll provide additional feedback as I get a better feel for what you've done. -Andy From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Danil Malyshev Sent: Tuesday, February 07, 2012 12:24 PM To: llvm-commits at cs.uiuc.edu Subject: [llvm-commits] RuntimeDyLd new features Hello everyone, Please review the RuntimeDyLd-01.patch. This patch makes the following changes: 1. The main works will made in the RuntimeDyLdImpl with uses the ObjectFile class. RuntimeDyLdMachO and RuntimeDyLdELF now only parses relocations and resolve it. This is allows to make improvements of the RuntimeDyLd more easily. In addition the support for COFF can be easily added. 2. Added ARM relocations to RuntimeDyLdELF. 3. Added support for stub functions for the ARM, allowing to do a long branch. 4. Added support for external functions that are not loaded from the object files, but can be loaded from external libraries. Now MCJIT can correctly execute the code containing the printf, putc, and etc. 5. The sections emitted instead functions, thanks Jim Grosbach. MemoryManager.startFunctionBody() and MemoryManager.endFunctionBody() have been removed. 6. MCJITMemoryManager.allocateDataSection() and MCJITMemoryManager. allocateCodeSection() used JMM->allocateSpace() instead of JMM->allocateCodeSection() and JMM->allocateDataSection(), because I got an error: "Cannot allocate an allocated block!" with object file contains more than one code or data sections. 7. Fixed ELF::R_X86_64_PC32 relocation for the case when RealOffset is negative value. 8. Added new testing folder: ExecutionEngine/MCJIT because mcjit tests can be running only for x86 and arm and it's can be filtered with dg.exp. Tested in Ubuntu x86_64, Ubuntu armv7 and MacOS 64. Thank you, Danil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/5cd168d9/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: 02-MCJIT_tests-01.patch Type: application/octet-stream Size: 48102 bytes Desc: 02-MCJIT_tests-01.patch Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/5cd168d9/attachment-0002.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: 01-RuntimeDyLd-02.patch Type: application/octet-stream Size: 83388 bytes Desc: 01-RuntimeDyLd-02.patch Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/5cd168d9/attachment-0003.obj From dmalyshev at accesssoftek.com Wed Feb 22 15:08:25 2012 From: dmalyshev at accesssoftek.com (Danil Malyshev) Date: Wed, 22 Feb 2012 13:08:25 -0800 Subject: [llvm-commits] RuntimeDyLd new features In-Reply-To: <0983E6C011D2DC4188F8761B533492DE0683E9@ORSMSX105.amr.corp.intel.com> References: <6AE1604EE3EC5F4296C096518C6B77EE1AA5238F8A@mail.accesssoftek.com> <0983E6C011D2DC4188F8761B533492DE04EA17@ORSMSX105.amr.corp.intel.com> <6AE1604EE3EC5F4296C096518C6B77EE1AA53541E7@mail.accesssoftek.com> <0983E6C011D2DC4188F8761B533492DE066602@ORSMSX105.amr.corp.intel.com> <0983E6C011D2DC4188F8761B533492DE0683E9@ORSMSX105.amr.corp.intel.com> Message-ID: <6AE1604EE3EC5F4296C096518C6B77EE1AA5354B42@mail.accesssoftek.com> Hi Jim, The MCJIT with changed RuntimeDyLd passes most of ExecutionEngine tests on Mac OS, except of 3 tests: stubs.ll, test-common-symbols.ll and test-global.ll. And I will work to ensure that these three tests are also passed. Please look 01-RuntimeDyLd-02.patch of the previous letter, can I commit it? Regards, Danil ________________________________ From: Kaylor, Andrew [mailto:andrew.kaylor at intel.com] Sent: Saturday, February 18, 2012 5:41 AM To: Danil Malyshev; llvm-commits at cs.uiuc.edu Cc: Jim Grosbach Subject: RE: RuntimeDyLd new features Hi Danil, I'd like to make clear that if Jim is OK with the impact of your patch on MachO JIT loading then I'd be happy for you to proceed with your patch, incorporating my comments below, and we will withdraw our previous uncommitted patch and I will merge the GDB JIT debugging integration code we have with your changes after they have been committed. Thanks, Andy From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Kaylor, Andrew Sent: Tuesday, February 14, 2012 4:53 PM To: Danil Malyshev; llvm-commits at cs.uiuc.edu Subject: Re: [llvm-commits] RuntimeDyLd new features Hi Danil, I've been working with your patch also. Mostly, it looks pretty good. I've been able to layer most of our added functionality on top of it, and I have GDB integration working and our integration tests passing. There are a few issues I'd like to bring up, however. The first thing I saw with your patch is that I had problems loading images that were generated with debug information included. In particular, applying relocations to debug sections using the actual addresses of the debug sections causes problems. This is really a small issue because, as you mentioned, debug sections don't need to be loaded. I worked around this problem by adding a new member function to SectionRef to query whether or not the section is required for execution. This is fairly trivial for ELF. A related problem is that your code does not properly handle sections which are only represented by a header in the ELF image (that is, SHT_NOBITS sections) or sections which need to be zero-initialized. I worked around these problems using the existing isBSS() member in SectionRef, but it would probably be better to split these two concepts. Similarly, your code does not handle symbols which are marked as relative to the SHN_COMMON section. Fixing this is a bit more complicated. I think we can probably build a table of these symbols in the RuntimeDyldImpl class by adding a new member to SectionRef, but we'll need deeper access to the format-specific classes to update the symbol addresses. I'm working on an implementation of this for ELF. The code which loads the sections is currently assuming pointer-sized alignment for all sections. I ran into a case using floating point numbers where 16-byte alignment was required. This is a fairly simple fix as the alignment value is accessible through SectionRef. I think it would be worthwhile adding an function to SectionRef to query whether or not a section contains code rather than the current algorithmic method you are using. In a few places you are using uintptr_t or uint8_t* in places that will restrict cross-architecture JITing. The TargetAddr in the SectionEntry structure is an example that comes to mind. The distinction between code and data for memory allocation will be important going forward. I think it would be better to fix the existing bug that to disable the specific allocations. In RuntimeDyld::loadObject, in the "parse and process relocations loop" "SectionID == 0" is used to identify sections that need to be looked up, but zero is a valid SectionID. For that section, it goes into the lookup for every relocation. I'm continuing to work on integrating our code, including some that hasn't yet been submitted to the list for review, with your changes. I need to go over what I've done with the rest of my co-workers, but I wanted to give you a progress update now. -Andy From: Danil Malyshev [mailto:dmalyshev at accesssoftek.com] Sent: Tuesday, February 14, 2012 10:30 AM To: Kaylor, Andrew; llvm-commits at cs.uiuc.edu Cc: Jim Grosbach Subject: RE: RuntimeDyLd new features Hi Andrew, Thank you for the detailed explanation. I have carefully studied your patch and DyldELFObject. A gdb support is very important and it's actually a big step for MCJIT. I like your patch, its loadObject() looks faster than my. But I see one big conceptual problem. The RuntimeDyLd was developed as a linker, which is able to prepare data for running on another platform. The RuntimeDyldMachO largely implements it. In the RuntimeDyldELF you went the other way. Now it is very far from remote execution. And even if the object file will be emitted with RTDyldMemoryManager, it is not a good idea: (1) remote execution doesn't need many parts of object file, such as debugging information, headers, section table and etc, (2) some sections is code and must has execution permit, some sections is data without execution permit, so the best way is use a different methods for emits different type of sections. If your patch will be committed, we obtain a RuntimeDyldMachO and RuntimeDyldELF, which different principles and a different results. And most likely, for ELF will never be fully realization for remote execution. I think another ways will be better, just for instance, two possible solutions: 1. Always emits the sections required to execution with a RTDyldMemoryManager. Resolve relocation in these sections. And if the isDebugging flag is set, then in addition, DyldELFObject::rebaseObject make his job, except that for the sections stored by the RTDyldMemoryManager write the correct address. 2. Check the debug flag at first, before load object file. If it set, just use your realization of loadObject, otherwise - use normal way with RTDyldMemoryManager. Both alternatives have their shortcomings, perhaps you find another solution. Also, I would be glad to hear that Jim thinks about it. Now I trying to merge your patch with my. Regards, Danil ________________________________ From: Kaylor, Andrew [mailto:andrew.kaylor at intel.com] Sent: Thursday, February 09, 2012 4:56 AM To: Danil Malyshev; llvm-commits at cs.uiuc.edu Subject: RE: RuntimeDyLd new features Hi Danil, Thanks for your efforts in this area. As Eli Bendersky mentioned, we have a patch out for review in this area also. I'm hopeful that we can find a convergence between our code, your code and the code that Jim Grosbach has put in place. Unfortunately, we have been submitting our code in small chunks for ease of review and to keep things stable, and it may not be obvious from what we've put out for review what our intentions were or our intended solutions to the problems that were left open. I'd like to take this opportunity to discuss the direction we we're heading and see how it might align with what you and Jim have done. Let me first explain what we have done, and then I'll offer specific comments on your code and possible next steps. We have had two primary goals: (1) to get MCJIT generated code to work correctly on Intel architecture and help pave the way for other implementations and (2) enable source-level debugging of JITed code with GDB. This second goal seems to be dropping from view, but it places a few constraints on the eventual implementation. We've had GDB integration working, BTW. In order to get GDB to handle JITed code, we need to register an ELF object image through an interface GDB defines. As you might expect, GDB has some peculiar expectations for what this ELF object image should look like. In particular, we need to set a flag in the ELF header and update the sh_addr members in the section headers to reflect the address where the section contents reside in memory. Our most recent patch (http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120130/135997.html, not yet committed) begins by copying the entire ELF image emitted by the MC code generator into an executable buffer. This was intended as a temporary step toward our eventual solution. It enabled us to perform relocations in-place on the object and execute functions in place (thus eliminating an extra copy that was previously being done). We were in the process of implementing a smarter section-based approach, but Jim Grosbach was implementing a similar approach in parallel and our submission ended up appearing out of step in this regard. So that's our background. Now, returning to your patch.... I like the idea of combining as much common code as possible into the RuntimeDyldImpl class. I'm interested to hear from users of the MachO loader if your implementation has lost any of the specialization that they need. I think it's a promising approach. There are some ELF-specific details that we will need to have incorporated to re-enable GDB integration, but I expect that we'll be able to find a way to work that in with a few well-placed overloaded function calls. I have some reservations about the use of the basic ObjectFile interface, which has some serious limitations. We've been working toward exposing the ELFObjectFile template for use in the runtime loading process (as well as other unrelated uses). It may be that this is something that can be generalized enough to fit with your approach. My main concern in this regard is that we need to be able to update specific entries in the ELF image, as described above. A related issue is that section loading can be refined with some ELF-specific details. Some sections need to have memory allocated for their contents. Other sections can be left in place in the originally generated image. There is a good bit of unnecessary copying going on in the existing implementation, and I'm not clear to what extent your patch addresses that. Before the object is loaded, it is copied into a new buffer and then the contents of each section are copied again as we go. What I'd like is for the runtime loaders to use the buffer into which the object is originally generated and only make copies where it is strictly necessary. This isn't necessarily something you need to do for your work to be acceptable, but I mention it as a likely next step. Over the next few days I intend to apply your patch locally and try to merge our work into it. I'll provide additional feedback as I get a better feel for what you've done. -Andy From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Danil Malyshev Sent: Tuesday, February 07, 2012 12:24 PM To: llvm-commits at cs.uiuc.edu Subject: [llvm-commits] RuntimeDyLd new features Hello everyone, Please review the RuntimeDyLd-01.patch. This patch makes the following changes: 1. The main works will made in the RuntimeDyLdImpl with uses the ObjectFile class. RuntimeDyLdMachO and RuntimeDyLdELF now only parses relocations and resolve it. This is allows to make improvements of the RuntimeDyLd more easily. In addition the support for COFF can be easily added. 2. Added ARM relocations to RuntimeDyLdELF. 3. Added support for stub functions for the ARM, allowing to do a long branch. 4. Added support for external functions that are not loaded from the object files, but can be loaded from external libraries. Now MCJIT can correctly execute the code containing the printf, putc, and etc. 5. The sections emitted instead functions, thanks Jim Grosbach. MemoryManager.startFunctionBody() and MemoryManager.endFunctionBody() have been removed. 6. MCJITMemoryManager.allocateDataSection() and MCJITMemoryManager. allocateCodeSection() used JMM->allocateSpace() instead of JMM->allocateCodeSection() and JMM->allocateDataSection(), because I got an error: "Cannot allocate an allocated block!" with object file contains more than one code or data sections. 7. Fixed ELF::R_X86_64_PC32 relocation for the case when RealOffset is negative value. 8. Added new testing folder: ExecutionEngine/MCJIT because mcjit tests can be running only for x86 and arm and it's can be filtered with dg.exp. Tested in Ubuntu x86_64, Ubuntu armv7 and MacOS 64. Thank you, Danil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/d72f10d3/attachment.html From viridia at gmail.com Wed Feb 22 15:11:17 2012 From: viridia at gmail.com (Talin) Date: Wed, 22 Feb 2012 13:11:17 -0800 Subject: [llvm-commits] [PATCH] RFC: fix some problems in GeneralHash In-Reply-To: References: Message-ID: So if we're going to be using memcpy, then I guess we might as well go to a block-based approach as Chandler suggested in the other thread. Basically I'd have a member variable that was something like uint32_t BlockData[16] and then logic to detect when it overflows. But that's for a future CL. On Wed, Feb 22, 2012 at 7:50 AM, Jay Foad wrote: > Here's an updated patch. I've rewritten the contentious comment, and > re-inlined finish() and mix(). > > Jay. > -- -- Talin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/13c7ba5c/attachment.html From hfinkel at anl.gov Wed Feb 22 15:11:47 2012 From: hfinkel at anl.gov (Hal Finkel) Date: Wed, 22 Feb 2012 21:11:47 -0000 Subject: [llvm-commits] [llvm] r151200 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/PowerPC/PPCAsmPrinter.cpp test/CodeGen/PowerPC/ppc64-linux-func-size.ll Message-ID: <20120222211147.D77782A6C12F@llvm.org> Author: hfinkel Date: Wed Feb 22 15:11:47 2012 New Revision: 151200 URL: http://llvm.org/viewvc/llvm-project?rev=151200&view=rev Log: Allow the use of an alternate symbol for calculating a function's size. The standard function epilog includes a .size directive, but ppc64 uses an alternate local symbol to tag the actual start of each function. Until recently, binutils accepted the .size directive as: .size test1, .Ltmp0-test1 however, using this directive with recent binutils will result in the error: .size expression for XXX does not evaluate to a constant so we must use the label which actually tags the start of the function. Added: llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=151200&r1=151199&r2=151200&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Wed Feb 22 15:11:47 2012 @@ -88,6 +88,11 @@ /// MCSymbol *CurrentFnSym; + /// The symbol used to represent the start of the current function for the + /// purpose of calculating its size (e.g. using the .size directive). By + /// default, this is equal to CurrentFnSym. + MCSymbol *CurrentFnSymForSize; + private: // GCMetadataPrinters - The garbage collection metadata printer table. void *GCMetadataPrinters; // Really a DenseMap. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=151200&r1=151199&r2=151200&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Feb 22 15:11:47 2012 @@ -100,6 +100,7 @@ OutStreamer(Streamer), LastMI(0), LastFn(0), Counter(~0U), SetCounter(0) { DD = 0; DE = 0; MMI = 0; LI = 0; + CurrentFnSym = CurrentFnSymForSize = 0; GCMetadataPrinters = 0; VerboseAsm = Streamer.isVerboseAsm(); } @@ -761,7 +762,8 @@ const MCExpr *SizeExp = MCBinaryExpr::CreateSub(MCSymbolRefExpr::Create(FnEndLabel, OutContext), - MCSymbolRefExpr::Create(CurrentFnSym, OutContext), + MCSymbolRefExpr::Create(CurrentFnSymForSize, + OutContext), OutContext); OutStreamer.EmitELFSize(CurrentFnSym, SizeExp); } @@ -951,6 +953,7 @@ this->MF = &MF; // Get the function symbol. CurrentFnSym = Mang->getSymbol(MF.getFunction()); + CurrentFnSymForSize = CurrentFnSym; if (isVerbose()) LI = &getAnalysis(); Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=151200&r1=151199&r2=151200&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Wed Feb 22 15:11:47 2012 @@ -398,7 +398,11 @@ OutStreamer.EmitRawText("\t.quad .L." + Twine(CurrentFnSym->getName()) + ",.TOC. at tocbase"); OutStreamer.EmitRawText(StringRef("\t.previous")); - OutStreamer.EmitRawText(".L." + Twine(CurrentFnSym->getName()) + ":"); + + MCSymbol *RealFnSym = OutContext.GetOrCreateSymbol( + ".L." + Twine(CurrentFnSym->getName())); + OutStreamer.EmitLabel(RealFnSym); + CurrentFnSymForSize = RealFnSym; } Added: llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll?rev=151200&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll Wed Feb 22 15:11:47 2012 @@ -0,0 +1,18 @@ +; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=g5 | FileCheck %s + +; CHECK: test1: +; CHECK-NEXT: .quad .L.test1,.TOC. at tocbase +; CHECK-NEXT: .previous +; CHECK-NEXT: .L.test1: + +define i32 @test1(i32 %a) nounwind { +entry: + ret i32 %a +} + +; Until recently, binutils accepted the .size directive as: +; .size test1, .Ltmp0-test1 +; however, using this directive with recent binutils will result in the error: +; .size expression for XXX does not evaluate to a constant +; so we must use the label which actually tags the start of the function. +; CHECK: .size test1, .Ltmp0-.L.test1 From chandlerc at google.com Wed Feb 22 15:22:40 2012 From: chandlerc at google.com (Chandler Carruth) Date: Wed, 22 Feb 2012 13:22:40 -0800 Subject: [llvm-commits] [PATCH] RFC: fix some problems in GeneralHash In-Reply-To: References: Message-ID: On Wed, Feb 22, 2012 at 1:11 PM, Talin wrote: > So if we're going to be using memcpy Don't misunderstand -- there will be no actual memcpy in the generated code. This is a mechanism for reading underlying storage with well defined behavior, it'll disappear in the optimizer. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/1a5de734/attachment.html From rdivacky at freebsd.org Wed Feb 22 15:49:59 2012 From: rdivacky at freebsd.org (Roman Divacky) Date: Wed, 22 Feb 2012 22:49:59 +0100 Subject: [llvm-commits] [llvm] r151200 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/PowerPC/PPCAsmPrinter.cpp test/CodeGen/PowerPC/ppc64-linux-func-size.ll In-Reply-To: <20120222211147.D77782A6C12F@llvm.org> References: <20120222211147.D77782A6C12F@llvm.org> Message-ID: <20120222214959.GA90313@freebsd.org> > Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=151200&r1=151199&r2=151200&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original) > +++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Wed Feb 22 15:11:47 2012 > @@ -398,7 +398,11 @@ > OutStreamer.EmitRawText("\t.quad .L." + Twine(CurrentFnSym->getName()) + > ",.TOC. at tocbase"); > OutStreamer.EmitRawText(StringRef("\t.previous")); > - OutStreamer.EmitRawText(".L." + Twine(CurrentFnSym->getName()) + ":"); > + > + MCSymbol *RealFnSym = OutContext.GetOrCreateSymbol( > + ".L." + Twine(CurrentFnSym->getName())); > + OutStreamer.EmitLabel(RealFnSym); > + CurrentFnSymForSize = RealFnSym; > } The EmitRawText here must vanish. Are you ok with the attached patch? It properly MCizes this. If you dont object I'd like to (finaly) commit that. roman -------------- next part -------------- A non-text attachment was scrubbed... Name: powerpc.mc.patch Type: text/x-diff Size: 2564 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/0cdca0e6/attachment.bin From kledzik at apple.com Wed Feb 22 15:57:00 2012 From: kledzik at apple.com (Nick Kledzik) Date: Wed, 22 Feb 2012 21:57:00 -0000 Subject: [llvm-commits] [lld] r151204 - in /lld/trunk: include/lld/Core/ include/lld/Platform/ lib/Core/ test/ tools/lld-core/ Message-ID: <20120222215700.4523A2A6C12F@llvm.org> Author: kledzik Date: Wed Feb 22 15:56:59 2012 New Revision: 151204 URL: http://llvm.org/viewvc/llvm-project?rev=151204&view=rev Log: Add support for SharedLibraryAtoms (proxy atoms for exported symbols from a shared library) and AbsoluteAtoms (proxy atoms for absolute address (e.g. ROM)). Redesign weak importing as can-be-null-at-runtime and can-be-null-at-build-time. Add lots of test cases for all the above. Added: lld/trunk/include/lld/Core/AbsoluteAtom.h lld/trunk/include/lld/Core/SharedLibraryAtom.h lld/trunk/test/absolute-basic.objtxt lld/trunk/test/empty.objtxt lld/trunk/test/shared-library-basic.objtxt lld/trunk/test/shared-library-coalesce.objtxt lld/trunk/test/undef-weak-coalesce.objtxt Modified: lld/trunk/include/lld/Core/Atom.h lld/trunk/include/lld/Core/File.h lld/trunk/include/lld/Core/Resolver.h lld/trunk/include/lld/Core/SymbolTable.h lld/trunk/include/lld/Core/UndefinedAtom.h lld/trunk/include/lld/Platform/Platform.h lld/trunk/lib/Core/NativeFileFormat.h lld/trunk/lib/Core/NativeReader.cpp lld/trunk/lib/Core/NativeWriter.cpp lld/trunk/lib/Core/Resolver.cpp lld/trunk/lib/Core/SymbolTable.cpp lld/trunk/lib/Core/YamlKeyValues.cpp lld/trunk/lib/Core/YamlKeyValues.h lld/trunk/lib/Core/YamlReader.cpp lld/trunk/lib/Core/YamlWriter.cpp lld/trunk/tools/lld-core/lld-core.cpp Added: lld/trunk/include/lld/Core/AbsoluteAtom.h URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/AbsoluteAtom.h?rev=151204&view=auto ============================================================================== --- lld/trunk/include/lld/Core/AbsoluteAtom.h (added) +++ lld/trunk/include/lld/Core/AbsoluteAtom.h Wed Feb 22 15:56:59 2012 @@ -0,0 +1,41 @@ +//===- Core/AbsoluteAtom.h - An absolute Atom -----------------------------===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLD_CORE_ABSOLUTE_ATOM_H_ +#define LLD_CORE_ABSOLUTE_ATOM_H_ + +#include "lld/Core/Atom.h" + +namespace lld { + +/// An AbsoluteAtom has no content. +/// It exists to represent content at fixed addresses in memory. +class AbsoluteAtom : public Atom { +public: + virtual Definition definition() const { + return Atom::definitionAbsolute; + } + + /// like dynamic_cast, if atom is definitionAbsolute + /// returns atom cast to AbsoluteAtom*, else returns NULL + virtual const AbsoluteAtom* absoluteAtom() const { + return this; + } + + virtual uint64_t value() const = 0; + + +protected: + AbsoluteAtom() {} + virtual ~AbsoluteAtom() {} +}; + +} // namespace lld + +#endif // LLD_CORE_ABSOLUTE_ATOM_H_ Modified: lld/trunk/include/lld/Core/Atom.h URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Atom.h?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/include/lld/Core/Atom.h (original) +++ lld/trunk/include/lld/Core/Atom.h Wed Feb 22 15:56:59 2012 @@ -21,8 +21,10 @@ class File; class DefinedAtom; class UndefinedAtom; +class SharedLibraryAtom; +class AbsoluteAtom; -/// + /// /// The linker has a Graph Theory model of linking. An object file is seen /// as a set of Atoms with References to other Atoms. Each Atom is a node /// and each Reference is an edge. An Atom can be a DefinedAtom which has @@ -52,12 +54,20 @@ /// definedAtom - like dynamic_cast, if atom is definitionRegular /// returns atom cast to DefinedAtom*, else returns nullptr; - virtual const DefinedAtom* definedAtom() const { return 0; } + virtual const DefinedAtom* definedAtom() const { return NULL; } /// undefinedAtom - like dynamic_cast, if atom is definitionUndefined /// returns atom cast to UndefinedAtom*, else returns NULL; virtual const UndefinedAtom* undefinedAtom() const { return NULL; } + /// sharedLibraryAtom - like dynamic_cast, if atom is definitionSharedLibrary + /// returns atom cast to SharedLibraryAtom*, else returns nullptr; + virtual const SharedLibraryAtom* sharedLibraryAtom() const { return NULL; } + + /// absoluteAtom - like dynamic_cast, if atom is definitionAbsolute + /// returns atom cast to AbsoluteAtom*, else returns nullptr; + virtual const AbsoluteAtom* absoluteAtom() const { return NULL; } + protected: /// Atom is an abstract base class. Only subclasses can access constructor. Atom() {} Modified: lld/trunk/include/lld/Core/File.h URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/File.h?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/include/lld/Core/File.h (original) +++ lld/trunk/include/lld/Core/File.h Wed Feb 22 15:56:59 2012 @@ -14,6 +14,8 @@ #include "lld/Core/DefinedAtom.h" #include "lld/Core/UndefinedAtom.h" +#include "lld/Core/SharedLibraryAtom.h" +#include "lld/Core/AbsoluteAtom.h" namespace lld { @@ -27,6 +29,8 @@ virtual ~AtomHandler() {} virtual void doDefinedAtom(const class DefinedAtom &) = 0; virtual void doUndefinedAtom(const class UndefinedAtom &) = 0; + virtual void doSharedLibraryAtom(const class SharedLibraryAtom &) = 0; + virtual void doAbsoluteAtom(const class AbsoluteAtom &) = 0; virtual void doFile(const class File &) = 0; }; Modified: lld/trunk/include/lld/Core/Resolver.h URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/include/lld/Core/Resolver.h (original) +++ lld/trunk/include/lld/Core/Resolver.h Wed Feb 22 15:56:59 2012 @@ -43,6 +43,8 @@ // AtomHandler methods virtual void doDefinedAtom(const class DefinedAtom&); virtual void doUndefinedAtom(const class UndefinedAtom&); + virtual void doSharedLibraryAtom(const class SharedLibraryAtom &); + virtual void doAbsoluteAtom(const class AbsoluteAtom &); virtual void doFile(const File&); /// @brief do work of merging and resolving and return list Added: lld/trunk/include/lld/Core/SharedLibraryAtom.h URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/SharedLibraryAtom.h?rev=151204&view=auto ============================================================================== --- lld/trunk/include/lld/Core/SharedLibraryAtom.h (added) +++ lld/trunk/include/lld/Core/SharedLibraryAtom.h Wed Feb 22 15:56:59 2012 @@ -0,0 +1,51 @@ +//===- Core/SharedLibraryAtom.h - A Shared Library Atom -------------------===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLD_CORE_SHARED_LIBRARY_ATOM_H_ +#define LLD_CORE_SHARED_LIBRARY_ATOM_H_ + +#include "lld/Core/Atom.h" + +namespace llvm { + class StringRef; +} + +namespace lld { + +/// A SharedLibraryAtom has no content. +/// It exists to represent a symbol which will be bound at runtime. +class SharedLibraryAtom : public Atom { +public: + virtual Definition definition() const { + return Atom::definitionSharedLibrary; + } + + /// like dynamic_cast, if atom is definitionSharedLibrary + /// returns atom cast to SharedLibraryAtom*, else returns NULL + virtual const SharedLibraryAtom* sharedLibraryAtom() const { + return this; + } + + /// Returns shared library name used to load it at runtime. + /// On linux that is the DT_NEEDED name. + /// On Darwin it is the LC_DYLIB_LOAD dylib name. + virtual llvm::StringRef loadName() const = 0; + + /// Returns if shared library symbol can be missing at runtime and if + /// so the loader should silently resolve address of symbol to be NULL. + virtual bool canBeNullAtRuntime() const = 0; + +protected: + SharedLibraryAtom() {} + virtual ~SharedLibraryAtom() {} +}; + +} // namespace lld + +#endif // LLD_CORE_SHARED_LIBRARY_ATOM_H_ Modified: lld/trunk/include/lld/Core/SymbolTable.h URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/SymbolTable.h?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/include/lld/Core/SymbolTable.h (original) +++ lld/trunk/include/lld/Core/SymbolTable.h Wed Feb 22 15:56:59 2012 @@ -24,6 +24,8 @@ class Atom; class DefinedAtom; class UndefinedAtom; +class SharedLibraryAtom; +class AbsoluteAtom; class Platform; /// The SymbolTable class is responsible for coalescing atoms. @@ -41,6 +43,12 @@ /// @brief add atom to symbol table void add(const UndefinedAtom &); + /// @brief add atom to symbol table + void add(const SharedLibraryAtom &); + + /// @brief add atom to symbol table + void add(const AbsoluteAtom &); + /// @brief checks if name is in symbol table and if so atom is not /// UndefinedAtom bool isDefined(llvm::StringRef sym); Modified: lld/trunk/include/lld/Core/UndefinedAtom.h URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/UndefinedAtom.h?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/include/lld/Core/UndefinedAtom.h (original) +++ lld/trunk/include/lld/Core/UndefinedAtom.h Wed Feb 22 15:56:59 2012 @@ -12,8 +12,6 @@ #include "lld/Core/Atom.h" -#include "llvm/ADT/StringRef.h" - namespace lld { /// An UndefinedAtom has no content. @@ -30,9 +28,40 @@ return this; } - /// returns if undefined symbol can be missing at runtime - virtual bool weakImport() const = 0; + /// Whether this undefined symbol needs to be resolved, + /// or whether it can just evaluate to NULL. + /// This concept is often called "weak", but that term + /// is overloaded to mean other things too. + enum CanBeNull { + /// Normal symbols must be resolved at build time + canBeNullNever, + + /// This symbol can be missing at runtime and will evalute to NULL. + /// That is, the static linker still must find a definition (usually + /// is some shared library), but at runtime, the dynamic loader + /// will allow the symbol to be missing and resolved to NULL. + /// + /// On Darwin this is generated using a function prototype with + /// __attribute__((weak_import)). + /// On linux this is generated using a function prototype with + /// __attribute__((weak)). + canBeNullAtRuntime, + + + /// This symbol can be missing at build time. + /// That is, the static linker will not error if a definition for + /// this symbol is not found at build time. Instead, the linker + /// will build an executable that lets the dynamic loader find the + /// symbol at runtime. + /// This feature is not supported on Darwin. + /// On linux this is generated using a function prototype with + /// __attribute__((weak)). + canBeNullAtBuildtime + }; + + virtual CanBeNull canBeNull() const = 0; + protected: UndefinedAtom() {} virtual ~UndefinedAtom() {} Modified: lld/trunk/include/lld/Platform/Platform.h URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Platform/Platform.h?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/include/lld/Platform/Platform.h (original) +++ lld/trunk/include/lld/Platform/Platform.h Wed Feb 22 15:56:59 2012 @@ -78,6 +78,24 @@ virtual void errorWithUndefines(const std::vector& undefs, const std::vector& all) = 0; + /// When core linking finds undefined atoms from different object + /// files that have different canBeNull values, this method is called. + /// The useUndef2 parameter is set to which canBeNull setting the + /// linker should use, and can be changed by this method. Or this + /// method can emit a warning/error about the mismatch. + virtual void undefineCanBeNullMismatch(const UndefinedAtom& undef1, + const UndefinedAtom& undef2, + bool& useUndef2) = 0; + + /// When core linking finds shared library atoms from different object + /// files that have different attribute values, this method is called. + /// The useShlib2 parameter is set to which atom attributes the + /// linker should use, and can be changed by this method. Or this + /// method can emit a warning/error about the mismatch. + virtual void sharedLibrarylMismatch(const SharedLibraryAtom& shLib1, + const SharedLibraryAtom& shLib2, + bool& useShlib2) = 0; + /// @brief last chance for platform to tweak atoms virtual void postResolveTweaks(std::vector& all) = 0; }; Modified: lld/trunk/lib/Core/NativeFileFormat.h URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/NativeFileFormat.h?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/lib/Core/NativeFileFormat.h (original) +++ lld/trunk/lib/Core/NativeFileFormat.h Wed Feb 22 15:56:59 2012 @@ -90,12 +90,14 @@ NCS_DefinedAtomsV1 = 1, NCS_AttributesArrayV1 = 2, NCS_UndefinedAtomsV1 = 3, - NCS_Strings = 4, - NCS_ReferencesArrayV1 = 5, - NCS_ReferencesArrayV2 = 6, - NCS_TargetsTable = 7, - NCS_AddendsTable = 8, - NCS_Content = 9, + NCS_SharedLibraryAtomsV1 = 4, + NCS_AbsoluteAtomsV1 = 5, + NCS_Strings = 6, + NCS_ReferencesArrayV1 = 7, + NCS_ReferencesArrayV2 = 8, + NCS_TargetsTable = 9, + NCS_AddendsTable = 10, + NCS_Content = 11, }; // @@ -165,6 +167,27 @@ +// +// The NCS_SharedLibraryAtomsV1 chunk contains an array of these structs +// +struct NativeSharedLibraryAtomIvarsV1 { + uint32_t nameOffset; + uint32_t loadNameOffset; + uint32_t flags; +}; + + + +// +// The NCS_AbsoluteAtomsV1 chunk contains an array of these structs +// +struct NativeAbsoluteAtomIvarsV1 { + uint32_t nameOffset; + uint32_t reserved; + uint64_t value; +}; + + // // The NCS_ReferencesArrayV1 chunk contains an array of these structs Modified: lld/trunk/lib/Core/NativeReader.cpp URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/NativeReader.cpp?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/lib/Core/NativeReader.cpp (original) +++ lld/trunk/lib/Core/NativeReader.cpp Wed Feb 22 15:56:59 2012 @@ -77,7 +77,7 @@ virtual DefinedAtom::DeadStripKind deadStrip() const { return (DefinedAtom::DeadStripKind)(attributes().deadStrip); - } + } virtual DefinedAtom::ContentPermissions permissions() const { return (DefinedAtom::ContentPermissions)(attributes().permissions); @@ -117,16 +117,64 @@ virtual const File& file() const; virtual llvm::StringRef name() const; - virtual bool weakImport() const { - return (_ivarData->flags & 0x1); + virtual CanBeNull canBeNull() const { + return (CanBeNull)(_ivarData->flags & 0x3); } + private: const NativeFile* _file; const NativeUndefinedAtomIvarsV1* _ivarData; }; +// +// An object of this class is instantied for each NativeUndefinedAtomIvarsV1 +// struct in the NCS_SharedLibraryAtomsV1 chunk. +// +class NativeSharedLibraryAtomV1 : public SharedLibraryAtom { +public: + NativeSharedLibraryAtomV1(const NativeFile& f, + const NativeSharedLibraryAtomIvarsV1* ivarData) + : _file(&f), _ivarData(ivarData) { } + + virtual const File& file() const; + virtual llvm::StringRef name() const; + virtual llvm::StringRef loadName() const; + + virtual bool canBeNullAtRuntime() const { + return (_ivarData->flags & 0x1); + } + +private: + const NativeFile* _file; + const NativeSharedLibraryAtomIvarsV1* _ivarData; +}; + + +// +// An object of this class is instantied for each NativeAbsoluteAtomIvarsV1 +// struct in the NCS_AbsoluteAtomsV1 chunk. +// +class NativeAbsoluteAtomV1 : public AbsoluteAtom { +public: + NativeAbsoluteAtomV1(const NativeFile& f, + const NativeAbsoluteAtomIvarsV1* ivarData) + : _file(&f), _ivarData(ivarData) { } + + virtual const File& file() const; + virtual llvm::StringRef name() const; + + virtual uint64_t value() const { + return _ivarData->value; + } + +private: + const NativeFile* _file; + const NativeAbsoluteAtomIvarsV1* _ivarData; +}; + + // // An object of this class is instantied for each NativeReferenceIvarsV1 @@ -206,6 +254,12 @@ case NCS_UndefinedAtomsV1: ec = file->processUndefinedAtomsV1(base, chunk); break; + case NCS_SharedLibraryAtomsV1: + ec = file->processSharedLibraryAtomsV1(base, chunk); + break; + case NCS_AbsoluteAtomsV1: + ec = file->processAbsoluteAtomsV1(base, chunk); + break; case NCS_ReferencesArrayV1: ec = file->processReferencesV1(base, chunk); break; @@ -247,23 +301,45 @@ // to just delete the memory. delete _definedAtoms.arrayStart; delete _undefinedAtoms.arrayStart; + delete _sharedLibraryAtoms.arrayStart; + delete _absoluteAtoms.arrayStart; delete _references.arrayStart; delete _targetsTable; } // visits each atom in the file virtual bool forEachAtom(AtomHandler& handler) const { + bool didSomething = false; for(const uint8_t* p=_definedAtoms.arrayStart; p != _definedAtoms.arrayEnd; p += _definedAtoms.elementSize) { const DefinedAtom* atom = reinterpret_cast(p); handler.doDefinedAtom(*atom); + didSomething = true; } - for(const uint8_t* p=_undefinedAtoms.arrayStart; p != _undefinedAtoms.arrayEnd; - p += _undefinedAtoms.elementSize) { + for(const uint8_t* p=_undefinedAtoms.arrayStart; + p != _undefinedAtoms.arrayEnd; + p += _undefinedAtoms.elementSize) { const UndefinedAtom* atom = reinterpret_cast(p); handler.doUndefinedAtom(*atom); + didSomething = true; + } + for(const uint8_t* p=_sharedLibraryAtoms.arrayStart; + p != _sharedLibraryAtoms.arrayEnd; + p += _sharedLibraryAtoms.elementSize) { + const SharedLibraryAtom* atom + = reinterpret_cast(p); + handler.doSharedLibraryAtom(*atom); + didSomething = true; + } + for(const uint8_t* p=_absoluteAtoms.arrayStart; + p != _absoluteAtoms.arrayEnd; + p += _absoluteAtoms.elementSize) { + const AbsoluteAtom* atom + = reinterpret_cast(p); + handler.doAbsoluteAtom(*atom); + didSomething = true; } - return (_definedAtoms.arrayStart != _definedAtoms.arrayEnd); + return didSomething; } // not used @@ -275,6 +351,8 @@ private: friend class NativeDefinedAtomV1; friend class NativeUndefinedAtomV1; + friend class NativeSharedLibraryAtomV1; + friend class NativeAbsoluteAtomV1; friend class NativeReferenceV1; // instantiate array of DefinedAtoms from v1 ivar data in file @@ -308,12 +386,14 @@ } // set up pointers to attributes array - llvm::error_code processAttributesV1(const uint8_t* base, const NativeChunk* chunk) { + llvm::error_code processAttributesV1(const uint8_t* base, + const NativeChunk* chunk) { this->_attributes = base + chunk->fileOffset; this->_attributesMaxOffset = chunk->fileSize; return make_error_code(native_reader_error::success); } + // instantiate array of UndefinedAtoms from v1 ivar data in file llvm::error_code processUndefinedAtomsV1(const uint8_t* base, const NativeChunk* chunk) { const size_t atomSize = sizeof(NativeUndefinedAtomV1); @@ -344,6 +424,70 @@ } + // instantiate array of ShareLibraryAtoms from v1 ivar data in file + llvm::error_code processSharedLibraryAtomsV1(const uint8_t* base, + const NativeChunk* chunk) { + const size_t atomSize = sizeof(NativeSharedLibraryAtomV1); + size_t atomsArraySize = chunk->elementCount * atomSize; + uint8_t* atomsStart = reinterpret_cast + (operator new(atomsArraySize, std::nothrow)); + if (atomsStart == NULL ) + return make_error_code(native_reader_error::memory_error); + const size_t ivarElementSize = chunk->fileSize + / chunk->elementCount; + if ( ivarElementSize != sizeof(NativeSharedLibraryAtomIvarsV1) ) + return make_error_code(native_reader_error::file_malformed); + uint8_t* atomsEnd = atomsStart + atomsArraySize; + const NativeSharedLibraryAtomIvarsV1* ivarData = + reinterpret_cast + (base + chunk->fileOffset); + for(uint8_t* s = atomsStart; s != atomsEnd; s += atomSize) { + NativeSharedLibraryAtomV1* atomAllocSpace = + reinterpret_cast(s); + new (atomAllocSpace) NativeSharedLibraryAtomV1(*this, ivarData); + ++ivarData; + } + this->_sharedLibraryAtoms.arrayStart = atomsStart; + this->_sharedLibraryAtoms.arrayEnd = atomsEnd; + this->_sharedLibraryAtoms.elementSize = atomSize; + this->_sharedLibraryAtoms.elementCount = chunk->elementCount; + return make_error_code(native_reader_error::success); + } + + + // instantiate array of AbsoluteAtoms from v1 ivar data in file + llvm::error_code processAbsoluteAtomsV1(const uint8_t* base, + const NativeChunk* chunk) { + const size_t atomSize = sizeof(NativeAbsoluteAtomV1); + size_t atomsArraySize = chunk->elementCount * atomSize; + uint8_t* atomsStart = reinterpret_cast + (operator new(atomsArraySize, std::nothrow)); + if (atomsStart == NULL ) + return make_error_code(native_reader_error::memory_error); + const size_t ivarElementSize = chunk->fileSize + / chunk->elementCount; + if ( ivarElementSize != sizeof(NativeAbsoluteAtomIvarsV1) ) + return make_error_code(native_reader_error::file_malformed); + uint8_t* atomsEnd = atomsStart + atomsArraySize; + const NativeAbsoluteAtomIvarsV1* ivarData = + reinterpret_cast + (base + chunk->fileOffset); + for(uint8_t* s = atomsStart; s != atomsEnd; s += atomSize) { + NativeAbsoluteAtomV1* atomAllocSpace = + reinterpret_cast(s); + new (atomAllocSpace) NativeAbsoluteAtomV1(*this, ivarData); + ++ivarData; + } + this->_absoluteAtoms.arrayStart = atomsStart; + this->_absoluteAtoms.arrayEnd = atomsEnd; + this->_absoluteAtoms.elementSize = atomSize; + this->_absoluteAtoms.elementCount = chunk->elementCount; + return make_error_code(native_reader_error::success); + } + + + + // instantiate array of Referemces from v1 ivar data in file llvm::error_code processReferencesV1(const uint8_t* base, const NativeChunk* chunk) { @@ -398,7 +542,24 @@ this->_targetsTable[i] = reinterpret_cast(p); continue; } - return make_error_code(native_reader_error::file_malformed); + const uint32_t slIndex = index - _definedAtoms.elementCount + - _undefinedAtoms.elementCount; + if ( slIndex < _sharedLibraryAtoms.elementCount ) { + const uint8_t* p = _sharedLibraryAtoms.arrayStart + + slIndex * _sharedLibraryAtoms.elementSize; + this->_targetsTable[i] = reinterpret_cast(p); + continue; + } + const uint32_t abIndex = index - _definedAtoms.elementCount + - _undefinedAtoms.elementCount + - _sharedLibraryAtoms.elementCount; + if ( abIndex < _absoluteAtoms.elementCount ) { + const uint8_t* p = _absoluteAtoms.arrayStart + + slIndex * _absoluteAtoms.elementSize; + this->_targetsTable[i] = reinterpret_cast(p); + continue; + } + return make_error_code(native_reader_error::file_malformed); } return make_error_code(native_reader_error::success); } @@ -491,7 +652,8 @@ _contentStart(NULL), _contentEnd(NULL) { - _header = reinterpret_cast(_buffer->getBufferStart()); + _header = reinterpret_cast + (_buffer->getBufferStart()); } struct IvarArray { @@ -507,6 +669,8 @@ const NativeFileHeader* _header; IvarArray _definedAtoms; IvarArray _undefinedAtoms; + IvarArray _sharedLibraryAtoms; + IvarArray _absoluteAtoms; const uint8_t* _attributes; uint32_t _attributesMaxOffset; IvarArray _references; @@ -567,6 +731,31 @@ } + + +inline const class File& NativeSharedLibraryAtomV1::file() const { + return *_file; +} + +inline llvm::StringRef NativeSharedLibraryAtomV1::name() const { + return _file->string(_ivarData->nameOffset); +} + +inline llvm::StringRef NativeSharedLibraryAtomV1::loadName() const { + return _file->string(_ivarData->loadNameOffset); +} + + + +inline const class File& NativeAbsoluteAtomV1::file() const { + return *_file; +} + +inline llvm::StringRef NativeAbsoluteAtomV1::name() const { + return _file->string(_ivarData->nameOffset); +} + + inline const Atom* NativeReferenceV1::target() const { return _file->target(_ivarData->targetIndex); } Modified: lld/trunk/lib/Core/NativeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/NativeWriter.cpp?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/lib/Core/NativeWriter.cpp (original) +++ lld/trunk/lib/Core/NativeWriter.cpp Wed Feb 22 15:56:59 2012 @@ -61,7 +61,21 @@ out.write((char*)&_undefinedAtomIvars[0], _undefinedAtomIvars.size()*sizeof(NativeUndefinedAtomIvarsV1)); } - + + if ( !_sharedLibraryAtomIvars.empty() ) { + assert( out.tell() == findChunk(NCS_SharedLibraryAtomsV1).fileOffset ); + out.write((char*)&_sharedLibraryAtomIvars[0], + _sharedLibraryAtomIvars.size() + * sizeof(NativeSharedLibraryAtomIvarsV1)); + } + + if ( !_absoluteAtomIvars.empty() ) { + assert( out.tell() == findChunk(NCS_AbsoluteAtomsV1).fileOffset ); + out.write((char*)&_absoluteAtomIvars[0], + _absoluteAtomIvars.size() + * sizeof(NativeAbsoluteAtomIvarsV1)); + } + if (!_stringPool.empty()) { assert( out.tell() == findChunk(NCS_Strings).fileOffset ); out.write(&_stringPool[0], _stringPool.size()); @@ -110,23 +124,55 @@ _undefinedAtomIndex[&atom] = _undefinedAtomIvars.size(); NativeUndefinedAtomIvarsV1 ivar; ivar.nameOffset = getNameOffset(atom); - ivar.flags = (atom.weakImport() ? 1 : 0); + ivar.flags = (atom.canBeNull() & 0x03); _undefinedAtomIvars.push_back(ivar); } // visitor routine called by forEachAtom() + virtual void doSharedLibraryAtom(const SharedLibraryAtom& atom) { + _sharedLibraryAtomIndex[&atom] = _sharedLibraryAtomIvars.size(); + NativeSharedLibraryAtomIvarsV1 ivar; + ivar.nameOffset = getNameOffset(atom); + ivar.loadNameOffset = getSharedLibraryNameOffset(atom.loadName()); + ivar.flags = atom.canBeNullAtRuntime(); + _sharedLibraryAtomIvars.push_back(ivar); + } + + // visitor routine called by forEachAtom() + virtual void doAbsoluteAtom(const AbsoluteAtom& atom) { + _absoluteAtomIndex[&atom] = _absoluteAtomIvars.size(); + NativeAbsoluteAtomIvarsV1 ivar; + ivar.nameOffset = getNameOffset(atom); + ivar.reserved = 0; + ivar.value = atom.value(); + _absoluteAtomIvars.push_back(ivar); + } + + // visitor routine called by forEachAtom() virtual void doFile(const File &) { } // fill out native file header and chunk directory void makeHeader() { + const bool hasDefines = !_definedAtomIvars.empty(); const bool hasUndefines = !_undefinedAtomIvars.empty(); + const bool hasSharedLibraries = !_sharedLibraryAtomIvars.empty(); + const bool hasAbsolutes = !_absoluteAtomIvars.empty(); + const bool hasReferences = !_references.empty(); const bool hasTargetsTable = !_targetsTableIndex.empty(); const bool hasAddendTable = !_addendsTableIndex.empty(); - int chunkCount = 5; + const bool hasContent = !_contentPool.empty(); + + int chunkCount = 1; // always have string pool chunk + if ( hasDefines ) chunkCount += 2; if ( hasUndefines ) ++chunkCount; + if ( hasSharedLibraries ) ++chunkCount; + if ( hasAbsolutes ) ++chunkCount; + if ( hasReferences ) ++chunkCount; if ( hasTargetsTable ) ++chunkCount; if ( hasAddendTable ) ++chunkCount; + if ( hasContent ) ++chunkCount; + _headerBufferSize = sizeof(NativeFileHeader) + chunkCount*sizeof(NativeChunk); _headerBuffer = reinterpret_cast @@ -140,23 +186,25 @@ _headerBuffer->fileSize = 0; _headerBuffer->chunkCount = chunkCount; - - // create chunk for atom ivar array + // create chunk for defined atom ivar array int nextIndex = 0; - NativeChunk& chd = chunks[nextIndex++]; - chd.signature = NCS_DefinedAtomsV1; - chd.fileOffset = _headerBufferSize; - chd.fileSize = _definedAtomIvars.size()*sizeof(NativeDefinedAtomIvarsV1); - chd.elementCount = _definedAtomIvars.size(); - uint32_t nextFileOffset = chd.fileOffset + chd.fileSize; - - // create chunk for attributes - NativeChunk& cha = chunks[nextIndex++]; - cha.signature = NCS_AttributesArrayV1; - cha.fileOffset = nextFileOffset; - cha.fileSize = _attributes.size()*sizeof(NativeAtomAttributesV1); - cha.elementCount = _attributes.size(); - nextFileOffset = cha.fileOffset + cha.fileSize; + uint32_t nextFileOffset = _headerBufferSize; + if ( hasDefines ) { + NativeChunk& chd = chunks[nextIndex++]; + chd.signature = NCS_DefinedAtomsV1; + chd.fileOffset = nextFileOffset; + chd.fileSize = _definedAtomIvars.size()*sizeof(NativeDefinedAtomIvarsV1); + chd.elementCount = _definedAtomIvars.size(); + nextFileOffset = chd.fileOffset + chd.fileSize; + + // create chunk for attributes + NativeChunk& cha = chunks[nextIndex++]; + cha.signature = NCS_AttributesArrayV1; + cha.fileOffset = nextFileOffset; + cha.fileSize = _attributes.size()*sizeof(NativeAtomAttributesV1); + cha.elementCount = _attributes.size(); + nextFileOffset = cha.fileOffset + cha.fileSize; + } // create chunk for undefined atom array if ( hasUndefines ) { @@ -169,6 +217,28 @@ nextFileOffset = chu.fileOffset + chu.fileSize; } + // create chunk for shared library atom array + if ( hasSharedLibraries ) { + NativeChunk& chsl = chunks[nextIndex++]; + chsl.signature = NCS_SharedLibraryAtomsV1; + chsl.fileOffset = nextFileOffset; + chsl.fileSize = _sharedLibraryAtomIvars.size() * + sizeof(NativeSharedLibraryAtomIvarsV1); + chsl.elementCount = _sharedLibraryAtomIvars.size(); + nextFileOffset = chsl.fileOffset + chsl.fileSize; + } + + // create chunk for shared library atom array + if ( hasAbsolutes ) { + NativeChunk& chsl = chunks[nextIndex++]; + chsl.signature = NCS_AbsoluteAtomsV1; + chsl.fileOffset = nextFileOffset; + chsl.fileSize = _absoluteAtomIvars.size() * + sizeof(NativeAbsoluteAtomIvarsV1); + chsl.elementCount = _absoluteAtomIvars.size(); + nextFileOffset = chsl.fileOffset + chsl.fileSize; + } + // create chunk for symbol strings // pad end of string pool to 4-bytes while ( (_stringPool.size() % 4) != 0 ) @@ -181,13 +251,15 @@ nextFileOffset = chs.fileOffset + chs.fileSize; // create chunk for references - NativeChunk& chr = chunks[nextIndex++]; - chr.signature = NCS_ReferencesArrayV1; - chr.fileOffset = nextFileOffset; - chr.fileSize = _references.size() * sizeof(NativeReferenceIvarsV1); - chr.elementCount = _references.size(); - nextFileOffset = chr.fileOffset + chr.fileSize; - + if ( hasReferences ) { + NativeChunk& chr = chunks[nextIndex++]; + chr.signature = NCS_ReferencesArrayV1; + chr.fileOffset = nextFileOffset; + chr.fileSize = _references.size() * sizeof(NativeReferenceIvarsV1); + chr.elementCount = _references.size(); + nextFileOffset = chr.fileOffset + chr.fileSize; + } + // create chunk for target table if ( hasTargetsTable ) { NativeChunk& cht = chunks[nextIndex++]; @@ -209,13 +281,15 @@ } // create chunk for content - NativeChunk& chc = chunks[nextIndex++]; - chc.signature = NCS_Content; - chc.fileOffset = nextFileOffset; - chc.fileSize = _contentPool.size(); - chc.elementCount = _contentPool.size(); - nextFileOffset = chc.fileOffset + chc.fileSize; - + if ( hasContent ) { + NativeChunk& chc = chunks[nextIndex++]; + chc.signature = NCS_Content; + chc.fileOffset = nextFileOffset; + chc.fileSize = _contentPool.size(); + chc.elementCount = _contentPool.size(); + nextFileOffset = chc.fileOffset + chc.fileSize; + } + _headerBuffer->fileSize = nextFileOffset; } @@ -237,7 +311,23 @@ return this->getNameOffset(atom.name()); } - // append atom name to string pool and return offset + // check if name is already in pool or append and return offset + uint32_t getSharedLibraryNameOffset(llvm::StringRef name) { + assert( ! name.empty() ); + // look to see if this library name was used by another atom + for(NameToOffsetVector::iterator it = _sharedLibraryNames.begin(); + it != _sharedLibraryNames.end(); ++it) { + if ( name.equals(it->first) ) + return it->second; + } + // first use of this library name + uint32_t result = this->getNameOffset(name); + _sharedLibraryNames.push_back( + std::make_pair(name, result)); + return result; + } + + // append atom name to string pool and return offset uint32_t getNameOffset(llvm::StringRef name) { if ( name.empty() ) return 0; @@ -356,8 +446,26 @@ } else { pos = _undefinedAtomIndex.find(atom); - assert(pos != _undefinedAtomIndex.end()); - atomIndex = pos->second + _definedAtomIvars.size(); + if ( pos != _undefinedAtomIndex.end() ) { + atomIndex = pos->second + _definedAtomIvars.size(); + } + else { + pos = _sharedLibraryAtomIndex.find(atom); + if ( pos != _sharedLibraryAtomIndex.end() ) { + assert(pos != _sharedLibraryAtomIndex.end()); + atomIndex = pos->second + + _definedAtomIvars.size() + + _undefinedAtomIndex.size(); + } + else { + pos = _absoluteAtomIndex.find(atom); + assert(pos != _absoluteAtomIndex.end()); + atomIndex = pos->second + + _definedAtomIvars.size() + + _undefinedAtomIndex.size() + + _sharedLibraryAtomIndex.size(); + } + } } targetIndexes[targetIndex] = atomIndex; } @@ -405,12 +513,17 @@ std::vector _definedAtomIvars; std::vector _attributes; std::vector _undefinedAtomIvars; + std::vector _sharedLibraryAtomIvars; + std::vector _absoluteAtomIvars; std::vector _references; TargetToIndex _targetsTableIndex; TargetToIndex _definedAtomIndex; TargetToIndex _undefinedAtomIndex; + TargetToIndex _sharedLibraryAtomIndex; + TargetToIndex _absoluteAtomIndex; AddendToIndex _addendsTableIndex; NameToOffsetVector _sectionNames; + NameToOffsetVector _sharedLibraryNames; }; Modified: lld/trunk/lib/Core/Resolver.cpp URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/lib/Core/Resolver.cpp (original) +++ lld/trunk/lib/Core/Resolver.cpp Wed Feb 22 15:56:59 2012 @@ -134,6 +134,24 @@ } } +void Resolver::doSharedLibraryAtom(const SharedLibraryAtom& atom) { + // add to list of known atoms + _atoms.push_back(&atom); + + // tell symbol table + _symbolTable.add(atom); +} + +void Resolver::doAbsoluteAtom(const AbsoluteAtom& atom) { + // add to list of known atoms + _atoms.push_back(&atom); + + // tell symbol table + _symbolTable.add(atom); +} + + + // utility to add a vector of atoms void Resolver::addAtoms(const std::vector& newAtoms) { for (std::vector::const_iterator it = newAtoms.begin(); Modified: lld/trunk/lib/Core/SymbolTable.cpp URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/lib/Core/SymbolTable.cpp (original) +++ lld/trunk/lib/Core/SymbolTable.cpp Wed Feb 22 15:56:59 2012 @@ -11,10 +11,11 @@ #include "lld/Core/Atom.h" #include "lld/Core/DefinedAtom.h" #include "lld/Core/UndefinedAtom.h" +#include "lld/Core/SharedLibraryAtom.h" +#include "lld/Core/AbsoluteAtom.h" #include "lld/Core/File.h" #include "lld/Core/InputFiles.h" #include "lld/Core/Resolver.h" -#include "lld/Core/UndefinedAtom.h" #include "lld/Platform/Platform.h" #include "llvm/Support/ErrorHandling.h" @@ -36,6 +37,14 @@ this->addByName(atom); } +void SymbolTable::add(const SharedLibraryAtom &atom) { + this->addByName(atom); +} + +void SymbolTable::add(const AbsoluteAtom &atom) { + this->addByName(atom); +} + void SymbolTable::add(const DefinedAtom &atom) { assert(atom.scope() != DefinedAtom::scopeTranslationUnit); if ( !atom.name().empty() ) { @@ -49,7 +58,9 @@ enum NameCollisionResolution { NCR_First, NCR_Second, - NCR_Dup, + NCR_DupDef, + NCR_DupUndef, + NCR_DupShLib, NCR_Error }; @@ -57,7 +68,7 @@ //regular absolute undef sharedLib { // first is regular - NCR_Dup, NCR_Error, NCR_First, NCR_First + NCR_DupDef, NCR_Error, NCR_First, NCR_First }, { // first is absolute @@ -65,11 +76,11 @@ }, { // first is undef - NCR_Second, NCR_Second, NCR_First, NCR_Second + NCR_Second, NCR_Second, NCR_DupUndef, NCR_Second }, { // first is sharedLib - NCR_Second, NCR_Second, NCR_First, NCR_First + NCR_Second, NCR_Second, NCR_First, NCR_DupShLib } }; @@ -129,7 +140,7 @@ case NCR_Second: useNew = true; break; - case NCR_Dup: + case NCR_DupDef: assert(existing->definition() == Atom::definitionRegular); assert(newAtom.definition() == Atom::definitionRegular); switch ( mergeSelect(((DefinedAtom*)existing)->merge(), @@ -148,6 +159,39 @@ break; } break; + case NCR_DupUndef: { + const UndefinedAtom* existingUndef = existing->undefinedAtom(); + const UndefinedAtom* newUndef = newAtom.undefinedAtom(); + assert(existingUndef != NULL); + assert(newUndef != NULL); + if ( existingUndef->canBeNull() == newUndef->canBeNull() ) { + useNew = false; + } + else { + useNew = (newUndef->canBeNull() < existingUndef->canBeNull()); + // give platform a change to override which to use + _platform.undefineCanBeNullMismatch(*existingUndef, + *newUndef, useNew); + } + } + break; + case NCR_DupShLib: { + const SharedLibraryAtom* existingShLib = existing->sharedLibraryAtom(); + const SharedLibraryAtom* newShLib = newAtom.sharedLibraryAtom(); + assert(existingShLib != NULL); + assert(newShLib != NULL); + if ( (existingShLib->canBeNullAtRuntime() + == newShLib->canBeNullAtRuntime()) && + existingShLib->loadName().equals(newShLib->loadName()) ) { + useNew = false; + } + else { + useNew = false; // use existing shared library by default + // give platform a change to override which to use + _platform.sharedLibrarylMismatch(*existingShLib, *newShLib, useNew); + } + } + break; default: llvm::report_fatal_error("SymbolTable::addByName(): unhandled switch clause"); } Modified: lld/trunk/lib/Core/YamlKeyValues.cpp URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/YamlKeyValues.cpp?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/lib/Core/YamlKeyValues.cpp (original) +++ lld/trunk/lib/Core/YamlKeyValues.cpp Wed Feb 22 15:56:59 2012 @@ -30,10 +30,12 @@ const char* const KeyValues::isAliasKeyword = "is-alias"; const char* const KeyValues::sectionNameKeyword = "section-name"; const char* const KeyValues::contentKeyword = "content"; +const char* const KeyValues::loadNameKeyword = "load-name"; const char* const KeyValues::sizeKeyword = "size"; +const char* const KeyValues::valueKeyword = "value"; const char* const KeyValues::fixupsKeyword = "fixups"; const char* const KeyValues::permissionsKeyword = "permissions"; -const char* const KeyValues::weakImportKeyword = "weak-import"; +const char* const KeyValues::canBeNullKeyword = "can-be-null"; const char* const KeyValues::fixupsKindKeyword = "kind"; const char* const KeyValues::fixupsOffsetKeyword = "offset"; const char* const KeyValues::fixupsTargetKeyword = "target"; @@ -51,7 +53,7 @@ const DefinedAtom::ContentPermissions KeyValues::permissionsDefault = DefinedAtom::permR__; const bool KeyValues::isThumbDefault = false; const bool KeyValues::isAliasDefault = false; -const bool KeyValues::weakImportDefault = false; +const UndefinedAtom::CanBeNull KeyValues::canBeNullDefault = UndefinedAtom::canBeNullNever; @@ -389,17 +391,34 @@ -bool KeyValues::weakImport(const char* s) +struct CanBeNullMapping { + const char* string; + UndefinedAtom::CanBeNull value; +}; + +static const CanBeNullMapping cbnMappings[] = { + { "never", UndefinedAtom::canBeNullNever }, + { "at-runtime", UndefinedAtom::canBeNullAtRuntime }, + { "at-buildtime", UndefinedAtom::canBeNullAtBuildtime }, + { NULL, UndefinedAtom::canBeNullNever } +}; + + +UndefinedAtom::CanBeNull KeyValues::canBeNull(const char* s) { - if ( strcmp(s, "true") == 0 ) - return true; - else if ( strcmp(s, "false") == 0 ) - return false; - llvm::report_fatal_error("bad weak-import value"); + for (const CanBeNullMapping* p = cbnMappings; p->string != NULL; ++p) { + if ( strcmp(p->string, s) == 0 ) + return p->value; + } + llvm::report_fatal_error("bad can-be-null value"); } -const char* KeyValues::weakImport(bool b) { - return b ? "true" : "false"; +const char* KeyValues::canBeNull(UndefinedAtom::CanBeNull c) { + for (const CanBeNullMapping* p = cbnMappings; p->string != NULL; ++p) { + if ( p->value == c ) + return p->string; + } + llvm::report_fatal_error("bad can-be-null value"); } Modified: lld/trunk/lib/Core/YamlKeyValues.h URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/YamlKeyValues.h?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/lib/Core/YamlKeyValues.h (original) +++ lld/trunk/lib/Core/YamlKeyValues.h Wed Feb 22 15:56:59 2012 @@ -12,6 +12,7 @@ #include "lld/Core/Atom.h" #include "lld/Core/DefinedAtom.h" +#include "lld/Core/UndefinedAtom.h" namespace lld { @@ -24,6 +25,8 @@ static const char* const sectionNameKeyword; static const char* const contentKeyword; static const char* const sizeKeyword; + static const char* const loadNameKeyword; + static const char* const valueKeyword; static const char* const fixupsKeyword; static const char* const definitionKeyword; @@ -76,10 +79,10 @@ static bool isAlias(const char*); static const char* isAlias(bool); - static const char* const weakImportKeyword; - static const bool weakImportDefault; - static bool weakImport(const char*); - static const char* weakImport(bool); + static const char* const canBeNullKeyword; + static const UndefinedAtom::CanBeNull canBeNullDefault; + static UndefinedAtom::CanBeNull canBeNull(const char*); + static const char* canBeNull(UndefinedAtom::CanBeNull); static const char* const fixupsKindKeyword; Modified: lld/trunk/lib/Core/YamlReader.cpp URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/YamlReader.cpp?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/lib/Core/YamlReader.cpp (original) +++ lld/trunk/lib/Core/YamlReader.cpp Wed Feb 22 15:56:59 2012 @@ -13,6 +13,9 @@ #include "lld/Core/YamlReader.h" #include "lld/Core/Atom.h" +#include "lld/Core/UndefinedAtom.h" +#include "lld/Core/SharedLibraryAtom.h" +#include "lld/Core/AbsoluteAtom.h" #include "lld/Core/Error.h" #include "lld/Core/File.h" #include "lld/Core/Reference.h" @@ -200,9 +203,7 @@ } break; case inValue: - if (isalnum(c) || (c == '-') || (c == '_')) { - *p++ = c; - } else if (c == '\n') { + if (c == '\n') { *p = '\0'; entries.push_back(new Entry(key, value, NULL, depth, nextKeyIsStartOfDocument, @@ -212,6 +213,9 @@ state = inDocument; depth = 0; } + else { + *p++ = c; + } break; case inValueSequence: if (c == ']') { @@ -300,6 +304,8 @@ void bindTargetReferences(); void addDefinedAtom(YAMLDefinedAtom* atom, const char* refName); void addUndefinedAtom(UndefinedAtom* atom); + void addSharedLibraryAtom(SharedLibraryAtom* atom); + void addAbsoluteAtom(AbsoluteAtom* atom); Atom* findAtom(const char* name); struct NameAtomPair { @@ -310,6 +316,8 @@ std::vector _definedAtoms; std::vector _undefinedAtoms; + std::vector _sharedLibraryAtoms; + std::vector _absoluteAtoms; std::vector _references; std::vector _nameToAtomMapping; unsigned int _lastRefIndex; @@ -465,8 +473,38 @@ class YAMLUndefinedAtom : public UndefinedAtom { public: - YAMLUndefinedAtom(YAMLFile& f, int32_t ord, const char* nm, bool wi) - : _file(f), _name(nm), _ordinal(ord), _weakImport(wi) { } + YAMLUndefinedAtom(YAMLFile& f, int32_t ord, const char* nm, + UndefinedAtom::CanBeNull cbn) + : _file(f), _name(nm), _ordinal(ord), _canBeNull(cbn) { } + + virtual const class File& file() const { + return _file; + } + + virtual llvm::StringRef name() const { + return _name; + } + + virtual CanBeNull canBeNull() const { + return _canBeNull; + } + + +private: + YAMLFile& _file; + const char * _name; + uint32_t _ordinal; + UndefinedAtom::CanBeNull _canBeNull; +}; + + + +class YAMLSharedLibraryAtom : public SharedLibraryAtom { +public: + YAMLSharedLibraryAtom(YAMLFile& f, int32_t ord, const char* nm, + const char* ldnm, bool cbn) + : _file(f), _name(nm), _ordinal(ord), + _loadName(ldnm), _canBeNull(cbn) { } virtual const class File& file() const { return _file; @@ -476,18 +514,52 @@ return _name; } - virtual bool weakImport() const { - return _weakImport; + virtual llvm::StringRef loadName() const { + return _loadName; + } + + virtual bool canBeNullAtRuntime() const { + return _canBeNull; } + private: YAMLFile& _file; const char * _name; uint32_t _ordinal; - bool _weakImport; + const char * _loadName; + bool _canBeNull; }; + +class YAMLAbsoluteAtom : public AbsoluteAtom { +public: + YAMLAbsoluteAtom(YAMLFile& f, int32_t ord, const char* nm, uint64_t v) + : _file(f), _name(nm), _ordinal(ord), _value(v) { } + + virtual const class File& file() const { + return _file; + } + + virtual llvm::StringRef name() const { + return _name; + } + + virtual uint64_t value() const { + return _value; + } + +private: + YAMLFile& _file; + const char * _name; + uint32_t _ordinal; + uint64_t _value; +}; + + + + bool YAMLFile::forEachAtom(File::AtomHandler &handler) const { handler.doFile(*this); for (std::vector::const_iterator it = _definedAtoms.begin(); @@ -498,6 +570,17 @@ it != _undefinedAtoms.end(); ++it) { handler.doUndefinedAtom(**it); } + for (std::vector::const_iterator + it = _sharedLibraryAtoms.begin(); + it != _sharedLibraryAtoms.end(); ++it) { + handler.doSharedLibraryAtom(**it); + } + for (std::vector::const_iterator + it = _absoluteAtoms.begin(); + it != _absoluteAtoms.end(); ++it) { + handler.doAbsoluteAtom(**it); + } + return true; } @@ -534,6 +617,16 @@ _nameToAtomMapping.push_back(NameAtomPair(atom->name().data(), atom)); } +void YAMLFile::addSharedLibraryAtom(SharedLibraryAtom* atom) { + _sharedLibraryAtoms.push_back(atom); + _nameToAtomMapping.push_back(NameAtomPair(atom->name().data(), atom)); +} + +void YAMLFile::addAbsoluteAtom(AbsoluteAtom* atom) { + _absoluteAtoms.push_back(atom); + _nameToAtomMapping.push_back(NameAtomPair(atom->name().data(), atom)); +} + class YAMLAtomState { public: @@ -544,9 +637,7 @@ void setAlign2(const char *n); void setFixupKind(const char *n); - void setFixupOffset(const char *n); void setFixupTarget(const char *n); - void setFixupAddend(const char *n); void addFixup(YAMLFile *f); void makeAtom(YAMLFile&); @@ -554,7 +645,9 @@ const char * _name; const char * _refName; const char * _sectionName; + const char* _loadName; unsigned long long _size; + uint64_t _value; uint32_t _ordinal; std::vector* _content; DefinedAtom::Alignment _alignment; @@ -568,7 +661,7 @@ DefinedAtom::ContentPermissions _permissions; bool _isThumb; bool _isAlias; - bool _weakImport; + UndefinedAtom::CanBeNull _canBeNull; YAMLReference _ref; }; @@ -577,7 +670,9 @@ : _name(NULL) , _refName(NULL) , _sectionName(NULL) + , _loadName(NULL) , _size(0) + , _value(0) , _ordinal(0) , _content(NULL) , _alignment(0, 0) @@ -591,7 +686,7 @@ , _permissions(KeyValues::permissionsDefault) , _isThumb(KeyValues::isThumbDefault) , _isAlias(KeyValues::isAliasDefault) - , _weakImport(false) + , _canBeNull(KeyValues::canBeNullDefault) { } @@ -606,16 +701,30 @@ ++_ordinal; } else if ( _definition == Atom::definitionUndefined ) { - UndefinedAtom *a = new YAMLUndefinedAtom(f, _ordinal, _name, _weakImport); + UndefinedAtom *a = new YAMLUndefinedAtom(f, _ordinal, _name, _canBeNull); f.addUndefinedAtom(a); ++_ordinal; } - + else if ( _definition == Atom::definitionSharedLibrary ) { + bool nullable = (_canBeNull == UndefinedAtom::canBeNullAtRuntime); + SharedLibraryAtom *a = new YAMLSharedLibraryAtom(f, _ordinal, _name, + _loadName, nullable); + f.addSharedLibraryAtom(a); + ++_ordinal; + } + else if ( _definition == Atom::definitionAbsolute ) { + AbsoluteAtom *a = new YAMLAbsoluteAtom(f, _ordinal, _name, _value); + f.addAbsoluteAtom(a); + ++_ordinal; + } + // reset state for next atom _name = NULL; _refName = NULL; _sectionName = NULL; + _loadName = NULL; _size = 0; + _value = 0; _ordinal = 0; _content = NULL; _alignment.powerOf2= 0; @@ -630,7 +739,7 @@ _permissions = KeyValues::permissionsDefault; _isThumb = KeyValues::isThumbDefault; _isAlias = KeyValues::isAliasDefault; - _weakImport = KeyValues::weakImportDefault; + _canBeNull = KeyValues::canBeNullDefault; _ref._target = NULL; _ref._targetName = NULL; _ref._addend = 0; @@ -666,24 +775,10 @@ } } -void YAMLAtomState::setFixupOffset(const char *s) { - if ((s[0] == '0') && (s[1] == 'x')) - llvm::StringRef(s).getAsInteger(16, _ref._offsetInAtom); - else - llvm::StringRef(s).getAsInteger(10, _ref._offsetInAtom); -} - void YAMLAtomState::setFixupTarget(const char *s) { _ref._targetName = s; } -void YAMLAtomState::setFixupAddend(const char *s) { - if ((s[0] == '0') && (s[1] == 'x')) - llvm::StringRef(s).getAsInteger(16, _ref._addend); - else - llvm::StringRef(s).getAsInteger(10, _ref._addend); -} - void YAMLAtomState::addFixup(YAMLFile *f) { f->_references.push_back(_ref); @@ -805,8 +900,12 @@ atomState._isAlias = KeyValues::isAlias(entry->value); haveAtom = true; } - else if (strcmp(entry->key, KeyValues::weakImportKeyword) == 0) { - atomState._weakImport = KeyValues::weakImport(entry->value); + else if (strcmp(entry->key, KeyValues::canBeNullKeyword) == 0) { + atomState._canBeNull = KeyValues::canBeNull(entry->value); + if ( atomState._definition == Atom::definitionSharedLibrary ) { + if ( atomState._canBeNull == UndefinedAtom::canBeNullAtBuildtime ) + return make_error_code(yaml_reader_error::illegal_value); + } haveAtom = true; } else if (strcmp(entry->key, KeyValues::sectionNameKeyword) == 0) { @@ -829,7 +928,14 @@ } else if (strcmp(entry->key, KeyValues::fixupsKeyword) == 0) { inFixups = true; - + } + else if (strcmp(entry->key, KeyValues::loadNameKeyword) == 0) { + atomState._loadName = entry->value; + haveAtom = true; + } + else if (strcmp(entry->key, KeyValues::valueKeyword) == 0) { + llvm::StringRef(entry->value).getAsInteger(0, atomState._value); + haveAtom = true; } else { return make_error_code(yaml_reader_error::unknown_keyword); @@ -847,7 +953,8 @@ haveFixup = true; } else if (strcmp(entry->key, KeyValues::fixupsOffsetKeyword) == 0) { - atomState.setFixupOffset(entry->value); + llvm::StringRef(entry->value).getAsInteger(0, + atomState._ref._offsetInAtom); haveFixup = true; } else if (strcmp(entry->key, KeyValues::fixupsTargetKeyword) == 0) { @@ -855,7 +962,8 @@ haveFixup = true; } else if (strcmp(entry->key, KeyValues::fixupsAddendKeyword) == 0) { - atomState.setFixupAddend(entry->value); + llvm::StringRef(entry->value).getAsInteger(0, + atomState._ref._addend); haveFixup = true; } } @@ -865,9 +973,10 @@ if (haveAtom) { atomState.makeAtom(*file); } - - file->bindTargetReferences(); - result.push_back(file); + if ( file != NULL ) { + file->bindTargetReferences(); + result.push_back(file); + } return make_error_code(yaml_reader_error::success); } Modified: lld/trunk/lib/Core/YamlWriter.cpp URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/YamlWriter.cpp?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/lib/Core/YamlWriter.cpp (original) +++ lld/trunk/lib/Core/YamlWriter.cpp Wed Feb 22 15:56:59 2012 @@ -71,6 +71,14 @@ buildDuplicateNameMap(atom); } + virtual void doSharedLibraryAtom(const SharedLibraryAtom& atom) { + buildDuplicateNameMap(atom); + } + + virtual void doAbsoluteAtom(const AbsoluteAtom& atom) { + buildDuplicateNameMap(atom); + } + void buildDuplicateNameMap(const Atom& atom) { assert(!atom.name().empty()); NameToAtom::iterator pos = _nameMap.find(atom.name()); @@ -132,10 +140,14 @@ virtual void doFile(const class File &) { _firstAtom = true; } virtual void doDefinedAtom(const class DefinedAtom &atom) { - // add blank line between atoms for readability - if ( !_firstAtom ) + if ( _firstAtom ) { + _out << "atoms:\n"; + _firstAtom = false; + } + else { + // add blank line between atoms for readability _out << "\n"; - _firstAtom = false; + } bool hasDash = false; if ( !atom.name().empty() ) { @@ -313,35 +325,115 @@ virtual void doUndefinedAtom(const class UndefinedAtom &atom) { - // add blank line between atoms for readability - if ( !_firstAtom ) - _out << "\n"; + if ( _firstAtom ) { + _out << "atoms:\n"; _firstAtom = false; + } + else { + // add blank line between atoms for readability + _out << "\n"; + } - _out << " - " - << KeyValues::nameKeyword + _out << " - " + << KeyValues::nameKeyword + << ":" + << spacePadding(KeyValues::nameKeyword) + << atom.name() + << "\n"; + + _out << " " + << KeyValues::definitionKeyword + << ":" + << spacePadding(KeyValues::definitionKeyword) + << KeyValues::definition(atom.definition()) + << "\n"; + + if ( atom.canBeNull() != KeyValues::canBeNullDefault ) { + _out << " " + << KeyValues::canBeNullKeyword << ":" - << spacePadding(KeyValues::nameKeyword) - << atom.name() + << spacePadding(KeyValues::canBeNullKeyword) + << KeyValues::canBeNull(atom.canBeNull()) << "\n"; + } + } + + virtual void doSharedLibraryAtom(const SharedLibraryAtom& atom) { + if ( _firstAtom ) { + _out << "atoms:\n"; + _firstAtom = false; + } + else { + // add blank line between atoms for readability + _out << "\n"; + } + + _out << " - " + << KeyValues::nameKeyword + << ":" + << spacePadding(KeyValues::nameKeyword) + << atom.name() + << "\n"; + + _out << " " + << KeyValues::definitionKeyword + << ":" + << spacePadding(KeyValues::definitionKeyword) + << KeyValues::definition(atom.definition()) + << "\n"; + if ( !atom.loadName().empty() ) { _out << " " - << KeyValues::definitionKeyword + << KeyValues::loadNameKeyword << ":" - << spacePadding(KeyValues::definitionKeyword) - << KeyValues::definition(atom.definition()) + << spacePadding(KeyValues::loadNameKeyword) + << atom.loadName() << "\n"; + } - if ( atom.weakImport() != KeyValues::weakImportDefault ) { + if ( atom.canBeNullAtRuntime() ) { _out << " " - << KeyValues::weakImportKeyword + << KeyValues::canBeNullKeyword << ":" - << spacePadding(KeyValues::weakImportKeyword) - << KeyValues::weakImport(atom.weakImport()) + << spacePadding(KeyValues::canBeNullKeyword) + << KeyValues::canBeNull(UndefinedAtom::canBeNullAtRuntime) << "\n"; } - } + } + + virtual void doAbsoluteAtom(const AbsoluteAtom& atom) { + if ( _firstAtom ) { + _out << "atoms:\n"; + _firstAtom = false; + } + else { + // add blank line between atoms for readability + _out << "\n"; + } + + _out << " - " + << KeyValues::nameKeyword + << ":" + << spacePadding(KeyValues::nameKeyword) + << atom.name() + << "\n"; + _out << " " + << KeyValues::definitionKeyword + << ":" + << spacePadding(KeyValues::definitionKeyword) + << KeyValues::definition(atom.definition()) + << "\n"; + + _out << " " + << KeyValues::valueKeyword + << ":" + << spacePadding(KeyValues::valueKeyword) + << "0x"; + _out.write_hex(atom.value()); + _out << "\n"; + } + private: // return a string of the correct number of spaces to align value @@ -380,7 +472,6 @@ // Write out all atoms AtomWriter h(rnb, out); out << "---\n"; - out << "atoms:\n"; file.forEachAtom(h); out << "...\n"; } Added: lld/trunk/test/absolute-basic.objtxt URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/absolute-basic.objtxt?rev=151204&view=auto ============================================================================== --- lld/trunk/test/absolute-basic.objtxt (added) +++ lld/trunk/test/absolute-basic.objtxt Wed Feb 22 15:56:59 2012 @@ -0,0 +1,25 @@ +# RUN: lld-core %s | FileCheck %s + +# +# Test that absolute symbols are parsed and preserved +# + +--- +atoms: + - name: putchar + definition: absolute + value: 0xFFFF0040 + + - name: reset + definition: absolute + value: 0xFFFF0080 + +... + +# CHECK: name: putchar +# CHECK: definition: absolute +# CHECK: value: 0xffff0040 +# CHECK: name: reset +# CHECK: definition: absolute +# CHECK: value: 0xffff0080 +# CHECK: ... Added: lld/trunk/test/empty.objtxt URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/empty.objtxt?rev=151204&view=auto ============================================================================== --- lld/trunk/test/empty.objtxt (added) +++ lld/trunk/test/empty.objtxt Wed Feb 22 15:56:59 2012 @@ -0,0 +1,11 @@ +# RUN: lld-core %s | FileCheck %s + +# +# Test that an empty file is handled properly +# + +--- +... + +# CHECK: --- +# CHECK: ... Added: lld/trunk/test/shared-library-basic.objtxt URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/shared-library-basic.objtxt?rev=151204&view=auto ============================================================================== --- lld/trunk/test/shared-library-basic.objtxt (added) +++ lld/trunk/test/shared-library-basic.objtxt Wed Feb 22 15:56:59 2012 @@ -0,0 +1,34 @@ +# RUN: lld-core %s | FileCheck %s + +# +# Test that shared-library symbols are parsed and preserved +# + +--- +atoms: + - name: malloc + definition: shared-library + load-name: libc.so + + - name: free + definition: shared-library + load-name: libc.so + + - name: fast_malloc + definition: shared-library + load-name: libc.so + can-be-null: at-runtime + +... + +# CHECK: name: malloc +# CHECK: definition: shared-library +# CHECK: load-name: libc.so +# CHECK: name: free +# CHECK: definition: shared-library +# CHECK: load-name: libc.so +# CHECK: name: fast_malloc +# CHECK: definition: shared-library +# CHECK: load-name: libc.so +# CHECK: can-be-null: at-runtime +# CHECK: ... Added: lld/trunk/test/shared-library-coalesce.objtxt URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/shared-library-coalesce.objtxt?rev=151204&view=auto ============================================================================== --- lld/trunk/test/shared-library-coalesce.objtxt (added) +++ lld/trunk/test/shared-library-coalesce.objtxt Wed Feb 22 15:56:59 2012 @@ -0,0 +1,110 @@ +# RUN: lld-core %s | FileCheck %s + +# +# Test that shared library symbols preserve their attributes and merge properly +# + +--- +atoms: + - name: foo1 + definition: shared-library + load-name: libc.so + + - name: foo2 + definition: shared-library + load-name: libc.so + + - name: bar1 + definition: shared-library + load-name: libc.so + can-be-null: at-runtime + + - name: bar2 + definition: shared-library + load-name: libc.so + can-be-null: at-runtime + + - name: mismatchNull1 + definition: shared-library + load-name: libc.so + can-be-null: at-runtime + + - name: mismatchNull2 + definition: shared-library + load-name: libc.so + + - name: mismatchload1 + definition: shared-library + load-name: liba.so + + - name: mismatchload2 + definition: shared-library + load-name: libb.so + +--- +atoms: + - name: foo2 + definition: shared-library + load-name: libc.so + + - name: foo3 + definition: shared-library + load-name: libc.so + + - name: bar2 + definition: shared-library + load-name: libc.so + can-be-null: at-runtime + + - name: bar3 + definition: shared-library + load-name: libc.so + can-be-null: at-runtime + + - name: mismatchNull1 + definition: shared-library + load-name: libc.so + + - name: mismatchNull2 + definition: shared-library + load-name: libc.so + can-be-null: at-runtime + + - name: mismatchload1 + definition: shared-library + load-name: libb.so + + - name: mismatchload2 + definition: shared-library + load-name: liba.so + +... + +# CHECK: name: foo1 +# CHECK: definition: shared-library +# CHECK: name: foo2 +# CHECK: definition: shared-library +# CHECK: name: bar1 +# CHECK: definition: shared-library +# CHECK: can-be-null: at-runtime +# CHECK: name: bar2 +# CHECK: definition: shared-library +# CHECK: can-be-null: at-runtime +# CHECK: name: mismatchNull1 +# CHECK: definition: shared-library +# CHECK: can-be-null: at-runtime +# CHECK: name: mismatchNull2 +# CHECK: definition: shared-library +# CHECK-NOT: can-be-null: at-runtime +# CHECK: name: mismatchload1 +# CHECK: definition: shared-library +# CHECK: load-name: liba.so +# CHECK: name: mismatchload2 +# CHECK: definition: shared-library +# CHECK: load-name: libb.so +# CHECK: name: foo3 +# CHECK: definition: shared-library +# CHECK: name: bar3 +# CHECK: definition: shared-library +# CHECK: can-be-null: at-runtime +# CHECK: ... Added: lld/trunk/test/undef-weak-coalesce.objtxt URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/undef-weak-coalesce.objtxt?rev=151204&view=auto ============================================================================== --- lld/trunk/test/undef-weak-coalesce.objtxt (added) +++ lld/trunk/test/undef-weak-coalesce.objtxt Wed Feb 22 15:56:59 2012 @@ -0,0 +1,117 @@ +# RUN: lld-core %s | FileCheck %s + +# +# Test that undefined symbols preserve their attributes and merge properly +# + +--- +atoms: + - name: regular_func + definition: undefined + can-be-null: never + + - name: weak_import_func + definition: undefined + can-be-null: at-runtime + + - name: weak_func + definition: undefined + can-be-null: at-buildtime + + - name: bar1 + definition: undefined + can-be-null: never + + - name: bar2 + definition: undefined + can-be-null: at-runtime + + - name: bar3 + definition: undefined + can-be-null: at-buildtime + + - name: bar4 + definition: undefined + can-be-null: never + + - name: bar5 + definition: undefined + can-be-null: at-runtime + + - name: bar6 + definition: undefined + can-be-null: at-buildtime + + - name: bar7 + definition: undefined + can-be-null: never + + - name: bar8 + definition: undefined + can-be-null: at-runtime + + - name: bar9 + definition: undefined + can-be-null: at-buildtime + +--- +atoms: + - name: bar1 + definition: undefined + can-be-null: never + + - name: bar2 + definition: undefined + can-be-null: at-runtime + + - name: bar3 + definition: undefined + can-be-null: at-buildtime + + - name: bar4 + definition: undefined + can-be-null: at-runtime + + - name: bar5 + definition: undefined + can-be-null: at-buildtime + + - name: bar6 + definition: undefined + can-be-null: never + + - name: bar7 + definition: undefined + can-be-null: at-buildtime + + - name: bar8 + definition: undefined + can-be-null: never + + - name: bar9 + definition: undefined + can-be-null: at-runtime +... + +# CHECK: name: regular_func +# CHECK: definition: undefined +# CHECK: name: weak_import_func +# CHECK: definition: undefined +# CHECK: can-be-null: at-runtime +# CHECK: name: weak_func +# CHECK: definition: undefined +# CHECK: can-be-null: at-buildtime +# CHECK: name: bar1 +# CHECK: name: bar2 +# CHECK: can-be-null: at-runtime +# CHECK: name: bar3 +# CHECK: can-be-null: at-buildtime +# CHECK: name: bar4 +# CHECK: name: bar5 +# CHECK: can-be-null: at-runtime +# CHECK: name: bar7 +# CHECK: name: bar6 +# CHECK: name: bar8 +# CHECK: name: bar9 +# CHECK: can-be-null: at-runtime +# CHECK: ... Modified: lld/trunk/tools/lld-core/lld-core.cpp URL: http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld-core/lld-core.cpp?rev=151204&r1=151203&r2=151204&view=diff ============================================================================== --- lld/trunk/tools/lld-core/lld-core.cpp (original) +++ lld/trunk/tools/lld-core/lld-core.cpp Wed Feb 22 15:56:59 2012 @@ -141,6 +141,17 @@ virtual void errorWithUndefines(const std::vector &undefs, const std::vector &all) {} + // print out undefined can-be-null mismatches + virtual void undefineCanBeNullMismatch(const UndefinedAtom& undef1, + const UndefinedAtom& undef2, + bool& useUndef2) { } + + // print out shared library mismatches + virtual void sharedLibrarylMismatch(const SharedLibraryAtom& shLib1, + const SharedLibraryAtom& shLib2, + bool& useShlib2) { } + + // last chance for platform to tweak atoms virtual void postResolveTweaks(std::vector &all) {} @@ -186,6 +197,20 @@ if ( atom ) handler.doUndefinedAtom(*atom); } + // visit shared library atoms + for (std::vector::iterator it = _atoms.begin(); + it != _atoms.end(); ++it) { + const SharedLibraryAtom* atom = (*it)->sharedLibraryAtom(); + if ( atom ) + handler.doSharedLibraryAtom(*atom); + } + // visit absolute atoms + for (std::vector::iterator it = _atoms.begin(); + it != _atoms.end(); ++it) { + const AbsoluteAtom* atom = (*it)->absoluteAtom(); + if ( atom ) + handler.doAbsoluteAtom(*atom); + } return true; } @@ -220,7 +245,7 @@ // write new atom graph out as YAML doc std::string errorInfo; llvm::raw_fd_ostream out("-", errorInfo); - //yaml::writeObjectText(outFile, out); +// yaml::writeObjectText(outFile, out); // make unique temp .o file to put generated object file int fd; @@ -232,6 +257,8 @@ writeNativeObjectFile(outFile, binaryOut); binaryOut.close(); // manually close so that file can be read next +// out << "native file: " << tempPath.str() << "\n"; + // read native file llvm::OwningPtr natFile; if ( error(parseNativeObjectFileOrSTDIN(tempPath, natFile)) ) From atrick at apple.com Wed Feb 22 15:59:00 2012 From: atrick at apple.com (Andrew Trick) Date: Wed, 22 Feb 2012 21:59:00 -0000 Subject: [llvm-commits] [llvm] r151205 - in /llvm/trunk/lib/CodeGen: ScheduleDAGInstrs.cpp ScheduleDAGInstrs.h Message-ID: <20120222215900.CCA8F2A6C12F@llvm.org> Author: atrick Date: Wed Feb 22 15:59:00 2012 New Revision: 151205 URL: http://llvm.org/viewvc/llvm-project?rev=151205&view=rev Log: misched: Use SparseSet for VRegDegs for constant time clear(). Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=151205&r1=151204&r2=151205&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Wed Feb 22 15:59:00 2012 @@ -373,13 +373,18 @@ // uses. We're conservative for now until we have a way to guarantee the uses // are not eliminated sometime during scheduling. The output dependence edge // is also useful if output latency exceeds def-use latency. - SUnit *&DefSU = VRegDefs[Reg]; - if (DefSU && DefSU != SU && DefSU != &ExitSU) { - unsigned OutLatency = TII->getOutputLatency(InstrItins, MI, OperIdx, - DefSU->getInstr()); - DefSU->addPred(SDep(SU, SDep::Output, OutLatency, Reg)); + VReg2SUnitMap::iterator DefI = findVRegDef(Reg); + if (DefI == VRegDefs.end()) + VRegDefs.insert(VReg2SUnit(Reg, SU)); + else { + SUnit *DefSU = DefI->SU; + if (DefSU != SU && DefSU != &ExitSU) { + unsigned OutLatency = TII->getOutputLatency(InstrItins, MI, OperIdx, + DefSU->getInstr()); + DefSU->addPred(SDep(SU, SDep::Output, OutLatency, Reg)); + } + DefI->SU = SU; } - DefSU = SU; } /// addVRegUseDeps - Add a register data dependency if the instruction that @@ -418,12 +423,9 @@ } // Add antidependence to the following def of the vreg it uses. - DenseMap::const_iterator I = VRegDefs.find(Reg); - if (I != VRegDefs.end()) { - SUnit *DefSU = I->second; - if (DefSU != SU) - DefSU->addPred(SDep(SU, SDep::Anti, 0, Reg)); - } + VReg2SUnitMap::iterator DefI = findVRegDef(Reg); + if (DefI != VRegDefs.end() && DefI->SU != SU) + DefI->SU->addPred(SDep(SU, SDep::Anti, 0, Reg)); } /// Create an SUnit for each real instruction, numbered in top-down toplological @@ -488,7 +490,11 @@ assert(Defs[i].empty() && "Only BuildGraph should push/pop Defs"); } - assert(VRegDefs.size() == 0 && "Only BuildSchedGraph may access VRegDefs"); + assert(VRegDefs.empty() && "Only BuildSchedGraph may access VRegDefs"); + // FIXME: Allow SparseSet to reserve space for the creation of virtual + // registers during scheduling. Don't artificially inflate the Universe + // because we want to assert that vregs are not created during DAG building. + VRegDefs.setUniverse(MRI.getNumVirtRegs()); // Walk the list of instructions, from bottom moving up. MachineInstr *PrevMI = NULL; Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h?rev=151205&r1=151204&r2=151205&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.h Wed Feb 22 15:59:00 2012 @@ -20,8 +20,8 @@ #include "llvm/CodeGen/ScheduleDAG.h" #include "llvm/Support/Compiler.h" #include "llvm/Target/TargetRegisterInfo.h" -#include "llvm/ADT/IndexedMap.h" #include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SparseSet.h" #include namespace llvm { @@ -125,9 +125,24 @@ std::vector > Defs; std::vector > Uses; + /// An individual mapping from virtual register number to SUnit. + struct VReg2SUnit { + unsigned VirtReg; + SUnit *SU; + + VReg2SUnit(unsigned reg, SUnit *su): VirtReg(reg), SU(su) {} + + unsigned getSparseSetKey() const { + return TargetRegisterInfo::virtReg2Index(VirtReg); + } + }; + // Use SparseSet as a SparseMap by relying on the fact that it never + // compares ValueT's, only unsigned keys. This allows the set to be cleared + // between scheduling regions in constant time. + typedef SparseSet VReg2SUnitMap; + // Track the last instructon in this region defining each virtual register. - // FIXME: turn this into a sparse set with constant time clear(). - DenseMap VRegDefs; + VReg2SUnitMap VRegDefs; /// PendingLoads - Remember where unknown loads are after the most recent /// unknown store, as we iterate. As with Defs and Uses, this is here @@ -235,6 +250,10 @@ void addPhysRegDeps(SUnit *SU, unsigned OperIdx); void addVRegDefDeps(SUnit *SU, unsigned OperIdx); void addVRegUseDeps(SUnit *SU, unsigned OperIdx); + + VReg2SUnitMap::iterator findVRegDef(unsigned VirtReg) { + return VRegDefs.find(TargetRegisterInfo::virtReg2Index(VirtReg)); + } }; } From rdivacky at freebsd.org Wed Feb 22 16:11:47 2012 From: rdivacky at freebsd.org (Roman Divacky) Date: Wed, 22 Feb 2012 23:11:47 +0100 Subject: [llvm-commits] [llvm] r151200 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/PowerPC/PPCAsmPrinter.cpp test/CodeGen/PowerPC/ppc64-linux-func-size.ll In-Reply-To: <20120222214959.GA90313@freebsd.org> References: <20120222211147.D77782A6C12F@llvm.org> <20120222214959.GA90313@freebsd.org> Message-ID: <20120222221147.GA92504@freebsd.org> grrr.. I misread , as . there should be two symbols emitted. Here's the updated patch. Please review. On Wed, Feb 22, 2012 at 10:49:59PM +0100, Roman Divacky wrote: > > Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp > > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=151200&r1=151199&r2=151200&view=diff > > ============================================================================== > > --- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original) > > +++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Wed Feb 22 15:11:47 2012 > > @@ -398,7 +398,11 @@ > > OutStreamer.EmitRawText("\t.quad .L." + Twine(CurrentFnSym->getName()) + > > ",.TOC. at tocbase"); > > OutStreamer.EmitRawText(StringRef("\t.previous")); > > - OutStreamer.EmitRawText(".L." + Twine(CurrentFnSym->getName()) + ":"); > > + > > + MCSymbol *RealFnSym = OutContext.GetOrCreateSymbol( > > + ".L." + Twine(CurrentFnSym->getName())); > > + OutStreamer.EmitLabel(RealFnSym); > > + CurrentFnSymForSize = RealFnSym; > > } > > The EmitRawText here must vanish. Are you ok with the attached patch? It > properly MCizes this. If you dont object I'd like to (finaly) commit that. > > roman > _______________________________________________ > 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: powerpc.mc.patch Type: text/x-diff Size: 2765 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120222/67e261c3/attachment.bin From daniel at zuster.org Wed Feb 22 16:28:13 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 22 Feb 2012 22:28:13 -0000 Subject: [llvm-commits] [zorg] r151206 - in /zorg/trunk/lnt/lnt/server: reporting/runs.py ui/templates/v4_run.html ui/views.py Message-ID: <20120222222813.5F3392A6C12F@llvm.org> Author: ddunbar Date: Wed Feb 22 16:28:13 2012 New Revision: 151206 URL: http://llvm.org/viewvc/llvm-project?rev=151206&view=rev Log: [lnt] lnt.server.ui.views/run overview: Avoid unnecessary reload of the comparison window. Modified: zorg/trunk/lnt/lnt/server/reporting/runs.py zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/server/reporting/runs.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/reporting/runs.py?rev=151206&r1=151205&r2=151206&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/reporting/runs.py (original) +++ zorg/trunk/lnt/lnt/server/reporting/runs.py Wed Feb 22 16:28:13 2012 @@ -13,7 +13,7 @@ def generate_run_report(run, baseurl, only_html_body = False, num_comparison_runs = 10, result = None, - compare_to = None): + compare_to = None, comparison_window = None): """ generate_run_report(...) -> (str: subject, str: text_report, str: html_report) @@ -31,8 +31,9 @@ machine_parameters = machine.parameters # Gather the runs to use for statistical data. - comparison_window = list(ts.get_previous_runs_on_machine( - run, num_comparison_runs)) + if comparison_window is None: + comparison_window = list(ts.get_previous_runs_on_machine( + run, num_comparison_runs)) # Get the specific run to compare to. if compare_to is None and comparison_window: Modified: zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html?rev=151206&r1=151205&r2=151206&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html Wed Feb 22 16:28:13 2012 @@ -228,7 +228,7 @@ for field in primary_fields %}{% set cr = request_info.sri.get_run_comparison_result( - run, compare_to, test_id, field, comparison_window) + run, compare_to, test_id, field, request_info.comparison_window) %} {{cr.previous}} {{cr.current}} {{cr.pct_delta}}{% endfor %} {% Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=151206&r1=151205&r2=151206&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Wed Feb 22 16:28:13 2012 @@ -782,10 +782,21 @@ self.compare_to = None self.comparison_neighboring_runs = self.neighboring_runs + try: + self.num_comparison_runs = int( + request.args.get('num_comparison_runs')) + except: + self.num_comparison_runs = 10 + + # Gather the runs to use for statistical data. + self.comparison_window = list(ts.get_previous_runs_on_machine( + self.run, self.num_comparison_runs)) + reports = lnt.server.reporting.runs.generate_run_report( self.run, baseurl=db_url_for('index', _external=True), - only_html_body=only_html_body, - result=None, compare_to=self.compare_to) + only_html_body=only_html_body, result=None, + compare_to=self.compare_to, + comparison_window=self.comparison_window) _, self.text_report, self.html_report, self.sri = reports @v4_route("//report") @@ -821,11 +832,7 @@ options['show_data_table'] = bool(request.args.get('show_data_table')) options['hide_report_by_default'] = bool( request.args.get('hide_report_by_default')) - try: - num_comparison_runs = int(request.args.get('num_comparison_runs')) - except: - num_comparison_runs = 10 - options['num_comparison_runs'] = num_comparison_runs + options['num_comparison_runs'] = info.num_comparison_runs options['test_filter'] = test_filter_str = request.args.get( 'test_filter', '') if test_filter_str: @@ -840,10 +847,6 @@ else: test_min_value_filter = 0.0 - # Gather the runs to use for statistical data. - comparison_window = list(ts.get_previous_runs_on_machine( - run, num_comparison_runs)) - # Get the test names. test_info = ts.query(ts.Test.name, ts.Test.id).\ order_by(ts.Test.name).all() @@ -857,7 +860,6 @@ return render_template( "v4_run.html", ts=ts, options=options, primary_fields=list(ts.Sample.get_primary_fields()), - comparison_window=comparison_window, test_info=test_info, runinfo=runinfo, test_min_value_filter=test_min_value_filter, request_info=info) From daniel at zuster.org Wed Feb 22 16:28:15 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 22 Feb 2012 22:28:15 -0000 Subject: [llvm-commits] [zorg] r151207 - /zorg/trunk/lnt/lnt/util/NTEmailReport.py Message-ID: <20120222222815.73EB82A6C12F@llvm.org> Author: ddunbar Date: Wed Feb 22 16:28:15 2012 New Revision: 151207 URL: http://llvm.org/viewvc/llvm-project?rev=151207&view=rev Log: [lnt] lnt.util.NTEmailReport: Fix refacto. Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=151207&r1=151206&r2=151207&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Wed Feb 22 16:28:15 2012 @@ -448,7 +448,7 @@ reports = lnt.server.reporting.runs.generate_run_report( run, baseurl=baseurl, only_html_body=only_html_body, result=result, compare_to=compare_to) - return reports[:2] + return reports[:3] # Use a simple report unless the tag indicates this is an old style nightly # test run. From clattner at apple.com Wed Feb 22 16:49:18 2012 From: clattner at apple.com (Chris Lattner) Date: Wed, 22 Feb 2012 14:49:18 -0800 Subject: [llvm-commits] [llvm] r151093 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/constantfold-initializers.ll In-Reply-To: <4F448A53.8060507@mxc.ca> References: <20120221220806.ED6AD2A6C12F@llvm.org> <1D190D19-E8E3-4D63-A46B-DF6EA8D8D2A1@apple.com> <4F448A53.8060507@mxc.ca> Message-ID: <5D5210A6-26D9-4D08-9476-2A5E55B62E4E@apple.com> On Feb 21, 2012, at 10:25 PM, Nick Lewycky wrote: > Chris Lattner wrote: >> >> On Feb 21, 2012, at 2:08 PM, Nick Lewycky wrote: >> >>> Author: nicholas >>> Date: Tue Feb 21 16:08:06 2012 >>> New Revision: 151093 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=151093&view=rev >>> Log: >>> Use the target-aware constant folder on expressions to improve the chance >>> they'll be simple enough to simulate, and to reduce the chance we'll encounter >>> equal but different simple pointer constants. >>> >>> This removes the symptoms from PR11352 but is not a full fix. A proper fix would >>> either require a guarantee that two constant objects we simulate are folded >>> when equal, or a different way of handling equal pointers (ie., trying a >>> constantexpr icmp on them to see whether we know they're equal or non-equal or >>> unsure). >> >> I think it should be enough to consider two constants the same if they are pointer equal and neither is a ConstantExpr. > > Sure that's sufficient, but we'd like to handle ConstantExpr's, such as an all-zero GEP. > > Yep, the non-TD constant folder can't pick one of: > getelementptr inbounds (%closure* @f, i32 0, i32 0) > getelementptr inbounds (%closure* @f, i64 0, i32 0) > . Oops, and that breaks GlobalOpt. Double-oops. > > Really, I'd rather figure out some way to constant fold those into the same Constant* rather than teach globalopt anything new. The simplest way is to use ConstantExpr::getICmp(EQ, a, b) and see if the result is a ConstantInt. However, you really have a three way comparison here: 1. If the Constant*'s are the same, you know they are equal. 2. If the Constant*'s are not constant exprs, you know they are non-equal. 3. Otherwise you don't know. -Chris From stoklund at 2pi.dk Wed Feb 22 16:50:15 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 22 Feb 2012 22:50:15 -0000 Subject: [llvm-commits] [llvm] r151210 - /llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Message-ID: <20120222225015.1CA0A2A6C130@llvm.org> Author: stoklund Date: Wed Feb 22 16:50:14 2012 New Revision: 151210 URL: http://llvm.org/viewvc/llvm-project?rev=151210&view=rev Log: Handle regmasks in RegisterScavenging. Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterScavenging.cpp?rev=151210&r1=151209&r2=151210&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegisterScavenging.cpp (original) +++ llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Wed Feb 22 16:50:14 2012 @@ -148,6 +148,8 @@ DefRegs.reset(); for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); + if (MO.isRegMask()) + (isPred ? DefRegs : KillRegs).setBitsNotInMask(MO.getRegMask()); if (!MO.isReg()) continue; unsigned Reg = MO.getReg(); @@ -279,6 +281,8 @@ // Remove any candidates touched by instruction. for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); + if (MO.isRegMask()) + Candidates.clearBitsNotInMask(MO.getRegMask()); if (!MO.isReg() || MO.isUndef() || !MO.getReg()) continue; if (TargetRegisterInfo::isVirtualRegister(MO.getReg())) { From stoklund at 2pi.dk Wed Feb 22 16:52:52 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 22 Feb 2012 22:52:52 -0000 Subject: [llvm-commits] [llvm] r151211 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Message-ID: <20120222225252.8A4792A6C12F@llvm.org> Author: stoklund Date: Wed Feb 22 16:52:52 2012 New Revision: 151211 URL: http://llvm.org/viewvc/llvm-project?rev=151211&view=rev Log: Don't compute latencies for regmask operands. Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=151211&r1=151210&r2=151211&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Wed Feb 22 16:52:52 2012 @@ -737,7 +737,9 @@ // %Q1 = VMULv8i16 %Q1, %Q3, ... // What we want is to compute latency between def of %D6/%D7 and use of // %Q3 instead. - DefIdx = DefMI->findRegisterDefOperandIdx(Reg, false, true, TRI); + unsigned Op2 = DefMI->findRegisterDefOperandIdx(Reg, false, true, TRI); + if (DefMI->getOperand(Op2).isReg()) + DefIdx = Op2; } MachineInstr *UseMI = Use->getInstr(); // For all uses of the register, calculate the maxmimum latency From daniel at zuster.org Wed Feb 22 17:49:51 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 22 Feb 2012 23:49:51 -0000 Subject: [llvm-commits] [llvm] r151213 - in /llvm/trunk: lib/MC/MCNullStreamer.cpp test/CodeGen/X86/null-streamer.ll Message-ID: <20120222234951.1F8852A6C12F@llvm.org> Author: ddunbar Date: Wed Feb 22 17:49:50 2012 New Revision: 151213 URL: http://llvm.org/viewvc/llvm-project?rev=151213&view=rev Log: MC: Fix the MCNullStreamer which was broken in r147763. Added: llvm/trunk/test/CodeGen/X86/null-streamer.ll Modified: llvm/trunk/lib/MC/MCNullStreamer.cpp Modified: llvm/trunk/lib/MC/MCNullStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCNullStreamer.cpp?rev=151213&r1=151212&r2=151213&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCNullStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCNullStreamer.cpp Wed Feb 22 17:49:50 2012 @@ -95,6 +95,10 @@ virtual void EmitInstruction(const MCInst &Inst) {} virtual void FinishImpl() {} + + virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) { + RecordProcEnd(Frame); + } /// @} }; Added: llvm/trunk/test/CodeGen/X86/null-streamer.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/null-streamer.ll?rev=151213&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/null-streamer.ll (added) +++ llvm/trunk/test/CodeGen/X86/null-streamer.ll Wed Feb 22 17:49:50 2012 @@ -0,0 +1,11 @@ +; Check the MCNullStreamer operates correctly, at least on a minimal test case. +; +; RUN: llc -filetype=null -o %t -march=x86 %s + +define void @f0() { + ret void +} + +define void @f1() { + ret void +} From daniel at zuster.org Wed Feb 22 18:08:11 2012 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 23 Feb 2012 00:08:11 -0000 Subject: [llvm-commits] [zorg] r151215 - /zorg/trunk/lnt/lnt/tests/compile.py Message-ID: <20120223000811.610C72A6C12F@llvm.org> Author: ddunbar Date: Wed Feb 22 18:08:11 2012 New Revision: 151215 URL: http://llvm.org/viewvc/llvm-project?rev=151215&view=rev Log: [lnt] lnt.tests.compile: Include project record in last unpack hash, to catch changes to patch files and things. Modified: zorg/trunk/lnt/lnt/tests/compile.py Modified: zorg/trunk/lnt/lnt/tests/compile.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/compile.py?rev=151215&r1=151214&r2=151215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/compile.py (original) +++ zorg/trunk/lnt/lnt/tests/compile.py Wed Feb 22 18:08:11 2012 @@ -228,7 +228,7 @@ # Check if we need to expand the archive into the sandbox. archive_path = get_input_path(opts, project['archive']) with open(archive_path) as f: - archive_hash = hashlib.md5(f.read()).hexdigest() + archive_hash = hashlib.md5(f.read() + str(project)).hexdigest() # Compute the path to unpack to. source_path = get_output_path("..", "Sources", project['name']) From preston.gurd at intel.com Wed Feb 22 19:14:07 2012 From: preston.gurd at intel.com (Gurd, Preston) Date: Thu, 23 Feb 2012 01:14:07 +0000 Subject: [llvm-commits] [llvm][PATCH][Review request] Add SSE itineraries for Atom Scheduling In-Reply-To: <1BE637DE-451F-4C47-8386-8BD14FD844E7@apple.com> References: <1BE637DE-451F-4C47-8386-8BD14FD844E7@apple.com> Message-ID: Hello Bill, Thank you for having a look at this patch. The patch basically adds an itinerary class (whose name is prefixed by IIC_) or a group of itinerary classes (prefixed by SSE_) to every instruction emitted by X86InstrSSE.td, except for AVX only instructions or classes. In my original patch, there a few changes to the formatting which came about because I undid a change without undoing the change in formatting. I have corrected this in the attached updated patch. In pretty much all of the rest of the patch, it was often necessary to add a newline in the middle of the changed line in order to observe the 80 column width rule. If you would like me to provide a version of this patch which does not split lines, then please let me know and I will do so. Thanks, Preston -----Original Message----- From: Bill Wendling [mailto:wendling at apple.com] Sent: Sunday, February 19, 2012 3:17 PM To: Gurd, Preston Cc: llvm-commits at cs.uiuc.edu Subject: Re: [llvm-commits] [llvm][PATCH][Review request] Add SSE itineraries for Atom Scheduling Hi Preston, It's hard to tease out your actual change from the formatting changes. Could you separate them please? -bw On Feb 17, 2012, at 1:33 PM, Gurd, Preston wrote: > The attached patch adds instruction itineraries for the SSE instructions to the instruction scheduler for the Intel Atom. > > Please review. > > Thanks, > > Preston > > -- > Preston Gurd > Intel Waterloo > > > > _______________________________________________ > 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: atomsse.diff Type: application/octet-stream Size: 236876 bytes Desc: atomsse.diff Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20120223/9afd4664/attachment-0001.obj From stoklund at 2pi.dk Wed Feb 22 19:13:33 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 23 Feb 2012 01:13:33 -0000 Subject: [llvm-commits] [llvm] r151222 - in /llvm/trunk: include/llvm/CodeGen/RegisterScavenging.h lib/CodeGen/RegisterScavenging.cpp Message-ID: <20120223011333.1F9F02A6C12F@llvm.org> Author: stoklund Date: Wed Feb 22 19:13:32 2012 New Revision: 151222 URL: http://llvm.org/viewvc/llvm-project?rev=151222&view=rev Log: Track reserved registers separately from RegsAvailable. The bulk masking operations from register mask operands don't account for reserved registers. Modified: llvm/trunk/include/llvm/CodeGen/RegisterScavenging.h llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Modified: llvm/trunk/include/llvm/CodeGen/RegisterScavenging.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RegisterScavenging.h?rev=151222&r1=151221&r2=151222&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/RegisterScavenging.h (original) +++ llvm/trunk/include/llvm/CodeGen/RegisterScavenging.h Wed Feb 22 19:13:32 2012 @@ -134,8 +134,9 @@ /// isUsed / isUnused - Test if a register is currently being used. /// - bool isUsed(unsigned Reg) const { return !RegsAvailable.test(Reg); } - bool isUnused(unsigned Reg) const { return RegsAvailable.test(Reg); } + bool isUsed(unsigned Reg) const { + return !RegsAvailable.test(Reg) || ReservedRegs.test(Reg); + } /// isAliasUsed - Is Reg or an alias currently in use? bool isAliasUsed(unsigned Reg) const; Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterScavenging.cpp?rev=151222&r1=151221&r2=151222&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegisterScavenging.cpp (original) +++ llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Wed Feb 22 19:13:32 2012 @@ -59,9 +59,6 @@ // All registers started out unused. RegsAvailable.set(); - // Reserved registers are always used. - RegsAvailable ^= ReservedRegs; - if (!MBB) return; @@ -225,9 +222,11 @@ void RegScavenger::getRegsUsed(BitVector &used, bool includeReserved) { used = RegsAvailable; - if (!includeReserved) - used |= ReservedRegs; used.flip(); + if (includeReserved) + used |= ReservedRegs; + else + used.reset(ReservedRegs); } unsigned RegScavenger::FindUnusedReg(const TargetRegisterClass *RC) const { From stoklund at 2pi.dk Wed Feb 22 19:15:26 2012 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 23 Feb 2012 01:15:26 -0000 Subject: [llvm-commits] [llvm] r151223 - /llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp Message-ID: <20120223011526.95F0B2A6C12F@llvm.org> Author: stoklund Date: Wed Feb 22 19:15:26 2012 New Revision: 151223 URL: http://llvm.org/viewvc/llvm-project?rev=151223&view=rev Log: Handle regmasks in CriticalAntiDepBreaker. Modified: llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp Modified: llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp?rev=151223&r1=151222&r2=151223&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp (original) +++ llvm/trunk/lib/CodeGen/CriticalAntiDepBreaker.cpp Wed Feb 22 19:15:26 2012 @@ -253,6 +253,17 @@ // address updates. for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand &MO = MI->getOperand(i); + + if (MO.isRegMask()) + for (unsigned i = 0, e = TRI->getNumRegs(); i != e; ++i) + if (MO.clobbersPhysReg(i)) { + DefIndices[i] = Count; + KillIndices[i] = ~0u; + KeepRegs.erase(i); + Classes[i] = 0; + RegRefs.erase(i); + } + if (!MO.isReg()) continue; unsigned Reg = MO.getReg(); if (Reg == 0) continue; @@ -355,6 +366,9 @@ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &CheckOper = MI->getOperand(i); + if (CheckOper.isRegMask() && CheckOper.clobbersPhysReg(NewReg)) + return true; + if (!CheckOper.isReg() || !CheckOper.isDef() || CheckOper.getReg() != NewReg) continue; From evan.cheng at apple.com Wed Feb 22 19:19:07 2012 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 23 Feb 2012 01:19:07 -0000 Subject: [llvm-commits] [llvm] r151224 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/select_xform.ll Message-ID: <20120223011907.6295C2A6C12F@llvm.org> Author: evancheng Date: Wed Feb 22 19:19:06 2012 New Revision: 151224 URL: http://llvm.org/viewvc/llvm-project?rev=151224&view=rev Log: Optimize a couple of common patterns involving conditional moves where the false value is zero. Instead of a cmov + op, issue an conditional op instead. e.g. cmp r9, r4 mov r4, #0 moveq r4, #1 orr lr, lr, r4 should be: cmp r9, r4 orreq lr, lr, #1 That is, optimize (or x, (cmov 0, y, cond)) to (or.cond x, y). Similarly extend this to xor as well as (and x, (cmov -1, y, cond)) => (and.cond x, y). It's possible to extend this to ADD and SUB but I don't think they are common. rdar://8659097 Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/test/CodeGen/ARM/select_xform.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=151224&r1=151223&r2=151224&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Feb 22 19:19:06 2012 @@ -244,6 +244,7 @@ /// SelectCMOVOp - Select CMOV instructions for ARM. SDNode *SelectCMOVOp(SDNode *N); + SDNode *SelectConditionalOp(SDNode *N); SDNode *SelectT2CMOVShiftOp(SDNode *N, SDValue FalseVal, SDValue TrueVal, ARMCC::CondCodes CCVal, SDValue CCR, SDValue InFlag); @@ -2302,9 +2303,6 @@ // Pattern: (ARMcmov:i32 GPR:i32:$false, so_reg:i32:$true, (imm:i32):$cc) // Emits: (MOVCCs:i32 GPR:i32:$false, so_reg:i32:$true, (imm:i32):$cc) // Pattern complexity = 18 cost = 1 size = 0 - SDValue CPTmp0; - SDValue CPTmp1; - SDValue CPTmp2; if (Subtarget->isThumb()) { SDNode *Res = SelectT2CMOVShiftOp(N, FalseVal, TrueVal, CCVal, CCR, InFlag); @@ -2377,6 +2375,116 @@ return CurDAG->SelectNodeTo(N, Opc, VT, Ops, 5); } +SDNode *ARMDAGToDAGISel::SelectConditionalOp(SDNode *N) { + EVT VT = N->getValueType(0); + SDValue FalseVal = N->getOperand(0); + SDValue TrueVal = N->getOperand(1); + ARMCC::CondCodes CCVal = + (ARMCC::CondCodes)cast(N->getOperand(2))->getZExtValue(); + SDValue CCR = N->getOperand(3); + assert(CCR.getOpcode() == ISD::Register); + SDValue InFlag = N->getOperand(4); + SDValue CC = CurDAG->getTargetConstant(CCVal, MVT::i32); + SDValue Reg0 = CurDAG->getRegister(0, MVT::i32); + + if (Subtarget->isThumb()) { + SDValue CPTmp0; + SDValue CPTmp1; + if (SelectT2ShifterOperandReg(TrueVal, CPTmp0, CPTmp1)) { + unsigned Opc; + switch (N->getOpcode()) { + default: llvm_unreachable("Unexpected node"); + case ARMISD::CAND: Opc = ARM::t2ANDCCrs; break; + case ARMISD::COR: Opc = ARM::t2ORRCCrs; break; + case ARMISD::CXOR: Opc = ARM::t2EORCCrs; break; + } + SDValue Ops[] = { FalseVal, CPTmp0, CPTmp1, CC, CCR, Reg0, InFlag }; + return CurDAG->SelectNodeTo(N, Opc, MVT::i32, Ops, 7); + } + + ConstantSDNode *T = dyn_cast(TrueVal); + if (T) { + unsigned TrueImm = T->getZExtValue(); + if (is_t2_so_imm(TrueImm)) { + unsigned Opc; + switch (N->getOpcode()) { + default: llvm_unreachable("Unexpected node"); + case ARMISD::CAND: Opc = ARM::t2ANDCCri; break; + case ARMISD::COR: Opc = ARM::t2ORRCCri; break; + case ARMISD::CXOR: Opc = ARM::t2EORCCri; break; + } + SDValue True = CurDAG->getTargetConstant(TrueImm, MVT::i32); + SDValue Ops[] = { FalseVal, True, CC, CCR, Reg0, InFlag }; + return CurDAG->SelectNodeTo(N, Opc, MVT::i32, Ops, 6); + } + } + + unsigned Opc; + switch (N->getOpcode()) { + default: llvm_unreachable("Unexpected node"); + case ARMISD::CAND: Opc = ARM::t2ANDCCrr; break; + case ARMISD::COR: Opc = ARM::t2ORRCCrr; break; + case ARMISD::CXOR: Opc = ARM::t2EORCCrr; break; + } + SDValue Ops[] = { FalseVal, TrueVal, CC, CCR, Reg0, InFlag }; + return CurDAG->SelectNodeTo(N, Opc, MVT::i32, Ops, 6); + } + + SDValue CPTmp0; + SDValue CPTmp1; + SDValue CPTmp2; + if (SelectImmShifterOperand(TrueVal, CPTmp0, CPTmp2)) { + unsigned Opc; + switch (N->getOpcode()) { + default: llvm_unreachable("Unexpected node"); + case ARMISD::CAND: Opc = ARM::ANDCCrsi; break; + case ARMISD::COR: Opc = ARM::ORRCCrsi; break; + case ARMISD::CXOR: Opc = ARM::EORCCrsi; break; + } + SDValue Ops[] = { FalseVal, CPTmp0, CPTmp2, CC, CCR, Reg0, InFlag }; + return CurDAG->SelectNodeTo(N, Opc, MVT::i32, Ops, 7); + } + + if (SelectRegShifterOperand(TrueVal, CPTmp0, CPTmp1, CPTmp2)) { + unsigned Opc; + switch (N->getOpcode()) { + default: llvm_unreachable("Unexpected node"); + case ARMISD::CAND: Opc = ARM::ANDCCrsr; break; + case ARMISD::COR: Opc = ARM::ORRCCrsr; break; + case ARMISD::CXOR: Opc = ARM::EORCCrsr; break; + } + SDValue Ops[] = { FalseVal, CPTmp0, CPTmp1, CPTmp2, CC, CCR, Reg0, InFlag }; + return CurDAG->SelectNodeTo(N, Opc, MVT::i32, Ops, 8); + } + + ConstantSDNode *T = dyn_cast(TrueVal); + if (T) { + unsigned TrueImm = T->getZExtValue(); + if (is_so_imm(TrueImm)) { + unsigned Opc; + switch (N->getOpcode()) { + default: llvm_unreachable("Unexpected node"); + case ARMISD::CAND: Opc = ARM::ANDCCri; break; + case ARMISD::COR: Opc = ARM::ORRCCri; break; + case ARMISD::CXOR: Opc = ARM::EORCCri; break; + } + SDValue True = CurDAG->getTargetConstant(TrueImm, MVT::i32); + SDValue Ops[] = { FalseVal, True, CC, CCR, Reg0, InFlag }; + return CurDAG->SelectNodeTo(N, Opc, MVT::i32, Ops, 6); + } + } + + unsigned Opc; + switch (N->getOpcode()) { + default: llvm_unreachable("Unexpected node"); + case ARMISD::CAND: Opc = ARM::ANDCCrr; break; + case ARMISD::COR: Opc = ARM::ORRCCrr; break; + case ARMISD::CXOR: Opc = ARM::EORCCrr; break; + } + SDValue Ops[] = { FalseVal, TrueVal, CC, CCR, Reg0, InFlag }; + return CurDAG->SelectNodeTo(N, Opc, MVT::i32, Ops, 6); +} + /// Target-specific DAG combining for ISD::XOR. /// Target-independent combining lowers SELECT_CC nodes of the form /// select_cc setg[ge] X, 0, X, -X @@ -2714,6 +2822,10 @@ } case ARMISD::CMOV: return SelectCMOVOp(N); + case ARMISD::CAND: + case ARMISD::COR: + case ARMISD::CXOR: + return SelectConditionalOp(N); case ARMISD::VZIP: { unsigned Opc = 0; EVT VT = N->getValueType(0); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=151224&r1=151223&r2=151224&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Feb 22 19:19:06 2012 @@ -794,10 +794,11 @@ setTargetDAGCombine(ISD::SUB); setTargetDAGCombine(ISD::MUL); - if (Subtarget->hasV6T2Ops() || Subtarget->hasNEON()) - setTargetDAGCombine(ISD::OR); - if (Subtarget->hasNEON()) + if (Subtarget->hasV6T2Ops() || Subtarget->hasNEON()) { setTargetDAGCombine(ISD::AND); + setTargetDAGCombine(ISD::OR); + setTargetDAGCombine(ISD::XOR); + } setStackPointerRegisterToSaveRestore(ARM::SP); @@ -890,7 +891,11 @@ case ARMISD::CMPFPw0: return "ARMISD::CMPFPw0"; case ARMISD::BCC_i64: return "ARMISD::BCC_i64"; case ARMISD::FMSTAT: return "ARMISD::FMSTAT"; + case ARMISD::CMOV: return "ARMISD::CMOV"; + case ARMISD::CAND: return "ARMISD::CAND"; + case ARMISD::COR: return "ARMISD::COR"; + case ARMISD::CXOR: return "ARMISD::CXOR"; case ARMISD::RBIT: return "ARMISD::RBIT"; @@ -6843,8 +6848,52 @@ return SDValue(); } +static bool isCMOVWithZeroOrAllOnesLHS(SDValue N, bool AllOnes) { + if (N.getOpcode() != ARMISD::CMOV || !N.getNode()->hasOneUse()) + return false; + + SDValue FalseVal = N.getOperand(0); + ConstantSDNode *C = dyn_cast(FalseVal); + if (!C) + return false; + if (AllOnes) + return C->isAllOnesValue(); + return C->isNullValue(); +} + +/// formConditionalOp - Combine an operation with a conditional move operand +/// to form a conditional op. e.g. (or x, (cmov 0, y, cond)) => (or.cond x, y) +/// (and x, (cmov -1, y, cond)) => (and.cond, x, y) +static SDValue formConditionalOp(SDNode *N, SelectionDAG &DAG, + bool Commutable) { + SDValue N0 = N->getOperand(0); + SDValue N1 = N->getOperand(1); + + bool isAND = N->getOpcode() == ISD::AND; + bool isCand = isCMOVWithZeroOrAllOnesLHS(N1, isAND); + if (!isCand && Commutable) { + isCand = isCMOVWithZeroOrAllOnesLHS(N0, isAND); + if (isCand) + std::swap(N0, N1); + } + if (!isCand) + return SDValue(); + + unsigned Opc = 0; + switch (N->getOpcode()) { + default: llvm_unreachable("Unexpected node"); + case ISD::AND: Opc = ARMISD::CAND; break; + case ISD::OR: Opc = ARMISD::COR; break; + case ISD::XOR: Opc = ARMISD::CXOR; break; + } + return DAG.getNode(Opc, N->getDebugLoc(), N->getValueType(0), N0, + N1.getOperand(1), N1.getOperand(2), N1.getOperand(3), + N1.getOperand(4)); +} + static SDValue PerformANDCombine(SDNode *N, - TargetLowering::DAGCombinerInfo &DCI) { + TargetLowering::DAGCombinerInfo &DCI, + const ARMSubtarget *Subtarget) { // Attempt to use immediate-form VBIC BuildVectorSDNode *BVN = dyn_cast(N->getOperand(1)); @@ -6875,6 +6924,13 @@ } } + if (!Subtarget->isThumb1Only()) { + // (and x, (cmov -1, y, cond)) => (and.cond x, y) + SDValue CAND = formConditionalOp(N, DAG, true); + if (CAND.getNode()) + return CAND; + } + return SDValue(); } @@ -6911,6 +6967,13 @@ } } + if (!Subtarget->isThumb1Only()) { + // (or x, (cmov 0, y, cond)) => (or.cond x, y) + SDValue COR = formConditionalOp(N, DAG, true); + if (COR.getNode()) + return COR; + } + SDValue N0 = N->getOperand(0); if (N0.getOpcode() != ISD::AND) return SDValue(); @@ -7059,6 +7122,25 @@ return SDValue(); } +static SDValue PerformXORCombine(SDNode *N, + TargetLowering::DAGCombinerInfo &DCI, + const ARMSubtarget *Subtarget) { + EVT VT = N->getValueType(0); + SelectionDAG &DAG = DCI.DAG; + + if(!DAG.getTargetLoweringInfo().isTypeLegal(VT)) + return SDValue(); + + if (!Subtarget->isThumb1Only()) { + // (xor x, (cmov 0, y, cond)) => (xor.cond x, y) + SDValue CXOR = formConditionalOp(N, DAG, true); + if (CXOR.getNode()) + return CXOR; + } + + return SDValue(); +} + /// PerformBFICombine - (bfi A, (and B, Mask1), Mask2) -> (bfi A, B, Mask2) iff /// the bits being cleared by the AND are not demanded by the BFI. static SDValue PerformBFICombine(SDNode *N, @@ -8110,7 +8192,8 @@ case ISD::SUB: return PerformSUBCombine(N, DCI); case ISD::MUL: return PerformMULCombine(N, DCI, Subtarget); case ISD::OR: return PerformORCombine(N, DCI, Subtarget); - case ISD::AND: return PerformANDCombine(N, DCI); + case ISD::XOR: return PerformXORCombine(N, DCI, Subtarget); + case ISD::AND: return PerformANDCombine(N, DCI, Subtarget); case ARMISD::BFI: re